Class Popover

java.lang.Object
me.hackware.api.gui.Popover

public final class Popover extends Object
A reusable anchored-popover component — the macro "Add" picker, the profiles Import / row menus, the wheel adder, the search quick-nav, IntelliSense, and any other floating panel that drops from a control. Built once, so every popover shares one look and one open/close animation: a 125ms opacity-0→1 with a subtle 0.9→1 scale that grows out of the control it belongs to, over a darkened panel-tinted fill lifted with a shadow-xl.

Use it like a component: give each popover an instance, drive it with open()/close(), gate the host's render on isVisible() and its input on isOpen(), and draw the body through render(me.hackware.api.gui.UiContext, int, int, int, int, int, float, float, me.hackware.api.gui.Popover.Body):

   if (popover.isVisible())
       popover.render(ui, x, y, w, h, UiContext.R_MD, pivotX, pivotY, alpha -> {
           // draw rows / fields here, multiplying every colour by `alpha`
       });
 
render(me.hackware.api.gui.UiContext, int, int, int, int, int, float, float, me.hackware.api.gui.Popover.Body) advances the animation, applies the scale transform about the pivot, paints the surface, then calls the body with the current alpha (which the body threads through its own colours). isOpen() flips false the instant a close starts, so the fading-out ghost stops taking input while it finishes.

The static helpers (advance(float, boolean, me.hackware.api.gui.UiContext), scale(float), surface(me.hackware.api.gui.UiContext, int, int, int, int, int, float)) expose the same pieces for popovers that own bespoke layout/lifecycle (freezing content across a close, extra visibility guards) and can't hand their whole body to render(me.hackware.api.gui.UiContext, int, int, int, int, int, float, float, me.hackware.api.gui.Popover.Body).

  • Field Details

    • ANIM_MS

      public static final float ANIM_MS
      Open/close animation length, ms.
      See Also:
  • Constructor Details

    • Popover

      public Popover()
  • Method Details

    • isOpen

      public boolean isOpen()
      Live and interactive. False the moment a close begins, even mid-fade.
    • isVisible

      public boolean isVisible()
      On screen — open or fading out. Gate the host's render pass on this.
    • alpha

      public float alpha()
      Current 0..1 opacity/progress.
    • open

      public void open()
    • close

      public void close()
    • setOpen

      public void setOpen(boolean open)
    • reset

      public void reset()
      Snaps straight to closed, skipping the fade — for popovers whose visibility is derived rather than driven by close(), so the next open pops in again instead of resuming from a half-faded state.
    • render

      public boolean render(UiContext ui, int x, int y, int w, int h, int radiusPx, float pivotX, float pivotY, Popover.Body body)
      Renders the animated shell — scale-from-pivot + the faded surface(me.hackware.api.gui.UiContext, int, int, int, int, int, float) — then the body, and advances the open/close animation. Returns false when fully hidden (nothing drawn). pivotX/pivotY is the point the pop grows out of (the anchor control's edge), in the same logical space the body draws in.
    • renderBare

      public boolean renderBare(UiContext ui, float pivotX, float pivotY, Popover.Body body)
      Like render(me.hackware.api.gui.UiContext, int, int, int, int, int, float, float, me.hackware.api.gui.Popover.Body) but paints no surface — for popovers whose body draws its own (a bespoke fill). Still owns the animation, the scale transform and alpha.
    • renderBare

      public boolean renderBare(UiContext ui, float pivotX, float pivotY, Popover.Body backdrop, Popover.Body body)
      renderBare(me.hackware.api.gui.UiContext, float, float, me.hackware.api.gui.Popover.Body) with a backdrop slot: drawn after the animation ticks but outside the scale transform, so it fades in step with the body without being scaled by it. This is what a modal's full-screen scrim needs — scaling a screen-sized dim to 0.9 would uncover the edges, and drawing it before the tick would leave it a frame behind the card.
    • advance

      public static float advance(float anim, boolean open, UiContext ui)
      Eases anim toward 1 (open) or 0 (closed) over ~ANIM_MS with a frame-rate-independent ease-out; snaps straight to the target when animations are disabled. Feed the result back in each frame.
    • scale

      public static float scale(float anim)
      The pop-in scale (0.9→1) for a given progress.
    • surface

      public static void surface(UiContext ui, int x, int y, int w, int h, int radiusPx, float alpha)
      The shared popover surface: a darkened panel-tinted opaque fill, lifted by a shadow-xl and ringed with a 1px border — all faded by alpha. Opaque because MC can't blur GUI content behind a GUI popup, so the fill is what hides the rows underneath.