Class: Potty::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/potty/layout.rb

Overview

Layout engine for positioning and sizing widgets

Defined Under Namespace

Classes: Rect

Class Method Summary collapse

Class Method Details

.stack(container_rect, widgets, spacing: 0) ⇒ Object

Vertical stack layout



14
15
16
17
18
19
20
21
22
# File 'lib/potty/layout.rb', line 14

def self.stack(container_rect, widgets, spacing: 0)
  y = container_rect.y
  widgets.map do |widget|
    height = widget.preferred_height(container_rect.width)
    rect = Rect.new(container_rect.x, y, container_rect.width, height)
    y += height + spacing
    rect
  end
end