Class: Tuile::Component::Layout::Vertical

Inherits:
Box
  • Object
show all
Defined in:
lib/tuile/component/layout/vertical.rb,
sig/tuile.rbs

Overview

Stacks children top to bottom. The main axis is vertical, so a child's positional constraint is its height and cross: is its width; align: :start is the left edge, :end the right.

form = Component::Layout::Vertical.new(spacing: 1)
form.add(caption, Component::Layout::Fixed[1])
form.add(field, Component::Layout::Fixed[1], cross: Component::Layout::Fixed[30])
form.add(log, Component::Layout::Expand[1])   # takes whatever is left below

Inside a subclass the constraints need no prefix at all — see Box.

See Box for the constraint vocabulary and how the space is divided.

Constant Summary collapse

DEFAULT_PLACEMENT =

Returns:

  • (::Hash[Symbol, Object])
ALIGNMENTS =

Returns:

  • (::Array[Symbol])

Instance Attribute Summary

Attributes inherited from Box

#padding, #spacing

Instance Method Summary collapse

Methods inherited from Box

#add, #align_offset, #cross_placement, #distribute_expand, #initialize, #inner_rect, #main_sizes, #percent_of, #place_children, #placement, #rect=, #relayout, #remove, #validate_align, #validate_cross, #validate_main, #validate_spacing

Constructor Details

This class inherits a constructor from Tuile::Component::Layout::Box

Instance Method Details

#build_rect(inner, main_offset, main_size, cross_offset, cross_size) ⇒ Object

@param inner

@param main_offset — rows down from inner's top.

@param main_size — height.

@param cross_offset — columns right of inner's left.

@param cross_size — width.



35
36
37
# File 'lib/tuile/component/layout/vertical.rb', line 35

def build_rect(inner, main_offset, main_size, cross_offset, cross_size)
  Rect.new(inner.left + cross_offset, inner.top + main_offset, cross_size, main_size)
end

#cross_extent(rect) ⇒ Integer

@param rect

Parameters:

Returns:

  • (Integer)


27
# File 'lib/tuile/component/layout/vertical.rb', line 27

def cross_extent(rect) = rect.width

#main_extent(rect) ⇒ Integer

@param rect

Parameters:

Returns:

  • (Integer)


23
# File 'lib/tuile/component/layout/vertical.rb', line 23

def main_extent(rect) = rect.height