Class Keycap

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

public final class Keycap extends Object
Shared docs-site <kbd>-style keycap rendering plus key-combo label helpers, reused by the sidebar rows, filter hints and the KeybindInput recorder so keycaps look identical everywhere.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Keycap face height in logical px.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    comboParts(int mods, int code)
    Keycap labels for a stored combo: modifiers in order, then the main key.
    static void
    dashedRect(UiContext ui, int x, int y, int w, int h, int dash, int gap, int color)
    A 1px dotted rectangle border (dash on, gap off).
    static int
    draw(UiContext ui, int x, int capY, String label, float alpha)
    A raised keycap: an elevated face over a darker base edge peeking out below, like a physical key.
    static int
    drawGhost(UiContext ui, int x, int capY, String label, float alpha)
    Dashed ghost keycap: muted text inside a dotted border, no face or shadow.
    static int
    drawIcon(UiContext ui, int x, int capY, Icons.Icon icon, float alpha)
    As draw(me.hackware.api.gui.UiContext, int, int, java.lang.String, float), but the face carries a tinted icon sprite — used for modifiers that have a glyph rather than a name (macOS ⌘).
    static int
    Width of a keycap whose face carries an icon rather than a label: square, so the glyph gets the same padding on every side.
    static String
    Platform name of the OS/super modifier.
    static int
    width(UiContext ui, String label)
    Width of a keycap for label (text + horizontal padding).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HEIGHT

      public static final int HEIGHT
      Keycap face height in logical px.
      See Also:
  • Method Details

    • width

      public static int width(UiContext ui, String label)
      Width of a keycap for label (text + horizontal padding).
    • draw

      public static int draw(UiContext ui, int x, int capY, String label, float alpha)
      A raised keycap: an elevated face over a darker base edge peeking out below, like a physical key. capY is the face top; returns the x after it plus spacing.
    • iconWidth

      public static int iconWidth()
      Width of a keycap whose face carries an icon rather than a label: square, so the glyph gets the same padding on every side. Text caps pad their label horizontally instead, which on a glyph as wide as it is tall just reads as a stretched cap.
    • drawIcon

      public static int drawIcon(UiContext ui, int x, int capY, Icons.Icon icon, float alpha)
      As draw(me.hackware.api.gui.UiContext, int, int, java.lang.String, float), but the face carries a tinted icon sprite — used for modifiers that have a glyph rather than a name (macOS ⌘). Same face, base edge and spacing, so it lines up with text caps in the same run.
    • drawGhost

      public static int drawGhost(UiContext ui, int x, int capY, String label, float alpha)
      Dashed ghost keycap: muted text inside a dotted border, no face or shadow.
    • dashedRect

      public static void dashedRect(UiContext ui, int x, int y, int w, int h, int dash, int gap, int color)
      A 1px dotted rectangle border (dash on, gap off).
    • superName

      public static String superName()
      Platform name of the OS/super modifier.
    • comboParts

      public static List<String> comboParts(int mods, int code)
      Keycap labels for a stored combo: modifiers in order, then the main key.