LDK_UI_INPUT_CODEPOINTS_CAPACITY
#define LDK_UI_INPUT_CODEPOINTS_CAPACITY 16
Build UI layouts, windows, widgets, popups, and render data.
#define LDK_UI_INPUT_CODEPOINTS_CAPACITY 16
#define LDK_UI_DEFAULT_CONTROL_HEIGHT 22.0f
#define LDK_UI_DEFAULT_CONTROL_WIDTH 16.0f
#define LDK_UI_LAYOUT_STACK_CAPACITY 64
#define LDK_UI_LAYOUT_ITEM_CAPACITY 512
#define LDK_UI_LAYOUT_ITEM_CACHE_CAPACITY 64
#define LDK_UI_MEASURE_ENTRY_CAPACITY 64
#define LDK_UI_WINDOW_CAPACITY 16
#define LDK_UI_WINDOW_STACK_CAPACITY 16
#define LDK_UI_SCROLLVIEW_STACK_CAPACITY 16
#define LDK_UI_SCROLLVIEW_CACHE_CAPACITY 16
#define LDK_UI_SCROLLBAR_SIZE 12.0f
#define LDK_UI_AREA_STACK_CAPACITY 64
#define LDK_UI_POPUP_STACK_CAPACITY 16
#define LDK_UI_MIN_WINDOW_WIDTH 64.0f
#define LDK_UI_MIN_WINDOW_HEIGHT 1
#define LDK_UI_TITLE_BAR_HEIGHT 24.0f
#define LDK_UI_DEFAULT_SPACING 4.0f
#define LDK_UI_DEFAULT_PADDING 4.0f
#define LDK_UI_TREE_NODE_INDENT_WIDTH 8.0f
#define LDK_UI_TREE_NODE_CHEVRON_WIDTH 10.0f
#define LDK_UI_TAB_BAR_TAB_HEIGHT 34.0f
#define LDK_UI_TAB_BAR_HEIGHT 34.0f
#define LDK_UI_TAB_BAR_TAB_PADDING 14.0f
#define LDK_UI_AREA_HEADER_HEIGHT 34.0f
#define LDK_UI_AREA_PADDING 8.0f
#define LDK_UI_TAB_BAR_MENU_BUTTON_WIDTH 24.0f
#define LDK_UI_TAB_BAR_SPACING 2.0f
#define LDK_UI_TAB_BAR_LINE_THICKNESS 1.2f
typedef uint32_t LDKUIId;
typedef uintptr_t LDKUITextureHandle;
Callback resolving the texture for a font atlas page.
typedef LDKUITextureHandle(*LDKUIGetFontPageTextureFn)(void *user, LDKFontInstance *font, u32 page_index);
userfontpage_indexHandle to the requested object or resource.
typedef u32 LDKUIColor;
typedef LDKPointf LDKUIPoint;
typedef LDKSizef LDKUISize;
typedef LDKRectf LDKUIRect;
typedef struct LDKUILayout LDKUILayout;
typedef struct LDKUIWindow LDKUIWindow;
typedef struct LDKUIWindowStackEntry LDKUIWindowStackEntry;
typedef struct LDKUIScrollViewCache LDKUIScrollViewCache;
typedef struct LDKUIScrollViewStackEntry LDKUIScrollViewStackEntry;
typedef struct LDKUIAreaStackEntry LDKUIAreaStackEntry;
typedef struct LDKUIPopupStackEntry LDKUIPopupStackEntry;
typedef struct LDKUIPopupFrameEntry LDKUIPopupFrameEntry;
typedef struct LDKUIPopupCache LDKUIPopupCache;
typedef struct LDKUIHitCandidate LDKUIHitCandidate;
typedef struct LDKUIContext LDKUIContext;
typedef enum LDKUIColorSlot{
LDK_UI_COLOR_TEXT,
LDK_UI_COLOR_TEXT_DISABLED,
LDK_UI_COLOR_WINDOW_BG,
LDK_UI_COLOR_PANEL_BG,
LDK_UI_COLOR_CONTROL_BG,
LDK_UI_COLOR_CONTROL_BG_HOVERED,
LDK_UI_COLOR_CONTROL_BG_ACTIVE,
LDK_UI_COLOR_CONTROL_BG_ACTIVE_HOVERED,
LDK_UI_COLOR_CONTROL_TEXT,
LDK_UI_COLOR_CONTROL_TEXT_HOVERED,
LDK_UI_COLOR_CONTROL_TEXT_ACTIVE,
LDK_UI_COLOR_CONTROL_TEXT_ACTIVE_HOVERED,
LDK_UI_COLOR_CONTROL_TEXT_DISABLED,
LDK_UI_COLOR_CONTROL_BORDER,
LDK_UI_COLOR_CONTROL_BORDER_HOVERED,
LDK_UI_COLOR_CONTROL_BORDER_ACTIVE,
LDK_UI_COLOR_CONTROL_BORDER_ACTIVE_HOVERED,
LDK_UI_COLOR_CONTROL_BORDER_DISABLED,
LDK_UI_COLOR_BORDER,
LDK_UI_COLOR_FOCUS,
LDK_UI_COLOR_SLIDER_TRACK,
LDK_UI_COLOR_SLIDER_TRACK_HOVERED,
LDK_UI_COLOR_SLIDER_TRACK_ACTIVE,
LDK_UI_COLOR_SLIDER_FILL,
LDK_UI_COLOR_SLIDER_THUMB,
LDK_UI_COLOR_SLIDER_THUMB_HOVERED,
LDK_UI_COLOR_SLIDER_THUMB_ACTIVE,
LDK_UI_COLOR_TITLE,
LDK_UI_COLOR_TITLE_BAR,
LDK_UI_COLOR_TITLE_BAR_FOCUSED,
LDK_UI_COLOR_SCROLLBAR_TRACK,
LDK_UI_COLOR_SCROLLBAR_THUMB,
LDK_UI_COLOR_SCROLLBAR_THUMB_HOVERED,
LDK_UI_COLOR_SCROLLBAR_THUMB_ACTIVE,
LDK_UI_COLOR_TAB_BAR_BG,
LDK_UI_COLOR_TAB_BAR_SEPARATOR,
LDK_UI_COLOR_TAB_BG,
LDK_UI_COLOR_TAB_BG_HOVERED,
LDK_UI_COLOR_TAB_TEXT,
LDK_UI_COLOR_TAB_TEXT_HOVERED,
LDK_UI_COLOR_TAB_BORDER,
LDK_UI_COLOR_TAB_BORDER_HOVERED,
LDK_UI_COLOR_TAB_ACTIVE_BG,
LDK_UI_COLOR_TAB_ACTIVE_TEXT,
LDK_UI_COLOR_TAB_ACTIVE_BORDER,
LDK_UI_COLOR_SEPARATOR,
LDK_UI_COLOR_INPUT_BORDER,
LDK_UI_COLOR_INPUT_BG,
LDK_UI_COLOR_INPUT_BG_HOVERED,
LDK_UI_COLOR_INPUT_BG_ACTIVE,
LDK_UI_COLOR_INPUT_BG_ACTIVE_HOVERED,
LDK_UI_COLOR_COUNT,
}LDKUIColorSlot;
typedef struct LDKUIIcon{
uintptr_t texture;
LDKUIRect uv;
LDKUISize size;
rgba32 color;
}LDKUIIcon;
typedef enum LDKUIThemeIconSlot{
LDK_UI_THEME_ICON_TREE_NODE_COLLAPSED,
LDK_UI_THEME_ICON_TREE_NODE_EXPANDED,
LDK_UI_THEME_ICON_TOGGLE_UNCHECKED,
LDK_UI_THEME_ICON_TOGGLE_CHECKED,
LDK_UI_THEME_ICON_MORE_HORIZ,
LDK_UI_THEME_ICON_MORE_VERT,
LDK_UI_THEME_ICON_EJECT,
LDK_UI_THEME_ICON_COUNT,
}LDKUIThemeIconSlot;
Uniform content inset for windows and panels, in pixels.
typedef struct LDKUITheme{
rgba32 colors[LDK_UI_COLOR_COUNT];
LDKUIIcon icons[LDK_UI_THEME_ICON_COUNT];
float control_border_size;
float input_border_size;
float window_border_size;
float window_interaction_border_size;
float slider_track_height;
float slider_thumb_width;
bool text_cursor_blink;
float text_cursor_blink_interval;
float text_cursor_width;
float text_cursor_padding_y;
/** Uniform content inset for windows and panels, in pixels. */float panel_padding;
}LDKUITheme;
typedef struct LDKUIVertex{
float x;
float y;
float u;
float v;
rgba32 color;
}LDKUIVertex;
typedef struct LDKUIDrawCmd{
LDKUITextureHandle texture;
LDKUIRect clip_rect;
u32 index_offset;
u32 index_count;
}LDKUIDrawCmd;
X_ARRAY_TYPE_NAMED(
LDKUIId,
ldk_ui_id
);
typedef enum LDKUIThemeType{
LDK_UI_THEME_CUSTOM=0,
LDK_UI_THEME_DEFAULT_LIGHT=1,
LDK_UI_THEME_DEFAULT_DARK=2,
}LDKUIThemeType;
Logical viewport used to generate the vertices and clip rectangles.
typedef struct LDKUIRenderData{
LDKUIVertex const *vertices;
u32 vertex_count;
u32 const *indices;
u32 index_count;
LDKUIDrawCmd const *commands;
uint32_t command_count;
/** Logical viewport used to generate the vertices and clip rectangles. */LDKUISize viewport_size;
}LDKUIRenderData;
typedef enum LDKUILayoutDirection{
LDK_UI_LAYOUT_VERTICAL=0,
LDK_UI_LAYOUT_HORIZONTAL=1,
}LDKUILayoutDirection;
typedef enum LDKUIItemType{
LDK_UI_ITEM_WINDOW=1,
LDK_UI_ITEM_LABEL=2,
LDK_UI_ITEM_BUTTON=3,
LDK_UI_ITEM_SLIDER=4,
LDK_UI_ITEM_SCROLLVIEW=5,
LDK_UI_ITEM_LAYOUT_VERTICAL=6,
LDK_UI_ITEM_LAYOUT_HORIZONTAL=7,
LDK_UI_ITEM_INPUT_BOX=8,
LDK_UI_ITEM_IMAGE=9,
LDK_UI_ITEM_ICON_BUTTON=10,
LDK_UI_ITEM_PANEL=11,
LDK_UI_ITEM_SPACER=12,
LDK_UI_ITEM_TOGGLE=13,
LDK_UI_ITEM_SEPARATOR=14,
LDK_UI_ITEM_ICON_LABEL=15,
LDK_UI_ITEM_COMBO_BOX=16,
LDK_UI_ITEM_TAB_BAR=17,
LDK_UI_ITEM_RESIZE_HANDLE=18,
LDK_UI_ITEM_SLIDER_INPUT=19,
}LDKUIItemType;
typedef enum LDKUISizeMode{
LDK_UI_SIZE_PIXELS=0,
LDK_UI_SIZE_PERCENT=1,
LDK_UI_SIZE_FILL=2,
LDK_UI_SIZE_AUTO=3,
}LDKUISizeMode;
typedef struct LDKUILayoutSize{
LDKUISizeMode mode;
float value;
}LDKUILayoutSize;
typedef enum LDKUIWindowFlags{
LDK_UI_WINDOW_NONE=0,
LDK_UI_WINDOW_TITLE_BAR=1<<0,
LDK_UI_WINDOW_DRAGGABLE=1<<1,
LDK_UI_WINDOW_RESIZABLE=1<<2,
LDK_UI_WINDOW_BORDER=1<<3,
LDK_UI_WINDOW_NO_BG=1<<4,
LDK_UI_WINDOW_CLOSE_BUTTON=1<<5,
LDK_UI_WINDOW_NO_PADDING=1<<6,
LDK_UI_WINDOW_CACHEABLE=1<<7,
LDK_UI_WINDOW_TOOL=LDK_UI_WINDOW_CLOSE_BUTTON|LDK_UI_WINDOW_TITLE_BAR|LDK_UI_WINDOW_DRAGGABLE|LDK_UI_WINDOW_RESIZABLE|LDK_UI_WINDOW_BORDER,
}LDKUIWindowFlags;
typedef enum LDKUIScrollViewFlags{
LDK_UI_SCROLL_NONE=0,
LDK_UI_SCROLL_VERTICAL=1<<0,
LDK_UI_SCROLL_HORIZONTAL=1<<1,
LDK_UI_SCROLL_IF_NEEDED=1<<2,
}LDKUIScrollViewFlags;
typedef enum LDKTreeNodeFlags{
LDK_UI_TREE_NODE_NONE=0,
LDK_UI_TREE_NODE_LEAF=1<<0,
LDK_UI_TREE_NODE_SELECTED=1<<1
}LDKTreeNodeFlags;
typedef enum LDKTreeNodeResult{
LDK_UI_TREE_NODE_RESULT_NONE=0,
LDK_UI_TREE_NODE_RESULT_CLICKED=1<<0,
LDK_UI_TREE_NODE_RESULT_TOGGLED=1<<1,
}LDKTreeNodeResult;
typedef struct LDKUIMark{
LDKUILayout *layout;
u32 measure_index;
}LDKUIMark;
typedef struct LDKUIMeasureEntry{
LDKUILayout *layout;
LDKUIRect rect;
}LDKUIMeasureEntry;
typedef struct LDKUILayoutRequest{
LDKUIItemType type;
LDKUISize min_size;
LDKUILayoutSize width;
LDKUILayoutSize height;
float weight;
bool has_height;
bool has_width;
bool hit_test;
}LDKUILayoutRequest;
typedef struct LDKUILayoutItem{
LDKUIId layout_id;
u32 item_index;
u32 next_layout_item_array_index;
u32 cache_array_index;
LDKUILayoutRequest request;
LDKUIRect fallback_rect;
}LDKUILayoutItem;
typedef struct LDKUILayoutItemCache{
LDKUIId layout_id;
LDKUIId owner_window_id;
u32 item_index;
LDKUIRect rect;
u32 last_frame_touched;
}LDKUILayoutItemCache;
typedef struct LDKUIConfig{
u32 frame_arena_size;
u32 initial_vertex_capacity;
u32 initial_index_capacity;
u32 initial_command_capacity;
u32 initial_window_capacity;
u32 initial_id_stack_capacity;
LDKFontInstance *font;
void *font_texture_user;
LDKUIGetFontPageTextureFn get_font_page_texture;
LDKUIThemeType theme;
u32 font_size;
}LDKUIConfig;
typedef enum LDKUIControlVisualState{
LDK_UI_CONTROL_VISUAL_STATE_IDLE=0,
LDK_UI_CONTROL_VISUAL_STATE_HOVERED=1,
LDK_UI_CONTROL_VISUAL_STATE_ACTIVE=2,
LDK_UI_CONTROL_VISUAL_STATE_ACTIVE_HOVERED=3,
LDK_UI_CONTROL_VISUAL_STATE_DISABLED=4,
}LDKUIControlVisualState;
typedef struct LDKUITextInputState{
u32 codepoints[LDK_UI_INPUT_CODEPOINTS_CAPACITY];
u32 codepoint_count;
}LDKUITextInputState;
typedef enum LDKUIInputBoxResult{
LDK_UI_INPUT_BOX_NONE=0,
LDK_UI_INPUT_BOX_CHANGED=1<<0,
LDK_UI_INPUT_BOX_COMMITTED=1<<1,
LDK_UI_INPUT_BOX_CANCELED=1<<2,
}LDKUIInputBoxResult;
typedef struct LDKUISliderInputState{
LDKUIId id;
char buffer[64];
float initial_value;
float value;
}LDKUISliderInputState;
typedef enum LDKUIHitLayer{
LDK_UI_HIT_LAYER_NORMAL=0,
LDK_UI_HIT_LAYER_POPUP=1,
}LDKUIHitLayer;
typedef struct LDKUITabFocusEntry{
LDKUIId window_id;
LDKUIId item_id;
}LDKUITabFocusEntry;
typedef struct LDKUITabBarItem{
LDKUIId id;
LDKUIIcon icon;
char const *label;
}LDKUITabBarItem;
typedef struct LDKUITabBarResult{
u32 active_index;
u32 pressed_index;
bool changed;
}LDKUITabBarResult;
Initialize the UI.
LDK_API bool ldk_ui_initialize(
LDKUIContext *ctx,
LDKUIConfig const *config
);
LDKUIContext *ctxLDKUIConfig const *configTrue if the operation succeeds; false otherwise.
Shut down the UI.
LDK_API void ldk_ui_terminate(LDKUIContext *ctx);
LDKUIContext *ctxGet the UI theme.
LDK_API bool ldk_ui_theme_get(
LDKUIThemeType type,
LDKUITheme *theme
);
LDKUIThemeType typeLDKUITheme *themeTrue if the operation succeeds; false otherwise.
Set the UI theme.
LDK_API bool ldk_ui_theme_set(
LDKUIContext *ctx,
LDKUITheme *theme
);
LDKUIContext *ctxLDKUITheme *themeTrue if the operation succeeds; false otherwise.
Start a UI frame with the current input snapshots and viewport.
LDK_API void ldk_ui_begin_frame(
LDKUIContext *ctx,
float delta,
LDKMouseState const *mouse,
LDKKeyboardState const *keyboard,
LDKUITextInputState const *text_input,
LDKUIRect viewport
);
LDKUIContext *ctxfloat deltaLDKMouseState const *mouseLDKKeyboardState const *keyboardLDKUITextInputState const *text_inputLDKUIRect viewportFinish the current UI frame and prepare render data.
LDK_API void ldk_ui_end_frame(LDKUIContext *ctx);
LDKUIContext *ctxAccess draw data produced by the completed UI frame.
LDK_API LDKUIRenderData const * ldk_ui_get_render_data(LDKUIContext const *ctx);
LDKUIContext const *ctxPointer to the requested object or data; NULL when unavailable.
Associate a native window with UI clipboard operations.
LDK_API void ldk_ui_clipboard_window_set(
LDKUIContext *ctx,
LDKWindow window
);
LDKUIContext *ctxLDKWindow windowPush an integer onto the hierarchical UI ID stack.
LDK_API void ldk_ui_push_id_u32(
LDKUIContext *ctx,
uint32_t value
);
LDKUIContext *ctxuint32_t valuePush a pointer identity onto the hierarchical UI ID stack.
LDK_API void ldk_ui_push_id_ptr(
LDKUIContext *ctx,
void const *value
);
LDKUIContext *ctxvoid const *valuePush a string identity onto the hierarchical UI ID stack.
LDK_API void ldk_ui_push_id_cstr(
LDKUIContext *ctx,
char const *value
);
LDKUIContext *ctxchar const *valueRemove the most recent UI ID scope.
LDK_API void ldk_ui_pop_id(LDKUIContext *ctx);
LDKUIContext *ctxSet disabled state for the next UI item.
LDK_API void ldk_ui_set_next_disabled(
LDKUIContext *ctx,
bool disabled
);
LDKUIContext *ctxbool disabledRequest keyboard focus for the next UI item.
LDK_API void ldk_ui_set_next_focus(LDKUIContext *ctx);
LDKUIContext *ctxBegin a nested disabled-state scope.
LDK_API void ldk_ui_begin_disabled(
LDKUIContext *ctx,
bool disabled
);
LDKUIContext *ctxbool disabledEnd the current disabled-state scope.
LDK_API void ldk_ui_end_disabled(LDKUIContext *ctx);
LDKUIContext *ctxConstruct a UI rectangle from position and dimensions.
LDK_API LDKUIRect ldk_ui_rect(
float x,
float y,
float w,
float h
);
float xfloat yfloat wfloat hThe resulting rectangle.
Format a floating-point value for UI display.
LDK_API void ldk_ui_format_float(
char *buffer,
u32 buffer_size,
float value
);
char *bufferu32 buffer_sizefloat valueBegin a UI window with fixed placement.
LDK_API LDKUIRect ldk_ui_begin_window_fixed(
LDKUIContext *ctx,
char const *title,
LDKUIRect rect,
u32 flags
);
LDKUIContext *ctxchar const *titleLDKUIRect rectu32 flagsThe resulting rectangle.
Begin a UI window.
LDK_API LDKUIRect ldk_ui_begin_window(
LDKUIContext *ctx,
char const *title,
LDKUIRect rect,
u32 flags
);
LDKUIContext *ctxchar const *titleLDKUIRect rectu32 flagsThe resulting rectangle.
Begin an optionally closable window with editable geometry.
LDK_API bool ldk_ui_begin_window_open(
LDKUIContext *ctx,
char const *title,
LDKUIRect *rect,
bool *open,
u32 flags
);
LDKUIContext *ctxchar const *titleLDKUIRect *rectbool *openu32 flagsTrue when the UI condition or interaction is active; false otherwise.
Report whether the current window has requested closure.
LDK_API bool ldk_ui_window_close_requested(LDKUIContext *ctx);
LDKUIContext *ctxTrue when the UI condition or interaction is active; false otherwise.
Determine whether cached window content needs rebuilding.
LDK_API bool ldk_ui_window_content_should_build(LDKUIContext *ctx);
LDKUIContext *ctxTrue if the operation succeeds; false otherwise.
Request focus for the specified UI window.
LDK_API bool ldk_ui_window_focus(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idTrue if the operation succeeds; false otherwise.
Invalidate cached contents of one UI window.
LDK_API void ldk_ui_window_invalidate(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idInvalidate cached contents of all UI windows.
LDK_API void ldk_ui_windows_invalidate(LDKUIContext *ctx);
LDKUIContext *ctxFinish building the current UI window.
LDK_API void ldk_ui_end_window(LDKUIContext *ctx);
LDKUIContext *ctxCreate a pixel-based UI layout size.
LDK_API LDKUILayoutSize ldk_ui_px(float value);
float valueThe resulting size.
Create a percentage-based UI layout size.
LDK_API LDKUILayoutSize ldk_ui_percent(float value);
float valueThe resulting size.
Create a UI layout size that fills available space.
LDK_API LDKUILayoutSize ldk_ui_fill(void);
The resulting size.
Set the width constraint for the next UI item.
LDK_API void ldk_ui_set_next_width(
LDKUIContext *ctx,
LDKUILayoutSize width
);
LDKUIContext *ctxLDKUILayoutSize widthSet the height constraint for the next UI item.
LDK_API void ldk_ui_set_next_height(
LDKUIContext *ctx,
LDKUILayoutSize height
);
LDKUIContext *ctxLDKUILayoutSize heightSet width and height constraints for the next UI item.
LDK_API void ldk_ui_set_next_size(
LDKUIContext *ctx,
LDKUILayoutSize width,
LDKUILayoutSize height
);
LDKUIContext *ctxLDKUILayoutSize widthLDKUILayoutSize heightSet the minimum size for the next UI item.
LDK_API void ldk_ui_set_next_min_size(
LDKUIContext *ctx,
float width,
float height
);
LDKUIContext *ctxfloat widthfloat heightSet the layout weight of the next UI item.
LDK_API void ldk_ui_set_next_weight(
LDKUIContext *ctx,
float weight
);
LDKUIContext *ctxfloat weightGet the rectangle of the most recently emitted UI item.
LDK_API LDKUIRect ldk_ui_last_rect(LDKUIContext *ctx);
LDKUIContext *ctxThe resulting rectangle.
Get the outer bounding rectangle of the most recent UI item.
LDK_API LDKUIRect ldk_ui_last_bounding_rect(LDKUIContext *ctx);
LDKUIContext *ctxThe resulting rectangle.
Capture the current position in UI layout construction.
LDK_API LDKUIMark ldk_ui_mark(LDKUIContext *ctx);
LDKUIContext *ctxThe requested value.
Measure the bounding rectangle of UI items added after a mark.
LDK_API LDKUIRect ldk_ui_measure_from(
LDKUIContext *ctx,
LDKUIMark mark
);
LDKUIContext *ctxLDKUIMark markThe resulting rectangle.
Begin a vertical auto-layout scope.
LDK_API void ldk_ui_begin_vertical(LDKUIContext *ctx);
LDKUIContext *ctxBegin a horizontal auto-layout scope.
LDK_API void ldk_ui_begin_horizontal(LDKUIContext *ctx);
LDKUIContext *ctxClose a vertical auto-layout scope.
LDK_API void ldk_ui_end_vertical(LDKUIContext *ctx);
LDKUIContext *ctxClose a horizontal auto-layout scope.
LDK_API void ldk_ui_end_horizontal(LDKUIContext *ctx);
LDKUIContext *ctxSet the current container's uniform content inset in pixels. Call after successfully opening a window, an expanded area, or a vertical/horizontal/scrollview layout, before adding children. Nested containers keep their own padding. Zero removes the inset; negative or nonfinite values are treated as zero.
LDK_API void ldk_ui_set_padding(
LDKUIContext *ctx,
float padding
);
LDKUIContext *ctxfloat paddingBegin a scrollable region and restore its scroll position.
LDK_API LDKUIPoint ldk_ui_begin_scrollview(
LDKUIContext *ctx,
LDKUIPoint scroll,
u32 flags
);
LDKUIContext *ctxLDKUIPoint scrollu32 flagsThe resulting point.
End the active scrollable region.
LDK_API void ldk_ui_end_scrollview(LDKUIContext *ctx);
LDKUIContext *ctxBegin a collapsible UI area with an optional icon.
LDK_API bool ldk_ui_begin_area_ex(
LDKUIContext *ctx,
char const *title,
LDKUIIcon icon,
bool expanded
);
LDKUIContext *ctxchar const *titleLDKUIIcon iconbool expandedTrue when the UI condition or interaction is active; false otherwise.
Begin a collapsible UI area.
LDK_API bool ldk_ui_begin_area(
LDKUIContext *ctx,
char const *title,
bool expanded
);
LDKUIContext *ctxchar const *titlebool expandedTrue when the UI condition or interaction is active; false otherwise.
Rectangle of the current area's header, for header action buttons.
LDK_API LDKUIRect ldk_ui_area_header_rect(LDKUIContext *ctx);
LDKUIContext *ctxThe resulting rectangle.
Close the current UI area.
LDK_API void ldk_ui_end_area(LDKUIContext *ctx);
LDKUIContext *ctxOpen a popup identified by a UI ID.
LDK_API void ldk_ui_open_popup(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idOpen a popup at the requested screen position.
LDK_API void ldk_ui_open_popup_at(
LDKUIContext *ctx,
LDKUIId id,
LDKUIPoint position
);
LDKUIContext *ctxLDKUIId idLDKUIPoint positionClose the popup with the specified UI ID.
LDK_API void ldk_ui_close_popup(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idClose the active popup.
LDK_API void ldk_ui_close_current_popup(LDKUIContext *ctx);
LDKUIContext *ctxClose all open popups.
LDK_API void ldk_ui_close_all_popups(LDKUIContext *ctx);
LDKUIContext *ctxCheck whether a popup is currently open.
LDK_API bool ldk_ui_popup_is_open(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idTrue when the queried condition holds; false otherwise.
Begin drawing the named popup when it is open.
LDK_API bool ldk_ui_begin_popup(
LDKUIContext *ctx,
LDKUIId id
);
LDKUIContext *ctxLDKUIId idTrue when the UI condition or interaction is active; false otherwise.
Finish drawing the active popup.
LDK_API void ldk_ui_end_popup(LDKUIContext *ctx);
LDKUIContext *ctxDraw an image UI item using a texture region and size.
LDK_API void ldk_ui_image(
LDKUIContext *ctx,
LDKUITextureHandle texture,
LDKUIRect uv,
LDKUISize size
);
LDKUIContext *ctxLDKUITextureHandle textureLDKUIRect uvLDKUISize sizeDraw an icon UI item.
LDK_API void ldk_ui_icon(
LDKUIContext *ctx,
LDKUIIcon icon
);
LDKUIContext *ctxLDKUIIcon iconDraw an icon button and report its interaction.
LDK_API bool ldk_ui_icon_button(
LDKUIContext *ctx,
LDKUIIcon icon,
char const *text
);
LDKUIContext *ctxLDKUIIcon iconchar const *textTrue when the UI condition or interaction is active; false otherwise.
Draw a label UI element.
LDK_API void ldk_ui_label(
LDKUIContext *ctx,
char const *text
);
LDKUIContext *ctxchar const *textDraw an icon alongside text.
LDK_API void ldk_ui_icon_label(
LDKUIContext *ctx,
LDKUIIcon icon,
char const *text
);
LDKUIContext *ctxLDKUIIcon iconchar const *textDraw selectable UI text.
LDK_API void ldk_ui_selectable_text(
LDKUIContext *ctx,
char const *text
);
LDKUIContext *ctxchar const *textDraw and interact with a color view control.
LDK_API bool ldk_ui_color_view(
LDKUIContext *ctx,
rgba32 color
);
LDKUIContext *ctxrgba32 colorTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a button control.
LDK_API bool ldk_ui_button(
LDKUIContext *ctx,
char const *text
);
LDKUIContext *ctxchar const *textTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a toggle control.
LDK_API bool ldk_ui_toggle(
LDKUIContext *ctx,
bool value
);
LDKUIContext *ctxbool valueTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a button flat control.
LDK_API bool ldk_ui_button_flat(
LDKUIContext *ctx,
char const *text
);
LDKUIContext *ctxchar const *textTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a combo box control.
LDK_API u32 ldk_ui_combo_box(
LDKUIContext *ctx,
const char *const *items,
u32 item_count,
u32 selected_index
);
LDKUIContext *ctxconst char *const *itemsu32 item_countu32 selected_indexThe resulting numeric value.
Draw and interact with a slider control.
LDK_API float ldk_ui_slider(
LDKUIContext *ctx,
float value,
float min_value,
float max_value
);
LDKUIContext *ctxfloat valuefloat min_valuefloat max_valueThe resulting value.
Draw and interact with a slider input control.
LDK_API float ldk_ui_slider_input(
LDKUIContext *ctx,
float value,
float min_value,
float max_value
);
LDKUIContext *ctxfloat valuefloat min_valuefloat max_valueThe resulting value.
Draw a hierarchical tree item with icon and additional options.
LDK_API u32 ldk_ui_tree_node_ex(
LDKUIContext *ctx,
char const *title,
LDKUIIcon icon,
bool expanded,
u32 depth,
u32 flags
);
LDKUIContext *ctxchar const *titleLDKUIIcon iconbool expandedu32 depthu32 flagsThe resulting numeric value.
Draw a hierarchical tree item with expand/collapse state.
LDK_API bool ldk_ui_tree_node(
LDKUIContext *ctx,
char const *title,
bool expanded,
u32 depth,
u32 flags
);
LDKUIContext *ctxchar const *titlebool expandedu32 depthu32 flagsTrue when the UI condition or interaction is active; false otherwise.
Draw an editable text box and update its buffer.
LDK_API u32 ldk_ui_input_box(
LDKUIContext *ctx,
char *buffer,
u32 buffer_size
);
LDKUIContext *ctxchar *bufferu32 buffer_sizeThe resulting numeric value.
Draw an editable text label and update its buffer.
LDK_API u32 ldk_ui_input_label(
LDKUIContext *ctx,
char *buffer,
u32 buffer_size
);
LDKUIContext *ctxchar *bufferu32 buffer_sizeThe resulting numeric value.
Draw a horizontal line UI element.
LDK_API void ldk_ui_horizontal_line(LDKUIContext *ctx);
LDKUIContext *ctxDraw and interact with a resize handle horizontal control.
LDK_API float ldk_ui_resize_handle_horizontal(
LDKUIContext *ctx,
float value,
float min_value,
float max_value
);
LDKUIContext *ctxfloat valuefloat min_valuefloat max_valueThe resulting value.
Draw and interact with a resize handle vertical control.
LDK_API float ldk_ui_resize_handle_vertical(
LDKUIContext *ctx,
float value,
float min_value,
float max_value
);
LDKUIContext *ctxfloat valuefloat min_valuefloat max_valueThe resulting value.
Draw a spacer UI element.
LDK_API void ldk_ui_spacer(LDKUIContext *ctx);
LDKUIContext *ctxDraw and interact with a tab bar control.
LDK_API LDKUITabBarResult ldk_ui_tab_bar(
LDKUIContext *ctx,
LDKUITabBarItem const *items,
u32 item_count,
u32 active_index
);
LDKUIContext *ctxLDKUITabBarItem const *itemsu32 item_countu32 active_indexResult of the operation.
Draw a UI panel at an explicit rectangle.
LDK_API void ldk_ui_widget_panel(
LDKUIContext *ctx,
LDKUIId id,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idLDKUIRect rectDraw UI text at an explicit rectangle.
LDK_API void ldk_ui_widget_label(
LDKUIContext *ctx,
LDKUIId id,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idchar const *textLDKUIRect rectDraw an icon label UI element.
LDK_API void ldk_ui_widget_icon_label(
LDKUIContext *ctx,
LDKUIId id,
LDKUIIcon icon,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idLDKUIIcon iconchar const *textLDKUIRect rectDraw a UI image at an explicit rectangle.
LDK_API void ldk_ui_widget_image(
LDKUIContext *ctx,
LDKUIId id,
LDKUITextureHandle texture,
LDKUIRect uv,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idLDKUITextureHandle textureLDKUIRect uvLDKUIRect rectDraw a four-corner UI color gradient.
LDK_API void ldk_ui_widget_gradient(
LDKUIContext *ctx,
LDKUIId id,
rgba32 top_left,
rgba32 top_right,
rgba32 bottom_right,
rgba32 bottom_left,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idrgba32 top_leftrgba32 top_rightrgba32 bottom_rightrgba32 bottom_leftLDKUIRect rectDraw and interact with a color view control.
LDK_API bool ldk_ui_widget_color_view(
LDKUIContext *ctx,
LDKUIId id,
rgba32 color,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idrgba32 colorLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a button control.
LDK_API bool ldk_ui_widget_button(
LDKUIContext *ctx,
LDKUIId id,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idchar const *textLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with an icon button control.
LDK_API bool ldk_ui_widget_icon_button(
LDKUIContext *ctx,
LDKUIId id,
LDKUIIcon icon,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idLDKUIIcon iconchar const *textLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with an icon button flat control.
LDK_API bool ldk_ui_widget_icon_button_flat(
LDKUIContext *ctx,
LDKUIId id,
LDKUIIcon icon,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idLDKUIIcon iconchar const *textLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a button flat control.
LDK_API bool ldk_ui_widget_button_flat(
LDKUIContext *ctx,
LDKUIId id,
char const *text,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idchar const *textLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw a boolean toggle at an explicit rectangle.
LDK_API bool ldk_ui_widget_toggle(
LDKUIContext *ctx,
LDKUIId id,
bool value,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idbool valueLDKUIRect rectTrue when the UI condition or interaction is active; false otherwise.
Draw and interact with a combo box control.
LDK_API u32 ldk_ui_widget_combo_box(
LDKUIContext *ctx,
LDKUIId id,
const char *const *items,
u32 item_count,
u32 selected_index,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idconst char *const *itemsu32 item_countu32 selected_indexLDKUIRect rectThe resulting numeric value.
Draw a numeric slider at an explicit rectangle.
LDK_API float ldk_ui_widget_slider(
LDKUIContext *ctx,
LDKUIId id,
float value,
float min_value,
float max_value,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat valuefloat min_valuefloat max_valueLDKUIRect rectThe resulting value.
Draw an editable numeric slider at an explicit rectangle.
LDK_API float ldk_ui_widget_slider_input(
LDKUIContext *ctx,
LDKUIId id,
float value,
float min_value,
float max_value,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat valuefloat min_valuefloat max_valueLDKUIRect rectThe resulting value.
Draw a vertical scrollbar at an explicit rectangle.
LDK_API float ldk_ui_widget_scrollbar_vertical(
LDKUIContext *ctx,
LDKUIId id,
float scroll,
float visible_size,
float content_size,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat scrollfloat visible_sizefloat content_sizeLDKUIRect rectThe resulting value.
Draw a horizontal scrollbar at an explicit rectangle.
LDK_API float ldk_ui_widget_scrollbar_horizontal(
LDKUIContext *ctx,
LDKUIId id,
float scroll,
float visible_size,
float content_size,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat scrollfloat visible_sizefloat content_sizeLDKUIRect rectThe resulting value.
Draw an editable text box at an explicit rectangle.
LDK_API u32 ldk_ui_widget_input_box(
LDKUIContext *ctx,
LDKUIId id,
char *buffer,
u32 buffer_size,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idchar *bufferu32 buffer_sizeLDKUIRect rectThe resulting numeric value.
Draw an editable text label at an explicit rectangle.
LDK_API u32 ldk_ui_widget_input_label(
LDKUIContext *ctx,
LDKUIId id,
char *buffer,
u32 buffer_size,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idchar *bufferu32 buffer_sizeLDKUIRect rectThe resulting numeric value.
Draw a tab UI item at an explicit rectangle.
LDK_API bool ldk_ui_widget_tab(
LDKUIContext *ctx,
LDKUIId id,
LDKUIIcon icon,
char const *text,
LDKUIRect rect,
bool active
);
LDKUIContext *ctxLDKUIId idLDKUIIcon iconchar const *textLDKUIRect rectbool activeTrue when the UI condition or interaction is active; false otherwise.
Draw a horizontal resize handle at an explicit rectangle.
LDK_API float ldk_ui_widget_resize_handle_horizontal(
LDKUIContext *ctx,
LDKUIId id,
float value,
float min_value,
float max_value,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat valuefloat min_valuefloat max_valueLDKUIRect rectThe resulting value.
Draw a vertical resize handle at an explicit rectangle.
LDK_API float ldk_ui_widget_resize_handle_vertical(
LDKUIContext *ctx,
LDKUIId id,
float value,
float min_value,
float max_value,
LDKUIRect rect
);
LDKUIContext *ctxLDKUIId idfloat valuefloat min_valuefloat max_valueLDKUIRect rectThe resulting value.
A resolved UI theme and its display name. Contains no owned resources.
typedef struct LDKUIThemeFile{
LDKUITheme theme;
char name[128];
}LDKUIThemeFile;
Parse an LDK theme from a null-terminated TML string. The output is replaced only on success. The theme inherits the selected built-in palette, and its icon handles are not loaded from the document. On failure, error receives a diagnostic when a buffer is provided.
LDK_API bool ldk_ui_theme_tml_parse(
char const *source,
LDKUIThemeFile *out_theme,
char *error,
size_t error_size
);
char const *sourceLDKUIThemeFile *out_themechar *errorsize_t error_sizeTrue if the operation succeeds; false otherwise.
Read and parse a UTF-8 TML theme file. The path is an ordinary filesystem path; discovery and application of the theme are separate responsibilities. The output is unchanged on failure.
LDK_API bool ldk_ui_theme_tml_load(
char const *path,
LDKUIThemeFile *out_theme,
char *error,
size_t error_size
);
char const *pathLDKUIThemeFile *out_themechar *errorsize_t error_sizeTrue if the operation succeeds; false otherwise.