joka.ui

The ui module includes a UI library.

Types 32

aliasUiFont = void *

The UI font type.

aliasUiTexture = void *

The UI texture type.

aliasUiIconId = uint

The UI icon ID type.

aliasUiTextSizeFunc = IVec2 function(UiFont font, uint fontScale, IStr text)

A function used for getting the width and height of the text.

aliasUiIconIdSizeFunc = IVec2 function(UiIconId iconId)

A function used for getting the width and height of an icon.

enumUiColorType : ubyte

A UI color.

borderDefault border color.
borderOffBorder color on no interaction.
iconDefault icon color.
iconOffIcon color on no interaction.
textDefault text color.
textOffText color on no interaction.
buttonDefault button color.
buttonOffButton color on no interaction.
buttonHoverButton color on hover.
buttonActiveButton color on press.
buttonFocusButton color on focus.
aliasUiColors = StaticArray!(Rgba, UiColorType.max + 1)

Static table of UI colors with UiColorType being the key.

structUiStyle

A style defines the visual appearance of the UI.

Fields
UiFont font
UiTexture texture
UiColors colors
uint fontScale
uint border
uint padding
aliasUiMouseButtonFlags = ubyte

A bitmask type for mouse button state, combining one or more UiMouseButtonFlag values.

Individual mouse button flags for use in a UiMouseButtonFlags bitmask.

none = 0x0No mouse button.
left = 0x1The left mouse button.
right = 0x2The right mouse button.
middle = 0x4The middle mouse button.
aliasUiKeyFlags = ushort

A bitmask type for keyboard key state, combining one or more UiKeyFlag values.

Individual key flags for use in a UiKeyFlags bitmask.

none = 0No key.
left = 1U << 1The left arrow key.
right = 1U << 2The right arrow key.
up = 1U << 3The up arrow key.
down = 1U << 4The down arrow key.
tab = 1U << 5The Tab key.
enter = 1U << 6The Enter key.
esc = 1U << 7The Escape key.
shift = 1U << 8The Shift key.
enumUiKeyNavigation : ubyte

Controls which axis or axes keyboard navigation responds to.

noneKeyboard navigation is disabled.
verticalOrHorizontalNavigation responds to both axes.
verticalNavigation responds to the vertical axis only.
horizontalNavigation responds to the horizontal axis only.
structUiInput
Fields
IVec2 mousePosition
IVec2 mousePressedPosition
UiMouseButtonFlags mouseButtonDown
UiMouseButtonFlags mouseButtonPressed
UiMouseButtonFlags mouseButtonReleased
bool mouseActionOnRelease
UiKeyFlags keyDown
UiKeyFlags keyPressed
UiKeyFlags keyReleased
UiKeyNavigation keyNavigation
UiKeyNavigation nextKeyNavigation
aliasUiCommandFlags = ubyte
none = 0x00
hover = 0x01
active = 0x02
focus = 0x04
off = 0x08
enumUiCommandType : ubyte
none
rect
text
icon
Fields
UiColorType colorType
Fields
ushort border
IRect data
Fields
IRect area
IStr data
Fields
IRect area
Fields
UiCommand[] data
Sz length
Methods
bool isEmpty()
bool appendRef(ref UiCommand command) @trusted
void clear()
bool nextIsRectWith(Sz currentIndex, UiCommandFlags flags)
aliasUiResultFlags = ubyte

The result of a UI control function.

The result values of a UI control function.

none = 0x00None.
active = 0x01Control is active (e.g. active window).
submitted = 0x02Control value submitted (e.g. clicked button).
changed = 0x04Control value changed (e.g. modified text).
pressedLeft = 0x08Pressed left on a active control in vertical navigation mode.
pressedRight = 0x10Pressed right on a active control in vertical navigation mode.
pressedUp = 0x20Pressed up on a active control in horizontal navigation mode.
pressedDown = 0x40Pressed down on a active control in horizontal navigation mode.
aliasUiFlags = ubyte

The option flags of a UI control function.

The option flag values of a UI control function.

none = 0x0000None.
alignCenter = 0x0001Align to the center.
alignRight = 0x0002Align to the right.
turnOff = 0x0004Turn off interactions.
checkNavigation = 0x0008Include key actions in result flags.
Fields
int currentFocusId
int nextFocusId
IVec2 nextFocusIdWrap
int focusIdCounter
bool focusIsActive
Methods
bool isFocused(int id)
void setCurrentFocusId(int id)
void wrapCurrentFocusIdIfNeeded(int startInclusive, int endInclusive)

