parin.joka.microui

Rxi's tiny immediate-mode UI library, but with Joka specific changes.

Types 36

aliasMuId = uint

The control ID type of microui.

aliasMuFont = void *

The font type of microui.

aliasMuTexture = void *

The texture type of microui.

aliasMuSliceMode = ubyte

The slice repeat mode type of microui.

enumMuClip : ubyte

The clipping kind.

noneNo clipping.
partPartial clipping (for scrollable areas).
allFull clipping to container bounds.
enumMuCommand : ubyte

The command kind.

noneNo command.
jumpJump to another command in the buffer.
clipSet a clipping region.
rectDraw a rectangle.
textDraw text.
iconDraw an icon.
enumMuColor : ubyte

The color kind.

textDefault text color.
borderBorder color for controls.
windowBgBackground color of windows.
titleBgBackground color of window titles.
titleTextText color for window titles.
panelBgBackground color of panels.
buttonDefault button color.
buttonHoverButton color on hover.
buttonFocusButton color when focused.
baseBase background for text input or sliders.
baseHoverHover color for base controls.
baseFocusFocus color for base controls.
scrollBaseBackground of scrollbars.
scrollThumbScrollbar thumb color.
enumMuIcon : ubyte

The icon kind.

noneNo icon.
closeClose icon.
checkCheckmark icon.
collapsedCollapsed tree icon.
expandedExpanded tree icon.
enumMuAtlas : ubyte

The atlas area kind.

noneNo atlas rectangle.
buttonDefault button atlas rectangle.
buttonHoverButton atlas rectangle on hover.
buttonFocusButton atlas rectangle when focused.
aliasMuResFlags = ubyte

Bitmask type for result flags.

Result flags indicating the outcome of a control interaction.

none = 0No result.
active = (1 << 0)Control is active (e.g., active window).
submit = (1 << 1)Control value submitted (e.g., clicked button).
change = (1 << 2)Control value changed (e.g., modified text input).
aliasMuOptFlags = ushort

Bitmask type for option flags.

Option flags controlling control and window behaviour.

none = 0No option.
alignCenter = (1 << 0)Center-align control content.
alignRight = (1 << 1)Right-align control content.
noInteract = (1 << 2)Disable interaction.
noFrame = (1 << 3)Draw control without a frame.
noResize = (1 << 4)Disable resizing for windows.
noScroll = (1 << 5)Disable scrolling for containers.
noClose = (1 << 6)Remove close button from window.
noTitle = (1 << 7)Remove title bar from window.
holdFocus = (1 << 8)Keep control focused after click.
autoSize = (1 << 9)Window automatically sizes to content. Implies `noResize` and `noScroll`.
popup = (1 << 10)Marks window as popup (e.g., closed on mouse click).
closed = (1 << 11)Window starts closed.
expanded = (1 << 12)Window starts expanded.
noName = (1 << 13)Hides window name.
defaultFocus = (1 << 14)Keep focus when no other control is focused.
aliasMuMouseFlags = ubyte

Bitmask type for mouse button flags.

Flags representing which mouse buttons are pressed.

none = 0No mouse button.
left = (1 << 0)Left mouse button.
right = (1 << 1)Right mouse button.
middle = (1 << 2)Middle mouse button.
aliasMuKeyFlags = uint

Bitmask type for keyboard key flags.

Flags representing which keys are currently held down.

none = 0No key.
shift = (1 << 0)Shift key down.
ctrl = (1 << 1)Control key down.
alt = (1 << 2)Alt key down.
backspace = (1 << 3)Backspace key down.
enter = (1 << 4)Return key down.
tab = (1 << 5)Tab key down.
left = (1 << 6)Left key down.
right = (1 << 7)Right key down.
up = (1 << 8)Up key down.
down = (1 << 9)Down key down.
home = (1 << 10)Home key down.
end = (1 << 11)End key down.
pageUp = (1 << 12)Page up key down.
pageDown = (1 << 13)Page down key down.
f1 = (1 << 14)F1 key down.
f2 = (1 << 15)F2 key down.
f3 = (1 << 16)F3 key down.
f4 = (1 << 17)F4 key down.
aliasMuTextWidthFunc = int function(MuFont font, IStr str)

Used for getting the width of the text.

aliasMuTextHeightFunc = int function(MuFont font)

Used for getting the height of the text.

aliasMuDrawFrameFunc = void function(MuContext * ctx, IRect rect, MuColor colorId, MuAtlas atlasId = MuAtlas.none)

