Class UiContext

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

public final class UiContext extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    boolean
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    final net.minecraft.client.gui.Font
     
    float
     
    final net.minecraft.client.gui.GuiGraphics
     
    static final int
     
    final int
     
    final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    double
    Physical pixels per logical unit (window GUI scale × any extra pose scale).
    final net.minecraft.client.gui.screens.Screen
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    int
     
    int
    accentBg(float opacity)
    The accent colour tinted onto a dark background — for accent chips / fills behind text.
    int
    Focus-ring / input-border thickness in native px: a 2 logical-px stroke scaled by the ClickGui panel zoom only.
    static int
    darken(int argb, float factor)
    Darkens an ARGB colour by the given factor (0 = unchanged, 1 = black).
    void
    elevate(int x, int y, int w, int h, int radiusPx)
    Cheap elevation: a faint rounded shadow offset one px below the surface.
    ellipsize(String s, int maxWidth)
    Truncates s with a trailing ellipsis so it fits within maxWidth px.
    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.
    void
    hairlineH(int x, int y, int w, int color)
    A horizontal hairline exactly 1 physical pixel tall (separator rules).
    void
    hairlineV(int x, int y, int h, int color)
    A vertical hairline exactly 1 physical pixel wide (separator rules).
    boolean
    hover(int x, int y, int w, int h)
     
    void
    iconCentered(Icons.Icon icon, float cx, float cy, int size, int color)
    Draw a tintable icon sprite (Icons) at size, centred on (cx,cy), tinted color.
    int
     
    static boolean
    pointIn(double px, double py, int x, int y, int w, int h)
     
    void
    rect(int x, int y, int w, int h, int color)
     
    void
    roundRect(int x, int y, int w, int h, int radiusPx, int color)
    Rounded fill.
    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.
    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.).
    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.).
    scaled(float uiScale)
    Declares that rendering happens inside a pose scaled by uiScale (e.g.
    void
     
    void
    scissorOn(int x, int y, int w, int h)
    Scissors logical-space coordinates.
    void
    scissorOn(int x, int y, int w, int h, boolean vInside)
    As scissorOn(int, int, int, int), but when vInside is true the top/bottom edges are pulled inward by V_CLIP_INSET of a gui pixel before rounding, rather than expanding outward.
    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.
    void
    text(String s, int x, int y, int color)
     
    void
    textCentered(String s, int x, int y, int w, int color)
    Draw text centred within [x, x+w].
    void
    textItalic(String s, int x, int y, int color)
    Italic text (for type tags / hints), full scale.
    int
    Width of textItalic(java.lang.String, int, int, int) for s (includes the italic skew).
    int
     
    int
     
    int
     
    void
    textShadow(String s, int x, int y, int color)
     
    int
     
    timing(float frameDeltaMs, boolean animationsEnabled)
    Supplies animation timing (from the host screen) for smooth scrolling.
    void
    tinyText(String s, int x, int y, int color)
    Half-scale text for micro adornments (badges, popup footers, type tags).
    int
    Width of tinyText(java.lang.String, int, int, int) for s, in logical px.
    int
    toPx(int guiRadius)
    GUI-space radius → physical-pixel radius (for circles sized in GUI px, e.g.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 res
      Physical 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

      public UiContext timing(float frameDeltaMs, boolean animationsEnabled)
      Supplies animation timing (from the host screen) for smooth scrolling.
    • scaled

      public UiContext scaled(float uiScale)
      Declares that rendering happens inside a pose scaled by uiScale (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. radiusPx is in physical pixels (see R_SM etc.).
    • 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/radiusPx are 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. res folds in BOTH the MC gui density and the panel zoom, so toPx(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 (mirrors ClickGUIScreen.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)
      As scissorOn(int, int, int, int), but when vInside is true the top/bottom edges are pulled inward by V_CLIP_INSET of 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 is guiScale physical 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

      public void text(String s, int x, int y, int color)
    • textShadow

      public void textShadow(String s, int x, int y, int color)
    • textCentered

      public void textCentered(String s, int x, int y, int w, int color)
      Draw text centred within [x, x+w].
    • textWidth

      public int textWidth(String s)
    • lineHeight

      public int lineHeight()
    • tinyText

      public void tinyText(String s, int x, int y, int color)
      Half-scale text for micro adornments (badges, popup footers, type tags).
    • tinyTextWidth

      public int tinyTextWidth(String s)
      Width of tinyText(java.lang.String, int, int, int) for s, in logical px.
    • textItalic

      public void textItalic(String s, int x, int y, int color)
      Italic text (for type tags / hints), full scale.
    • textItalicWidth

      public int textItalicWidth(String s)
      Width of textItalic(java.lang.String, int, int, int) for s (includes the italic skew).
    • iconCentered

      public void iconCentered(Icons.Icon icon, float cx, float cy, int size, int color)
      Draw a tintable icon sprite (Icons) at size, centred on (cx,cy), tinted color.
    • ellipsize

      public String ellipsize(String s, int maxWidth)
      Truncates s with a trailing ellipsis so it fits within maxWidth px.