FVector2
structFVector2 : struct {
x : f32 = 0.0
y : f32 = 0.0
} Immediate-mode user interface tools for windows, panels, buttons, menus, and text fields. Includes layout, styling, input, font faces and fallback chains, glyph atlases, text measurement, and drawing commands.
30 structs · 82 functions · Public API
FVector2 : struct {
x : f32 = 0.0
y : f32 = 0.0
} Vertex : struct {
x : f32 = 0.0
y : f32 = 0.0
u : f32 = 0.0
v : f32 = 0.0
color : u32
} DrawCommand : struct {
clipRect : math.RectF {}
// Portable texture selection. Platform handles never enter core.imgui.
texture : DrawTexture = DrawTexture.None
vtxOffset : i32 = 0
idxOffset : i32 = 0
count : i32 = 0
} GlyphKey : struct {
font_id : FontId
codepoint : rune
} AtlasRect : struct {
x : i32 = 0
y : i32 = 0
width : i32 = 0
height : i32 = 0
} CachedGlyph : struct {
key : GlyphKey
metrics : GlyphMetrics
atlas_rect : AtlasRect
u0 : f32 = 0.0
v0 : f32 = 0.0
u1 : f32 = 0.0
v1 : f32 = 0.0
has_atlas_pixels : bool = false
} A value copy of cached glyph data. Atlas coordinates and UVs remain stable for the lifetime of the FontSystem because a full atlas never repacks.
FontAtlas : struct {
pixels : ^u8 = null
width : i32 = 1024
height : i32 = 1024
stride : i32 = 1024
padding : i32 = 1
cursor_x : i32 = 0
cursor_y : i32 = 0
shelf_height : i32 = 0
dirty : bool = false
revision : u64 = 0
} CPU-owned 8-bit grayscale atlas. Pixels are allocated lazily on the first non-empty cached glyph. A renderer may upload pixels when dirty is true and call font_system_mark_atlas_clean after observing revision.
FontFaceMetrics : struct {
units_per_em : f32 = 1.0
ascent : f32 = 0.0
descent : f32 = 0.0
line_gap : f32 = 0.0
max_advance : f32 = 0.0
glyph_width : f32 = 0.0
glyph_height : f32 = 0.0
} FontMetrics : struct {
ascent : f32 = 0.0
descent : f32 = 0.0
line_gap : f32 = 0.0
line_height : f32 = 0.0
max_advance : f32 = 0.0
} FontFace : struct {
id : FaceId
data : ^u8 = null
data_size : i64 = 0
owns_data : bool = false
renderer : FontRendererKind = FontRendererKind.None
metrics : FontFaceMetrics
glyph_count : i32 = 0
} Font : struct {
id : FontId
kind : FontKind = FontKind.SizedFace
face_id : FaceId
chain_offset : i64 = 0
chain_count : i64 = 0
size : f32 = 0.0
scale : f32 = 0.0
renderer : FontRendererKind = FontRendererKind.None
metrics : FontMetrics
glyph_width : f32 = 0.0
glyph_height : f32 = 0.0
glyph_advance : f32 = 0.0
pixel_size : f32 = 0.0
} A Font is either a sized face instance or an immutable ordered fallback chain. Chains copy the primary member's layout metrics and own no face data.
GlyphMetrics : struct {
codepoint : rune
glyph_index : i32 = 0
has_glyph : bool = false
advance : f32 = 0.0
left_side_bearing : f32 = 0.0
bitmap_width : i32 = 0
bitmap_height : i32 = 0
bitmap_x_offset : i32 = 0
bitmap_y_offset : i32 = 0
} ResolvedGlyph : struct {
font_id : FontId
metrics : GlyphMetrics
} Resolution identifies the sized font that owns glyph_index. Pair kerning, glyph caching, and rasterization must use font_id rather than a logical fallback-chain ID.
GlyphBitmap : struct {
metrics : GlyphMetrics
pixels : ^u8 = null
byte_count : i64 = 0
stride : i32 = 0
allocator : ^Allocator = null
} Owns pixels allocated by FontSystem's allocator. DestroyGlyphBitmap must be called before that allocator is destroyed. When FontSystem owns the allocator, release the bitmap before DestroyFontSystem.
FontSystem : struct {
allocator : ^Allocator = null
owns_allocator : bool = false
faces : container.ArrayList<FontFace>
fonts : container.ArrayList<Font>
font_folders : container.ArrayList<string>
font_chain_members : container.ArrayList<FontId>
glyph_cache : container.ArrayList<CachedGlyph>
atlas : FontAtlas
next_face_id : FaceId = 1
next_font_id : FontId = 1
default_face_id : FaceId
} InputModifiers : struct {
shift : bool = false
control : bool = false
option : bool = false
command : bool = false
} InputEvent : struct {
kind : InputEventKind = InputEventKind.None
key : KeyCode = KeyCode.Unknown
text : string
} MouseInputState : struct {
position : FVector2
mouse_wheel : FVector2
left_button : MouseButtonState = MouseButtonState.Idle
right_button : MouseButtonState = MouseButtonState.Idle
modifiers : InputModifiers
event : InputEvent
} Size : struct{
kind : SizeKind
value: f32
} PopupContext : struct {
state : PopupOpenState = PopupOpenState.Closed
owner : UIID = 0
anchor_rect : math.RectF
close_reason : PopupCloseReason = PopupCloseReason.None
level_count : i64 = 0
submenu_owner : [PopupLevelSlot.count]UIID
submenu_anchor : [PopupLevelSlot.count]math.RectF
} Screen : struct {
width : i32
height : i32
} UI area dimensions in whole logical units, using the mouse input coordinate space.
State : struct {
root : ^Widget
popup_root : ^Widget
popup_roots : [PopupLevelSlot.count]^Widget
current_parent : ^Widget
popup_parent : ^Widget
popup_parents : [PopupLevelSlot.count]^Widget
popup_next_id : [PopupLevelSlot.count]UIID
current_popup_level : i64 = -1
hot : UIID
active : UIID
focused : UIID
clicked : UIID
clicked_rect : math.RectF
popup : PopupContext
next_id : UIID = 1
debug_input : bool = false
debug_frame : i64 = 0
debug_last_hot : UIID = -1
debug_last_active : UIID = -1
debug_last_clicked : UIID = -1
debug_last_open_popup : UIID = -1
debug_last_left_button : i64 = -1
debug_last_width : f32 = -1.0
debug_last_height : f32 = -1.0
debug_last_vertex_count : i64 = -1
debug_last_command_count : i64 = -1
mouse_state : MouseInputState {}
current_clip_rect : math.RectF
style : ^Style = null
font_system : ^FontSystem = null
text_box_buffer : [256]u8
text_box_length : i64 = 0
text_box_caret : i64 = 0
arena_widget : ^Allocator = null
arena_cmd : ^Allocator = null
arena_vtx : ^Allocator = null
vertices : container.ArrayList<Vertex>
commands : container.ArrayList<DrawCommand>
} Color : struct {
r : u8 = 0
g : u8 = 0
b : u8 = 0
a : u8 = 0
} LayoutPadding : struct {
left : f32 = 0.0
top : f32 = 0.0
right : f32 = 0.0
bottom : f32 = 0.0
} TextStyle : struct {
color : Color
font_slot : FontSlot = FontSlot.Default
horizontal_align : LayoutAlign = LayoutAlign.Start
vertical_align : LayoutAlign = LayoutAlign.Start
line_height_scale : f32 = 1.0
} VisualStyle : struct {
background_color : Color
border_color : Color
caret_color : Color
text : TextStyle
radius : f32 = 0.0
border_thickness : f32 = 0.0
padding : LayoutPadding
gap : f32 = 0.0
} StyleRule : struct {
role : StyleRole = StyleRole.Window
state : StyleState = StyleState.Normal
visual : VisualStyle
} Style : struct {
fonts : [FontSlot.count]FontId
rules : [StyleRole.count][StyleState.count]VisualStyle
} TextMetrics : struct {
width : f32 = 0.0
height : f32 = 0.0
} Widget : struct {
kind : WidgetKind = WidgetKind.Unknown
id : UIID
text : string
flags: WidgetFlags = WidgetFlags.None
sx : Size
sy : Size
padding : LayoutPadding
gap : f32 = 0.0
main_align : LayoutAlign = LayoutAlign.Start
cross_align : LayoutCrossAlign = LayoutCrossAlign.Start
background_color : Color
border_color : Color
caret_color : Color
border_thickness : f32 = 0.0
radius : f32 = 0.0
text_style : TextStyle
rect : math.RectF
compute_rect : math.RectF
// Should be converted to n-Ary
parent : ^Widget
first_child : ^Widget
last_child : ^Widget
next : ^Widget
prev : ^Widget
} draw_box : func(rect : math.RectF, color : Color) draw_round_box : func(rect : math.RectF, color : Color, radius : f32) draw_border : func(rect : math.RectF, color : Color, thickness : f32) font_system_get_cached_glyph : func(
self : ^FontSystem,
font_id : FontId,
codepoint : rune) -> [CachedGlyph, FontStatus] Returns a stable value copy. A cache hit performs no allocation, rasterization, atlas packing, or revision change.
font_system_mark_atlas_clean : func(self : ^FontSystem, uploaded_revision : u64) Marks the current atlas revision as observed by a renderer. Adding another non-empty glyph will set dirty again and increment revision.
add_font_folder : func(self : ^FontSystem, folder : string) -> FontStatus Font folders are searched in insertion order after load_ttf_font fails to open the path as supplied. Folder strings are copied into FontSystem-owned storage and remain valid until DestroyFontSystem.
load_ttf_font : func(self : ^FontSystem, path : string) -> [FaceId, FontStatus] Loads a trusted TrueType/OpenType font by path. If the path cannot be opened directly, each registered font folder is searched in order.
font_system_get_face : func(self : ^FontSystem, id : FaceId) -> ^FontFace Returned pointers are borrowed views and may be invalidated when another face is added. Persist FaceId rather than the pointer.
font_system_get_font : func(self : ^FontSystem, id : FontId) -> ^Font Returned pointers are borrowed views and may be invalidated when another sized instance is added. Persist FontId rather than the pointer.
font_system_load_face_memory : func(
self : ^FontSystem,
data : []u8,
metrics : FontFaceMetrics,
ownership : FontMemoryOwnership) -> [FaceId, FontStatus] Registers encoded font bytes and their design-unit metrics. Borrowed bytes must outlive the face; Copied bytes become FontSystem-owned.
font_system_load_truetype_memory : func(
self : ^FontSystem,
data : []u8,
ownership : FontMemoryOwnership) -> [FaceId, FontStatus] Parses the first TrueType/OpenType face in trusted data through stb_truetype. Face metrics are read from the font; callers do not supply design-unit metrics. Borrowed bytes must outlive the face. Copied bytes are released by DestroyFontSystem. stb_truetype is not a hardened parser for hostile input.
font_system_load_truetype_file : func(
self : ^FontSystem,
path : string) -> [FaceId, FontStatus] Loads and owns the first trusted TrueType/OpenType face in path. The file buffer is retained because stb_truetype face data must stay alive until destruction. Do not use this parser for untrusted font files.
font_system_create_font : func(
self : ^FontSystem,
face_id : FaceId,
size : f32,
line_height : f32) -> [FontId, FontStatus] Creates or reuses a sized face instance. A non-positive line_height selects the natural line height derived from the face metrics.
font_system_create_font_chain : func(
self : ^FontSystem,
font_ids : []FontId) -> [FontId, FontStatus] Creates an immutable logical font from ordered sized TrueType fonts. The first member owns line metrics and baseline placement. Chain members cannot themselves be chains, which keeps resolution deterministic and cycle-free.
font_system_resolve_glyph : func(
self : ^FontSystem,
font_id : FontId,
codepoint : rune) -> [ResolvedGlyph, FontStatus] Resolves one Unicode scalar to the first sized font that contains it. If no chain member contains the scalar, the primary font's glyph-zero metrics are returned so missing-glyph behavior stays deterministic.
font_system_get_glyph_metrics : func(
self : ^FontSystem,
font_id : FontId,
codepoint : rune) -> [GlyphMetrics, FontStatus] Resolves a Unicode scalar through a sized or logical fallback font. Call font_system_resolve_glyph when the actual FontId is also required.
font_system_get_glyph_kerning : func(
self : ^FontSystem,
font_id : FontId,
left_glyph_index : i32,
right_glyph_index : i32) -> [f32, FontStatus] Returns the scaled horizontal adjustment between two resolved glyphs in a sized TrueType font. Glyph zero represents a missing Unicode scalar and deliberately contributes no kerning. This query does not allocate.
font_system_rasterize_glyph : func(
self : ^FontSystem,
font_id : FontId,
codepoint : rune) -> [GlyphBitmap, FontStatus] Allocates and rasterizes an 8-bit grayscale glyph bitmap. Empty glyphs such as spaces return Ok with no allocation. The caller owns the returned pixels and releases them with DestroyGlyphBitmap.
DestroyGlyphBitmap : func(bitmap : ^GlyphBitmap) FontSystemWithAtlasSize : func(
allocator : ^Allocator,
owns_allocator : bool,
atlas_width : i32,
atlas_height : i32) -> ^FontSystem Creates a FontSystem. owns_allocator controls whether DestroyFontSystem also destroys and releases the allocator object supplied here.
FontSystem : func(allocator : ^Allocator, owns_allocator : bool) -> ^FontSystem Creates a FontSystem with a stable library-owned default atlas size. Atlas pixels remain unallocated until the first non-empty cached glyph.
DefaultFontSystem : func() -> ^FontSystem DestroyFontSystem : func(self : ^FontSystem) Releases copied face bytes and all sized instances. When owns_allocator was true at construction, this also destroys and releases the allocator object.
Box : func(sx : Size, sy : Size) -> ^Widget RoundBox : func(sx : Size, sy : Size) -> ^Widget Title : func(text : string, sx : Size, sy : Size) -> ^Widget Label : func(text : string, sx : Size, sy : Size) -> ^Widget TextBox : func(sx : Size, sy : Size) -> ^Widget Button : func(text : string) -> bool Button : func(text : string, sx : Size, sy : Size) -> bool RoundButton : func(text : string, sx : Size, sy : Size) -> bool MenuButton : func(text : string, sx : Size, sy : Size) -> bool BeginWindow : func(axis : Axis, sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginPanel : func(axis : Axis, sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginLayout : func(axis : Axis, sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginVerticalWindow : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginHorizontalWindow : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginVerticalLayout : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginHorizontalLayout : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginVerticalPanel : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginHorizontalPanel : func(sx : Size, sy : Size, padding : LayoutPadding, gap : f32) -> ^Widget BeginMenu : func(sx : Size, sy : Size) -> ^Widget BeginPopup : func(sx : Size, sy : Size) -> ^Widget EndPopup : func() EndLayout : func() MenuItem : func(text : string, sx : Size, sy : Size) -> bool MenuItemShortcut : func(text : string, shortcut : string, sx : Size, sy : Size) -> bool MenuSeparator : func() -> ^Widget BeginSubmenu : func(text : string, popup_sx : Size, popup_sy : Size) -> ^Widget EndSubmenu : func() PopupIsOpen : func() -> bool PopupLevelCount : func() -> i64 PopupLevelRoot : func(level : i64) -> ^Widget PopupLevelRect : func(level : i64) -> math.RectF SizeFixed : func(value : f32) -> Size SizeFill : func() -> Size SizeTextContent : func() -> Size SizeChildrenSum : func() -> Size SizeChildrenMax : func() -> Size SizePercent : func(value : f32) -> Size InitState : func(command_capacity : i64) DeinitState : func() begin_frame : func(input : MouseInputState, screen : Screen) end_frame : func() color_to_u32 : func(col : Color) -> u32 Padding : func(all : f32) -> LayoutPadding PaddingXY : func(x : f32, y : f32) -> LayoutPadding PaddingLTRB : func(left : f32, top : f32, right : f32, bottom : f32) -> LayoutPadding style_set : func(style : ^Style, rule : StyleRule) style_get : func(style : ^Style, role : StyleRole, state : StyleState) -> VisualStyle style_set_font : func(style : ^Style, slot : FontSlot, font : FontId) style_get_font : func(style : ^Style, slot : FontSlot) -> FontId TextStyleDefault : func(slot : FontSlot, color : Color) -> TextStyle TextStyleCentered : func(slot : FontSlot, color : Color) -> TextStyle InitDefaultStyle : func(style : ^Style, font_system : ^FontSystem) DefaultStyle : func(font_system : ^FontSystem) -> Style background : func(self : ^Widget, color : Color, radius : f32) -> ^Widget border : func(self : ^Widget, color : Color, thickness : f32) -> ^Widget make_widget : func(kind : WidgetKind, id : UIID, text : string, flags : WidgetFlags, sx : Size, sy : Size) -> ^Widget add_widget : func(widget : ^Widget) -> ^Widget push_parent : func(widget : ^Widget) pop_parent : func()