Package tripleplay.ui.layout
Class AxisLayout
java.lang.Object
tripleplay.ui.Layout
tripleplay.ui.layout.AxisLayout
- Direct Known Subclasses:
AxisLayout.Horizontal
,AxisLayout.Vertical
Lays out elements in a horizontal or vertical group. Separate policies are enforced for on-axis
and off-axis sizing.
On-axis, the available space is divided up as follows: non-stretched elements are given
their preferred size, and remaining space is divided up among the stretched elements
proportional to their configured weight (which defaults to one). If no stretched elements exist,
elements are aligned per the Style.HAlign
and
Style.VAlign
properties on the containing group.
Off-axis sizing can be configured to either size elements to their preferred size, stretch them all to a uniform size (equal to the preferred size of the largest element), or to stretch them all to the size allotted to the container. When elements are not stretched to fill the size allotted to the container, they may be aligned as above.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Defines axis layout constraints.static class
A horizontal axis layout.static enum
Specifies the off-axis layout policy.static class
A vertical axis layout. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AxisLayout.Constraint
fixed()
Returns a layout constraint indicating that the associated element should not be stretched.gap
(int gap) Configures the inter-element gap, in pixels.static AxisLayout.Horizontal
Creates a horizontal axis layout with default gap (5), and off-axis sizing policy (preferred size).Configures this layout to constrain elements to the size of this container on the off-axis, leaving their size alone if it is smaller.Configures this layout to stretch all elements to the size of the largest element on the off-axis.offPolicy
(AxisLayout.Policy policy) Configures the off-axis sizing policy for this layout.Configures this layout to stretch all elements to the available size on the off-axis.static <T extends Element<?>>
Tstretch
(T elem) Configures the supplied element with astretched()
constraint.static <T extends Element<?>>
Tstretch
(T elem, float weight) Configures the supplied element with a weightedstretched(float)
constraint.Configures the default constraint for elements added to this layout to be stretched.static AxisLayout.Constraint
Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with weight 1.static AxisLayout.Constraint
stretched
(float weight) Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with the specified weight.static AxisLayout.Vertical
vertical()
Creates a vertical axis layout with default gap (5), and off-axis sizing policy (preferred size).Methods inherited from class tripleplay.ui.Layout
computeSize, layout
-
Constructor Details
-
AxisLayout
public AxisLayout()
-
-
Method Details
-
vertical
Creates a vertical axis layout with default gap (5), and off-axis sizing policy (preferred size). -
horizontal
Creates a horizontal axis layout with default gap (5), and off-axis sizing policy (preferred size). -
stretched
Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with weight 1. -
fixed
Returns a layout constraint indicating that the associated element should not be stretched. -
stretched
Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with the specified weight. -
stretch
Configures the supplied element with astretched()
constraint. -
stretch
Configures the supplied element with a weightedstretched(float)
constraint. -
stretchByDefault
Configures the default constraint for elements added to this layout to be stretched. This is equivalent to callingElement.setConstraint(Layout.Constraint)
withstretched()
for each element added to the parent container. -
offPolicy
Configures the off-axis sizing policy for this layout. -
offStretch
Configures this layout to stretch all elements to the available size on the off-axis. -
offEqualize
Configures this layout to stretch all elements to the size of the largest element on the off-axis. -
offConstrain
Configures this layout to constrain elements to the size of this container on the off-axis, leaving their size alone if it is smaller. -
gap
Configures the inter-element gap, in pixels.
-