Class: RETerm::Layouts::Vertical
- Inherits:
-
RETerm::Layout
- Object
- Component
- RETerm::Layout
- RETerm::Layouts::Vertical
- Defined in:
- lib/reterm/layouts/vertical.rb
Overview
Layout which arainges items vertically down screen rows
Constant Summary
Constants included from NavControls
NavControls::DOWN_CONTROLS, NavControls::ENTER_CONTROLS, NavControls::LEFT_CONTROLS, NavControls::MOVEMENT_CONTROLS, NavControls::QUIT_CONTROLS, NavControls::RIGHT_CONTROLS, NavControls::UP_CONTROLS
Constants included from MouseInput
MouseInput::ALL_EVENTS, MouseInput::MOUSE_MAP
Constants included from RETerm::LogHelpers
Instance Attribute Summary
Attributes inherited from RETerm::Layout
Attributes included from NavInput
Attributes inherited from Component
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary collapse
- #add_child(h = {}) ⇒ Object
- #current_cols ⇒ Object
- #current_rows ⇒ Object
- #exceeds_bounds_with?(child) ⇒ Boolean
- #valid_input?(ch, from_parent) ⇒ Boolean
Methods inherited from RETerm::Layout
#activatable?, #activate!, #child_windows, #children, #contains?, #draw!, #empty?, #exceeds_bounds?, #expandable?, #highlight_focus?, #layout_containing, #parent, #parent?
Methods included from NavInput
#focusable, #focusable?, #handle_input
Methods included from NavControls
Methods included from MouseInput
#mouse_paste?, #on_button, #process_mouse
Methods inherited from Component
#activatable?, #activate!, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #initialize, #reactivate!, #requested_cols, #requested_rows, #resize, #sync!, #sync_getch
Methods included from KeyBindings
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from RETerm::LogHelpers
Methods included from EventDispatcher
Constructor Details
This class inherits a constructor from RETerm::Component
Instance Method Details
#add_child(h = {}) ⇒ Object
28 29 30 31 |
# File 'lib/reterm/layouts/vertical.rb', line 28 def add_child(h={}) # set x/y to next appropriate location super(h.merge(:y => current_rows, :x => 1)) end |
#current_cols ⇒ Object
10 11 12 13 |
# File 'lib/reterm/layouts/vertical.rb', line 10 def current_cols return 1 if empty? child_windows.max { |w1, w2| w1.cols <=> w2.cols }.cols end |
#current_rows ⇒ Object
5 6 7 8 |
# File 'lib/reterm/layouts/vertical.rb', line 5 def current_rows return 1 if empty? child_windows.sum { |c| c.rows } + 1 end |
#exceeds_bounds_with?(child) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reterm/layouts/vertical.rb', line 15 def exceeds_bounds_with?(child) cols = child.is_a?(Hash) ? [current_cols, child[:cols]].compact.max : [current_cols, child.cols].max rows = child.is_a?(Hash) ? current_rows + child[:rows] : current_rows + child.rows cols > window.cols || rows > window.rows end |
#valid_input?(ch, from_parent) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/reterm/layouts/vertical.rb', line 33 def valid_input?(ch, from_parent) return true unless from_parent !((LEFT_CONTROLS.include?(ch) && window.first_child?) || (RIGHT_CONTROLS.include?(ch) && window.last_child?)) end |