Class: SilkLayout::Layout::FlexLayout

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

Defined Under Namespace

Classes: Item, Line

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(box, context, cursor_y, parent_x, containing_width) ⇒ FlexLayout

Returns a new instance of FlexLayout.



20
21
22
23
24
25
26
# File 'lib/silk_layout/layout/flex_layout.rb', line 20

def initialize(box, context, cursor_y, parent_x, containing_width)
  @box = box
  @context = context
  @cursor_y = cursor_y
  @parent_x = parent_x
  @containing_width = containing_width
end

Class Method Details

.layout(box, context, cursor_y = 0, parent_x = 0, containing_width = nil) ⇒ Object



16
17
18
# File 'lib/silk_layout/layout/flex_layout.rb', line 16

def self.layout(box, context, cursor_y = 0, parent_x = 0, containing_width = nil)
  new(box, context, cursor_y, parent_x, containing_width).layout
end

Instance Method Details

#layoutObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/silk_layout/layout/flex_layout.rb', line 28

def layout
  setup_container

  if column?
    layout_column
  else
    layout_row
  end

  @box.width =
    @content_width +
    @box.padding[:left] + @box.padding[:right] +
    @box.border[:left] + @box.border[:right]

  @box.height =
    @content_height +
    @box.padding[:top] + @box.padding[:bottom] +
    @box.border[:top] + @box.border[:bottom]
end