A UI focus grabber.

Fields
UiContext * _uiContext
int _previousFocusIdCounter
bool _canIgnore
Constructors
this(ref UiContext context, UiKeyNavigation keyNavigation = UiKeyNavigation.none, bool canIgnore = false)
Destructors
structUiLayout

A UI layout helper.

Fields
IRect area
int slice
int spacing
bool isVertical
bool fromRightOrBottom
Methods
int w()
int h()
IRect pop(bool span = false)
Fields
bool submittedByKeyboard
bool hover
bool active
bool focus
uint focusId
bool mouseAction
structUiContext

The UI context.

Fields
UiCommands commands
UiFocusState focusState
UiStyle * style
UiStyle _style
UiInput input
bool manualBordersMode
char[] charDataBuffer
Sz charDataLength
int charHeight
int charOffset
Methods
void ready(UiTextSizeFunc textSizeFunc, UiCommand[] commandsBuffer, char[] charDataBuffer, UiFont font, uint fontScale = 1, UiIconIdSizeFunc iconSizeFunc = null)
void setBuffers(UiCommand[] newCommandsBuffer, char[] newCharDataBuffer)
void setFont(UiFont font, uint fontScale = 1)
void restoreDefaultStyle() @trusted
ScopedUiFocus captureFocus(UiKeyNavigation keyNavigation = UiKeyNavigation.none, bool canIgnore = false)
UiLayout _row(IRect area, int areaCount, int spacing, bool fromRight, int infiniteSlice)
UiLayout rowItems(IRect area, int count, int spacing, bool fromRight = false)
UiLayout rowSlice(IRect area, int slice, int spacing)
UiLayout _col(IRect area, int areaCount, int spacing, bool fromBottom, int infiniteSlice)
UiLayout colItems(IRect area, int count, int spacing, bool fromBottom = false)
UiLayout colSlice(IRect area, int slice, int spacing)
IStrz makeStrzCopy(IStr text) @trusted
void drawRect(IRect area, UiColorType colorType, bool hover, bool active, bool focus, bool off, uint border) @trusted
void drawBorder(IRect area, bool off, uint border)
void drawBox(IRect area, UiColorType colorType, bool hover, bool active, bool focus, bool off, uint border)
void drawIcon(UiIconId iconId, UiColorType colorType, IRect area, UiFlags optionFlags)
void drawText(IStr text, UiColorType colorType, IRect area, UiFlags optionFlags) @trusted
void drawLabelContent(IRect area, IStr text, UiIconId iconId = 0, UiFlags optionFlags = defaultUiFlags)
void begin()
void end()
UiResultFlags label(IRect area, IStr text, UiIconId iconId = 0, UiFlags optionFlags = defaultUiFlags)
UiResultFlags icon(IRect area, UiIconId iconId, UiFlags optionFlags = defaultUiFlags)
UiResultFlags buttonWithIcon(IRect area, IStr text, UiIconId iconId, UiFlags optionFlags = defaultUiFlags)
UiResultFlags button(IRect area, IStr text, UiFlags optionFlags = defaultUiFlags)
UiResultFlags stepper(T)(IRect area, ref T number, T startInclusive, T stopInclusive, T step, IStr info = "", bool canLoop = true, IStr fmtStr = defaultAsciiFmtArgStr, UiFlags optionFlags = defaultUiFlags)
UiResultFlags stepper(IRect area, ref int number, IStr info = "", bool canLoop = true, IStr fmtStr = "{}%", UiFlags optionFlags = defaultUiFlags)
UiResultFlags cycler(T)(IRect area, ref T enumNumber, IStr info = "", bool canLoop = true, bool canKeepFirstChar = false, UiFlags optionFlags = defaultUiFlags)
UiResultFlags toggle(IRect area, ref bool state, IStr info = "", IStr offText = "OFF", IStr onText = "ON", UiFlags optionFlags = defaultUiFlags)
Constructors
this(UiTextSizeFunc textSizeFunc, UiCommand[] commandsBuffer, char[] charDataBuffer, UiFont font, uint fontScale = 1, UiIconIdSizeFunc iconSizeFunc = null)

Functions 1

fnIVec2 tempUiTextSizeFunc(UiFont font, uint fontScale, IStr text) @safe nothrow @nogc

Variables 1

enumvardefaultUiFlags = UiFlag.alignCenter

The default control flags.