Class: Tuile::Component::Layout::Fixed
- Inherits:
-
Object
- Object
- Tuile::Component::Layout::Fixed
- Includes:
- Constraint
- Defined in:
- lib/tuile/component/layout.rb,
sig/tuile.rbs
Overview
How much space a child gets along one axis of a Box: exactly #cells, clamped to whatever is still unassigned.
add(prompt, Fixed[4]) # 4 rows in a Vertical
add(field, Fixed[1], cross: Fixed[30]) # 1 row, 30 columns wide
Fixed[0] collapses the child: it and its whole subtree get an empty
rect and paint nothing. That is not the same as hiding it — an empty
rect is a paint convention and gates nothing else, so the subtree keeps
its tab stops and still takes keys. To hide a child, set
Tuile::Component#visible= false; it then costs no Box#spacing gap either,
where a collapsed child still does. The difference is exactly that: a
collapsed child is still a member of the sequence, a hidden one is not
(D_visibility).
Instance Attribute Summary collapse
-
#cells ⇒ Integer
readonly
@return — cell count along the axis.
Instance Method Summary collapse
-
#initialize(cells:) ⇒ Fixed
constructor
@param
cells— cell count along the axis;>= 0. -
#resolve(_available) ⇒ Integer
@param
_available.
Constructor Details
#initialize(cells:) ⇒ Fixed
@param cells — cell count along the axis; >= 0.
76 77 78 79 80 81 82 |
# File 'lib/tuile/component/layout.rb', line 76 def initialize(cells:) unless cells.is_a?(Integer) && !cells.negative? raise ArgumentError, "Fixed expects a non-negative Integer, got #{cells.inspect}" end super end |
Instance Attribute Details
#cells ⇒ Integer (readonly)
@return — cell count along the axis.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/tuile/component/layout.rb', line 71 class Fixed < Data.define(:cells) include Constraint # @param cells [Integer] cell count along the axis; `>= 0`. # @raise [ArgumentError] unless `cells` is a non-negative Integer. def initialize(cells:) unless cells.is_a?(Integer) && !cells.negative? raise ArgumentError, "Fixed expects a non-negative Integer, got #{cells.inspect}" end super end # @api private # @param _available [Integer] # @return [Integer] {#cells}. def resolve(_available) = cells end |
Instance Method Details
#resolve(_available) ⇒ Integer
@param _available
@return — #cells.
87 |
# File 'lib/tuile/component/layout.rb', line 87 def resolve(_available) = cells |