major simplification pass over command query system; eliminate per-window query views, just collapse down to a single query view stack per-window (way simpler and honestly just what everyone does anyways); simplify/dejankify ui focus system

This commit is contained in:
Ryan Fleury
2024-01-21 21:07:04 -08:00
parent 58a0084024
commit a94e1b1928
20 changed files with 2894 additions and 2903 deletions
+170 -130
View File
@@ -3,133 +3,173 @@
//- GENERATED CODE
internal UI_Box * ui_push_parent(UI_Box * v) {return UI_StackPush(parent, v);}
internal Axis2 ui_push_child_layout_axis(Axis2 v) {return UI_StackPush(child_layout_axis, v);}
internal F32 ui_push_fixed_x(F32 v) {return UI_StackPush(fixed_x, v);}
internal F32 ui_push_fixed_y(F32 v) {return UI_StackPush(fixed_y, v);}
internal F32 ui_push_fixed_width(F32 v) {return UI_StackPush(fixed_width, v);}
internal F32 ui_push_fixed_height(F32 v) {return UI_StackPush(fixed_height, v);}
internal UI_Size ui_push_pref_width(UI_Size v) {return UI_StackPush(pref_width, v);}
internal UI_Size ui_push_pref_height(UI_Size v) {return UI_StackPush(pref_height, v);}
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v) {return UI_StackPush(flags, v);}
internal U32 ui_push_fastpath_codepoint(U32 v) {return UI_StackPush(fastpath_codepoint, v);}
internal Vec4F32 ui_push_background_color(Vec4F32 v) {return UI_StackPush(background_color, v);}
internal Vec4F32 ui_push_text_color(Vec4F32 v) {return UI_StackPush(text_color, v);}
internal Vec4F32 ui_push_border_color(Vec4F32 v) {return UI_StackPush(border_color, v);}
internal Vec4F32 ui_push_overlay_color(Vec4F32 v) {return UI_StackPush(overlay_color, v);}
internal Vec4F32 ui_push_text_select_color(Vec4F32 v) {return UI_StackPush(text_select_color, v);}
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v) {return UI_StackPush(text_cursor_color, v);}
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v) {return UI_StackPush(hover_cursor, v);}
internal F_Tag ui_push_font(F_Tag v) {return UI_StackPush(font, v);}
internal F32 ui_push_font_size(F32 v) {return UI_StackPush(font_size, v);}
internal F32 ui_push_corner_radius_00(F32 v) {return UI_StackPush(corner_radius_00, v);}
internal F32 ui_push_corner_radius_01(F32 v) {return UI_StackPush(corner_radius_01, v);}
internal F32 ui_push_corner_radius_10(F32 v) {return UI_StackPush(corner_radius_10, v);}
internal F32 ui_push_corner_radius_11(F32 v) {return UI_StackPush(corner_radius_11, v);}
internal F32 ui_push_blur_size(F32 v) {return UI_StackPush(blur_size, v);}
internal F32 ui_push_text_padding(F32 v) {return UI_StackPush(text_padding, v);}
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v) {return UI_StackPush(text_alignment, v);}
internal UI_Box * ui_pop_parent(void) {UI_Box * popped; return UI_StackPop(parent, popped);}
internal Axis2 ui_pop_child_layout_axis(void) {Axis2 popped; return UI_StackPop(child_layout_axis, popped);}
internal F32 ui_pop_fixed_x(void) {F32 popped; return UI_StackPop(fixed_x, popped);}
internal F32 ui_pop_fixed_y(void) {F32 popped; return UI_StackPop(fixed_y, popped);}
internal F32 ui_pop_fixed_width(void) {F32 popped; return UI_StackPop(fixed_width, popped);}
internal F32 ui_pop_fixed_height(void) {F32 popped; return UI_StackPop(fixed_height, popped);}
internal UI_Size ui_pop_pref_width(void) {UI_Size popped; return UI_StackPop(pref_width, popped);}
internal UI_Size ui_pop_pref_height(void) {UI_Size popped; return UI_StackPop(pref_height, popped);}
internal UI_BoxFlags ui_pop_flags(void) {UI_BoxFlags popped; return UI_StackPop(flags, popped);}
internal U32 ui_pop_fastpath_codepoint(void) {U32 popped; return UI_StackPop(fastpath_codepoint, popped);}
internal Vec4F32 ui_pop_background_color(void) {Vec4F32 popped; return UI_StackPop(background_color, popped);}
internal Vec4F32 ui_pop_text_color(void) {Vec4F32 popped; return UI_StackPop(text_color, popped);}
internal Vec4F32 ui_pop_border_color(void) {Vec4F32 popped; return UI_StackPop(border_color, popped);}
internal Vec4F32 ui_pop_overlay_color(void) {Vec4F32 popped; return UI_StackPop(overlay_color, popped);}
internal Vec4F32 ui_pop_text_select_color(void) {Vec4F32 popped; return UI_StackPop(text_select_color, popped);}
internal Vec4F32 ui_pop_text_cursor_color(void) {Vec4F32 popped; return UI_StackPop(text_cursor_color, popped);}
internal OS_Cursor ui_pop_hover_cursor(void) {OS_Cursor popped; return UI_StackPop(hover_cursor, popped);}
internal F_Tag ui_pop_font(void) {F_Tag popped; return UI_StackPop(font, popped);}
internal F32 ui_pop_font_size(void) {F32 popped; return UI_StackPop(font_size, popped);}
internal F32 ui_pop_corner_radius_00(void) {F32 popped; return UI_StackPop(corner_radius_00, popped);}
internal F32 ui_pop_corner_radius_01(void) {F32 popped; return UI_StackPop(corner_radius_01, popped);}
internal F32 ui_pop_corner_radius_10(void) {F32 popped; return UI_StackPop(corner_radius_10, popped);}
internal F32 ui_pop_corner_radius_11(void) {F32 popped; return UI_StackPop(corner_radius_11, popped);}
internal F32 ui_pop_blur_size(void) {F32 popped; return UI_StackPop(blur_size, popped);}
internal F32 ui_pop_text_padding(void) {F32 popped; return UI_StackPop(text_padding, popped);}
internal UI_TextAlign ui_pop_text_alignment(void) {UI_TextAlign popped; return UI_StackPop(text_alignment, popped);}
internal UI_Box * ui_top_parent(void) {return UI_StackTop(parent);}
internal Axis2 ui_top_child_layout_axis(void) {return UI_StackTop(child_layout_axis);}
internal F32 ui_top_fixed_x(void) {return UI_StackTop(fixed_x);}
internal F32 ui_top_fixed_y(void) {return UI_StackTop(fixed_y);}
internal F32 ui_top_fixed_width(void) {return UI_StackTop(fixed_width);}
internal F32 ui_top_fixed_height(void) {return UI_StackTop(fixed_height);}
internal UI_Size ui_top_pref_width(void) {return UI_StackTop(pref_width);}
internal UI_Size ui_top_pref_height(void) {return UI_StackTop(pref_height);}
internal UI_BoxFlags ui_top_flags(void) {return UI_StackTop(flags);}
internal U32 ui_top_fastpath_codepoint(void) {return UI_StackTop(fastpath_codepoint);}
internal Vec4F32 ui_top_background_color(void) {return UI_StackTop(background_color);}
internal Vec4F32 ui_top_text_color(void) {return UI_StackTop(text_color);}
internal Vec4F32 ui_top_border_color(void) {return UI_StackTop(border_color);}
internal Vec4F32 ui_top_overlay_color(void) {return UI_StackTop(overlay_color);}
internal Vec4F32 ui_top_text_select_color(void) {return UI_StackTop(text_select_color);}
internal Vec4F32 ui_top_text_cursor_color(void) {return UI_StackTop(text_cursor_color);}
internal OS_Cursor ui_top_hover_cursor(void) {return UI_StackTop(hover_cursor);}
internal F_Tag ui_top_font(void) {return UI_StackTop(font);}
internal F32 ui_top_font_size(void) {return UI_StackTop(font_size);}
internal F32 ui_top_corner_radius_00(void) {return UI_StackTop(corner_radius_00);}
internal F32 ui_top_corner_radius_01(void) {return UI_StackTop(corner_radius_01);}
internal F32 ui_top_corner_radius_10(void) {return UI_StackTop(corner_radius_10);}
internal F32 ui_top_corner_radius_11(void) {return UI_StackTop(corner_radius_11);}
internal F32 ui_top_blur_size(void) {return UI_StackTop(blur_size);}
internal F32 ui_top_text_padding(void) {return UI_StackTop(text_padding);}
internal UI_TextAlign ui_top_text_alignment(void) {return UI_StackTop(text_alignment);}
internal UI_Box * ui_bottom_parent(void) {return UI_StackBottom(parent);}
internal Axis2 ui_bottom_child_layout_axis(void) {return UI_StackBottom(child_layout_axis);}
internal F32 ui_bottom_fixed_x(void) {return UI_StackBottom(fixed_x);}
internal F32 ui_bottom_fixed_y(void) {return UI_StackBottom(fixed_y);}
internal F32 ui_bottom_fixed_width(void) {return UI_StackBottom(fixed_width);}
internal F32 ui_bottom_fixed_height(void) {return UI_StackBottom(fixed_height);}
internal UI_Size ui_bottom_pref_width(void) {return UI_StackBottom(pref_width);}
internal UI_Size ui_bottom_pref_height(void) {return UI_StackBottom(pref_height);}
internal UI_BoxFlags ui_bottom_flags(void) {return UI_StackBottom(flags);}
internal U32 ui_bottom_fastpath_codepoint(void) {return UI_StackBottom(fastpath_codepoint);}
internal Vec4F32 ui_bottom_background_color(void) {return UI_StackBottom(background_color);}
internal Vec4F32 ui_bottom_text_color(void) {return UI_StackBottom(text_color);}
internal Vec4F32 ui_bottom_border_color(void) {return UI_StackBottom(border_color);}
internal Vec4F32 ui_bottom_overlay_color(void) {return UI_StackBottom(overlay_color);}
internal Vec4F32 ui_bottom_text_select_color(void) {return UI_StackBottom(text_select_color);}
internal Vec4F32 ui_bottom_text_cursor_color(void) {return UI_StackBottom(text_cursor_color);}
internal OS_Cursor ui_bottom_hover_cursor(void) {return UI_StackBottom(hover_cursor);}
internal F_Tag ui_bottom_font(void) {return UI_StackBottom(font);}
internal F32 ui_bottom_font_size(void) {return UI_StackBottom(font_size);}
internal F32 ui_bottom_corner_radius_00(void) {return UI_StackBottom(corner_radius_00);}
internal F32 ui_bottom_corner_radius_01(void) {return UI_StackBottom(corner_radius_01);}
internal F32 ui_bottom_corner_radius_10(void) {return UI_StackBottom(corner_radius_10);}
internal F32 ui_bottom_corner_radius_11(void) {return UI_StackBottom(corner_radius_11);}
internal F32 ui_bottom_blur_size(void) {return UI_StackBottom(blur_size);}
internal F32 ui_bottom_text_padding(void) {return UI_StackBottom(text_padding);}
internal UI_TextAlign ui_bottom_text_alignment(void) {return UI_StackBottom(text_alignment);}
internal UI_Box * ui_set_next_parent(UI_Box * v) {return UI_StackSetNext(parent, v);}
internal Axis2 ui_set_next_child_layout_axis(Axis2 v) {return UI_StackSetNext(child_layout_axis, v);}
internal F32 ui_set_next_fixed_x(F32 v) {return UI_StackSetNext(fixed_x, v);}
internal F32 ui_set_next_fixed_y(F32 v) {return UI_StackSetNext(fixed_y, v);}
internal F32 ui_set_next_fixed_width(F32 v) {return UI_StackSetNext(fixed_width, v);}
internal F32 ui_set_next_fixed_height(F32 v) {return UI_StackSetNext(fixed_height, v);}
internal UI_Size ui_set_next_pref_width(UI_Size v) {return UI_StackSetNext(pref_width, v);}
internal UI_Size ui_set_next_pref_height(UI_Size v) {return UI_StackSetNext(pref_height, v);}
internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v) {return UI_StackSetNext(flags, v);}
internal U32 ui_set_next_fastpath_codepoint(U32 v) {return UI_StackSetNext(fastpath_codepoint, v);}
internal Vec4F32 ui_set_next_background_color(Vec4F32 v) {return UI_StackSetNext(background_color, v);}
internal Vec4F32 ui_set_next_text_color(Vec4F32 v) {return UI_StackSetNext(text_color, v);}
internal Vec4F32 ui_set_next_border_color(Vec4F32 v) {return UI_StackSetNext(border_color, v);}
internal Vec4F32 ui_set_next_overlay_color(Vec4F32 v) {return UI_StackSetNext(overlay_color, v);}
internal Vec4F32 ui_set_next_text_select_color(Vec4F32 v) {return UI_StackSetNext(text_select_color, v);}
internal Vec4F32 ui_set_next_text_cursor_color(Vec4F32 v) {return UI_StackSetNext(text_cursor_color, v);}
internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v) {return UI_StackSetNext(hover_cursor, v);}
internal F_Tag ui_set_next_font(F_Tag v) {return UI_StackSetNext(font, v);}
internal F32 ui_set_next_font_size(F32 v) {return UI_StackSetNext(font_size, v);}
internal F32 ui_set_next_corner_radius_00(F32 v) {return UI_StackSetNext(corner_radius_00, v);}
internal F32 ui_set_next_corner_radius_01(F32 v) {return UI_StackSetNext(corner_radius_01, v);}
internal F32 ui_set_next_corner_radius_10(F32 v) {return UI_StackSetNext(corner_radius_10, v);}
internal F32 ui_set_next_corner_radius_11(F32 v) {return UI_StackSetNext(corner_radius_11, v);}
internal F32 ui_set_next_blur_size(F32 v) {return UI_StackSetNext(blur_size, v);}
internal F32 ui_set_next_text_padding(F32 v) {return UI_StackSetNext(text_padding, v);}
internal UI_TextAlign ui_set_next_text_alignment(UI_TextAlign v) {return UI_StackSetNext(text_alignment, v);}
#if 0
#define UI_Parent(v) DeferLoop(ui_push_parent(v), ui_pop_parent())
#define UI_ChildLayoutAxis(v) DeferLoop(ui_push_child_layout_axis(v), ui_pop_child_layout_axis())
#define UI_FixedX(v) DeferLoop(ui_push_fixed_x(v), ui_pop_fixed_x())
#define UI_FixedY(v) DeferLoop(ui_push_fixed_y(v), ui_pop_fixed_y())
#define UI_FixedWidth(v) DeferLoop(ui_push_fixed_width(v), ui_pop_fixed_width())
#define UI_FixedHeight(v) DeferLoop(ui_push_fixed_height(v), ui_pop_fixed_height())
#define UI_PrefWidth(v) DeferLoop(ui_push_pref_width(v), ui_pop_pref_width())
#define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height())
#define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags())
#define UI_FocusHot(v) DeferLoop(ui_push_focus_hot(v), ui_pop_focus_hot())
#define UI_FocusActive(v) DeferLoop(ui_push_focus_active(v), ui_pop_focus_active())
#define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint())
#define UI_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color())
#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color())
#define UI_BorderColor(v) DeferLoop(ui_push_border_color(v), ui_pop_border_color())
#define UI_OverlayColor(v) DeferLoop(ui_push_overlay_color(v), ui_pop_overlay_color())
#define UI_TextSelectColor(v) DeferLoop(ui_push_text_select_color(v), ui_pop_text_select_color())
#define UI_TextCursorColor(v) DeferLoop(ui_push_text_cursor_color(v), ui_pop_text_cursor_color())
#define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor())
#define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font())
#define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size())
#define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00())
#define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01())
#define UI_CornerRadius10(v) DeferLoop(ui_push_corner_radius_10(v), ui_pop_corner_radius_10())
#define UI_CornerRadius11(v) DeferLoop(ui_push_corner_radius_11(v), ui_pop_corner_radius_11())
#define UI_BlurSize(v) DeferLoop(ui_push_blur_size(v), ui_pop_blur_size())
#define UI_TextPadding(v) DeferLoop(ui_push_text_padding(v), ui_pop_text_padding())
#define UI_TextAlignment(v) DeferLoop(ui_push_text_alignment(v), ui_pop_text_alignment())
#endif
internal UI_Box * ui_top_parent(void) { UI_StackTopImpl(ui_state, Parent, parent) }
internal Axis2 ui_top_child_layout_axis(void) { UI_StackTopImpl(ui_state, ChildLayoutAxis, child_layout_axis) }
internal F32 ui_top_fixed_x(void) { UI_StackTopImpl(ui_state, FixedX, fixed_x) }
internal F32 ui_top_fixed_y(void) { UI_StackTopImpl(ui_state, FixedY, fixed_y) }
internal F32 ui_top_fixed_width(void) { UI_StackTopImpl(ui_state, FixedWidth, fixed_width) }
internal F32 ui_top_fixed_height(void) { UI_StackTopImpl(ui_state, FixedHeight, fixed_height) }
internal UI_Size ui_top_pref_width(void) { UI_StackTopImpl(ui_state, PrefWidth, pref_width) }
internal UI_Size ui_top_pref_height(void) { UI_StackTopImpl(ui_state, PrefHeight, pref_height) }
internal UI_BoxFlags ui_top_flags(void) { UI_StackTopImpl(ui_state, Flags, flags) }
internal UI_FocusKind ui_top_focus_hot(void) { UI_StackTopImpl(ui_state, FocusHot, focus_hot) }
internal UI_FocusKind ui_top_focus_active(void) { UI_StackTopImpl(ui_state, FocusActive, focus_active) }
internal U32 ui_top_fastpath_codepoint(void) { UI_StackTopImpl(ui_state, FastpathCodepoint, fastpath_codepoint) }
internal Vec4F32 ui_top_background_color(void) { UI_StackTopImpl(ui_state, BackgroundColor, background_color) }
internal Vec4F32 ui_top_text_color(void) { UI_StackTopImpl(ui_state, TextColor, text_color) }
internal Vec4F32 ui_top_border_color(void) { UI_StackTopImpl(ui_state, BorderColor, border_color) }
internal Vec4F32 ui_top_overlay_color(void) { UI_StackTopImpl(ui_state, OverlayColor, overlay_color) }
internal Vec4F32 ui_top_text_select_color(void) { UI_StackTopImpl(ui_state, TextSelectColor, text_select_color) }
internal Vec4F32 ui_top_text_cursor_color(void) { UI_StackTopImpl(ui_state, TextCursorColor, text_cursor_color) }
internal OS_Cursor ui_top_hover_cursor(void) { UI_StackTopImpl(ui_state, HoverCursor, hover_cursor) }
internal F_Tag ui_top_font(void) { UI_StackTopImpl(ui_state, Font, font) }
internal F32 ui_top_font_size(void) { UI_StackTopImpl(ui_state, FontSize, font_size) }
internal F32 ui_top_corner_radius_00(void) { UI_StackTopImpl(ui_state, CornerRadius00, corner_radius_00) }
internal F32 ui_top_corner_radius_01(void) { UI_StackTopImpl(ui_state, CornerRadius01, corner_radius_01) }
internal F32 ui_top_corner_radius_10(void) { UI_StackTopImpl(ui_state, CornerRadius10, corner_radius_10) }
internal F32 ui_top_corner_radius_11(void) { UI_StackTopImpl(ui_state, CornerRadius11, corner_radius_11) }
internal F32 ui_top_blur_size(void) { UI_StackTopImpl(ui_state, BlurSize, blur_size) }
internal F32 ui_top_text_padding(void) { UI_StackTopImpl(ui_state, TextPadding, text_padding) }
internal UI_TextAlign ui_top_text_alignment(void) { UI_StackTopImpl(ui_state, TextAlignment, text_alignment) }
internal UI_Box * ui_bottom_parent(void) { UI_StackBottomImpl(ui_state, Parent, parent) }
internal Axis2 ui_bottom_child_layout_axis(void) { UI_StackBottomImpl(ui_state, ChildLayoutAxis, child_layout_axis) }
internal F32 ui_bottom_fixed_x(void) { UI_StackBottomImpl(ui_state, FixedX, fixed_x) }
internal F32 ui_bottom_fixed_y(void) { UI_StackBottomImpl(ui_state, FixedY, fixed_y) }
internal F32 ui_bottom_fixed_width(void) { UI_StackBottomImpl(ui_state, FixedWidth, fixed_width) }
internal F32 ui_bottom_fixed_height(void) { UI_StackBottomImpl(ui_state, FixedHeight, fixed_height) }
internal UI_Size ui_bottom_pref_width(void) { UI_StackBottomImpl(ui_state, PrefWidth, pref_width) }
internal UI_Size ui_bottom_pref_height(void) { UI_StackBottomImpl(ui_state, PrefHeight, pref_height) }
internal UI_BoxFlags ui_bottom_flags(void) { UI_StackBottomImpl(ui_state, Flags, flags) }
internal UI_FocusKind ui_bottom_focus_hot(void) { UI_StackBottomImpl(ui_state, FocusHot, focus_hot) }
internal UI_FocusKind ui_bottom_focus_active(void) { UI_StackBottomImpl(ui_state, FocusActive, focus_active) }
internal U32 ui_bottom_fastpath_codepoint(void) { UI_StackBottomImpl(ui_state, FastpathCodepoint, fastpath_codepoint) }
internal Vec4F32 ui_bottom_background_color(void) { UI_StackBottomImpl(ui_state, BackgroundColor, background_color) }
internal Vec4F32 ui_bottom_text_color(void) { UI_StackBottomImpl(ui_state, TextColor, text_color) }
internal Vec4F32 ui_bottom_border_color(void) { UI_StackBottomImpl(ui_state, BorderColor, border_color) }
internal Vec4F32 ui_bottom_overlay_color(void) { UI_StackBottomImpl(ui_state, OverlayColor, overlay_color) }
internal Vec4F32 ui_bottom_text_select_color(void) { UI_StackBottomImpl(ui_state, TextSelectColor, text_select_color) }
internal Vec4F32 ui_bottom_text_cursor_color(void) { UI_StackBottomImpl(ui_state, TextCursorColor, text_cursor_color) }
internal OS_Cursor ui_bottom_hover_cursor(void) { UI_StackBottomImpl(ui_state, HoverCursor, hover_cursor) }
internal F_Tag ui_bottom_font(void) { UI_StackBottomImpl(ui_state, Font, font) }
internal F32 ui_bottom_font_size(void) { UI_StackBottomImpl(ui_state, FontSize, font_size) }
internal F32 ui_bottom_corner_radius_00(void) { UI_StackBottomImpl(ui_state, CornerRadius00, corner_radius_00) }
internal F32 ui_bottom_corner_radius_01(void) { UI_StackBottomImpl(ui_state, CornerRadius01, corner_radius_01) }
internal F32 ui_bottom_corner_radius_10(void) { UI_StackBottomImpl(ui_state, CornerRadius10, corner_radius_10) }
internal F32 ui_bottom_corner_radius_11(void) { UI_StackBottomImpl(ui_state, CornerRadius11, corner_radius_11) }
internal F32 ui_bottom_blur_size(void) { UI_StackBottomImpl(ui_state, BlurSize, blur_size) }
internal F32 ui_bottom_text_padding(void) { UI_StackBottomImpl(ui_state, TextPadding, text_padding) }
internal UI_TextAlign ui_bottom_text_alignment(void) { UI_StackBottomImpl(ui_state, TextAlignment, text_alignment) }
internal UI_Box * ui_push_parent(UI_Box * v) { UI_StackPushImpl(ui_state, Parent, parent, UI_Box *, v) }
internal Axis2 ui_push_child_layout_axis(Axis2 v) { UI_StackPushImpl(ui_state, ChildLayoutAxis, child_layout_axis, Axis2, v) }
internal F32 ui_push_fixed_x(F32 v) { UI_StackPushImpl(ui_state, FixedX, fixed_x, F32, v) }
internal F32 ui_push_fixed_y(F32 v) { UI_StackPushImpl(ui_state, FixedY, fixed_y, F32, v) }
internal F32 ui_push_fixed_width(F32 v) { UI_StackPushImpl(ui_state, FixedWidth, fixed_width, F32, v) }
internal F32 ui_push_fixed_height(F32 v) { UI_StackPushImpl(ui_state, FixedHeight, fixed_height, F32, v) }
internal UI_Size ui_push_pref_width(UI_Size v) { UI_StackPushImpl(ui_state, PrefWidth, pref_width, UI_Size, v) }
internal UI_Size ui_push_pref_height(UI_Size v) { UI_StackPushImpl(ui_state, PrefHeight, pref_height, UI_Size, v) }
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v) { UI_StackPushImpl(ui_state, Flags, flags, UI_BoxFlags, v) }
internal UI_FocusKind ui_push_focus_hot(UI_FocusKind v) { UI_StackPushImpl(ui_state, FocusHot, focus_hot, UI_FocusKind, v) }
internal UI_FocusKind ui_push_focus_active(UI_FocusKind v) { UI_StackPushImpl(ui_state, FocusActive, focus_active, UI_FocusKind, v) }
internal U32 ui_push_fastpath_codepoint(U32 v) { UI_StackPushImpl(ui_state, FastpathCodepoint, fastpath_codepoint, U32, v) }
internal Vec4F32 ui_push_background_color(Vec4F32 v) { UI_StackPushImpl(ui_state, BackgroundColor, background_color, Vec4F32, v) }
internal Vec4F32 ui_push_text_color(Vec4F32 v) { UI_StackPushImpl(ui_state, TextColor, text_color, Vec4F32, v) }
internal Vec4F32 ui_push_border_color(Vec4F32 v) { UI_StackPushImpl(ui_state, BorderColor, border_color, Vec4F32, v) }
internal Vec4F32 ui_push_overlay_color(Vec4F32 v) { UI_StackPushImpl(ui_state, OverlayColor, overlay_color, Vec4F32, v) }
internal Vec4F32 ui_push_text_select_color(Vec4F32 v) { UI_StackPushImpl(ui_state, TextSelectColor, text_select_color, Vec4F32, v) }
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v) { UI_StackPushImpl(ui_state, TextCursorColor, text_cursor_color, Vec4F32, v) }
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v) { UI_StackPushImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) }
internal F_Tag ui_push_font(F_Tag v) { UI_StackPushImpl(ui_state, Font, font, F_Tag, v) }
internal F32 ui_push_font_size(F32 v) { UI_StackPushImpl(ui_state, FontSize, font_size, F32, v) }
internal F32 ui_push_corner_radius_00(F32 v) { UI_StackPushImpl(ui_state, CornerRadius00, corner_radius_00, F32, v) }
internal F32 ui_push_corner_radius_01(F32 v) { UI_StackPushImpl(ui_state, CornerRadius01, corner_radius_01, F32, v) }
internal F32 ui_push_corner_radius_10(F32 v) { UI_StackPushImpl(ui_state, CornerRadius10, corner_radius_10, F32, v) }
internal F32 ui_push_corner_radius_11(F32 v) { UI_StackPushImpl(ui_state, CornerRadius11, corner_radius_11, F32, v) }
internal F32 ui_push_blur_size(F32 v) { UI_StackPushImpl(ui_state, BlurSize, blur_size, F32, v) }
internal F32 ui_push_text_padding(F32 v) { UI_StackPushImpl(ui_state, TextPadding, text_padding, F32, v) }
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v) { UI_StackPushImpl(ui_state, TextAlignment, text_alignment, UI_TextAlign, v) }
internal UI_Box * ui_pop_parent(void) { UI_StackPopImpl(ui_state, Parent, parent) }
internal Axis2 ui_pop_child_layout_axis(void) { UI_StackPopImpl(ui_state, ChildLayoutAxis, child_layout_axis) }
internal F32 ui_pop_fixed_x(void) { UI_StackPopImpl(ui_state, FixedX, fixed_x) }
internal F32 ui_pop_fixed_y(void) { UI_StackPopImpl(ui_state, FixedY, fixed_y) }
internal F32 ui_pop_fixed_width(void) { UI_StackPopImpl(ui_state, FixedWidth, fixed_width) }
internal F32 ui_pop_fixed_height(void) { UI_StackPopImpl(ui_state, FixedHeight, fixed_height) }
internal UI_Size ui_pop_pref_width(void) { UI_StackPopImpl(ui_state, PrefWidth, pref_width) }
internal UI_Size ui_pop_pref_height(void) { UI_StackPopImpl(ui_state, PrefHeight, pref_height) }
internal UI_BoxFlags ui_pop_flags(void) { UI_StackPopImpl(ui_state, Flags, flags) }
internal UI_FocusKind ui_pop_focus_hot(void) { UI_StackPopImpl(ui_state, FocusHot, focus_hot) }
internal UI_FocusKind ui_pop_focus_active(void) { UI_StackPopImpl(ui_state, FocusActive, focus_active) }
internal U32 ui_pop_fastpath_codepoint(void) { UI_StackPopImpl(ui_state, FastpathCodepoint, fastpath_codepoint) }
internal Vec4F32 ui_pop_background_color(void) { UI_StackPopImpl(ui_state, BackgroundColor, background_color) }
internal Vec4F32 ui_pop_text_color(void) { UI_StackPopImpl(ui_state, TextColor, text_color) }
internal Vec4F32 ui_pop_border_color(void) { UI_StackPopImpl(ui_state, BorderColor, border_color) }
internal Vec4F32 ui_pop_overlay_color(void) { UI_StackPopImpl(ui_state, OverlayColor, overlay_color) }
internal Vec4F32 ui_pop_text_select_color(void) { UI_StackPopImpl(ui_state, TextSelectColor, text_select_color) }
internal Vec4F32 ui_pop_text_cursor_color(void) { UI_StackPopImpl(ui_state, TextCursorColor, text_cursor_color) }
internal OS_Cursor ui_pop_hover_cursor(void) { UI_StackPopImpl(ui_state, HoverCursor, hover_cursor) }
internal F_Tag ui_pop_font(void) { UI_StackPopImpl(ui_state, Font, font) }
internal F32 ui_pop_font_size(void) { UI_StackPopImpl(ui_state, FontSize, font_size) }
internal F32 ui_pop_corner_radius_00(void) { UI_StackPopImpl(ui_state, CornerRadius00, corner_radius_00) }
internal F32 ui_pop_corner_radius_01(void) { UI_StackPopImpl(ui_state, CornerRadius01, corner_radius_01) }
internal F32 ui_pop_corner_radius_10(void) { UI_StackPopImpl(ui_state, CornerRadius10, corner_radius_10) }
internal F32 ui_pop_corner_radius_11(void) { UI_StackPopImpl(ui_state, CornerRadius11, corner_radius_11) }
internal F32 ui_pop_blur_size(void) { UI_StackPopImpl(ui_state, BlurSize, blur_size) }
internal F32 ui_pop_text_padding(void) { UI_StackPopImpl(ui_state, TextPadding, text_padding) }
internal UI_TextAlign ui_pop_text_alignment(void) { UI_StackPopImpl(ui_state, TextAlignment, text_alignment) }
internal UI_Box * ui_set_next_parent(UI_Box * v) { UI_StackSetNextImpl(ui_state, Parent, parent, UI_Box *, v) }
internal Axis2 ui_set_next_child_layout_axis(Axis2 v) { UI_StackSetNextImpl(ui_state, ChildLayoutAxis, child_layout_axis, Axis2, v) }
internal F32 ui_set_next_fixed_x(F32 v) { UI_StackSetNextImpl(ui_state, FixedX, fixed_x, F32, v) }
internal F32 ui_set_next_fixed_y(F32 v) { UI_StackSetNextImpl(ui_state, FixedY, fixed_y, F32, v) }
internal F32 ui_set_next_fixed_width(F32 v) { UI_StackSetNextImpl(ui_state, FixedWidth, fixed_width, F32, v) }
internal F32 ui_set_next_fixed_height(F32 v) { UI_StackSetNextImpl(ui_state, FixedHeight, fixed_height, F32, v) }
internal UI_Size ui_set_next_pref_width(UI_Size v) { UI_StackSetNextImpl(ui_state, PrefWidth, pref_width, UI_Size, v) }
internal UI_Size ui_set_next_pref_height(UI_Size v) { UI_StackSetNextImpl(ui_state, PrefHeight, pref_height, UI_Size, v) }
internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v) { UI_StackSetNextImpl(ui_state, Flags, flags, UI_BoxFlags, v) }
internal UI_FocusKind ui_set_next_focus_hot(UI_FocusKind v) { UI_StackSetNextImpl(ui_state, FocusHot, focus_hot, UI_FocusKind, v) }
internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v) { UI_StackSetNextImpl(ui_state, FocusActive, focus_active, UI_FocusKind, v) }
internal U32 ui_set_next_fastpath_codepoint(U32 v) { UI_StackSetNextImpl(ui_state, FastpathCodepoint, fastpath_codepoint, U32, v) }
internal Vec4F32 ui_set_next_background_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, BackgroundColor, background_color, Vec4F32, v) }
internal Vec4F32 ui_set_next_text_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, TextColor, text_color, Vec4F32, v) }
internal Vec4F32 ui_set_next_border_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, BorderColor, border_color, Vec4F32, v) }
internal Vec4F32 ui_set_next_overlay_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, OverlayColor, overlay_color, Vec4F32, v) }
internal Vec4F32 ui_set_next_text_select_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, TextSelectColor, text_select_color, Vec4F32, v) }
internal Vec4F32 ui_set_next_text_cursor_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, TextCursorColor, text_cursor_color, Vec4F32, v) }
internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v) { UI_StackSetNextImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) }
internal F_Tag ui_set_next_font(F_Tag v) { UI_StackSetNextImpl(ui_state, Font, font, F_Tag, v) }
internal F32 ui_set_next_font_size(F32 v) { UI_StackSetNextImpl(ui_state, FontSize, font_size, F32, v) }
internal F32 ui_set_next_corner_radius_00(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius00, corner_radius_00, F32, v) }
internal F32 ui_set_next_corner_radius_01(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius01, corner_radius_01, F32, v) }
internal F32 ui_set_next_corner_radius_10(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius10, corner_radius_10, F32, v) }
internal F32 ui_set_next_corner_radius_11(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius11, corner_radius_11, F32, v) }
internal F32 ui_set_next_blur_size(F32 v) { UI_StackSetNextImpl(ui_state, BlurSize, blur_size, F32, v) }
internal F32 ui_set_next_text_padding(F32 v) { UI_StackSetNextImpl(ui_state, TextPadding, text_padding, F32, v) }
internal UI_TextAlign ui_set_next_text_alignment(UI_TextAlign v) { UI_StackSetNextImpl(ui_state, TextAlignment, text_alignment, UI_TextAlign, v) }
+243 -163
View File
@@ -6,142 +6,188 @@
#ifndef UI_META_H
#define UI_META_H
#define UI_StackDecls struct{\
struct { UI_Box * active; UI_Box * v[64]; U64 count; B32 auto_pop; } parent;\
struct { Axis2 active; Axis2 v[64]; U64 count; B32 auto_pop; } child_layout_axis;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } fixed_x;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } fixed_y;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } fixed_width;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } fixed_height;\
struct { UI_Size active; UI_Size v[64]; U64 count; B32 auto_pop; } pref_width;\
struct { UI_Size active; UI_Size v[64]; U64 count; B32 auto_pop; } pref_height;\
struct { UI_BoxFlags active; UI_BoxFlags v[64]; U64 count; B32 auto_pop; } flags;\
struct { U32 active; U32 v[64]; U64 count; B32 auto_pop; } fastpath_codepoint;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } background_color;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } text_color;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } border_color;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } overlay_color;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } text_select_color;\
struct { Vec4F32 active; Vec4F32 v[64]; U64 count; B32 auto_pop; } text_cursor_color;\
struct { OS_Cursor active; OS_Cursor v[64]; U64 count; B32 auto_pop; } hover_cursor;\
struct { F_Tag active; F_Tag v[64]; U64 count; B32 auto_pop; } font;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } font_size;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } corner_radius_00;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } corner_radius_01;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } corner_radius_10;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } corner_radius_11;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } blur_size;\
struct { F32 active; F32 v[64]; U64 count; B32 auto_pop; } text_padding;\
struct { UI_TextAlign active; UI_TextAlign v[64]; U64 count; B32 auto_pop; } text_alignment;\
typedef struct UI_ParentNode UI_ParentNode; struct UI_ParentNode{UI_ParentNode *next; UI_Box * v;};
typedef struct UI_ChildLayoutAxisNode UI_ChildLayoutAxisNode; struct UI_ChildLayoutAxisNode{UI_ChildLayoutAxisNode *next; Axis2 v;};
typedef struct UI_FixedXNode UI_FixedXNode; struct UI_FixedXNode{UI_FixedXNode *next; F32 v;};
typedef struct UI_FixedYNode UI_FixedYNode; struct UI_FixedYNode{UI_FixedYNode *next; F32 v;};
typedef struct UI_FixedWidthNode UI_FixedWidthNode; struct UI_FixedWidthNode{UI_FixedWidthNode *next; F32 v;};
typedef struct UI_FixedHeightNode UI_FixedHeightNode; struct UI_FixedHeightNode{UI_FixedHeightNode *next; F32 v;};
typedef struct UI_PrefWidthNode UI_PrefWidthNode; struct UI_PrefWidthNode{UI_PrefWidthNode *next; UI_Size v;};
typedef struct UI_PrefHeightNode UI_PrefHeightNode; struct UI_PrefHeightNode{UI_PrefHeightNode *next; UI_Size v;};
typedef struct UI_FlagsNode UI_FlagsNode; struct UI_FlagsNode{UI_FlagsNode *next; UI_BoxFlags v;};
typedef struct UI_FocusHotNode UI_FocusHotNode; struct UI_FocusHotNode{UI_FocusHotNode *next; UI_FocusKind v;};
typedef struct UI_FocusActiveNode UI_FocusActiveNode; struct UI_FocusActiveNode{UI_FocusActiveNode *next; UI_FocusKind v;};
typedef struct UI_FastpathCodepointNode UI_FastpathCodepointNode; struct UI_FastpathCodepointNode{UI_FastpathCodepointNode *next; U32 v;};
typedef struct UI_BackgroundColorNode UI_BackgroundColorNode; struct UI_BackgroundColorNode{UI_BackgroundColorNode *next; Vec4F32 v;};
typedef struct UI_TextColorNode UI_TextColorNode; struct UI_TextColorNode{UI_TextColorNode *next; Vec4F32 v;};
typedef struct UI_BorderColorNode UI_BorderColorNode; struct UI_BorderColorNode{UI_BorderColorNode *next; Vec4F32 v;};
typedef struct UI_OverlayColorNode UI_OverlayColorNode; struct UI_OverlayColorNode{UI_OverlayColorNode *next; Vec4F32 v;};
typedef struct UI_TextSelectColorNode UI_TextSelectColorNode; struct UI_TextSelectColorNode{UI_TextSelectColorNode *next; Vec4F32 v;};
typedef struct UI_TextCursorColorNode UI_TextCursorColorNode; struct UI_TextCursorColorNode{UI_TextCursorColorNode *next; Vec4F32 v;};
typedef struct UI_HoverCursorNode UI_HoverCursorNode; struct UI_HoverCursorNode{UI_HoverCursorNode *next; OS_Cursor v;};
typedef struct UI_FontNode UI_FontNode; struct UI_FontNode{UI_FontNode *next; F_Tag v;};
typedef struct UI_FontSizeNode UI_FontSizeNode; struct UI_FontSizeNode{UI_FontSizeNode *next; F32 v;};
typedef struct UI_CornerRadius00Node UI_CornerRadius00Node; struct UI_CornerRadius00Node{UI_CornerRadius00Node *next; F32 v;};
typedef struct UI_CornerRadius01Node UI_CornerRadius01Node; struct UI_CornerRadius01Node{UI_CornerRadius01Node *next; F32 v;};
typedef struct UI_CornerRadius10Node UI_CornerRadius10Node; struct UI_CornerRadius10Node{UI_CornerRadius10Node *next; F32 v;};
typedef struct UI_CornerRadius11Node UI_CornerRadius11Node; struct UI_CornerRadius11Node{UI_CornerRadius11Node *next; F32 v;};
typedef struct UI_BlurSizeNode UI_BlurSizeNode; struct UI_BlurSizeNode{UI_BlurSizeNode *next; F32 v;};
typedef struct UI_TextPaddingNode UI_TextPaddingNode; struct UI_TextPaddingNode{UI_TextPaddingNode *next; F32 v;};
typedef struct UI_TextAlignmentNode UI_TextAlignmentNode; struct UI_TextAlignmentNode{UI_TextAlignmentNode *next; UI_TextAlign v;};
#define UI_DeclStackNils \
struct\
{\
UI_ParentNode parent_nil_stack_top;\
UI_ChildLayoutAxisNode child_layout_axis_nil_stack_top;\
UI_FixedXNode fixed_x_nil_stack_top;\
UI_FixedYNode fixed_y_nil_stack_top;\
UI_FixedWidthNode fixed_width_nil_stack_top;\
UI_FixedHeightNode fixed_height_nil_stack_top;\
UI_PrefWidthNode pref_width_nil_stack_top;\
UI_PrefHeightNode pref_height_nil_stack_top;\
UI_FlagsNode flags_nil_stack_top;\
UI_FocusHotNode focus_hot_nil_stack_top;\
UI_FocusActiveNode focus_active_nil_stack_top;\
UI_FastpathCodepointNode fastpath_codepoint_nil_stack_top;\
UI_BackgroundColorNode background_color_nil_stack_top;\
UI_TextColorNode text_color_nil_stack_top;\
UI_BorderColorNode border_color_nil_stack_top;\
UI_OverlayColorNode overlay_color_nil_stack_top;\
UI_TextSelectColorNode text_select_color_nil_stack_top;\
UI_TextCursorColorNode text_cursor_color_nil_stack_top;\
UI_HoverCursorNode hover_cursor_nil_stack_top;\
UI_FontNode font_nil_stack_top;\
UI_FontSizeNode font_size_nil_stack_top;\
UI_CornerRadius00Node corner_radius_00_nil_stack_top;\
UI_CornerRadius01Node corner_radius_01_nil_stack_top;\
UI_CornerRadius10Node corner_radius_10_nil_stack_top;\
UI_CornerRadius11Node corner_radius_11_nil_stack_top;\
UI_BlurSizeNode blur_size_nil_stack_top;\
UI_TextPaddingNode text_padding_nil_stack_top;\
UI_TextAlignmentNode text_alignment_nil_stack_top;\
}
#define UI_ZeroAllStacks(ui_state) do{\
MemoryZeroStruct(&ui_state->parent);\
MemoryZeroStruct(&ui_state->child_layout_axis);\
MemoryZeroStruct(&ui_state->fixed_x);\
MemoryZeroStruct(&ui_state->fixed_y);\
MemoryZeroStruct(&ui_state->fixed_width);\
MemoryZeroStruct(&ui_state->fixed_height);\
MemoryZeroStruct(&ui_state->pref_width);\
MemoryZeroStruct(&ui_state->pref_height);\
MemoryZeroStruct(&ui_state->flags);\
MemoryZeroStruct(&ui_state->fastpath_codepoint);\
MemoryZeroStruct(&ui_state->background_color);\
MemoryZeroStruct(&ui_state->text_color);\
MemoryZeroStruct(&ui_state->border_color);\
MemoryZeroStruct(&ui_state->overlay_color);\
MemoryZeroStruct(&ui_state->text_select_color);\
MemoryZeroStruct(&ui_state->text_cursor_color);\
MemoryZeroStruct(&ui_state->hover_cursor);\
MemoryZeroStruct(&ui_state->font);\
MemoryZeroStruct(&ui_state->font_size);\
MemoryZeroStruct(&ui_state->corner_radius_00);\
MemoryZeroStruct(&ui_state->corner_radius_01);\
MemoryZeroStruct(&ui_state->corner_radius_10);\
MemoryZeroStruct(&ui_state->corner_radius_11);\
MemoryZeroStruct(&ui_state->blur_size);\
MemoryZeroStruct(&ui_state->text_padding);\
MemoryZeroStruct(&ui_state->text_alignment);\
} while(0)
#define UI_AutoPopAllStacks(ui_state) do{\
if(ui_state->parent.auto_pop) {ui_state->parent.auto_pop = 0; ui_pop_parent();}\
if(ui_state->child_layout_axis.auto_pop) {ui_state->child_layout_axis.auto_pop = 0; ui_pop_child_layout_axis();}\
if(ui_state->fixed_x.auto_pop) {ui_state->fixed_x.auto_pop = 0; ui_pop_fixed_x();}\
if(ui_state->fixed_y.auto_pop) {ui_state->fixed_y.auto_pop = 0; ui_pop_fixed_y();}\
if(ui_state->fixed_width.auto_pop) {ui_state->fixed_width.auto_pop = 0; ui_pop_fixed_width();}\
if(ui_state->fixed_height.auto_pop) {ui_state->fixed_height.auto_pop = 0; ui_pop_fixed_height();}\
if(ui_state->pref_width.auto_pop) {ui_state->pref_width.auto_pop = 0; ui_pop_pref_width();}\
if(ui_state->pref_height.auto_pop) {ui_state->pref_height.auto_pop = 0; ui_pop_pref_height();}\
if(ui_state->flags.auto_pop) {ui_state->flags.auto_pop = 0; ui_pop_flags();}\
if(ui_state->fastpath_codepoint.auto_pop) {ui_state->fastpath_codepoint.auto_pop = 0; ui_pop_fastpath_codepoint();}\
if(ui_state->background_color.auto_pop) {ui_state->background_color.auto_pop = 0; ui_pop_background_color();}\
if(ui_state->text_color.auto_pop) {ui_state->text_color.auto_pop = 0; ui_pop_text_color();}\
if(ui_state->border_color.auto_pop) {ui_state->border_color.auto_pop = 0; ui_pop_border_color();}\
if(ui_state->overlay_color.auto_pop) {ui_state->overlay_color.auto_pop = 0; ui_pop_overlay_color();}\
if(ui_state->text_select_color.auto_pop) {ui_state->text_select_color.auto_pop = 0; ui_pop_text_select_color();}\
if(ui_state->text_cursor_color.auto_pop) {ui_state->text_cursor_color.auto_pop = 0; ui_pop_text_cursor_color();}\
if(ui_state->hover_cursor.auto_pop) {ui_state->hover_cursor.auto_pop = 0; ui_pop_hover_cursor();}\
if(ui_state->font.auto_pop) {ui_state->font.auto_pop = 0; ui_pop_font();}\
if(ui_state->font_size.auto_pop) {ui_state->font_size.auto_pop = 0; ui_pop_font_size();}\
if(ui_state->corner_radius_00.auto_pop) {ui_state->corner_radius_00.auto_pop = 0; ui_pop_corner_radius_00();}\
if(ui_state->corner_radius_01.auto_pop) {ui_state->corner_radius_01.auto_pop = 0; ui_pop_corner_radius_01();}\
if(ui_state->corner_radius_10.auto_pop) {ui_state->corner_radius_10.auto_pop = 0; ui_pop_corner_radius_10();}\
if(ui_state->corner_radius_11.auto_pop) {ui_state->corner_radius_11.auto_pop = 0; ui_pop_corner_radius_11();}\
if(ui_state->blur_size.auto_pop) {ui_state->blur_size.auto_pop = 0; ui_pop_blur_size();}\
if(ui_state->text_padding.auto_pop) {ui_state->text_padding.auto_pop = 0; ui_pop_text_padding();}\
if(ui_state->text_alignment.auto_pop) {ui_state->text_alignment.auto_pop = 0; ui_pop_text_alignment();}\
} while(0)
internal UI_Box * ui_push_parent(UI_Box * v);
internal Axis2 ui_push_child_layout_axis(Axis2 v);
internal F32 ui_push_fixed_x(F32 v);
internal F32 ui_push_fixed_y(F32 v);
internal F32 ui_push_fixed_width(F32 v);
internal F32 ui_push_fixed_height(F32 v);
internal UI_Size ui_push_pref_width(UI_Size v);
internal UI_Size ui_push_pref_height(UI_Size v);
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v);
internal U32 ui_push_fastpath_codepoint(U32 v);
internal Vec4F32 ui_push_background_color(Vec4F32 v);
internal Vec4F32 ui_push_text_color(Vec4F32 v);
internal Vec4F32 ui_push_border_color(Vec4F32 v);
internal Vec4F32 ui_push_overlay_color(Vec4F32 v);
internal Vec4F32 ui_push_text_select_color(Vec4F32 v);
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal F_Tag ui_push_font(F_Tag v);
internal F32 ui_push_font_size(F32 v);
internal F32 ui_push_corner_radius_00(F32 v);
internal F32 ui_push_corner_radius_01(F32 v);
internal F32 ui_push_corner_radius_10(F32 v);
internal F32 ui_push_corner_radius_11(F32 v);
internal F32 ui_push_blur_size(F32 v);
internal F32 ui_push_text_padding(F32 v);
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v);
internal UI_Box * ui_pop_parent(void);
internal Axis2 ui_pop_child_layout_axis(void);
internal F32 ui_pop_fixed_x(void);
internal F32 ui_pop_fixed_y(void);
internal F32 ui_pop_fixed_width(void);
internal F32 ui_pop_fixed_height(void);
internal UI_Size ui_pop_pref_width(void);
internal UI_Size ui_pop_pref_height(void);
internal UI_BoxFlags ui_pop_flags(void);
internal U32 ui_pop_fastpath_codepoint(void);
internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal Vec4F32 ui_pop_overlay_color(void);
internal Vec4F32 ui_pop_text_select_color(void);
internal Vec4F32 ui_pop_text_cursor_color(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal F_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal F32 ui_pop_corner_radius_00(void);
internal F32 ui_pop_corner_radius_01(void);
internal F32 ui_pop_corner_radius_10(void);
internal F32 ui_pop_corner_radius_11(void);
internal F32 ui_pop_blur_size(void);
internal F32 ui_pop_text_padding(void);
internal UI_TextAlign ui_pop_text_alignment(void);
#define UI_InitStackNils(state) \
state->parent_nil_stack_top.v = &ui_g_nil_box;\
state->child_layout_axis_nil_stack_top.v = Axis2_X;\
state->fixed_x_nil_stack_top.v = 0;\
state->fixed_y_nil_stack_top.v = 0;\
state->fixed_width_nil_stack_top.v = 0;\
state->fixed_height_nil_stack_top.v = 0;\
state->pref_width_nil_stack_top.v = ui_px(250.f, 1.f);\
state->pref_height_nil_stack_top.v = ui_px(30.f, 1.f);\
state->flags_nil_stack_top.v = 0;\
state->focus_hot_nil_stack_top.v = UI_FocusKind_Null;\
state->focus_active_nil_stack_top.v = UI_FocusKind_Null;\
state->fastpath_codepoint_nil_stack_top.v = 0;\
state->background_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->text_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->border_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->overlay_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->text_select_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->text_cursor_color_nil_stack_top.v = v4f32(1, 0, 1, 1);\
state->hover_cursor_nil_stack_top.v = OS_Cursor_Pointer;\
state->font_nil_stack_top.v = f_tag_zero();\
state->font_size_nil_stack_top.v = 24.f;\
state->corner_radius_00_nil_stack_top.v = 0;\
state->corner_radius_01_nil_stack_top.v = 0;\
state->corner_radius_10_nil_stack_top.v = 0;\
state->corner_radius_11_nil_stack_top.v = 0;\
state->blur_size_nil_stack_top.v = 0;\
state->text_padding_nil_stack_top.v = 2;\
state->text_alignment_nil_stack_top.v = UI_TextAlign_Left;\
#define UI_DeclStacks \
struct\
{\
struct { UI_ParentNode *top; UI_Box * bottom_val; UI_ParentNode *free; B32 auto_pop; } parent_stack;\
struct { UI_ChildLayoutAxisNode *top; Axis2 bottom_val; UI_ChildLayoutAxisNode *free; B32 auto_pop; } child_layout_axis_stack;\
struct { UI_FixedXNode *top; F32 bottom_val; UI_FixedXNode *free; B32 auto_pop; } fixed_x_stack;\
struct { UI_FixedYNode *top; F32 bottom_val; UI_FixedYNode *free; B32 auto_pop; } fixed_y_stack;\
struct { UI_FixedWidthNode *top; F32 bottom_val; UI_FixedWidthNode *free; B32 auto_pop; } fixed_width_stack;\
struct { UI_FixedHeightNode *top; F32 bottom_val; UI_FixedHeightNode *free; B32 auto_pop; } fixed_height_stack;\
struct { UI_PrefWidthNode *top; UI_Size bottom_val; UI_PrefWidthNode *free; B32 auto_pop; } pref_width_stack;\
struct { UI_PrefHeightNode *top; UI_Size bottom_val; UI_PrefHeightNode *free; B32 auto_pop; } pref_height_stack;\
struct { UI_FlagsNode *top; UI_BoxFlags bottom_val; UI_FlagsNode *free; B32 auto_pop; } flags_stack;\
struct { UI_FocusHotNode *top; UI_FocusKind bottom_val; UI_FocusHotNode *free; B32 auto_pop; } focus_hot_stack;\
struct { UI_FocusActiveNode *top; UI_FocusKind bottom_val; UI_FocusActiveNode *free; B32 auto_pop; } focus_active_stack;\
struct { UI_FastpathCodepointNode *top; U32 bottom_val; UI_FastpathCodepointNode *free; B32 auto_pop; } fastpath_codepoint_stack;\
struct { UI_BackgroundColorNode *top; Vec4F32 bottom_val; UI_BackgroundColorNode *free; B32 auto_pop; } background_color_stack;\
struct { UI_TextColorNode *top; Vec4F32 bottom_val; UI_TextColorNode *free; B32 auto_pop; } text_color_stack;\
struct { UI_BorderColorNode *top; Vec4F32 bottom_val; UI_BorderColorNode *free; B32 auto_pop; } border_color_stack;\
struct { UI_OverlayColorNode *top; Vec4F32 bottom_val; UI_OverlayColorNode *free; B32 auto_pop; } overlay_color_stack;\
struct { UI_TextSelectColorNode *top; Vec4F32 bottom_val; UI_TextSelectColorNode *free; B32 auto_pop; } text_select_color_stack;\
struct { UI_TextCursorColorNode *top; Vec4F32 bottom_val; UI_TextCursorColorNode *free; B32 auto_pop; } text_cursor_color_stack;\
struct { UI_HoverCursorNode *top; OS_Cursor bottom_val; UI_HoverCursorNode *free; B32 auto_pop; } hover_cursor_stack;\
struct { UI_FontNode *top; F_Tag bottom_val; UI_FontNode *free; B32 auto_pop; } font_stack;\
struct { UI_FontSizeNode *top; F32 bottom_val; UI_FontSizeNode *free; B32 auto_pop; } font_size_stack;\
struct { UI_CornerRadius00Node *top; F32 bottom_val; UI_CornerRadius00Node *free; B32 auto_pop; } corner_radius_00_stack;\
struct { UI_CornerRadius01Node *top; F32 bottom_val; UI_CornerRadius01Node *free; B32 auto_pop; } corner_radius_01_stack;\
struct { UI_CornerRadius10Node *top; F32 bottom_val; UI_CornerRadius10Node *free; B32 auto_pop; } corner_radius_10_stack;\
struct { UI_CornerRadius11Node *top; F32 bottom_val; UI_CornerRadius11Node *free; B32 auto_pop; } corner_radius_11_stack;\
struct { UI_BlurSizeNode *top; F32 bottom_val; UI_BlurSizeNode *free; B32 auto_pop; } blur_size_stack;\
struct { UI_TextPaddingNode *top; F32 bottom_val; UI_TextPaddingNode *free; B32 auto_pop; } text_padding_stack;\
struct { UI_TextAlignmentNode *top; UI_TextAlign bottom_val; UI_TextAlignmentNode *free; B32 auto_pop; } text_alignment_stack;\
}
#define UI_InitStacks(state) \
state->parent_stack.top = &state->parent_nil_stack_top; state->parent_stack.bottom_val = &ui_g_nil_box; state->parent_stack.free = 0; state->parent_stack.auto_pop = 0;\
state->child_layout_axis_stack.top = &state->child_layout_axis_nil_stack_top; state->child_layout_axis_stack.bottom_val = Axis2_X; state->child_layout_axis_stack.free = 0; state->child_layout_axis_stack.auto_pop = 0;\
state->fixed_x_stack.top = &state->fixed_x_nil_stack_top; state->fixed_x_stack.bottom_val = 0; state->fixed_x_stack.free = 0; state->fixed_x_stack.auto_pop = 0;\
state->fixed_y_stack.top = &state->fixed_y_nil_stack_top; state->fixed_y_stack.bottom_val = 0; state->fixed_y_stack.free = 0; state->fixed_y_stack.auto_pop = 0;\
state->fixed_width_stack.top = &state->fixed_width_nil_stack_top; state->fixed_width_stack.bottom_val = 0; state->fixed_width_stack.free = 0; state->fixed_width_stack.auto_pop = 0;\
state->fixed_height_stack.top = &state->fixed_height_nil_stack_top; state->fixed_height_stack.bottom_val = 0; state->fixed_height_stack.free = 0; state->fixed_height_stack.auto_pop = 0;\
state->pref_width_stack.top = &state->pref_width_nil_stack_top; state->pref_width_stack.bottom_val = ui_px(250.f, 1.f); state->pref_width_stack.free = 0; state->pref_width_stack.auto_pop = 0;\
state->pref_height_stack.top = &state->pref_height_nil_stack_top; state->pref_height_stack.bottom_val = ui_px(30.f, 1.f); state->pref_height_stack.free = 0; state->pref_height_stack.auto_pop = 0;\
state->flags_stack.top = &state->flags_nil_stack_top; state->flags_stack.bottom_val = 0; state->flags_stack.free = 0; state->flags_stack.auto_pop = 0;\
state->focus_hot_stack.top = &state->focus_hot_nil_stack_top; state->focus_hot_stack.bottom_val = UI_FocusKind_Null; state->focus_hot_stack.free = 0; state->focus_hot_stack.auto_pop = 0;\
state->focus_active_stack.top = &state->focus_active_nil_stack_top; state->focus_active_stack.bottom_val = UI_FocusKind_Null; state->focus_active_stack.free = 0; state->focus_active_stack.auto_pop = 0;\
state->fastpath_codepoint_stack.top = &state->fastpath_codepoint_nil_stack_top; state->fastpath_codepoint_stack.bottom_val = 0; state->fastpath_codepoint_stack.free = 0; state->fastpath_codepoint_stack.auto_pop = 0;\
state->background_color_stack.top = &state->background_color_nil_stack_top; state->background_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->background_color_stack.free = 0; state->background_color_stack.auto_pop = 0;\
state->text_color_stack.top = &state->text_color_nil_stack_top; state->text_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->text_color_stack.free = 0; state->text_color_stack.auto_pop = 0;\
state->border_color_stack.top = &state->border_color_nil_stack_top; state->border_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->border_color_stack.free = 0; state->border_color_stack.auto_pop = 0;\
state->overlay_color_stack.top = &state->overlay_color_nil_stack_top; state->overlay_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->overlay_color_stack.free = 0; state->overlay_color_stack.auto_pop = 0;\
state->text_select_color_stack.top = &state->text_select_color_nil_stack_top; state->text_select_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->text_select_color_stack.free = 0; state->text_select_color_stack.auto_pop = 0;\
state->text_cursor_color_stack.top = &state->text_cursor_color_nil_stack_top; state->text_cursor_color_stack.bottom_val = v4f32(1, 0, 1, 1); state->text_cursor_color_stack.free = 0; state->text_cursor_color_stack.auto_pop = 0;\
state->hover_cursor_stack.top = &state->hover_cursor_nil_stack_top; state->hover_cursor_stack.bottom_val = OS_Cursor_Pointer; state->hover_cursor_stack.free = 0; state->hover_cursor_stack.auto_pop = 0;\
state->font_stack.top = &state->font_nil_stack_top; state->font_stack.bottom_val = f_tag_zero(); state->font_stack.free = 0; state->font_stack.auto_pop = 0;\
state->font_size_stack.top = &state->font_size_nil_stack_top; state->font_size_stack.bottom_val = 24.f; state->font_size_stack.free = 0; state->font_size_stack.auto_pop = 0;\
state->corner_radius_00_stack.top = &state->corner_radius_00_nil_stack_top; state->corner_radius_00_stack.bottom_val = 0; state->corner_radius_00_stack.free = 0; state->corner_radius_00_stack.auto_pop = 0;\
state->corner_radius_01_stack.top = &state->corner_radius_01_nil_stack_top; state->corner_radius_01_stack.bottom_val = 0; state->corner_radius_01_stack.free = 0; state->corner_radius_01_stack.auto_pop = 0;\
state->corner_radius_10_stack.top = &state->corner_radius_10_nil_stack_top; state->corner_radius_10_stack.bottom_val = 0; state->corner_radius_10_stack.free = 0; state->corner_radius_10_stack.auto_pop = 0;\
state->corner_radius_11_stack.top = &state->corner_radius_11_nil_stack_top; state->corner_radius_11_stack.bottom_val = 0; state->corner_radius_11_stack.free = 0; state->corner_radius_11_stack.auto_pop = 0;\
state->blur_size_stack.top = &state->blur_size_nil_stack_top; state->blur_size_stack.bottom_val = 0; state->blur_size_stack.free = 0; state->blur_size_stack.auto_pop = 0;\
state->text_padding_stack.top = &state->text_padding_nil_stack_top; state->text_padding_stack.bottom_val = 2; state->text_padding_stack.free = 0; state->text_padding_stack.auto_pop = 0;\
state->text_alignment_stack.top = &state->text_alignment_nil_stack_top; state->text_alignment_stack.bottom_val = UI_TextAlign_Left; state->text_alignment_stack.free = 0; state->text_alignment_stack.auto_pop = 0;\
#define UI_AutoPopStacks(state) \
if(state->parent_stack.auto_pop) { ui_pop_parent(); state->parent_stack.auto_pop = 0; }\
if(state->child_layout_axis_stack.auto_pop) { ui_pop_child_layout_axis(); state->child_layout_axis_stack.auto_pop = 0; }\
if(state->fixed_x_stack.auto_pop) { ui_pop_fixed_x(); state->fixed_x_stack.auto_pop = 0; }\
if(state->fixed_y_stack.auto_pop) { ui_pop_fixed_y(); state->fixed_y_stack.auto_pop = 0; }\
if(state->fixed_width_stack.auto_pop) { ui_pop_fixed_width(); state->fixed_width_stack.auto_pop = 0; }\
if(state->fixed_height_stack.auto_pop) { ui_pop_fixed_height(); state->fixed_height_stack.auto_pop = 0; }\
if(state->pref_width_stack.auto_pop) { ui_pop_pref_width(); state->pref_width_stack.auto_pop = 0; }\
if(state->pref_height_stack.auto_pop) { ui_pop_pref_height(); state->pref_height_stack.auto_pop = 0; }\
if(state->flags_stack.auto_pop) { ui_pop_flags(); state->flags_stack.auto_pop = 0; }\
if(state->focus_hot_stack.auto_pop) { ui_pop_focus_hot(); state->focus_hot_stack.auto_pop = 0; }\
if(state->focus_active_stack.auto_pop) { ui_pop_focus_active(); state->focus_active_stack.auto_pop = 0; }\
if(state->fastpath_codepoint_stack.auto_pop) { ui_pop_fastpath_codepoint(); state->fastpath_codepoint_stack.auto_pop = 0; }\
if(state->background_color_stack.auto_pop) { ui_pop_background_color(); state->background_color_stack.auto_pop = 0; }\
if(state->text_color_stack.auto_pop) { ui_pop_text_color(); state->text_color_stack.auto_pop = 0; }\
if(state->border_color_stack.auto_pop) { ui_pop_border_color(); state->border_color_stack.auto_pop = 0; }\
if(state->overlay_color_stack.auto_pop) { ui_pop_overlay_color(); state->overlay_color_stack.auto_pop = 0; }\
if(state->text_select_color_stack.auto_pop) { ui_pop_text_select_color(); state->text_select_color_stack.auto_pop = 0; }\
if(state->text_cursor_color_stack.auto_pop) { ui_pop_text_cursor_color(); state->text_cursor_color_stack.auto_pop = 0; }\
if(state->hover_cursor_stack.auto_pop) { ui_pop_hover_cursor(); state->hover_cursor_stack.auto_pop = 0; }\
if(state->font_stack.auto_pop) { ui_pop_font(); state->font_stack.auto_pop = 0; }\
if(state->font_size_stack.auto_pop) { ui_pop_font_size(); state->font_size_stack.auto_pop = 0; }\
if(state->corner_radius_00_stack.auto_pop) { ui_pop_corner_radius_00(); state->corner_radius_00_stack.auto_pop = 0; }\
if(state->corner_radius_01_stack.auto_pop) { ui_pop_corner_radius_01(); state->corner_radius_01_stack.auto_pop = 0; }\
if(state->corner_radius_10_stack.auto_pop) { ui_pop_corner_radius_10(); state->corner_radius_10_stack.auto_pop = 0; }\
if(state->corner_radius_11_stack.auto_pop) { ui_pop_corner_radius_11(); state->corner_radius_11_stack.auto_pop = 0; }\
if(state->blur_size_stack.auto_pop) { ui_pop_blur_size(); state->blur_size_stack.auto_pop = 0; }\
if(state->text_padding_stack.auto_pop) { ui_pop_text_padding(); state->text_padding_stack.auto_pop = 0; }\
if(state->text_alignment_stack.auto_pop) { ui_pop_text_alignment(); state->text_alignment_stack.auto_pop = 0; }\
internal UI_Box * ui_top_parent(void);
internal Axis2 ui_top_child_layout_axis(void);
internal F32 ui_top_fixed_x(void);
@@ -151,6 +197,8 @@ internal F32 ui_top_fixed_height(void);
internal UI_Size ui_top_pref_width(void);
internal UI_Size ui_top_pref_height(void);
internal UI_BoxFlags ui_top_flags(void);
internal UI_FocusKind ui_top_focus_hot(void);
internal UI_FocusKind ui_top_focus_active(void);
internal U32 ui_top_fastpath_codepoint(void);
internal Vec4F32 ui_top_background_color(void);
internal Vec4F32 ui_top_text_color(void);
@@ -177,6 +225,8 @@ internal F32 ui_bottom_fixed_height(void);
internal UI_Size ui_bottom_pref_width(void);
internal UI_Size ui_bottom_pref_height(void);
internal UI_BoxFlags ui_bottom_flags(void);
internal UI_FocusKind ui_bottom_focus_hot(void);
internal UI_FocusKind ui_bottom_focus_active(void);
internal U32 ui_bottom_fastpath_codepoint(void);
internal Vec4F32 ui_bottom_background_color(void);
internal Vec4F32 ui_bottom_text_color(void);
@@ -194,6 +244,62 @@ internal F32 ui_bottom_corner_radius_11(void);
internal F32 ui_bottom_blur_size(void);
internal F32 ui_bottom_text_padding(void);
internal UI_TextAlign ui_bottom_text_alignment(void);
internal UI_Box * ui_push_parent(UI_Box * v);
internal Axis2 ui_push_child_layout_axis(Axis2 v);
internal F32 ui_push_fixed_x(F32 v);
internal F32 ui_push_fixed_y(F32 v);
internal F32 ui_push_fixed_width(F32 v);
internal F32 ui_push_fixed_height(F32 v);
internal UI_Size ui_push_pref_width(UI_Size v);
internal UI_Size ui_push_pref_height(UI_Size v);
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v);
internal UI_FocusKind ui_push_focus_hot(UI_FocusKind v);
internal UI_FocusKind ui_push_focus_active(UI_FocusKind v);
internal U32 ui_push_fastpath_codepoint(U32 v);
internal Vec4F32 ui_push_background_color(Vec4F32 v);
internal Vec4F32 ui_push_text_color(Vec4F32 v);
internal Vec4F32 ui_push_border_color(Vec4F32 v);
internal Vec4F32 ui_push_overlay_color(Vec4F32 v);
internal Vec4F32 ui_push_text_select_color(Vec4F32 v);
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal F_Tag ui_push_font(F_Tag v);
internal F32 ui_push_font_size(F32 v);
internal F32 ui_push_corner_radius_00(F32 v);
internal F32 ui_push_corner_radius_01(F32 v);
internal F32 ui_push_corner_radius_10(F32 v);
internal F32 ui_push_corner_radius_11(F32 v);
internal F32 ui_push_blur_size(F32 v);
internal F32 ui_push_text_padding(F32 v);
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v);
internal UI_Box * ui_pop_parent(void);
internal Axis2 ui_pop_child_layout_axis(void);
internal F32 ui_pop_fixed_x(void);
internal F32 ui_pop_fixed_y(void);
internal F32 ui_pop_fixed_width(void);
internal F32 ui_pop_fixed_height(void);
internal UI_Size ui_pop_pref_width(void);
internal UI_Size ui_pop_pref_height(void);
internal UI_BoxFlags ui_pop_flags(void);
internal UI_FocusKind ui_pop_focus_hot(void);
internal UI_FocusKind ui_pop_focus_active(void);
internal U32 ui_pop_fastpath_codepoint(void);
internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal Vec4F32 ui_pop_overlay_color(void);
internal Vec4F32 ui_pop_text_select_color(void);
internal Vec4F32 ui_pop_text_cursor_color(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal F_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal F32 ui_pop_corner_radius_00(void);
internal F32 ui_pop_corner_radius_01(void);
internal F32 ui_pop_corner_radius_10(void);
internal F32 ui_pop_corner_radius_11(void);
internal F32 ui_pop_blur_size(void);
internal F32 ui_pop_text_padding(void);
internal UI_TextAlign ui_pop_text_alignment(void);
internal UI_Box * ui_set_next_parent(UI_Box * v);
internal Axis2 ui_set_next_child_layout_axis(Axis2 v);
internal F32 ui_set_next_fixed_x(F32 v);
@@ -203,6 +309,8 @@ internal F32 ui_set_next_fixed_height(F32 v);
internal UI_Size ui_set_next_pref_width(UI_Size v);
internal UI_Size ui_set_next_pref_height(UI_Size v);
internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v);
internal UI_FocusKind ui_set_next_focus_hot(UI_FocusKind v);
internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v);
internal U32 ui_set_next_fastpath_codepoint(U32 v);
internal Vec4F32 ui_set_next_background_color(Vec4F32 v);
internal Vec4F32 ui_set_next_text_color(Vec4F32 v);
@@ -220,33 +328,5 @@ internal F32 ui_set_next_corner_radius_11(F32 v);
internal F32 ui_set_next_blur_size(F32 v);
internal F32 ui_set_next_text_padding(F32 v);
internal UI_TextAlign ui_set_next_text_alignment(UI_TextAlign v);
#if 0
#define UI_Parent(v) DeferLoop(ui_push_parent(v), ui_pop_parent())
#define UI_ChildLayoutAxis(v) DeferLoop(ui_push_child_layout_axis(v), ui_pop_child_layout_axis())
#define UI_FixedX(v) DeferLoop(ui_push_fixed_x(v), ui_pop_fixed_x())
#define UI_FixedY(v) DeferLoop(ui_push_fixed_y(v), ui_pop_fixed_y())
#define UI_FixedWidth(v) DeferLoop(ui_push_fixed_width(v), ui_pop_fixed_width())
#define UI_FixedHeight(v) DeferLoop(ui_push_fixed_height(v), ui_pop_fixed_height())
#define UI_PrefWidth(v) DeferLoop(ui_push_pref_width(v), ui_pop_pref_width())
#define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height())
#define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags())
#define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint())
#define UI_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color())
#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color())
#define UI_BorderColor(v) DeferLoop(ui_push_border_color(v), ui_pop_border_color())
#define UI_OverlayColor(v) DeferLoop(ui_push_overlay_color(v), ui_pop_overlay_color())
#define UI_TextSelectColor(v) DeferLoop(ui_push_text_select_color(v), ui_pop_text_select_color())
#define UI_TextCursorColor(v) DeferLoop(ui_push_text_cursor_color(v), ui_pop_text_cursor_color())
#define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor())
#define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font())
#define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size())
#define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00())
#define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01())
#define UI_CornerRadius10(v) DeferLoop(ui_push_corner_radius_10(v), ui_pop_corner_radius_10())
#define UI_CornerRadius11(v) DeferLoop(ui_push_corner_radius_11(v), ui_pop_corner_radius_11())
#define UI_BlurSize(v) DeferLoop(ui_push_blur_size(v), ui_pop_blur_size())
#define UI_TextPadding(v) DeferLoop(ui_push_text_padding(v), ui_pop_text_padding())
#define UI_TextAlignment(v) DeferLoop(ui_push_text_alignment(v), ui_pop_text_alignment())
#endif
#endif // UI_META_H
+98 -55
View File
@@ -1,114 +1,157 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
@table(name, name_lower, type)
//- rjf: stack table
@table(name, name_lower, type, default)
UI_StackTable:
{
//- rjf: parents
{ Parent parent `UI_Box *` }
{ Parent parent `UI_Box *` `&ui_g_nil_box` }
//- rjf: layout params
{ ChildLayoutAxis child_layout_axis Axis2 }
{ ChildLayoutAxis child_layout_axis Axis2 `Axis2_X` }
//- rjf: size/position
{ FixedX fixed_x F32 }
{ FixedY fixed_y F32 }
{ FixedWidth fixed_width F32 }
{ FixedHeight fixed_height F32 }
{ PrefWidth pref_width UI_Size }
{ PrefHeight pref_height UI_Size }
{ FixedX fixed_x F32 0 }
{ FixedY fixed_y F32 0 }
{ FixedWidth fixed_width F32 0 }
{ FixedHeight fixed_height F32 0 }
{ PrefWidth pref_width UI_Size `ui_px(250.f, 1.f)`}
{ PrefHeight pref_height UI_Size `ui_px(30.f, 1.f)` }
//- rjf: flags
{ Flags flags UI_BoxFlags }
{ Flags flags UI_BoxFlags 0 }
//- rjf: interaction
{ FastpathCodepoint fastpath_codepoint U32 }
{ FocusHot focus_hot UI_FocusKind UI_FocusKind_Null }
{ FocusActive focus_active UI_FocusKind UI_FocusKind_Null }
{ FastpathCodepoint fastpath_codepoint U32 0 }
//- rjf: colors
{ BackgroundColor background_color Vec4F32 }
{ TextColor text_color Vec4F32 }
{ BorderColor border_color Vec4F32 }
{ OverlayColor overlay_color Vec4F32 }
{ TextSelectColor text_select_color Vec4F32 }
{ TextCursorColor text_cursor_color Vec4F32 }
{ BackgroundColor background_color Vec4F32 `v4f32(1, 0, 1, 1)`}
{ TextColor text_color Vec4F32 `v4f32(1, 0, 1, 1)`}
{ BorderColor border_color Vec4F32 `v4f32(1, 0, 1, 1)`}
{ OverlayColor overlay_color Vec4F32 `v4f32(1, 0, 1, 1)`}
{ TextSelectColor text_select_color Vec4F32 `v4f32(1, 0, 1, 1)`}
{ TextCursorColor text_cursor_color Vec4F32 `v4f32(1, 0, 1, 1)`}
//- rjf: hover cursor
{ HoverCursor hover_cursor OS_Cursor }
{ HoverCursor hover_cursor OS_Cursor OS_Cursor_Pointer }
//- rjf: font
{ Font font F_Tag }
{ FontSize font_size F32 }
{ Font font F_Tag `f_tag_zero()` }
{ FontSize font_size F32 24.f }
//- rjf: corner radii
{ CornerRadius00 corner_radius_00 F32 }
{ CornerRadius01 corner_radius_01 F32 }
{ CornerRadius10 corner_radius_10 F32 }
{ CornerRadius11 corner_radius_11 F32 }
{ CornerRadius00 corner_radius_00 F32 0 }
{ CornerRadius01 corner_radius_01 F32 0 }
{ CornerRadius10 corner_radius_10 F32 0 }
{ CornerRadius11 corner_radius_11 F32 0 }
//- rjf: blur size
{ BlurSize blur_size F32 }
{ BlurSize blur_size F32 0 }
//- rjf: text parameters
{ TextPadding text_padding F32 }
{ TextAlignment text_alignment UI_TextAlign }
{ TextPadding text_padding F32 2 }
{ TextAlignment text_alignment UI_TextAlign UI_TextAlign_Left }
}
//- rjf: declaring stack node types
@table_gen
{
`#define UI_StackDecls struct{\\`;
@expand(UI_StackTable a)
`struct { $(a.type) active; $(a.type) v[64]; U64 count; B32 auto_pop; } $(a.name_lower);\\`;
`}`;
@expand(UI_StackTable a) `typedef struct UI_$(a.name)Node UI_$(a.name)Node; struct UI_$(a.name)Node{UI_$(a.name)Node *next; $(a.type) v;};`
}
//- rjf: declaring all default stack tops
@table_gen
{
`#define UI_ZeroAllStacks(ui_state) do{\\`;
@expand(UI_StackTable a)
`MemoryZeroStruct(&ui_state->$(a.name_lower));\\`;
`} while(0)`;
`#define UI_DeclStackNils \\`;
`struct\\`;
`{\\`;
@expand(UI_StackTable a) `UI_$(a.name)Node $(a.name_lower)_nil_stack_top;\\`;
`}`;
}
//- rjf: initializing all default stack tops
@table_gen
{
`#define UI_AutoPopAllStacks(ui_state) do{\\`;
@expand(UI_StackTable a)
`if(ui_state->$(a.name_lower).auto_pop) {ui_state->$(a.name_lower).auto_pop = 0; ui_pop_$(a.name_lower)();}\\`;
`} while(0)`;
`#define UI_InitStackNils(state) \\`;
@expand(UI_StackTable a) `state->$(a.name_lower)_nil_stack_top.v = $(a.default);\\`;
``;
}
//- rjf: declaring all stack nodes & free lists
@table_gen
{
`#define UI_DeclStacks \\`;
`struct\\`;
`{\\`;
@expand(UI_StackTable a) `struct { UI_$(a.name)Node *top; $(a.type) bottom_val; UI_$(a.name)Node *free; B32 auto_pop; } $(a.name_lower)_stack;\\`;
`}`;
}
//- rjf: initing all stack nodes
@table_gen
{
`#define UI_InitStacks(state) \\`;
@expand(UI_StackTable a) `state->$(a.name_lower)_stack.top = &state->$(a.name_lower)_nil_stack_top; state->$(a.name_lower)_stack.bottom_val = $(a.default); state->$(a.name_lower)_stack.free = 0; state->$(a.name_lower)_stack.auto_pop = 0;\\`;
``;
}
//- rjf: auto-popping all stacks
@table_gen
{
`#define UI_AutoPopStacks(state) \\`
@expand(UI_StackTable a)
`if(state->$(a.name_lower)_stack.auto_pop) { ui_pop_$(a.name_lower)(); state->$(a.name_lower)_stack.auto_pop = 0; }\\`;
``;
}
//- rjf: decls for the stack function operation headers
@table_gen
{
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_push_$(a.name_lower)($(a.type) v);`;
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_pop_$(a.name_lower)(void);`;
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_top_$(a.name_lower)(void);`;
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_bottom_$(a.name_lower)(void);`;
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_set_next_$(a.name_lower)($(a.type) v);`;
`internal $(a.type) $(=>35) ui_top_$(a.name_lower)(void);`
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_bottom_$(a.name_lower)(void);`
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_push_$(a.name_lower)($(a.type) v);`
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_pop_$(a.name_lower)(void);`
@expand(UI_StackTable a)
`internal $(a.type) $(=>35) ui_set_next_$(a.name_lower)($(a.type) v);`
}
@table_gen
//- rjf: defer-loop helpers
@table_gen @c_file
{
`#if 0`;
@expand(UI_StackTable a)
`#define UI_$(a.name)(v) $(=>35) DeferLoop(ui_push_$(a.name_lower)(v), ui_pop_$(a.name_lower)())`;
`#define UI_$(a.name)(v) DeferLoop(ui_push_$(a.name_lower)(v), ui_pop_$(a.name_lower)())`
`#endif`;
}
//- rjf: decls for the stack operation implementations
@table_gen @c_file
{
@expand(UI_StackTable a)
`internal $(a.type) ui_push_$(a.name_lower)($(a.type) v) {return UI_StackPush($(a.name_lower), v);}`;
`internal $(a.type) ui_top_$(a.name_lower)(void) { UI_StackTopImpl(ui_state, $(a.name), $(a.name_lower)) }`;
@expand(UI_StackTable a)
`internal $(a.type) ui_pop_$(a.name_lower)(void) {$(a.type) popped; return UI_StackPop($(a.name_lower), popped);}`;
`internal $(a.type) ui_bottom_$(a.name_lower)(void) { UI_StackBottomImpl(ui_state, $(a.name), $(a.name_lower)) }`;
@expand(UI_StackTable a)
`internal $(a.type) ui_top_$(a.name_lower)(void) {return UI_StackTop($(a.name_lower));}`;
`internal $(a.type) ui_push_$(a.name_lower)($(a.type) v) { UI_StackPushImpl(ui_state, $(a.name), $(a.name_lower), $(a.type), v) }`;
@expand(UI_StackTable a)
`internal $(a.type) ui_bottom_$(a.name_lower)(void) {return UI_StackBottom($(a.name_lower));}`;
`internal $(a.type) ui_pop_$(a.name_lower)(void) { UI_StackPopImpl(ui_state, $(a.name), $(a.name_lower)) }`;
@expand(UI_StackTable a)
`internal $(a.type) ui_set_next_$(a.name_lower)($(a.type) v) {return UI_StackSetNext($(a.name_lower), v);}`;
`internal $(a.type) ui_set_next_$(a.name_lower)($(a.type) v) { UI_StackSetNextImpl(ui_state, $(a.name), $(a.name_lower), $(a.type), v) }`;
}
+12 -4
View File
@@ -163,14 +163,18 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
internal UI_Signal
ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size, U64 *edit_string_size_out, String8 pre_edit_value, String8 string)
{
//- rjf: build top-level box
//- rjf: make key
UI_Key key = ui_key_from_string(ui_active_seed_key(), string);
//- rjf: calculate focus
B32 is_auto_focus_hot = ui_is_key_auto_focus_hot(key);
B32 is_auto_focus_active = ui_is_key_auto_focus_active(key);
if(is_auto_focus_hot) { ui_set_focus_hot(1); }
if(is_auto_focus_active) { ui_set_focus_active(1); }
ui_push_focus_hot(is_auto_focus_hot ? UI_FocusKind_On : UI_FocusKind_Null);
ui_push_focus_active(is_auto_focus_active ? UI_FocusKind_On : UI_FocusKind_Null);
B32 is_focus_hot = ui_is_focus_hot();
B32 is_focus_active = ui_is_focus_active();
//- rjf: build top-level box
ui_set_next_hover_cursor(is_focus_active ? OS_Cursor_IBar : OS_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawBorder|
@@ -303,6 +307,10 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
box->view_off_target.x += max_delta;
}
//- rjf: pop focus
ui_pop_focus_hot();
ui_pop_focus_active();
return sig;
}
@@ -1380,7 +1388,7 @@ ui_scroll_list_begin(UI_ScrollListParams *params, UI_ScrollPt *scroll_pt, Vec2S6
}
//- rjf: build vertical scroll bar
UI_Parent(container_box)
UI_Parent(container_box) UI_Focus(UI_FocusKind_Null)
{
ui_set_next_fixed_width(ui_scroll_list_scroll_bar_dim_px);
ui_set_next_fixed_height(ui_scroll_list_dim_px.y);
+94 -125
View File
@@ -430,6 +430,7 @@ ui_state_alloc(void)
ui->drag_state_arena = arena_alloc();
ui->box_table_size = 4096;
ui->box_table = push_array(arena, UI_BoxHashSlot, ui->box_table_size);
UI_InitStackNils(ui);
return ui;
}
@@ -603,7 +604,7 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
{
//- rjf: reset per-build ui state
{
UI_ZeroAllStacks(ui_state);
UI_InitStacks(ui_state);
ui_state->root = &ui_g_nil_box;
ui_state->ctx_menu_touched_this_frame = 0;
ui_state->is_animating = 0;
@@ -905,7 +906,8 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
ui_state->ctx_menu_anchor_box_last_pos = anchor_box->rect.p0;
}
Vec2F32 anchor = add_2f32(ui_state->ctx_menu_anchor_box_last_pos, ui_state->ctx_menu_anchor_off);
UI_FixedX(anchor.x) UI_FixedY(anchor.y) UI_PrefWidth(ui_children_sum(1.f)) UI_PrefHeight(ui_children_sum(1.f)) UI_Focus(ui_state->ctx_menu_open)
UI_FixedX(anchor.x) UI_FixedY(anchor.y) UI_PrefWidth(ui_children_sum(1.f)) UI_PrefHeight(ui_children_sum(1.f))
UI_Focus(UI_FocusKind_On)
{
ui_set_next_child_layout_axis(Axis2_Y);
ui_state->ctx_menu_root = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawDropShadow|(ui_state->ctx_menu_open*UI_BoxFlag_DefaultFocusNavY), "###ctx_menu_%I64x", window.u64[0]);
@@ -1692,49 +1694,18 @@ ui_any_ctx_menu_is_open(void)
//- rjf: focus tree coloring
internal void
ui_set_focus_active(B32 check)
{
ui_state->focus_active_is_set = check;
ui_state->focus_active_is_possible = 1;
}
internal void
ui_unset_focus_active(void)
{
ui_state->focus_active_is_set = 0;
ui_state->focus_active_is_possible = 0;
}
internal void
ui_set_focus_hot(B32 check)
{
ui_state->focus_hot_is_set = check;
ui_state->focus_hot_is_possible = 1;
}
internal void
ui_unset_focus_hot(void)
{
ui_state->focus_hot_is_set = 0;
ui_state->focus_hot_is_possible = 0;
}
internal B32
ui_is_focus_active(void)
ui_is_focus_hot(void)
{
B32 result = ui_state->focus_active_is_set;
B32 result = (ui_state->focus_hot_stack.top->v == UI_FocusKind_On);
if(result)
{
for(UI_Box *box = ui_top_parent(); !ui_box_is_nil(box); box = box->parent)
for(UI_FocusHotNode *n = ui_state->focus_hot_stack.top; n != 0; n = n->next)
{
if(box->flags & UI_BoxFlag_FocusActive)
if(n->v == UI_FocusKind_Off)
{
result = !(box->flags & UI_BoxFlag_FocusActiveDisabled);
if(result == 0)
{
break;
}
result = 0;
break;
}
}
}
@@ -1742,20 +1713,17 @@ ui_is_focus_active(void)
}
internal B32
ui_is_focus_hot(void)
ui_is_focus_active(void)
{
B32 result = ui_state->focus_hot_is_set;
B32 result = (ui_state->focus_active_stack.top->v == UI_FocusKind_On);
if(result)
{
for(UI_Box *box = ui_top_parent(); !ui_box_is_nil(box); box = box->parent)
for(UI_FocusActiveNode *n = ui_state->focus_active_stack.top; n != 0; n = n->next)
{
if(box->flags & UI_BoxFlag_FocusHot)
if(n->v == UI_FocusKind_Off)
{
result = !(box->flags & UI_BoxFlag_FocusHotDisabled);
if(result == 0)
{
break;
}
result = 0;
break;
}
}
}
@@ -1901,8 +1869,8 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key)
//- rjf: fill box
{
box->key = key;
box->flags = flags|ui_state->flags.active;
box->fastpath_codepoint = ui_state->fastpath_codepoint.active;
box->flags = flags|ui_state->flags_stack.top->v;
box->fastpath_codepoint = ui_state->fastpath_codepoint_stack.top->v;
if(ui_is_focus_active() && (box->flags & UI_BoxFlag_DefaultFocusNav) && ui_key_match(ui_state->default_nav_root_key, ui_key_zero()))
{
@@ -1921,87 +1889,77 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key)
box->first_disabled_build_index = ui_state->build_index;
}
if(ui_state->fixed_x.count != 0)
if(ui_state->fixed_x_stack.top != &ui_state->fixed_x_nil_stack_top)
{
box->flags |= UI_BoxFlag_FloatingX;
box->fixed_position.x = ui_state->fixed_x.active;
box->fixed_position.x = ui_state->fixed_x_stack.top->v;
}
if(ui_state->fixed_y.count != 0)
if(ui_state->fixed_y_stack.top != &ui_state->fixed_y_nil_stack_top)
{
box->flags |= UI_BoxFlag_FloatingY;
box->fixed_position.y = ui_state->fixed_y.active;
box->fixed_position.y = ui_state->fixed_y_stack.top->v;
}
if(ui_state->fixed_width.count != 0)
if(ui_state->fixed_width_stack.top != &ui_state->fixed_width_nil_stack_top)
{
box->flags |= UI_BoxFlag_FixedWidth;
box->fixed_size.x = ui_state->fixed_width.active;
box->fixed_size.x = ui_state->fixed_width_stack.top->v;
}
else
{
box->pref_size[Axis2_X] = ui_state->pref_width.active;
box->pref_size[Axis2_X] = ui_state->pref_width_stack.top->v;
}
if(ui_state->fixed_height.count != 0)
if(ui_state->fixed_height_stack.top != &ui_state->fixed_height_nil_stack_top)
{
box->flags |= UI_BoxFlag_FixedHeight;
box->fixed_size.y = ui_state->fixed_height.active;
box->fixed_size.y = ui_state->fixed_height_stack.top->v;
}
else
{
box->pref_size[Axis2_Y] = ui_state->pref_height.active;
box->pref_size[Axis2_Y] = ui_state->pref_height_stack.top->v;
}
B32 is_auto_focus_active = ui_is_key_auto_focus_active(key);
B32 is_auto_focus_hot = ui_is_key_auto_focus_hot(key);
if(is_auto_focus_active)
{
ui_state->focus_active_is_possible = ui_state->focus_active_is_set = 1;
ui_set_next_focus_active(UI_FocusKind_On);
}
if(is_auto_focus_hot)
{
ui_state->focus_hot_is_possible = ui_state->focus_hot_is_set = 1;
ui_set_next_focus_hot(UI_FocusKind_On);
}
box->flags |= UI_BoxFlag_FocusHot*!!(ui_state->focus_hot_is_possible);
box->flags |= UI_BoxFlag_FocusActive*!!(ui_state->focus_active_is_possible);
box->flags |= UI_BoxFlag_FocusHotDisabled*(!(ui_state->focus_hot_is_set) && ui_state->focus_hot_is_possible);
box->flags |= UI_BoxFlag_FocusActiveDisabled*(!(ui_state->focus_active_is_set) && ui_state->focus_active_is_possible);
if((box->flags & UI_BoxFlag_FocusHot && ~box->flags & UI_BoxFlag_FocusHotDisabled) ||
(box->flags & UI_BoxFlag_FocusActive && ~box->flags & UI_BoxFlag_FocusActiveDisabled))
box->flags |= UI_BoxFlag_FocusHot * (ui_state->focus_hot_stack.top->v == UI_FocusKind_On);
box->flags |= UI_BoxFlag_FocusActive * (ui_state->focus_active_stack.top->v == UI_FocusKind_On);
if(box->flags & UI_BoxFlag_FocusHot && !ui_is_focus_hot())
{
for(UI_Box *p = box->parent; !ui_box_is_nil(p); p = p->parent)
{
if(p->flags & (UI_BoxFlag_FocusHotDisabled|UI_BoxFlag_FocusActiveDisabled))
{
box->flags |= (UI_BoxFlag_FocusHotDisabled|UI_BoxFlag_FocusActiveDisabled);
break;
}
}
box->flags |= UI_BoxFlag_FocusHotDisabled;
}
if(box->flags & UI_BoxFlag_FocusActive && !ui_is_focus_active())
{
box->flags |= UI_BoxFlag_FocusActiveDisabled;
}
ui_state->focus_hot_is_set = 0;
ui_state->focus_hot_is_possible = 0;
ui_state->focus_active_is_set = 0;
ui_state->focus_active_is_possible = 0;
box->text_align = ui_state->text_alignment.active;
box->child_layout_axis = ui_state->child_layout_axis.active;
box->background_color = ui_state->background_color.active;
box->text_color = ui_state->text_color.active;
box->border_color = ui_state->border_color.active;
box->overlay_color = ui_state->overlay_color.active;
box->font = ui_state->font.active;
box->font_size = ui_state->font_size.active;
box->corner_radii[Corner_00] = ui_state->corner_radius_00.active;
box->corner_radii[Corner_01] = ui_state->corner_radius_01.active;
box->corner_radii[Corner_10] = ui_state->corner_radius_10.active;
box->corner_radii[Corner_11] = ui_state->corner_radius_11.active;
box->blur_size = ui_state->blur_size.active;
box->text_padding = ui_state->text_padding.active;
box->hover_cursor = ui_state->hover_cursor.active;
box->text_align = ui_state->text_alignment_stack.top->v;
box->child_layout_axis = ui_state->child_layout_axis_stack.top->v;
box->background_color = ui_state->background_color_stack.top->v;
box->text_color = ui_state->text_color_stack.top->v;
box->border_color = ui_state->border_color_stack.top->v;
box->overlay_color = ui_state->overlay_color_stack.top->v;
box->font = ui_state->font_stack.top->v;
box->font_size = ui_state->font_size_stack.top->v;
box->corner_radii[Corner_00] = ui_state->corner_radius_00_stack.top->v;
box->corner_radii[Corner_01] = ui_state->corner_radius_01_stack.top->v;
box->corner_radii[Corner_10] = ui_state->corner_radius_10_stack.top->v;
box->corner_radii[Corner_11] = ui_state->corner_radius_11_stack.top->v;
box->blur_size = ui_state->blur_size_stack.top->v;
box->text_padding = ui_state->text_padding_stack.top->v;
box->hover_cursor = ui_state->hover_cursor_stack.top->v;
box->custom_draw = 0;
}
//- rjf: auto-pop all stacks
{
UI_AutoPopAllStacks(ui_state);
UI_AutoPopStacks(ui_state);
}
//- rjf: return
@@ -2603,35 +2561,6 @@ ui_signal_from_box(UI_Box *box)
////////////////////////////////
//~ rjf: Stacks
#define UI_StackPush(name, new_top)\
(\
(ui_state->name.v[ui_state->name.count] = ui_state->name.active),\
(ui_state->name.active = new_top),\
(ui_state->name.count += 1),\
(ui_state->name.v[ui_state->name.count-1])\
)
#define UI_StackPop(name, popped)\
(\
(ui_state->name.count -= 1),\
(popped = ui_state->name.active),\
(ui_state->name.active = ui_state->name.v[ui_state->name.count]),\
(popped)\
)
#define UI_StackSetNext(name, new_top)\
(\
(ui_state->name.auto_pop) ?\
(ui_state->name.active = new_top) :\
(\
(ui_state->name.v[ui_state->name.count] = ui_state->name.active),\
(ui_state->name.active = new_top),\
(ui_state->name.count += 1),\
(ui_state->name.auto_pop = 1),\
(ui_state->name.v[ui_state->name.count-1])\
)\
)
#define UI_StackTop(name) (ui_state->name.active)
#define UI_StackBottom(name) (ui_state->name.count > 1 ? ui_state->name.v[1] : ui_state->name.active)
//- rjf: helpers
internal Rng2F32
@@ -2710,4 +2639,44 @@ ui_pop_corner_radius(void)
////////////////////////////////
//~ rjf: Generated Code
#define UI_StackTopImpl(state, name_upper, name_lower) \
return state->name_lower##_stack.top->v;
#define UI_StackBottomImpl(state, name_upper, name_lower) \
return state->name_lower##_stack.bottom_val;
#define UI_StackPushImpl(state, name_upper, name_lower, type, new_value) \
UI_##name_upper##Node *node = state->name_lower##_stack.free;\
if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\
else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\
type old_value = state->name_lower##_stack.top->v;\
node->v = new_value;\
SLLStackPush(state->name_lower##_stack.top, node);\
if(node->next == &state->name_lower##_nil_stack_top)\
{\
state->name_lower##_stack.bottom_val = (new_value);\
}\
state->name_lower##_stack.auto_pop = 0;\
return old_value;
#define UI_StackPopImpl(state, name_upper, name_lower) \
UI_##name_upper##Node *popped = state->name_lower##_stack.top;\
if(popped != &state->name_lower##_nil_stack_top)\
{\
SLLStackPop(state->name_lower##_stack.top);\
SLLStackPush(state->name_lower##_stack.free, popped);\
state->name_lower##_stack.auto_pop = 0;\
}\
return popped->v;\
#define UI_StackSetNextImpl(state, name_upper, name_lower, type, new_value) \
UI_##name_upper##Node *node = state->name_lower##_stack.free;\
if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\
else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\
type old_value = state->name_lower##_stack.top->v;\
node->v = new_value;\
SLLStackPush(state->name_lower##_stack.top, node);\
state->name_lower##_stack.auto_pop = 1;\
return old_value;
#include "generated/ui.meta.c"
+106 -95
View File
@@ -31,6 +31,18 @@ struct UI_IconInfo
String8 icon_kind_text_map[UI_IconKind_COUNT];
};
////////////////////////////////
//~ rjf: Focus Types
typedef enum UI_FocusKind
{
UI_FocusKind_Null,
UI_FocusKind_Off,
UI_FocusKind_On,
UI_FocusKind_COUNT
}
UI_FocusKind;
////////////////////////////////
//~ rjf: Navigation Types
@@ -412,14 +424,9 @@ struct UI_State
F32 ctx_menu_open_t;
UI_Key ctx_menu_key;
//- rjf: build phase focus masks
B32 focus_hot_is_set;
B32 focus_hot_is_possible;
B32 focus_active_is_set;
B32 focus_active_is_possible;
//- rjf: build phase stacks
UI_StackDecls;
UI_DeclStackNils;
UI_DeclStacks;
};
////////////////////////////////
@@ -558,12 +565,8 @@ internal B32 ui_ctx_menu_is_open(UI_Key key);
internal B32 ui_any_ctx_menu_is_open(void);
//- rjf: focus tree coloring
internal void ui_set_focus_active(B32 check);
internal void ui_unset_focus_active(void);
internal void ui_set_focus_hot(B32 check);
internal void ui_unset_focus_hot(void);
internal B32 ui_is_focus_active(void);
internal B32 ui_is_focus_hot(void);
internal B32 ui_is_focus_active(void);
//- rjf: implicit auto-managed tree-based focus state
internal B32 ui_is_key_auto_focus_active(UI_Key key);
@@ -601,58 +604,6 @@ internal UI_Signal ui_signal_from_box(UI_Box *box);
//~ rjf: Stacks
//- rjf: base
internal UI_Box * ui_push_parent(UI_Box * v);
internal Axis2 ui_push_child_layout_axis(Axis2 v);
internal F32 ui_push_fixed_x(F32 v);
internal F32 ui_push_fixed_y(F32 v);
internal F32 ui_push_fixed_width(F32 v);
internal F32 ui_push_fixed_height(F32 v);
internal UI_Size ui_push_pref_width(UI_Size v);
internal UI_Size ui_push_pref_height(UI_Size v);
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v);
internal U32 ui_push_fastpath_codepoint(U32 v);
internal Vec4F32 ui_push_background_color(Vec4F32 v);
internal Vec4F32 ui_push_text_color(Vec4F32 v);
internal Vec4F32 ui_push_border_color(Vec4F32 v);
internal Vec4F32 ui_push_overlay_color(Vec4F32 v);
internal Vec4F32 ui_push_text_select_color(Vec4F32 v);
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal F_Tag ui_push_font(F_Tag v);
internal F32 ui_push_font_size(F32 v);
internal F32 ui_push_corner_radius_00(F32 v);
internal F32 ui_push_corner_radius_01(F32 v);
internal F32 ui_push_corner_radius_10(F32 v);
internal F32 ui_push_corner_radius_11(F32 v);
internal F32 ui_push_blur_size(F32 v);
internal F32 ui_push_text_padding(F32 v);
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v);
internal UI_Box * ui_pop_parent(void);
internal Axis2 ui_pop_child_layout_axis(void);
internal F32 ui_pop_fixed_x(void);
internal F32 ui_pop_fixed_y(void);
internal F32 ui_pop_fixed_width(void);
internal F32 ui_pop_fixed_height(void);
internal UI_Size ui_pop_pref_width(void);
internal UI_Size ui_pop_pref_height(void);
internal UI_BoxFlags ui_pop_flags(void);
internal U32 ui_pop_fastpath_codepoint(void);
internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal Vec4F32 ui_pop_overlay_color(void);
internal Vec4F32 ui_pop_text_select_color(void);
internal Vec4F32 ui_pop_text_cursor_color(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal F_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal F32 ui_pop_corner_radius_00(void);
internal F32 ui_pop_corner_radius_01(void);
internal F32 ui_pop_corner_radius_10(void);
internal F32 ui_pop_corner_radius_11(void);
internal F32 ui_pop_blur_size(void);
internal F32 ui_pop_text_padding(void);
internal UI_TextAlign ui_pop_text_alignment(void);
internal UI_Box * ui_top_parent(void);
internal Axis2 ui_top_child_layout_axis(void);
internal F32 ui_top_fixed_x(void);
@@ -662,6 +613,8 @@ internal F32 ui_top_fixed_height(void);
internal UI_Size ui_top_pref_width(void);
internal UI_Size ui_top_pref_height(void);
internal UI_BoxFlags ui_top_flags(void);
internal UI_FocusKind ui_top_focus_hot(void);
internal UI_FocusKind ui_top_focus_active(void);
internal U32 ui_top_fastpath_codepoint(void);
internal Vec4F32 ui_top_background_color(void);
internal Vec4F32 ui_top_text_color(void);
@@ -688,6 +641,8 @@ internal F32 ui_bottom_fixed_height(void);
internal UI_Size ui_bottom_pref_width(void);
internal UI_Size ui_bottom_pref_height(void);
internal UI_BoxFlags ui_bottom_flags(void);
internal UI_FocusKind ui_bottom_focus_hot(void);
internal UI_FocusKind ui_bottom_focus_active(void);
internal U32 ui_bottom_fastpath_codepoint(void);
internal Vec4F32 ui_bottom_background_color(void);
internal Vec4F32 ui_bottom_text_color(void);
@@ -705,6 +660,62 @@ internal F32 ui_bottom_corner_radius_11(void);
internal F32 ui_bottom_blur_size(void);
internal F32 ui_bottom_text_padding(void);
internal UI_TextAlign ui_bottom_text_alignment(void);
internal UI_Box * ui_push_parent(UI_Box * v);
internal Axis2 ui_push_child_layout_axis(Axis2 v);
internal F32 ui_push_fixed_x(F32 v);
internal F32 ui_push_fixed_y(F32 v);
internal F32 ui_push_fixed_width(F32 v);
internal F32 ui_push_fixed_height(F32 v);
internal UI_Size ui_push_pref_width(UI_Size v);
internal UI_Size ui_push_pref_height(UI_Size v);
internal UI_BoxFlags ui_push_flags(UI_BoxFlags v);
internal UI_FocusKind ui_push_focus_hot(UI_FocusKind v);
internal UI_FocusKind ui_push_focus_active(UI_FocusKind v);
internal U32 ui_push_fastpath_codepoint(U32 v);
internal Vec4F32 ui_push_background_color(Vec4F32 v);
internal Vec4F32 ui_push_text_color(Vec4F32 v);
internal Vec4F32 ui_push_border_color(Vec4F32 v);
internal Vec4F32 ui_push_overlay_color(Vec4F32 v);
internal Vec4F32 ui_push_text_select_color(Vec4F32 v);
internal Vec4F32 ui_push_text_cursor_color(Vec4F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal F_Tag ui_push_font(F_Tag v);
internal F32 ui_push_font_size(F32 v);
internal F32 ui_push_corner_radius_00(F32 v);
internal F32 ui_push_corner_radius_01(F32 v);
internal F32 ui_push_corner_radius_10(F32 v);
internal F32 ui_push_corner_radius_11(F32 v);
internal F32 ui_push_blur_size(F32 v);
internal F32 ui_push_text_padding(F32 v);
internal UI_TextAlign ui_push_text_alignment(UI_TextAlign v);
internal UI_Box * ui_pop_parent(void);
internal Axis2 ui_pop_child_layout_axis(void);
internal F32 ui_pop_fixed_x(void);
internal F32 ui_pop_fixed_y(void);
internal F32 ui_pop_fixed_width(void);
internal F32 ui_pop_fixed_height(void);
internal UI_Size ui_pop_pref_width(void);
internal UI_Size ui_pop_pref_height(void);
internal UI_BoxFlags ui_pop_flags(void);
internal UI_FocusKind ui_pop_focus_hot(void);
internal UI_FocusKind ui_pop_focus_active(void);
internal U32 ui_pop_fastpath_codepoint(void);
internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal Vec4F32 ui_pop_overlay_color(void);
internal Vec4F32 ui_pop_text_select_color(void);
internal Vec4F32 ui_pop_text_cursor_color(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal F_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal F32 ui_pop_corner_radius_00(void);
internal F32 ui_pop_corner_radius_01(void);
internal F32 ui_pop_corner_radius_10(void);
internal F32 ui_pop_corner_radius_11(void);
internal F32 ui_pop_blur_size(void);
internal F32 ui_pop_text_padding(void);
internal UI_TextAlign ui_pop_text_alignment(void);
internal UI_Box * ui_set_next_parent(UI_Box * v);
internal Axis2 ui_set_next_child_layout_axis(Axis2 v);
internal F32 ui_set_next_fixed_x(F32 v);
@@ -714,6 +725,8 @@ internal F32 ui_set_next_fixed_height(F32 v);
internal UI_Size ui_set_next_pref_width(UI_Size v);
internal UI_Size ui_set_next_pref_height(UI_Size v);
internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v);
internal UI_FocusKind ui_set_next_focus_hot(UI_FocusKind v);
internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v);
internal U32 ui_set_next_fastpath_codepoint(U32 v);
internal Vec4F32 ui_set_next_background_color(Vec4F32 v);
internal Vec4F32 ui_set_next_text_color(Vec4F32 v);
@@ -745,32 +758,34 @@ internal void ui_pop_corner_radius(void);
//~ rjf: Macro Loop Wrappers
//- rjf: stacks (base)
#define UI_Parent(v) DeferLoop(ui_push_parent(v), ui_pop_parent())
#define UI_ChildLayoutAxis(v) DeferLoop(ui_push_child_layout_axis(v), ui_pop_child_layout_axis())
#define UI_FixedX(v) DeferLoop(ui_push_fixed_x(v), ui_pop_fixed_x())
#define UI_FixedY(v) DeferLoop(ui_push_fixed_y(v), ui_pop_fixed_y())
#define UI_FixedWidth(v) DeferLoop(ui_push_fixed_width(v), ui_pop_fixed_width())
#define UI_FixedHeight(v) DeferLoop(ui_push_fixed_height(v), ui_pop_fixed_height())
#define UI_PrefWidth(v) DeferLoop(ui_push_pref_width(v), ui_pop_pref_width())
#define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height())
#define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags())
#define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint())
#define UI_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color())
#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color())
#define UI_BorderColor(v) DeferLoop(ui_push_border_color(v), ui_pop_border_color())
#define UI_OverlayColor(v) DeferLoop(ui_push_overlay_color(v), ui_pop_overlay_color())
#define UI_TextSelectColor(v) DeferLoop(ui_push_text_select_color(v), ui_pop_text_select_color())
#define UI_TextCursorColor(v) DeferLoop(ui_push_text_cursor_color(v), ui_pop_text_cursor_color())
#define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor())
#define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font())
#define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size())
#define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00())
#define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01())
#define UI_CornerRadius10(v) DeferLoop(ui_push_corner_radius_10(v), ui_pop_corner_radius_10())
#define UI_CornerRadius11(v) DeferLoop(ui_push_corner_radius_11(v), ui_pop_corner_radius_11())
#define UI_BlurSize(v) DeferLoop(ui_push_blur_size(v), ui_pop_blur_size())
#define UI_TextPadding(v) DeferLoop(ui_push_text_padding(v), ui_pop_text_padding())
#define UI_TextAlignment(v) DeferLoop(ui_push_text_alignment(v), ui_pop_text_alignment())
#define UI_Parent(v) DeferLoop(ui_push_parent(v), ui_pop_parent())
#define UI_ChildLayoutAxis(v) DeferLoop(ui_push_child_layout_axis(v), ui_pop_child_layout_axis())
#define UI_FixedX(v) DeferLoop(ui_push_fixed_x(v), ui_pop_fixed_x())
#define UI_FixedY(v) DeferLoop(ui_push_fixed_y(v), ui_pop_fixed_y())
#define UI_FixedWidth(v) DeferLoop(ui_push_fixed_width(v), ui_pop_fixed_width())
#define UI_FixedHeight(v) DeferLoop(ui_push_fixed_height(v), ui_pop_fixed_height())
#define UI_PrefWidth(v) DeferLoop(ui_push_pref_width(v), ui_pop_pref_width())
#define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height())
#define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags())
#define UI_FocusHot(v) DeferLoop(ui_push_focus_hot(v), ui_pop_focus_hot())
#define UI_FocusActive(v) DeferLoop(ui_push_focus_active(v), ui_pop_focus_active())
#define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint())
#define UI_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color())
#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color())
#define UI_BorderColor(v) DeferLoop(ui_push_border_color(v), ui_pop_border_color())
#define UI_OverlayColor(v) DeferLoop(ui_push_overlay_color(v), ui_pop_overlay_color())
#define UI_TextSelectColor(v) DeferLoop(ui_push_text_select_color(v), ui_pop_text_select_color())
#define UI_TextCursorColor(v) DeferLoop(ui_push_text_cursor_color(v), ui_pop_text_cursor_color())
#define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor())
#define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font())
#define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size())
#define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00())
#define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01())
#define UI_CornerRadius10(v) DeferLoop(ui_push_corner_radius_10(v), ui_pop_corner_radius_10())
#define UI_CornerRadius11(v) DeferLoop(ui_push_corner_radius_11(v), ui_pop_corner_radius_11())
#define UI_BlurSize(v) DeferLoop(ui_push_blur_size(v), ui_pop_blur_size())
#define UI_TextPadding(v) DeferLoop(ui_push_text_padding(v), ui_pop_text_padding())
#define UI_TextAlignment(v) DeferLoop(ui_push_text_alignment(v), ui_pop_text_alignment())
//- rjf: stacks (compositions)
#define UI_WidthFill UI_PrefWidth(ui_pct(1.f, 0.f))
@@ -778,6 +793,7 @@ internal void ui_pop_corner_radius(void);
#define UI_Rect(r) DeferLoop(ui_push_rect(r), ui_pop_rect())
#define UI_PrefSize(axis, v) DeferLoop(ui_push_pref_size((axis), (v)), ui_pop_pref_size(axis))
#define UI_CornerRadius(v) DeferLoop(ui_push_corner_radius(v), ui_pop_corner_radius())
#define UI_Focus(kind) DeferLoop((ui_push_focus_hot(kind), ui_push_focus_active(kind)), (ui_pop_focus_hot(), ui_pop_focus_active()))
//- rjf: tooltip
#define UI_TooltipBase DeferLoop(ui_tooltip_begin_base(), ui_tooltip_end_base())
@@ -786,9 +802,4 @@ internal void ui_pop_corner_radius(void);
//- rjf: context menu
#define UI_CtxMenu(key) DeferLoopChecked(ui_begin_ctx_menu(key), ui_end_ctx_menu())
//- rjf: focus
#define UI_FocusHot(is_focused) DeferLoop(ui_set_focus_hot(is_focused), ui_unset_focus_hot())
#define UI_FocusActive(is_focused) DeferLoop(ui_set_focus_active(is_focused), ui_unset_focus_hot())
#define UI_Focus(is_focused) UI_FocusHot(is_focused) UI_FocusActive(is_focused)
#endif // UI_H