Class ProgressBar

java.lang.Object
limn.scene.Widget
limn.components.ProgressBar

public class ProgressBar extends Widget
Simple horizontal progress bar. Determinate by default (setProgress(float) in [0..1]); setIndeterminate(boolean) switches to an animated sweeping pill (frame-clock ticker) for unknown-duration work. The determinate fill eases from the previous value to the new one through a shared Transition. A rounded track and fill, both from the Theme.

The bar follows the ControlSize resolved on it through exactly one token, progressThickness (4 / 6 / 8 / 10 / 12): every other quantity it paints already derives from Widget.height(): the pill radius, the minimum determinate fill, the indeterminate pill length and its travel. The long axis is free: 220 pt at every step, deliberately equal to Slider's so a bar and a slider stacked in a form line up, and a parent normally overrides it anyway.

setThickness(float) and setPreferredWidth(float) latch: an explicit value beats the step and survives every later step change, and a negative value (UNSET) hands the dimension back to the step.

  • Field Details

    • UNSET

      public static final float UNSET
      Marks a dimension as "follow the step", the SizedBox.UNSET idiom. Both dimensions start here, so a bar that was never explicitly sized tracks its ControlSize; anything >= 0 is an author's pin and wins.
      See Also:
  • Constructor Details

    • ProgressBar

      public ProgressBar()
  • Method Details

    • setProgress

      public ProgressBar setProgress(float value)
      Sets the determinate progress, clamped to [0..1]; the fill eases to it.
    • progress

      public float progress()
      Completion in [0,1]; meaningless while isIndeterminate().
    • isIndeterminate

      public boolean isIndeterminate()
      Whether the bar animates instead of showing a fraction.
    • setIndeterminate

      public ProgressBar setIndeterminate(boolean value)
      Switches to (or from) the animated indeterminate sweep.
    • setPreferredWidth

      public ProgressBar setPreferredWidth(float width)
      Overrides the 220 pt free axis; UNSET (any negative value) restores it.
    • setThickness

      public ProgressBar setThickness(float value)
      Pins the bar's thickness, overriding the step's progressThickness; UNSET (any negative value) hands it back to the step. A pinned value latches: a later setControlSize does not disturb it.
    • withControlSize

      public ProgressBar withControlSize(ControlSize size)
      Chaining form of Widget.setControlSize(limn.scene.ControlSize); setControlSize is void.
    • onAttached

      protected void onAttached()
      Description copied from class: Widget
      Called when this widget enters a scene (attached to the tree). Widget.scene() is the scene it just joined. Fires top-down, so a parent runs before its children. Default no-op.
      Overrides:
      onAttached in class Widget
    • onDetached

      protected void onDetached()
      Description copied from class: Widget
      Called when this widget leaves the scene (detached from the tree).

      Widget.scene() still answers the scene being left, and becomes null once this returns, so releasing something the scene owns needs no field of your own to remember it by. Fires bottom-up, so children run before their parent, and every one of them can still reach the scene.

      Release resources here, but GPU resources must be handed to Scene.disposeLater(limn.graphics.GpuSurface) (disposal needs the owning GL context, which is only current inside a frame). Not called on Widget.setVisible(boolean). Default no-op.

      Overrides:
      onDetached in class Widget
    • 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
    • onPaint

      protected void onPaint(Canvas canvas)
      Description copied from class: Widget
      Widget's own background/content, in local coordinates.
      Overrides:
      onPaint in class Widget