Used for drawing a frame.

structMuStack(T, Sz N)

A static stack.

Fields
int idx
StaticArray!(T, N) data
Methods
void push(T val)Pushes a value onto the stack.
void pop()Pops a value off the stack.

A pool item.

Fields
MuId id
int lastUpdate

Base structure for all render commands, containing type and size metadata.

Fields
int size

Command to jump to another location in the command buffer.

Fields
void * dst

Command to set a clipping rectangle.

Fields
IRect rect

Command to draw a rectangle with a given color.

Fields
IRect rect
Rgba color

Command to render text at a given position with a font and color. The text is a null-terminated string stored inline. Use str.ptr to access it.

Fields
MuFont font
IVec2 pos
Rgba color
int len
char[1] str
Methods

Command to draw an icon inside a rectangle with a given color.

Fields
IRect rect
Rgba color

A union of all possible render commands. The type and base fields are always valid, as all commands begin with a MuCommand and MuBaseCommand. Use type to determine the active command variant.

structMuLayout

Layout state used to position UI controls within a container.

Fields
IRect body
IRect next
IVec2 pos
IVec2 size
IVec2 max
int[muMaxWidths] widths
int items
int itemIndex
int nextRow
int nextType
int indent

A UI container holding commands.

Fields
IRect rect
IRect body
IVec2 contentSize
IVec2 scroll
int zIndex
bool open
structMuSlice

A 9-slice definition for an atlas area, controlling how it is sampled and tiled.

Fields
IRect area
Margin margin
structMuStyle

UI style settings including font, sizes, spacing, and colors.

Fields
MuFont font
MuTexture texture
IVec2 size
int padding
int spacing
int indent
int border
int titleHeight
int scrollbarSize
int scrollbarSpeed
int scrollbarKeySpeed
int thumbSize
int fontScale
StaticArray!(Rgba, MuColor.max + 1) colors
StaticArray!(MuSlice, MuAtlas.max + 1) slices
StaticArray!(IRect, MuIcon.max + 1) iconAtlasAreas
structMuPrivate

Used by the members function to hide data.

structMuMember

Used by the members function to show data in a specific way.

Fields
IStr name
float low
float high
float step
Constructors
this(float low, float high, float step = float.nan)Constructs a member with a slider range and optional step size.
this(float step)Constructs a member with only a step size.
this(IStr name, float low, float high, float step = float.nan)Constructs a member with a display name, slider range, and optional step size.
this(IStr name, float step = float.nan)Constructs a member with a display name and optional step size.
structMuContext

The UI context.

