Package me.hackware.api.gui
Class Popover
java.lang.Object
me.hackware.api.gui.Popover
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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDraws the popover's body, faded byalpha; runs inside the scale transform. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatEasesanimtoward 1 (open) or 0 (closed) over ~ANIM_MSwith a frame-rate-independent ease-out; snaps straight to the target when animations are disabled.floatalpha()Current 0..1 opacity/progress.voidclose()booleanisOpen()Live and interactive.booleanOn screen — open or fading out.voidopen()booleanrender(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 fadedsurface(me.hackware.api.gui.UiContext, int, int, int, int, int, float)— then the body, and advances the open/close animation.booleanrenderBare(UiContext ui, float pivotX, float pivotY, Popover.Body body) Likerender(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).booleanrenderBare(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 abackdropslot: drawn after the animation ticks but outside the scale transform, so it fades in step with the body without being scaled by it.voidreset()Snaps straight to closed, skipping the fade — for popovers whose visibility is derived rather than driven byclose(), so the next open pops in again instead of resuming from a half-faded state.static floatscale(float anim) The pop-in scale (0.9→1) for a given progress.voidsetOpen(boolean open) static voidThe shared popover surface: a darkened panel-tinted opaque fill, lifted by a shadow-xl and ringed with a 1px border — all faded byalpha.
-
Field Details
-
ANIM_MS
public static final float ANIM_MSOpen/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 byclose(), 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 fadedsurface(me.hackware.api.gui.UiContext, int, int, int, int, int, float)— then the body, and advances the open/close animation. Returnsfalsewhen fully hidden (nothing drawn).pivotX/pivotYis the point the pop grows out of (the anchor control's edge), in the same logical space the body draws in. -
renderBare
Likerender(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 abackdropslot: 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
Easesanimtoward 1 (open) or 0 (closed) over ~ANIM_MSwith 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
The shared popover surface: a darkened panel-tinted opaque fill, lifted by a shadow-xl and ringed with a 1px border — all faded byalpha. Opaque because MC can't blur GUI content behind a GUI popup, so the fill is what hides the rows underneath.
-