class Chamomile::Widgets::VerticalLayout
Vertical layout — stacks children.
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/chamomile/frame.rb, line 244 def horizontal(&block) layout = HorizontalLayout.new block.call(layout) if block @children << layout layout end
Source
# File lib/chamomile/frame.rb, line 231 def panel(title = nil, border: :rounded, width: nil, &block) p = Panel.new(title: title, border: border, width: width) block.call(p) if block @children << p p end
Source
# File lib/chamomile/frame.rb, line 257 def render(width: 80, height: 24) return "" if @children.empty? lines = [] remaining = height @children.each_with_index do |child, i| child_height = if i == @children.length - 1 remaining else [remaining / (@children.length - i), 1].max end lines << child.render(width: width, height: child_height) remaining -= child_height end lines.join("\n") end
Source
# File lib/chamomile/frame.rb, line 251 def status_bar(content) sb = StatusBar.new(content: content.to_s) @children << sb sb end
Source
# File lib/chamomile/frame.rb, line 238 def text(content) t = Text.new(content: content.to_s) @children << t t end