Package limn.components
Class TokenBox
java.lang.Object
limn.scene.Widget
limn.components.TokenBox
A
SizedBox whose fixed dimensions come from the resolved
ControlSize step instead of from a number baked at construction.
The fourth of the Token* family: TokenRow, TokenColumn and
TokenPadding do this for gaps and insets, and this does it for an extent. It
exists for the size-axis trap the repository keeps running into: a widget has no parent
while it is being built, so a size read there resolves against the process
default and stays there forever, whatever step the eventual parent declares.
// the colour picker, as wide as the step says a picker in a dialog should be
new TokenBox(SizeTokens::colorDialogW, null, picker)
null means "unset" on either axis, exactly as SizedBox.UNSET does:
that axis is whatever the child measures to.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceOne extent, read off a size step. -
Constructor Summary
ConstructorsConstructorDescriptionTokenBox(TokenBox.Extent fixedWidth, TokenBox.Extent fixedHeight, Widget child) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidonLayout()Containers position children here (measure +Widget.layoutBox(float, float, float, float)per child).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.Methods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onCharTyped, onDetached, onFileDrop, onFocusGained, onFocusLost, onKeyEvent, onMouseEvent, onPaint, onPaintOverlay, onPreedit, overlayPassesPointer, paintChildren, paintOutset, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
TokenBox
- Parameters:
fixedWidth- the width to impose, ornullto take the child'sfixedHeight- the height to impose, ornullto take the child'schild- the widget to size; nevernull
-
-
Method Details
-
onMeasure
Description copied from class:WidgetReports the size this widget wants withinconstraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.Resolve the
ControlSizeand theLayoutDirectiononce each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, andI18n.locale()answers it wherever text is resolved. -
onLayout
protected void onLayout()Description copied from class:WidgetContainers position children here (measure +Widget.layoutBox(float, float, float, float)per child).
-