Class SizedBox

java.lang.Object
limn.scene.Widget
limn.scene.layout.SizedBox

public final class SizedBox extends Widget
Forces a fixed width and/or height (unset dimensions pass through to the child, or collapse to zero without one). Also handy as a rigid spacer.
  • Field Details

    • UNSET

      public static final float UNSET
      Marks a dimension as "not fixed".
      See Also:
  • Constructor Details

    • SizedBox

      public SizedBox(float width, float height, Widget child)
      Forces child to an exact size; UNSET on an axis leaves it free.
    • SizedBox

      public SizedBox(float width, float height)
      An empty box of a fixed size: a spacer.
  • Method Details

    • 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