Package me.hackware.api.gui
Class UiContext
java.lang.Object
me.hackware.api.gui.UiContext
Per-frame render context and primitive-drawing toolkit shared by the ClickGUI
component kit (see this package). Works in raw GUI coordinates — the same space
mouse events arrive in — so hit-testing is trivial and the rounded-rect helper
(
GuiUtils.fillRoundedRect(net.minecraft.client.gui.GuiGraphics, double, int, int, int, int, int, int)) quantises to real pixels via the window GUI
scale.
Bound only to a base Screen + Font, so both the Macros tab and
the radial-menu screen can use it. Colours come from GuiTheme
(accent + text tiers) plus a small set of dark, shadcn-flavoured surface tokens.
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanstatic final intstatic final intstatic final intstatic final intstatic final intfinal net.minecraft.client.gui.Fontfloatfinal net.minecraft.client.gui.GuiGraphicsstatic final intfinal intfinal intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intdoublePhysical pixels per logical unit (window GUI scale × any extra pose scale).final net.minecraft.client.gui.screens.Screenstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionUiContext(net.minecraft.client.gui.screens.Screen screen, net.minecraft.client.gui.GuiGraphics g, net.minecraft.client.gui.Font font, int mouseX, int mouseY) -
Method Summary
Modifier and TypeMethodDescriptionintaccent()intaccentBg(float opacity) The accent colour tinted onto a dark background — for accent chips / fills behind text.intborderPx()Focus-ring / input-border thickness in native px: a 2 logical-px stroke scaled by the ClickGui panel zoom only.static intdarken(int argb, float factor) Darkens an ARGB colour by the given factor (0 = unchanged, 1 = black).voidelevate(int x, int y, int w, int h, int radiusPx) Cheap elevation: a faint rounded shadow offset one px below the surface.Truncatesswith a trailing ellipsis so it fits withinmaxWidthpx.voidfocusRing(int x, int y, int w, int h, int radiusPx, int color) The focused-input accent ring: an EXTERIOR ring at double the normal border width, sitting in the band just OUTSIDE the field's edge (its inner edge flush to the box), so focus reads as a ring around the field growing outward — not a thick inset border.voidhairlineH(int x, int y, int w, int color) A horizontal hairline exactly 1 physical pixel tall (separator rules).voidhairlineV(int x, int y, int h, int color) A vertical hairline exactly 1 physical pixel wide (separator rules).booleanhover(int x, int y, int w, int h) voidiconCentered(Icons.Icon icon, float cx, float cy, int size, int color) intstatic booleanpointIn(double px, double py, int x, int y, int w, int h) voidrect(int x, int y, int w, int h, int color) voidroundRect(int x, int y, int w, int h, int radiusPx, int color) Rounded fill.voidroundRectBorder(int x, int y, int w, int h, int radiusPx, int fill, int border) Rounded fill with a 1-physical-pixel hairline border.voidroundRectOutline(int x, int y, int w, int h, int radiusPx, int color) A 1-physical-pixel rounded outline only — no fill (outlined buttons etc.).voidroundRectOutline(int x, int y, int w, int h, int radiusPx, int thicknessPx, int color) Rounded outline with an explicit physical thickness (focus rings etc.).scaled(float uiScale) Declares that rendering happens inside a pose scaled byuiScale(e.g.voidvoidscissorOn(int x, int y, int w, int h) Scissors logical-space coordinates.voidscissorOn(int x, int y, int w, int h, boolean vInside) AsscissorOn(int, int, int, int), but whenvInsideis true the top/bottom edges are pulled inward byV_CLIP_INSETof a gui pixel before rounding, rather than expanding outward.voidscissorRaw(int gx1, int gy1, int gx2, int gy2) Scissors a rect given directly in vanilla GUI space (post-pose), the finest granularity the scissor supports — used for per-pixel gradient slicing.voidvoidtextCentered(String s, int x, int y, int w, int color) Draw text centred within [x, x+w].voidtextItalic(String s, int x, int y, int color) Italic text (for type tags / hints), full scale.intWidth oftextItalic(java.lang.String, int, int, int)fors(includes the italic skew).intintintvoidtextShadow(String s, int x, int y, int color) inttiming(float frameDeltaMs, boolean animationsEnabled) Supplies animation timing (from the host screen) for smooth scrolling.voidHalf-scale text for micro adornments (badges, popup footers, type tags).intWidth oftinyText(java.lang.String, int, int, int)fors, in logical px.inttoPx(int guiRadius) GUI-space radius → physical-pixel radius (for circles sized in GUI px, e.g.
-
Field Details
-
BG_CARD
public static final int BG_CARD- See Also:
-
BG_ELEVATED
public static final int BG_ELEVATED- See Also:
-
BG_INPUT
public static final int BG_INPUT- See Also:
-
BORDER
public static final int BORDER- See Also:
-
BORDER_STRONG
public static final int BORDER_STRONG- See Also:
-
HOVER_OVERLAY
public static final int HOVER_OVERLAY- See Also:
-
SEL_OVERLAY
public static final int SEL_OVERLAY- See Also:
-
R_SM
public static final int R_SM- See Also:
-
R_MD
public static final int R_MD- See Also:
-
R_LG
public static final int R_LG- See Also:
-
R_XL
public static final int R_XL- See Also:
-
R_2XL
public static final int R_2XL- See Also:
-
PILL
public static final int PILL- See Also:
-
screen
public final net.minecraft.client.gui.screens.Screen screen -
g
public final net.minecraft.client.gui.GuiGraphics g -
font
public final net.minecraft.client.gui.Font font -
mouseX
public final int mouseX -
mouseY
public final int mouseY -
res
public double resPhysical pixels per logical unit (window GUI scale × any extra pose scale). -
frameDeltaMs
public float frameDeltaMs -
animationsEnabled
public boolean animationsEnabled
-
-
Constructor Details
-
UiContext
public UiContext(net.minecraft.client.gui.screens.Screen screen, net.minecraft.client.gui.GuiGraphics g, net.minecraft.client.gui.Font font, int mouseX, int mouseY)
-
-
Method Details
-
timing
Supplies animation timing (from the host screen) for smooth scrolling. -
scaled
Declares that rendering happens inside a pose scaled byuiScale(e.g. the ClickGui panel scale), with mouse coordinates already converted to that logical space. Keeps physical-pixel radii/borders resolving to real pixels through the extra transform. -
accent
public int accent() -
textPrimary
public int textPrimary() -
textSecondary
public int textSecondary() -
textMuted
public int textMuted() -
accentBg
public int accentBg(float opacity) The accent colour tinted onto a dark background — for accent chips / fills behind text. -
hover
public boolean hover(int x, int y, int w, int h) -
pointIn
public static boolean pointIn(double px, double py, int x, int y, int w, int h) -
rect
public void rect(int x, int y, int w, int h, int color) -
roundRect
public void roundRect(int x, int y, int w, int h, int radiusPx, int color) Rounded fill.radiusPxis in physical pixels (seeR_SMetc.). -
roundRectBorder
public void roundRectBorder(int x, int y, int w, int h, int radiusPx, int fill, int border) Rounded fill with a 1-physical-pixel hairline border. -
roundRectOutline
public void roundRectOutline(int x, int y, int w, int h, int radiusPx, int color) A 1-physical-pixel rounded outline only — no fill (outlined buttons etc.). -
roundRectOutline
public void roundRectOutline(int x, int y, int w, int h, int radiusPx, int thicknessPx, int color) Rounded outline with an explicit physical thickness (focus rings etc.). -
focusRing
public void focusRing(int x, int y, int w, int h, int radiusPx, int color) The focused-input accent ring: an EXTERIOR ring at double the normal border width, sitting in the band just OUTSIDE the field's edge (its inner edge flush to the box), so focus reads as a ring around the field growing outward — not a thick inset border.x,y,w,h/radiusPxare the field's own bounds. -
darken
public static int darken(int argb, float factor) Darkens an ARGB colour by the given factor (0 = unchanged, 1 = black). -
elevate
public void elevate(int x, int y, int w, int h, int radiusPx) Cheap elevation: a faint rounded shadow offset one px below the surface. -
hairlineH
public void hairlineH(int x, int y, int w, int color) A horizontal hairline exactly 1 physical pixel tall (separator rules). -
hairlineV
public void hairlineV(int x, int y, int h, int color) A vertical hairline exactly 1 physical pixel wide (separator rules). -
toPx
public int toPx(int guiRadius) GUI-space radius → physical-pixel radius (for circles sized in GUI px, e.g. ripples). -
borderPx
public int borderPx()Focus-ring / input-border thickness in native px: a 2 logical-px stroke scaled by the ClickGui panel zoom only.resfolds in BOTH the MC gui density and the panel zoom, sotoPx(2)(=2·guiScale·uiScale) reads as "2px × scale" — far too thick. Dividing the density back out leaves 2·uiScale: a clean exterior 2px border that tracks the panel without ballooning at high gui scales. -
scissorOn
public void scissorOn(int x, int y, int w, int h) Scissors logical-space coordinates. Transforms the rect by the current pose manually and neutralises the pose for the actual scissor call (mirrorsClickGUIScreen.enablePanelScissor) so scaled poses don't shave a pixel off the edges via float round-tripping. -
scissorOn
public void scissorOn(int x, int y, int w, int h, boolean vInside) AsscissorOn(int, int, int, int), but whenvInsideis true the top/bottom edges are pulled inward byV_CLIP_INSETof a gui pixel before rounding, rather than expanding outward. The default outward rounding (floor top, ceil bottom) lets content bleed past the viewport at fractional panel scales; a whole-pixel inward pull (ceil/floor) over-corrects by a full gui pixel — which isguiScalephysical pixels once MC scales the clip rect to the framebuffer. The fractional pull is the tuned minimum that still keeps rows from spilling over an adjacent divider (top) or border (bottom). Horizontal edges stay outward. -
scissorOff
public void scissorOff() -
scissorRaw
public void scissorRaw(int gx1, int gy1, int gx2, int gy2) Scissors a rect given directly in vanilla GUI space (post-pose), the finest granularity the scissor supports — used for per-pixel gradient slicing. -
text
-
textShadow
-
textCentered
Draw text centred within [x, x+w]. -
textWidth
-
lineHeight
public int lineHeight() -
tinyText
Half-scale text for micro adornments (badges, popup footers, type tags). -
tinyTextWidth
Width oftinyText(java.lang.String, int, int, int)fors, in logical px. -
textItalic
Italic text (for type tags / hints), full scale. -
textItalicWidth
Width oftextItalic(java.lang.String, int, int, int)fors(includes the italic skew). -
iconCentered
-
ellipsize
Truncatesswith a trailing ellipsis so it fits withinmaxWidthpx.
-