Class Padding

java.lang.Object
limn.scene.Widget
limn.scene.layout.Padding
Direct Known Subclasses:
BackdropPanel, TokenPadding

public class Padding extends Widget
Wraps one child with edge insets.

Not final: a container that derives its insets from resolved ControlSize tokens subclasses this and pushes them from its own measure path. Without that, a size step would compact the controls and leave the page padding around them at whatever literal the app typed, and the spacing ramp is the widest of the three.

  • Constructor Details

    • Padding

      public Padding(Insets insets, Widget child)
      Insets child on each side; the padding is inside this widget's own box.
  • Method Details

    • all

      public static Padding all(float value, Widget child)
      The same inset on all four sides.
    • insets

      public final Insets insets()
      The current insets.
    • setInsets

      public final void setInsets(Insets newInsets)
      Replaces the insets, with an equality guard. Without the guard, a token-driven subclass that re-applies its insets on every measure pass calls Widget.markNeedsLayout() from inside onMeasure, which dirties the path to the root and schedules another pass: a layout loop that never settles.
    • setInsetsSilently

      protected final void setInsetsSilently(Insets newInsets)
      Assigns the insets without requesting a layout pass: the measure-path form, for a subclass that derives them 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 setInsets(limn.scene.Insets).
    • 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