Class Expanded
Column/Row it receives a share of
the leftover main-axis space proportional to flex. Without a child
it is a spacer(int): pure flexible whitespace.
The share is a tight constraint, so it overrides what the child asked for.
A flex child is measured with its main axis pinned to the share (minimum and maximum
both equal to it), and the size the child returns from its own onMeasure is
discarded on that axis. A control that measured itself at 116 pt because that is
what its chrome and its widest value need will be handed 35 pt in a crowded row
and will paint at 35, one part on top of another. That is the container doing as it
was told: nothing in the layout protocol lets a widget refuse.
atLeast(float) is how a call site refuses on the child's behalf. It is opt-in per
call site rather than a default, because the right floor is not a property of the
widget class: a caption that ellipsises wants to be squeezed (that is what the
ellipsis is for) and a stepper with a fixed chrome width does not, and the same
widget can be either one depending on the row it is in.
-
Method Summary
Modifier and TypeMethodDescriptionatLeast(float points) Declares a main-axis floor, in logical points: this child is never given less thanpoints, however little the weighted split would leave it.intflex()This child's share weight.floatminMain()static ExpandedAn equal share of the leftover space:flexof 1.static ExpandedGiveschilda share of the leftover space proportional toflex.protected 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.static Expandedspacer(int flex) Flexible empty space.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
-
Method Details
-
of
Giveschilda share of the leftover space proportional toflex. -
of
An equal share of the leftover space:flexof 1. -
spacer
Flexible empty space. -
flex
public int flex()This child's share weight. -
atLeast
Declares a main-axis floor, in logical points: this child is never given less thanpoints, however little the weighted split would leave it. Chains afterof(limn.scene.Widget, int). The default is0: no floor, and the distribution is the plain weighted one.The container satisfies floors before weight. A child whose share would fall under its floor is frozen at the floor and drops out of the split; whatever is left is re-divided among the others, which can push another one under its own floor, so this repeats until nothing is under. Siblings without floors absorb the whole loss, which is the point: a floored stepper beside an ellipsising label keeps its chrome and the label gives up the points.
Floors that do not fit overflow the container. When they add up to more than there is room for, every child still gets its floor and the row is over-subscribed; children paint past the container's edge. This is the same outcome a row of too-wide fixed children has today: a
Flexdoes not clip and does not wrap, so an over-subscribed row is visibly over-subscribed rather than silently truncated. Declare floors that fit, or give the container more room.Negative values clamp to
0. UI thread only. -
minMain
public float minMain()- Returns:
- the declared main-axis floor in points,
0when none was set
-
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).
-