Class BackdropPanel


public class BackdropPanel extends Padding
A panel whose background is the content behind it, put through a BackdropEffect: a glass control bar over video, a washed header over a picture, a redacted field. Wraps one child with insets, like the Padding it extends, and paints the effect under it.

Put it where it will be painted after what it sits over. The effect samples what the frame has already drawn, so a panel is a sibling after the content: in a stack, the layer above; in a column, nothing sits behind it and the effect shows the window's own background, which is a legitimate but very dull result.

Costs a batch break and a copy of its own bounds per frame it paints. That is a control bar's worth of work, not a list row's: a panel per row is the wrong shape for this widget, and a hundred of them will show up in the frame time.

Degrades to a flat panel in the effect's tint where the renderer has no backdrop support, with the same size, position and corner radius.

Size axis: the corner radius follows the resolved ControlSize row like every other component's chrome, unless setCornerRadius(float) pins it. The effect's own dimensions (a rim width, a cell size) are authored in points and do not scale with the step: they are optical properties of the material, not of the control.

  • Field Details

  • Constructor Details

  • Method Details

    • effect

      public final BackdropEffect effect()
      The first effect painted behind the child; see effects() for the whole stack.
    • effects

      public final List<BackdropEffect> effects()
      Every effect painted behind the child, in the order they are drawn.
    • setEffects

      public BackdropPanel setEffects(BackdropEffect... stack)
      Replaces the effect with a stack, drawn in order over the same shape.

      This is how the effects compose, and it needs nothing from the renderer: each one reads the framebuffer and writes it, so the second samples what the first left. It is what makes a frosted pane out of the pieces rather than out of a variant with four parameters, and what makes BackdropEffect.Blur affordable, since a separable blur IS two passes.

      Each pass costs one batch flush and one copy of the panel's own bounds, so a stack of three costs three of each. Over a small panel that is cheap and over a full-window one it is not; the cost is proportional to the shape, not to the window.

      Throws:
      IllegalArgumentException - if the stack is empty
    • setEffect

      public BackdropPanel setEffect(BackdropEffect newEffect)
      Replaces the effect. UI thread only.
    • setCornerRadius

      public BackdropPanel setCornerRadius(float radius)
      Pins the corner radius in points, or RADIUS_FROM_TOKENS to follow the resolved size row (the default). UI thread only.
    • onPaint

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