Class StackPanelImpl
java.lang.Object
org.inspirenxe.strata.core.node.BuiltInComponent<org.inspirenxe.strata.api.layout.StackPanel>
org.inspirenxe.strata.core.node.BuiltInComposite<org.inspirenxe.strata.api.layout.StackPanel>
org.inspirenxe.strata.core.node.BuiltInContainer<org.inspirenxe.strata.api.layout.StackPanel>
org.inspirenxe.strata.core.layout.StackPanelImpl
- All Implemented Interfaces:
org.inspirenxe.strata.api.component.Component<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.component.Container<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.component.Enableable<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.component.HasContextMenu<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.component.HasCursor<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.component.HasTooltip<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.event.EventTarget<org.inspirenxe.strata.api.layout.StackPanel>, org.inspirenxe.strata.api.layout.StackPanel
public final class StackPanelImpl
extends BuiltInContainer<org.inspirenxe.strata.api.layout.StackPanel>
implements org.inspirenxe.strata.api.layout.StackPanel
The core
StackPanel. Children without a weight are measured with unlimited space along the stacking axis
and the content size across it. Weighted children are measured after them, each with its share of the space the
others and the gaps leave, or with unlimited space when the panel itself has no limit; the panel asks for the
smallest weighted length that gives each its desired size in proportion, less what a child's maximum size cuts
from its part. Children are then placed one after another with the spacing between them, weighted ones in their
share of the room left in the content box. Each slot spans the whole content box across the axis. Hidden children
take no space and add no spacing. Spreading widens the gaps only when no visible child has a weight.
Shares respect each weighted child's minimum and maximum size along the axis, margin included: a child whose
share would cross a limit gets the limit, and the other weighted children share what is left, as
WeightedShares describes. The lower limit is the child's outer minimum
(MeasureContext.minimumSize(Component)), so a content minimum or a fixed size holds a share up too.
In a row, children aligned VerticalAlignment.BASELINE are lined up
as BaselineRow describes: the row is at least as tall as they need lined up, and each one's slot starts
where its baseline meets theirs, as tall as the child asked for.
The panel's own content minimum is its children's minimums along the axis plus the gaps, the largest across, and the padding.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.inspirenxe.strata.api.layout.StackPanel
org.inspirenxe.strata.api.layout.StackPanel.State -
Field Summary
Fields inherited from interface org.inspirenxe.strata.api.component.Component
ATTACHED, DETACHED, ENABLED, MEASURED, OPACITY, PAINT, PAINTED, VISIBLEFields inherited from interface org.inspirenxe.strata.api.component.HasContextMenu
SHOW_CONTEXT_MENUFields inherited from interface org.inspirenxe.strata.api.component.HasTooltip
TOOLTIP -
Constructor Summary
ConstructorsConstructorDescriptionStackPanelImpl(ComponentFactoryImpl ui, org.inspirenxe.strata.api.layout.Orientation orientation) Creates an empty panel with no spacing. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidarrange(org.inspirenxe.strata.api.extension.ArrangeContext context, org.inspirenxe.strata.api.geometry.Rect bounds) Gives every child its slot.booleanisSpread()protected org.inspirenxe.strata.api.geometry.Sizemeasure(org.inspirenxe.strata.api.extension.MeasureContext context, float availableWidth, float availableHeight) Returns the size the content needs within the given space, asCustomComponent.measuredoes.protected org.inspirenxe.strata.api.geometry.SizemeasureMinimum(org.inspirenxe.strata.api.extension.MeasureContext context) Returns the smallest size the content can work in, asCustomComponent.measureMinimumdoes.protected voidonChildRemoved(org.inspirenxe.strata.api.component.Component<?> child) Called after a child is removed, to drop any data kept about it.org.inspirenxe.strata.api.layout.Orientationorg.inspirenxe.strata.api.layout.StackPanelsetOrientation(org.inspirenxe.strata.api.layout.Orientation orientation) org.inspirenxe.strata.api.layout.StackPanelsetSpacing(float spacing) org.inspirenxe.strata.api.layout.StackPanelsetSpread(boolean spread) org.inspirenxe.strata.api.layout.StackPanelsetWeight(org.inspirenxe.strata.api.component.Component<?> child, float weight) protected ObjectReturns this component's own state for a snapshot, an immutable value without its children's state.floatspacing()floatweight(org.inspirenxe.strata.api.component.Component<?> child) Methods inherited from class BuiltInContainer
add, background, border, children, clear, clearPadding, clipsChildren, contentBox, indexOf, insert, lower, move, padding, paintOrder, raise, remove, setBackground, setBorder, setClipChildren, setPadding, setTextStyle, textStyleMethods inherited from class BuiltInComposite
addChild, addContent, childClip, childList, clearChildren, insertChild, insertContent, invalidateArrangement, lowerChild, moveChild, node, onDescendantFocused, paintOverChildren, raiseChild, removeChild, setChildClippingMethods inherited from class BuiltInComponent
acceptsTextInput, activatesOnPress, ancestor, baseline, bind, bounds, clearTooltip, contextMenu, cursor, desiredHeight, desiredWidth, environment, flow, flowDirection, hasStyleState, horizontalAlignment, hostRoot, id, invalidateLayout, isAttached, isEnabled, isFocusable, isFocused, isFocusFromPress, isFocusVisible, isFocusWithin, isHandled, isHitTestVisible, isHovered, isHoverWithin, isPressed, isRightToLeft, isTabbable, isVisible, margin, maxHeight, maxWidth, minHeight, minWidth, motionAnimator, nodeOf, offsetX, offsetY, onApplyTheme, onAttached, onChar, onClick, onDetached, onDisabled, onDrag, onDragEnd, onDragEnter, onDragExit, onDragOver, onDragStart, onDrop, onEdgeScroll, onEnabledChanged, onEvent, onFocusGained, onFocusLost, onKey, onOtherEvent, onPointerEnter, onPointerExit, onPointerMove, onPointerPress, onPointerRelease, onPressWithin, onReleased, onScroll, onTransferDone, opacity, paint, parent, parent, repaint, repaintAfter, repaintNextFrame, report, report, request, request, requestFocus, requiredStyleKeys, self, setAlignment, setContextMenu, setCursor, setEnabled, setFlowDirection, setFocusable, setFocusDelegate, setHeight, setHitTestVisible, setId, setMargin, setMaxSize, setMinSize, setOffset, setOpacity, setStyleState, setTabbable, setTabIndex, setTooltip, setVisible, setWidth, setZIndex, stylePaint, styleText, subscribe, tabIndex, textInputKind, theme, tooltip, toString, unbind, verticalAlignment, whileAttached, zIndexMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.inspirenxe.strata.api.component.Component
ancestor, bind, bounds, desiredHeight, desiredWidth, flowDirection, horizontalAlignment, id, isAttached, isEffectivelyEnabled, isEffectivelyVisible, isEnabled, isFocusWithin, isHitTestVisible, isVisible, margin, maxHeight, maxWidth, minHeight, minWidth, opacity, parent, parent, setAlignment, setAnchor, setEnabled, setFlowDirection, setHeight, setHitTestVisible, setId, setMargin, setMargin, setMargin, setMargin, setMaxSize, setMinSize, setOpacity, setSize, setVisible, setWidth, setZIndex, unbind, verticalAlignment, whileAttached, zIndexMethods inherited from interface org.inspirenxe.strata.api.component.Container
add, background, border, children, clear, clearPadding, clipsChildren, indexOf, insert, lower, move, padding, paintOrder, raise, remove, setBackground, setBorder, setClipChildren, setPadding, setPadding, setPadding, setPadding, setTextStyle, textStyleMethods inherited from interface org.inspirenxe.strata.api.event.EventTarget
onEvent, onEvent, subscribeMethods inherited from interface org.inspirenxe.strata.api.component.HasContextMenu
contextMenu, setContextMenuMethods inherited from interface org.inspirenxe.strata.api.component.HasCursor
cursor, setCursorMethods inherited from interface org.inspirenxe.strata.api.component.HasTooltip
clearTooltip, setTooltip, setTooltip, setTooltip, tooltipMethods inherited from interface org.inspirenxe.strata.api.layout.StackPanel
add
-
Constructor Details
-
StackPanelImpl
public StackPanelImpl(ComponentFactoryImpl ui, org.inspirenxe.strata.api.layout.Orientation orientation) Creates an empty panel with no spacing.- Parameters:
ui- the factory that owns the panelorientation- the stacking direction
-
-
Method Details
-
orientation
public org.inspirenxe.strata.api.layout.Orientation orientation()- Specified by:
orientationin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
setOrientation
public org.inspirenxe.strata.api.layout.StackPanel setOrientation(org.inspirenxe.strata.api.layout.Orientation orientation) - Specified by:
setOrientationin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
spacing
public float spacing()- Specified by:
spacingin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
setSpacing
public org.inspirenxe.strata.api.layout.StackPanel setSpacing(float spacing) - Specified by:
setSpacingin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
isSpread
public boolean isSpread()- Specified by:
isSpreadin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
setSpread
public org.inspirenxe.strata.api.layout.StackPanel setSpread(boolean spread) - Specified by:
setSpreadin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
weight
public float weight(org.inspirenxe.strata.api.component.Component<?> child) - Specified by:
weightin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
setWeight
public org.inspirenxe.strata.api.layout.StackPanel setWeight(org.inspirenxe.strata.api.component.Component<?> child, float weight) - Specified by:
setWeightin interfaceorg.inspirenxe.strata.api.layout.StackPanel
-
onChildRemoved
protected void onChildRemoved(org.inspirenxe.strata.api.component.Component<?> child) Description copied from class:BuiltInCompositeCalled after a child is removed, to drop any data kept about it. The default does nothing.- Overrides:
onChildRemovedin classBuiltInComposite<org.inspirenxe.strata.api.layout.StackPanel>- Parameters:
child- the removed child
-
measure
protected org.inspirenxe.strata.api.geometry.Size measure(org.inspirenxe.strata.api.extension.MeasureContext context, float availableWidth, float availableHeight) Description copied from class:BuiltInComponentReturns the size the content needs within the given space, asCustomComponent.measuredoes.- Specified by:
measurein classBuiltInComponent<org.inspirenxe.strata.api.layout.StackPanel>- Parameters:
context- text measurement and child measuringavailableWidth- the width offered, margin removed; may beFloat.POSITIVE_INFINITYavailableHeight- the height offered, margin removed; may beFloat.POSITIVE_INFINITY- Returns:
- the natural size of the content
-
arrange
protected void arrange(org.inspirenxe.strata.api.extension.ArrangeContext context, org.inspirenxe.strata.api.geometry.Rect bounds) Description copied from class:BuiltInCompositeGives every child its slot. Called afterBuiltInComponent.measure(MeasureContext, float, float), with the component's final bounds, and again with the same bounds afterBuiltInComposite.invalidateArrangement().- Specified by:
arrangein classBuiltInComposite<org.inspirenxe.strata.api.layout.StackPanel>- Parameters:
context- child sizes and slot assignmentbounds- the component's bounds
-
measureMinimum
protected org.inspirenxe.strata.api.geometry.Size measureMinimum(org.inspirenxe.strata.api.extension.MeasureContext context) Description copied from class:BuiltInComponentReturns the smallest size the content can work in, asCustomComponent.measureMinimumdoes. The default returnsSize.ZERO.- Overrides:
measureMinimumin classBuiltInComponent<org.inspirenxe.strata.api.layout.StackPanel>- Parameters:
context- text measurement and the children's minimums- Returns:
- the smallest size of the content
-
snapshotState
Description copied from class:BuiltInComponentReturns this component's own state for a snapshot, an immutable value without its children's state. Called only when an event with snapshots captures this component. The default returns null.- Overrides:
snapshotStatein classBuiltInComponent<org.inspirenxe.strata.api.layout.StackPanel>- Returns:
- the state, or null for none
-