Class: Charming::Layout::PaneBehavior

Inherits:
Object
  • Object
show all
Defined in:
lib/charming/presentation/layout/pane_behavior.rb

Overview

PaneBehavior holds the render-time options that control a Pane’s interaction with the focus ring and the embedded Viewport.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(focus:, scroll:, clip:, wrap:) ⇒ PaneBehavior

Returns a new instance of PaneBehavior.



14
15
16
17
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 14

def initialize(focus:, scroll:, clip:, wrap:)
  @focus, @scroll, @clip, @wrap = focus, scroll, clip, wrap
  freeze
end

Instance Attribute Details

#clipObject (readonly)

Returns the value of attribute clip.



8
9
10
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 8

def clip
  @clip
end

#focusObject (readonly)

Returns the value of attribute focus.



8
9
10
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 8

def focus
  @focus
end

#scrollObject (readonly)

Returns the value of attribute scroll.



8
9
10
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 8

def scroll
  @scroll
end

#wrapObject (readonly)

Returns the value of attribute wrap.



8
9
10
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 8

def wrap
  @wrap
end

Class Method Details

.build(focus: false, scroll: false, clip: true, wrap: false) ⇒ Object



10
11
12
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 10

def self.build(focus: false, scroll: false, clip: true, wrap: false)
  new(focus: focus, scroll: scroll, clip: clip, wrap: wrap)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



19
20
21
22
23
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 19

def ==(other)
  other.is_a?(PaneBehavior) &&
    focus == other.focus && scroll == other.scroll &&
    clip == other.clip && wrap == other.wrap
end

#focusable?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 30

def focusable?
  focus
end

#hashObject



26
27
28
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 26

def hash
  [focus, scroll, clip, wrap].hash
end

#should_viewport?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/charming/presentation/layout/pane_behavior.rb', line 34

def should_viewport?
  clip || scroll
end