Class Flex

java.lang.Object
limn.scene.Widget
limn.scene.layout.Flex
Direct Known Subclasses:
Column, Row

public abstract class Flex extends Widget
Simplified flexbox shared by Column and Row: children flow along the main axis with an optional gap; Expanded children split the leftover main-axis space by flex weight; alignment controls the distribution of leftovers (Flex.MainAlignment) and cross-axis placement (Flex.CrossAlignment, including STRETCH).
  • Method Details

    • gap

      public Flex gap(float newGap)
      Space between children, in logical points. Not applied before the first or after the last.
    • gapSilently

      protected final void gapSilently(float newGap)
      Sets the gap without requesting a layout pass: the measure-path form, for a container that derives its gap from resolved size tokens inside its own onMeasure. Safe there and only there: the caller is already inside the pass that will consume the new value, so requesting another one is at best wasteful and at worst non-terminating. Everything else uses gap(float).
    • mainAlignment

      public Flex mainAlignment(Flex.MainAlignment alignment)
      How leftover space along the layout axis is distributed.
    • crossAlignment

      public Flex crossAlignment(Flex.CrossAlignment alignment)
      How children are placed across the layout axis; BASELINE is the one for a row that mixes size steps and carries text.
    • onMeasure

      protected Size onMeasure(Constraints constraints)
      Description copied from class: Widget
      Reports the size this widget wants within constraints. 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 ControlSize and the LayoutDirection once each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, and I18n.locale() answers it wherever text is resolved.

      Specified by:
      onMeasure in class Widget
    • onLayout

      protected void onLayout()
      Description copied from class: Widget
      Containers position children here (measure + Widget.layoutBox(float, float, float, float) per child).
      Overrides:
      onLayout in class Widget