Fields
MuTextWidthFunc textWidth
MuTextHeightFunc textHeight
MuDrawFrameFunc drawFrame
MuStyle _style
MuStyle * style
MuId hover
MuId focus
MuId lastId
IRect lastRect
int lastZIndex
bool updatedFocus
int frame
MuContainer * hoverRoot
MuContainer * nextHoverRoot
MuContainer * scrollTarget
char[muMaxFmt] numberEditBuffer
MuId numberEdit
bool isExpectingEnd
uint buttonCounter
MuKeyFlags dragWindowKey
MuKeyFlags resizeWindowKey
MuStack!(char, muCommandListSize) commandList
MuStack!(MuContainer *, muRootListSize) rootList
MuStack!(MuContainer *, muContainerStackSize) containerStack
MuStack!(IRect, muClipStackSize) clipStack
MuStack!(MuId, muIdStackSize) idStack
MuStack!(MuLayout, muLayoutStackSize) layoutStack
StaticArray!(MuPoolItem, muContainerPoolSize) containerPool
StaticArray!(MuContainer, muContainerPoolSize) containers
StaticArray!(MuPoolItem, muTreeNodePoolSize) treeNodePool
IVec2 mousePos
IVec2 lastMousePos
IVec2 mouseDelta
IVec2 scrollDelta
MuMouseFlags mouseDown
MuMouseFlags mousePressed
MuKeyFlags keyDown
MuKeyFlags keyPressed
char[muInputTextSize] inputTextData
Str inputTextSlice
Methods
void ready(MuFont font, int fontScale = 1) @trusted
void readyWithFuncs(MuTextWidthFunc width, MuTextHeightFunc height, MuFont font, int fontScale = 1)
void begin()
void end() @trusted
void drawControlFrame(MuId id, IRect rect, MuColor colorId, MuOptFlags opt, MuAtlas atlasId = MuAtlas.none) @trusted
void drawControlText(IStr str, IRect rect, MuColor colorId, MuOptFlags opt)
void drawControlTextLegacy(IStrz str, IRect rect, MuColor colorId, MuOptFlags opt)
bool mouseOver(IRect rect) @trusted
void updateControl(MuId id, IRect rect, MuOptFlags opt, bool isDragOrResizeControl = false, MuMouseFlags action = MuMouseFlag.left)
void scrollbarY(MuContainer * cnt, IRect * b, IVec2 cs) @trusted
void scrollbarX(MuContainer * cnt, IRect * b, IVec2 cs) @trusted
void text(IStr str) @trustedIt handles both D strings and C strings, so you can also pass null-terminated buffers directly.
void textLegacy(IStrz str)
void label(IStr str)
void labelLegacy(IStrz str)
MuResFlags button(IStr str, MuIcon icon = MuIcon.none, MuOptFlags opt = MuOptFlag.alignCenter) @trusted
MuResFlags buttonLegacy(IStr str, MuIcon icon, MuOptFlags opt) @trusted
MuResFlags checkbox(ref bool state, IStr str = "") @trusted
MuResFlags checkboxLegacy(bool * state, IStr str) @trusted
MuResFlags textBoxRaw(Str buf, MuId id, IRect r, ref Sz newlen, MuOptFlags opt) @trusted
MuResFlags textBoxRawLegacy(Strz buf, Sz bufsz, MuId id, IRect r, Sz * newlen, MuOptFlags opt) @trusted
MuResFlags textBox(Str buf, ref Sz newlen, MuOptFlags opt = MuOptFlag.none) @trusted
MuResFlags textBox(Str buf, ref IStr newslice, MuOptFlags opt = MuOptFlag.none) @trusted
MuResFlags textBoxLegacy(Strz buf, Sz bufsz, Sz * newlen, MuOptFlags opt) @trusted
MuResFlags textBox(Sz N = 128, IStr file = __FILE__, Sz line = __LINE__)(ref IStr newslice, MuOptFlags opt = MuOptFlag.none)
MuResFlags slider(ref float value, float low, float high, float step = 0.01f, IStr fmt = muNumberFmt, MuOptFlags opt = MuOptFlag.alignCenter) @trusted
MuResFlags sliderLegacy(float * value, float low, float high, float step, IStr fmt, MuOptFlags opt, bool isFmtFloatAnInt) @trusted
MuResFlags slider(ref int value, int low, int high, int step = 1, IStr fmt = muNumberFmt, MuOptFlags opt = MuOptFlag.alignCenter) @trusted
MuResFlags sliderLegacy(int * value, int low, int high, int step, IStr fmt, MuOptFlags opt, bool isFmtFloatAnInt) @trusted
MuResFlags number(ref float value, float step = 0.01f, IStr fmt = muNumberFmt, MuOptFlags opt = MuOptFlag.alignCenter) @trusted
MuResFlags numberLegacy(float * value, float step, IStr fmt, MuOptFlags opt, bool isFmtFloatAnInt) @trusted
MuResFlags number(ref int value, int step = 1, IStr fmt = muNumberFmt, MuOptFlags opt = MuOptFlag.alignCenter) @trusted
MuResFlags numberLegacy(int * value, int step, IStr fmt, MuOptFlags opt, bool isFmtFloatAnInt) @trusted
MuResFlags header(IStr label, MuOptFlags opt = MuOptFlag.none) @trusted
MuResFlags beginTreeNode(IStr label, MuOptFlags opt = MuOptFlag.none) @trusted
void endTreeNode() @trusted
MuResFlags beginWindow(IStr title, IRect rect, MuOptFlags opt = MuOptFlag.none) @trusted
MuResFlags beginWindow(IStr title, int x, int y, int w, int h, MuOptFlags opt = MuOptFlag.none)
void endWindow() @trusted
void openPopup(IStr name)
void beginPanel(IStr name, MuOptFlags opt = MuOptFlag.none) @trusted
void endPanel() @trusted
void openDmenu()
MuResFlags beginDmenu(ref IStr selection, const(IStr)[] items, IVec2 canvas, IStr str = "", Vec2 scale = Vec2(0.5f, 0.7f)) @trusted
void members(T)(ref T data, int labelWidth, bool canShowPrivateMembers = false)
MuResFlags headerAndMembers(T)(ref T data, int labelWidth, IStr label = "", bool canShowPrivateMembers = false)
void beginColumn() @trusted
void endColumn() @trusted
void row(int height, const(int)[] widths...) @trusted
void rowLegacy(int items, const(int) * widths, int height) @trusted
void setLayoutWidth(int width) @trusted
void setLayoutHeight(int height) @trusted
void setNextLayout(IRect r, bool relative) @trusted
IRect nextLayout() @trusted
void inputMouseMove(int x, int y)
void inputMouseDown(int x, int y, MuMouseFlags btn)
void inputMouseUp(int x, int y, MuMouseFlags btn)
void inputScroll(int x, int y)
void inputText(IStr str) @trusted
int poolInit(MuPoolItem * items, Sz len, MuId id) @trusted
int poolGet(MuPoolItem * items, Sz len, MuId id) @trusted
void poolUpdate(MuPoolItem * items, Sz idx) @trusted
MuCommandData * pushCommand(MuCommand type, Sz size) @trusted
bool nextCommand(MuCommandData * * cmd) @trusted
void setClip(IRect rect)
void drawRect(IRect rect, Rgba color, MuAtlas atlasId = MuAtlas.none) @trusted
void drawBox(IRect rect, Rgba color)
void drawText(MuFont font, IStr str, IVec2 pos, Rgba color) @trusted
void drawIcon(MuIcon id, IRect rect, Rgba color)
void setFocus(MuId id)
MuId getId(const(void) * data, Sz size) @trusted
MuId getIdFromStr(IStr str) @trusted
void pushId(const(void) * data, Sz size)
void pushIdFromStr(IStr str) @trusted
void popId()
void pushClipRect(IRect rect)
MuContainer * getContainer(IStr name) @trusted
Constructors
this(MuTextWidthFunc width, MuTextHeightFunc height, MuFont font, int fontScale = 1)

