Class: Charming::Layout::PaneStyle
- Inherits:
-
Object
- Object
- Charming::Layout::PaneStyle
- Defined in:
- lib/charming/presentation/layout/pane_style.rb
Overview
PaneStyle holds a Pane’s base style and the focused-state override. It resolves which style to use at render time given the pane’s current focus state and the view’s theme.
Instance Attribute Summary collapse
-
#focused_style ⇒ Object
readonly
Returns the value of attribute focused_style.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(style:, focused_style:) ⇒ PaneStyle
constructor
A new instance of PaneStyle.
-
#resolve(view, focused:) ⇒ Object
Returns the active style for focused: the focused override when the pane is focused, otherwise the configured style or a default UI::Style.
Constructor Details
#initialize(style:, focused_style:) ⇒ PaneStyle
Returns a new instance of PaneStyle.
15 16 17 18 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 15 def initialize(style:, focused_style:) @style, @focused_style = style, focused_style freeze end |
Instance Attribute Details
#focused_style ⇒ Object (readonly)
Returns the value of attribute focused_style.
9 10 11 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 9 def focused_style @focused_style end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
9 10 11 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 9 def style @style end |
Class Method Details
.build(style: nil, focused_style: nil) ⇒ Object
11 12 13 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 11 def self.build(style: nil, focused_style: nil) new(style: style, focused_style: focused_style) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
20 21 22 23 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 20 def ==(other) other.is_a?(PaneStyle) && style == other.style && focused_style == other.focused_style end |
#hash ⇒ Object
26 27 28 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 26 def hash [style, focused_style].hash end |
#resolve(view, focused:) ⇒ Object
Returns the active style for focused: the focused override when the pane is focused, otherwise the configured style or a default UI::Style.
32 33 34 35 36 |
# File 'lib/charming/presentation/layout/pane_style.rb', line 32 def resolve(view, focused:) return focused_style || view.__send__(:theme).title if focused style || UI.style end |