Class: Potty::Widgets::VBox
- Defined in:
- lib/potty/widgets/container.rb
Overview
Vertical stack — children top to bottom, each at its preferred height.
Instance Attribute Summary
Attributes inherited from Container
Attributes inherited from Base
#app, #focused, #parent, #rect
Instance Method Summary collapse
Methods inherited from Container
#add, #focusable_widgets, #initialize, #on_layout, #render, #tick
Methods inherited from Base
#activate, #blur, #can_focus?, #deactivate, #focus, #handle_escape, #handle_key, #hide, #initialize, #layout, #on_blur, #on_focus, #on_layout, #render, #show, #theme, #tick, #visible=, #visible?
Methods included from Events
#emit, #listeners?, #off, #on
Constructor Details
This class inherits a constructor from Potty::Widgets::Container
Instance Method Details
#layout_children ⇒ Object
75 76 77 78 |
# File 'lib/potty/widgets/container.rb', line 75 def layout_children rects = Layout.stack(@rect.dup, @children, spacing: @spacing) @children.zip(rects).each { |child, rect| child.layout(rect) } end |
#preferred_height(width) ⇒ Object
69 70 71 72 73 |
# File 'lib/potty/widgets/container.rb', line 69 def preferred_height(width) return 0 if @children.empty? @children.sum { |c| c.preferred_height(width) } + @spacing * (@children.size - 1) end |