Functions 15

fnvoid _pushLayout(MuContext * ctx, IRect body, IVec2 scroll) @trusted
fnvoid _popContainer(MuContext * ctx)
fnMuContainer * _getContainer(MuContext * ctx, MuId id, MuOptFlags opt) @trusted
fnMuCommandData * _pushJump(MuContext * ctx, MuCommandData * dst) @trusted
fnbool _inHoverRoot(MuContext * ctx)
fnMuResFlags _numberTextbox(MuContext * ctx, float * value, IRect r, MuId id)
fnMuResFlags _header(MuContext * ctx, IStr label, int istreenode, MuOptFlags opt) @trusted
fnvoid _scrollbars(MuContext * ctx, MuContainer * cnt, IRect * body)
fnvoid _pushContainerBody(MuContext * ctx, MuContainer * cnt, IRect body, MuOptFlags opt) @trusted
fnvoid _endRootContainer(MuContext * ctx) @trusted
fnvoid defaultMuDrawFrame(MuContext * ctx, IRect rect, MuColor colorId, MuAtlas atlasId = MuAtlas.none)

Variables 19

enumvarmuVersion = "2.02"

Version of the original microui C library.

enumvarmuCommandSize = 1024

Size of the command, in bytes. Commands include extra space for strings. See muMaxStrSize.

enumvarmuCommandListSize = 256 * muCommandSize

Size of the command list, in bytes. Commands include extra space for strings. See muMaxStrSize.

enumvarmuRootListSize = 32

Maximum number of root containers (windows).

enumvarmuContainerStackSize = 32

Max depth for container stack.

enumvarmuClipStackSize = 32

Max depth for clipping region stack.

enumvarmuIdStackSize = 32

Max depth for ID stack.

enumvarmuLayoutStackSize = 16

Max depth for layout stack.

enumvarmuContainerPoolSize = 48

Number of reusable containers.

enumvarmuTreeNodePoolSize = 48

Number of reusable tree nodes.

enumvarmuInputTextSize = 1024

Maximum length of input text buffers.

enumvarmuMaxWidths = 16

Maximum number of columns per layout row.

enumvarmuNumberFmt = "{}"

Format string used for numbers.

enumvarmuNumberFmtWithZero = "{}\0"

Format string used for numbers, with a zero at the end.

enumvarmuMaxFmt = 127

Max length of any formatted string.

enumvarmuMaxStrSize = (cast(int) muCommandSize) - (cast(int) MuTextCommand.sizeof)

Maximum length of command strings.

enumvarrelative = 1
enumvarabsolute = 2
enumvarunclippedRect = IRect(0, 0, 0x1000000, 0x1000000)