os -> wm; *_w32_ -> w32_*_, *_lnx_ -> lnx_*_

This commit is contained in:
Ryan Fleury
2026-05-08 21:17:21 -07:00
parent 9a7782de47
commit 2f6d0f9aaa
52 changed files with 3086 additions and 3115 deletions
+5 -5
View File
@@ -62,7 +62,7 @@ internal Vec4F32 ui_top_background_color(void) { UI_StackTopImpl(ui_state, Backg
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 F32 ui_top_squish(void) { UI_StackTopImpl(ui_state, Squish, squish) }
internal OS_Cursor ui_top_hover_cursor(void) { UI_StackTopImpl(ui_state, HoverCursor, hover_cursor) }
internal WM_Cursor ui_top_hover_cursor(void) { UI_StackTopImpl(ui_state, HoverCursor, hover_cursor) }
internal FNT_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 FNT_RasterFlags ui_top_text_raster_flags(void) { UI_StackTopImpl(ui_state, TextRasterFlags, text_raster_flags) }
@@ -96,7 +96,7 @@ internal Vec4F32 ui_bottom_background_color(void) { UI_StackBottomImpl(ui_state,
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 F32 ui_bottom_squish(void) { UI_StackBottomImpl(ui_state, Squish, squish) }
internal OS_Cursor ui_bottom_hover_cursor(void) { UI_StackBottomImpl(ui_state, HoverCursor, hover_cursor) }
internal WM_Cursor ui_bottom_hover_cursor(void) { UI_StackBottomImpl(ui_state, HoverCursor, hover_cursor) }
internal FNT_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 FNT_RasterFlags ui_bottom_text_raster_flags(void) { UI_StackBottomImpl(ui_state, TextRasterFlags, text_raster_flags) }
@@ -130,7 +130,7 @@ internal Vec4F32 ui_push_background_color(Vec4F32 v) { UI_StackPushImpl(ui_state
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 F32 ui_push_squish(F32 v) { UI_StackPushImpl(ui_state, Squish, squish, F32, v) }
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v) { UI_StackPushImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) }
internal WM_Cursor ui_push_hover_cursor(WM_Cursor v) { UI_StackPushImpl(ui_state, HoverCursor, hover_cursor, WM_Cursor, v) }
internal FNT_Tag ui_push_font(FNT_Tag v) { UI_StackPushImpl(ui_state, Font, font, FNT_Tag, v) }
internal F32 ui_push_font_size(F32 v) { UI_StackPushImpl(ui_state, FontSize, font_size, F32, v) }
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_RasterFlags v) { UI_StackPushImpl(ui_state, TextRasterFlags, text_raster_flags, FNT_RasterFlags, v) }
@@ -164,7 +164,7 @@ internal Vec4F32 ui_pop_background_color(void) { UI_StackPopImpl(ui_state, Backg
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 F32 ui_pop_squish(void) { UI_StackPopImpl(ui_state, Squish, squish) }
internal OS_Cursor ui_pop_hover_cursor(void) { UI_StackPopImpl(ui_state, HoverCursor, hover_cursor) }
internal WM_Cursor ui_pop_hover_cursor(void) { UI_StackPopImpl(ui_state, HoverCursor, hover_cursor) }
internal FNT_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 FNT_RasterFlags ui_pop_text_raster_flags(void) { UI_StackPopImpl(ui_state, TextRasterFlags, text_raster_flags) }
@@ -198,7 +198,7 @@ internal Vec4F32 ui_set_next_background_color(Vec4F32 v) { UI_StackSetNextImpl(u
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 F32 ui_set_next_squish(F32 v) { UI_StackSetNextImpl(ui_state, Squish, squish, F32, v) }
internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v) { UI_StackSetNextImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) }
internal WM_Cursor ui_set_next_hover_cursor(WM_Cursor v) { UI_StackSetNextImpl(ui_state, HoverCursor, hover_cursor, WM_Cursor, v) }
internal FNT_Tag ui_set_next_font(FNT_Tag v) { UI_StackSetNextImpl(ui_state, Font, font, FNT_Tag, v) }
internal F32 ui_set_next_font_size(F32 v) { UI_StackSetNextImpl(ui_state, FontSize, font_size, F32, v) }
internal FNT_RasterFlags ui_set_next_text_raster_flags(FNT_RasterFlags v) { UI_StackSetNextImpl(ui_state, TextRasterFlags, text_raster_flags, FNT_RasterFlags, v) }
+9 -9
View File
@@ -29,7 +29,7 @@ typedef struct UI_BackgroundColorNode UI_BackgroundColorNode; struct UI_Backgrou
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_SquishNode UI_SquishNode; struct UI_SquishNode{UI_SquishNode *next; F32 v;};
typedef struct UI_HoverCursorNode UI_HoverCursorNode; struct UI_HoverCursorNode{UI_HoverCursorNode *next; OS_Cursor v;};
typedef struct UI_HoverCursorNode UI_HoverCursorNode; struct UI_HoverCursorNode{UI_HoverCursorNode *next; WM_Cursor v;};
typedef struct UI_FontNode UI_FontNode; struct UI_FontNode{UI_FontNode *next; FNT_Tag v;};
typedef struct UI_FontSizeNode UI_FontSizeNode; struct UI_FontSizeNode{UI_FontSizeNode *next; F32 v;};
typedef struct UI_TextRasterFlagsNode UI_TextRasterFlagsNode; struct UI_TextRasterFlagsNode{UI_TextRasterFlagsNode *next; FNT_RasterFlags v;};
@@ -104,7 +104,7 @@ state->background_color_nil_stack_top.v = v4f32(0, 0, 0, 0);\
state->text_color_nil_stack_top.v = v4f32(0, 0, 0, 0);\
state->border_color_nil_stack_top.v = v4f32(0, 0, 0, 0);\
state->squish_nil_stack_top.v = 0;\
state->hover_cursor_nil_stack_top.v = OS_Cursor_Pointer;\
state->hover_cursor_nil_stack_top.v = WM_Cursor_Pointer;\
state->font_nil_stack_top.v = fnt_tag_zero();\
state->font_size_nil_stack_top.v = 24.f;\
state->text_raster_flags_nil_stack_top.v = FNT_RasterFlag_Hinted;\
@@ -143,7 +143,7 @@ struct { UI_BackgroundColorNode *top; Vec4F32 bottom_val; UI_BackgroundColorNode
struct { UI_TextColorNode *top; Vec4F32 bottom_val; UI_TextColorNode *free; U64 gen; B32 auto_pop; } text_color_stack;\
struct { UI_BorderColorNode *top; Vec4F32 bottom_val; UI_BorderColorNode *free; U64 gen; B32 auto_pop; } border_color_stack;\
struct { UI_SquishNode *top; F32 bottom_val; UI_SquishNode *free; U64 gen; B32 auto_pop; } squish_stack;\
struct { UI_HoverCursorNode *top; OS_Cursor bottom_val; UI_HoverCursorNode *free; U64 gen; B32 auto_pop; } hover_cursor_stack;\
struct { UI_HoverCursorNode *top; WM_Cursor bottom_val; UI_HoverCursorNode *free; U64 gen; B32 auto_pop; } hover_cursor_stack;\
struct { UI_FontNode *top; FNT_Tag bottom_val; UI_FontNode *free; U64 gen; B32 auto_pop; } font_stack;\
struct { UI_FontSizeNode *top; F32 bottom_val; UI_FontSizeNode *free; U64 gen; B32 auto_pop; } font_size_stack;\
struct { UI_TextRasterFlagsNode *top; FNT_RasterFlags bottom_val; UI_TextRasterFlagsNode *free; U64 gen; B32 auto_pop; } text_raster_flags_stack;\
@@ -180,7 +180,7 @@ state->background_color_stack.top = &state->background_color_nil_stack_top; stat
state->text_color_stack.top = &state->text_color_nil_stack_top; state->text_color_stack.bottom_val = v4f32(0, 0, 0, 0); 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(0, 0, 0, 0); state->border_color_stack.free = 0; state->border_color_stack.auto_pop = 0;\
state->squish_stack.top = &state->squish_nil_stack_top; state->squish_stack.bottom_val = 0; state->squish_stack.free = 0; state->squish_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->hover_cursor_stack.top = &state->hover_cursor_nil_stack_top; state->hover_cursor_stack.bottom_val = WM_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 = fnt_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->text_raster_flags_stack.top = &state->text_raster_flags_nil_stack_top; state->text_raster_flags_stack.bottom_val = FNT_RasterFlag_Hinted; state->text_raster_flags_stack.free = 0; state->text_raster_flags_stack.auto_pop = 0;\
@@ -253,7 +253,7 @@ internal Vec4F32 ui_top_background_color(void);
internal Vec4F32 ui_top_text_color(void);
internal Vec4F32 ui_top_border_color(void);
internal F32 ui_top_squish(void);
internal OS_Cursor ui_top_hover_cursor(void);
internal WM_Cursor ui_top_hover_cursor(void);
internal FNT_Tag ui_top_font(void);
internal F32 ui_top_font_size(void);
internal FNT_RasterFlags ui_top_text_raster_flags(void);
@@ -288,7 +288,7 @@ internal Vec4F32 ui_bottom_background_color(void);
internal Vec4F32 ui_bottom_text_color(void);
internal Vec4F32 ui_bottom_border_color(void);
internal F32 ui_bottom_squish(void);
internal OS_Cursor ui_bottom_hover_cursor(void);
internal WM_Cursor ui_bottom_hover_cursor(void);
internal FNT_Tag ui_bottom_font(void);
internal F32 ui_bottom_font_size(void);
internal FNT_RasterFlags ui_bottom_text_raster_flags(void);
@@ -323,7 +323,7 @@ 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 F32 ui_push_squish(F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal WM_Cursor ui_push_hover_cursor(WM_Cursor v);
internal FNT_Tag ui_push_font(FNT_Tag v);
internal F32 ui_push_font_size(F32 v);
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_RasterFlags v);
@@ -358,7 +358,7 @@ internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal F32 ui_pop_squish(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal WM_Cursor ui_pop_hover_cursor(void);
internal FNT_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal FNT_RasterFlags ui_pop_text_raster_flags(void);
@@ -393,7 +393,7 @@ internal Vec4F32 ui_set_next_background_color(Vec4F32 v);
internal Vec4F32 ui_set_next_text_color(Vec4F32 v);
internal Vec4F32 ui_set_next_border_color(Vec4F32 v);
internal F32 ui_set_next_squish(F32 v);
internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v);
internal WM_Cursor ui_set_next_hover_cursor(WM_Cursor v);
internal FNT_Tag ui_set_next_font(FNT_Tag v);
internal F32 ui_set_next_font_size(F32 v);
internal FNT_RasterFlags ui_set_next_text_raster_flags(FNT_RasterFlags v);
+1 -1
View File
@@ -44,7 +44,7 @@ UI_StackTable:
{ Squish squish F32 0 }
//- rjf: hover cursor
{ HoverCursor hover_cursor OS_Cursor OS_Cursor_Pointer }
{ HoverCursor hover_cursor WM_Cursor WM_Cursor_Pointer }
//- rjf: font
{ Font font FNT_Tag `fnt_tag_zero()` }
+8 -8
View File
@@ -212,7 +212,7 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
B32 is_focus_active_disabled = (!is_focus_active && ui_top_focus_active() == UI_FocusKind_On);
//- rjf: build top-level box
ui_set_next_hover_cursor(is_focus_active ? OS_Cursor_IBar : OS_Cursor_Pointer);
ui_set_next_hover_cursor(is_focus_active ? WM_Cursor_IBar : WM_Cursor_Pointer);
UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_MouseClickable|
@@ -252,7 +252,7 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
// rjf: perform copy
if(op.flags & UI_TxtOpFlag_Copy)
{
os_set_clipboard_text(op.copy);
wm_set_clipboard_text(op.copy);
}
// rjf: commit op's changed cursor & mark to caller-provided state
@@ -436,7 +436,7 @@ ui_imagef(R_Handle texture, R_Tex2DSampleKind sample_kind, Rng2F32 region, Vec4F
internal UI_Signal
ui_expander(B32 is_expanded, String8 string)
{
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_hover_cursor(WM_Cursor_HandPoint);
ui_set_next_text_alignment(UI_TextAlign_Center);
ui_set_next_font(ui_icon_font());
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, string);
@@ -462,7 +462,7 @@ internal UI_Signal
ui_sort_header(B32 sorting, B32 ascending, String8 string)
{
ui_set_next_child_layout_axis(Axis2_X);
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_hover_cursor(WM_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawActiveEffects, string);
ui_push_parent(box);
@@ -649,7 +649,7 @@ internal UI_Signal
ui_sat_val_picker(F32 hue, F32 *out_sat, F32 *out_val, String8 string)
{
// rjf: build & interact
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_hover_cursor(WM_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable, string);
UI_SatValDrawData *user = push_array(ui_build_arena(), UI_SatValDrawData, 1);
ui_box_equip_custom_draw(box, ui_sat_val_picker_draw, user);
@@ -758,7 +758,7 @@ internal UI_Signal
ui_hue_picker(F32 *out_hue, F32 sat, F32 val, String8 string)
{
// rjf: build & interact
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_hover_cursor(WM_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable, string);
UI_HueDrawData *user = push_array(ui_build_arena(), UI_HueDrawData, 1);
ui_box_equip_custom_draw(box, ui_hue_picker_draw, user);
@@ -845,7 +845,7 @@ internal UI_Signal
ui_alpha_picker(F32 *out_alpha, String8 string)
{
// rjf: build & interact
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_hover_cursor(WM_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable, string);
UI_AlphaDrawData *user = push_array(ui_build_arena(), UI_AlphaDrawData, 1);
ui_box_equip_custom_draw(box, ui_alpha_picker_draw, user);
@@ -1006,7 +1006,7 @@ ui_table_begin(U64 column_pct_count, F32 **column_pcts, String8 string)
// rjf: make column boundary widget
UI_Rect(rect)
{
ui_set_next_hover_cursor(OS_Cursor_LeftRight);
ui_set_next_hover_cursor(WM_Cursor_LeftRight);
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "###%S_boundary_%I64u", table->string, column_idx);
F32 *left_pct_ptr = column_idx < ui_ts_col_pct_count ? column_pcts[column_idx-1] : 0;
+43 -43
View File
@@ -233,7 +233,7 @@ ui_single_line_txt_op_from_event(Arena *arena, UI_Event *event, String8 string,
if(event->flags & UI_EventFlag_Paste)
{
range = txt_rng(cursor, mark);
replace = os_get_clipboard_text(arena);
replace = wm_get_clipboard_text(arena);
next_cursor = next_mark = txt_pt(cursor.line, cursor.column+replace.size);
}
@@ -471,7 +471,7 @@ ui_build_arena(void)
return result;
}
internal OS_Window
internal WM_Window
ui_window(void)
{
return ui_state->window;
@@ -523,25 +523,25 @@ ui_next_event(UI_Event **ev)
if(!(perms & UI_PermissionFlag_ClicksLeft) &&
(n->v.kind == UI_EventKind_Press ||
n->v.kind == UI_EventKind_Release) &&
(n->v.key == OS_Key_LeftMouseButton))
(n->v.key == WM_Key_LeftMouseButton))
{
good = 0;
}
if(!(perms & UI_PermissionFlag_ClicksMiddle) &&
(n->v.kind == UI_EventKind_Press ||
n->v.kind == UI_EventKind_Release) &&
(n->v.key == OS_Key_MiddleMouseButton))
(n->v.key == WM_Key_MiddleMouseButton))
{
good = 0;
}
if(!(perms & UI_PermissionFlag_ClicksRight) &&
(n->v.kind == UI_EventKind_Press ||
n->v.kind == UI_EventKind_Release) &&
(n->v.key == OS_Key_RightMouseButton))
(n->v.key == WM_Key_RightMouseButton))
{
good = 0;
}
if(!(perms & UI_PermissionFlag_ScrollX) && (n->v.kind == UI_EventKind_Scroll) && (n->v.delta_2f32.x != 0 || n->v.modifiers == OS_Modifier_Shift))
if(!(perms & UI_PermissionFlag_ScrollX) && (n->v.kind == UI_EventKind_Scroll) && (n->v.delta_2f32.x != 0 || n->v.modifiers == WM_Modifier_Shift))
{
good = 0;
}
@@ -553,9 +553,9 @@ ui_next_event(UI_Event **ev)
n->v.kind == UI_EventKind_Release ||
n->v.kind == UI_EventKind_Navigate ||
n->v.kind == UI_EventKind_Edit) &&
(n->v.key != OS_Key_LeftMouseButton &&
n->v.key != OS_Key_MiddleMouseButton &&
n->v.key != OS_Key_RightMouseButton))
(n->v.key != WM_Key_LeftMouseButton &&
n->v.key != WM_Key_MiddleMouseButton &&
n->v.key != WM_Key_RightMouseButton))
{
if((perms & UI_PermissionFlag_Keyboard) == UI_PermissionFlag_KeyboardSecondary)
{
@@ -594,7 +594,7 @@ ui_eat_event(UI_Event *ev)
//- rjf: event consumption helpers
internal B32
ui_key_press(OS_Modifiers mods, OS_Key key)
ui_key_press(WM_Modifiers mods, WM_Key key)
{
B32 result = 0;
for(UI_Event *evt = 0; ui_next_event(&evt);)
@@ -610,7 +610,7 @@ ui_key_press(OS_Modifiers mods, OS_Key key)
}
internal B32
ui_key_release(OS_Modifiers mods, OS_Key key)
ui_key_release(WM_Modifiers mods, WM_Key key)
{
B32 result = 0;
for(UI_Event *evt = 0; ui_next_event(&evt);)
@@ -796,7 +796,7 @@ ui_box_from_key(UI_Key key)
//~ rjf: Top-Level Building API
internal void
ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt)
ui_begin_build(WM_Window window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt)
{
//- rjf: reset per-build ui state
{
@@ -872,11 +872,11 @@ ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, U
//- rjf: detect external press & holds
for EachEnumVal(UI_MouseButtonKind, k)
{
if(ui_key_match(ui_state->active_box_key[k], ui_key_zero()) && os_key_is_down(OS_Key_LeftMouseButton+k))
if(ui_key_match(ui_state->active_box_key[k], ui_key_zero()) && wm_key_is_down(WM_Key_LeftMouseButton+k))
{
ui_state->active_box_key[k] = ui_state->external_key;
}
else if(ui_key_match(ui_state->active_box_key[k], ui_state->external_key) && !os_key_is_down(OS_Key_LeftMouseButton+k))
else if(ui_key_match(ui_state->active_box_key[k], ui_state->external_key) && !wm_key_is_down(WM_Key_LeftMouseButton+k))
{
ui_state->active_box_key[k] = ui_key_zero();
}
@@ -887,7 +887,7 @@ ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, U
ui_state->theme = theme;
ui_state->events = events;
ui_state->window = window;
ui_state->mouse = (os_window_is_focused(window) || ui_state->last_time_mousemoved_us+500000 >= now_time_us()) ? os_mouse_from_window(window) : v2f32(-100, -100);
ui_state->mouse = (wm_window_is_focused(window) || ui_state->last_time_mousemoved_us+500000 >= now_time_us()) ? wm_mouse_from_window(window) : v2f32(-100, -100);
ui_state->animation_dt = animation_dt;
MemoryZeroStruct(&ui_state->icon_info);
ui_state->icon_info.icon_font = icon_info->icon_font;
@@ -921,11 +921,11 @@ ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, U
B32 nav_next = 0;
B32 nav_prev = 0;
Axis2 axis_lock = Axis2_Invalid;
if(ui_key_press(0, OS_Key_Tab))
if(ui_key_press(0, WM_Key_Tab))
{
nav_next = 1;
}
if(ui_key_press(OS_Modifier_Shift, OS_Key_Tab))
if(ui_key_press(WM_Modifier_Shift, WM_Key_Tab))
{
nav_prev = 1;
}
@@ -1123,7 +1123,7 @@ ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, U
//- rjf: build top-level root
{
Rng2F32 window_rect = os_client_rect_from_window(window);
Rng2F32 window_rect = wm_client_rect_from_window(window);
Vec2F32 window_rect_size = dim_2f32(window_rect);
ui_set_next_fixed_width(window_rect_size.x);
ui_set_next_fixed_height(window_rect_size.y);
@@ -1306,7 +1306,7 @@ ui_end_build(void)
UI_Box *root = floating_roots[idx];
if(!ui_box_is_nil(root))
{
Rng2F32 window_rect = os_client_rect_from_window(ui_window());
Rng2F32 window_rect = wm_client_rect_from_window(ui_window());
Vec2F32 window_dim = dim_2f32(window_rect);
Rng2F32 root_rect = root->rect;
Vec2F32 shift_down =
@@ -1538,7 +1538,7 @@ ui_end_build(void)
for(UI_Event *evt = 0; ui_next_event(&evt);)
{
if(evt->kind == UI_EventKind_Press &&
(evt->key == OS_Key_LeftMouseButton || evt->key == OS_Key_RightMouseButton))
(evt->key == WM_Key_LeftMouseButton || evt->key == WM_Key_RightMouseButton))
{
ui_ctx_menu_close();
}
@@ -1551,14 +1551,14 @@ ui_end_build(void)
UI_Box *hot = ui_box_from_key(ui_state->hot_box_key);
UI_Box *active = ui_box_from_key(ui_state->active_box_key[UI_MouseButtonKind_Left]);
UI_Box *box = ui_box_is_nil(active) ? hot : active;
OS_Cursor cursor = box->hover_cursor;
WM_Cursor cursor = box->hover_cursor;
if(box->flags & UI_BoxFlag_Disabled && box->flags & UI_BoxFlag_Clickable)
{
cursor = OS_Cursor_Disabled;
cursor = WM_Cursor_Disabled;
}
if(os_window_is_focused(ui_state->window) || !ui_box_is_nil(active))
if(wm_window_is_focused(ui_state->window) || !ui_box_is_nil(active))
{
os_set_cursor(cursor);
wm_set_cursor(cursor);
}
}
@@ -1583,7 +1583,7 @@ ui_end_build(void)
StringJoin join = {0};
join.sep = str8_lit(" ");
String8 string = str8_list_join(scratch.arena, &strs, &join);
os_set_clipboard_text(string);
wm_set_clipboard_text(string);
}
scratch_end(scratch);
}
@@ -2451,7 +2451,7 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key)
box->first = box->last = box->next = box->prev = box->parent = &ui_nil_box;
box->child_count = 0;
box->flags = 0;
box->hover_cursor = OS_Cursor_Pointer;
box->hover_cursor = WM_Cursor_Pointer;
MemoryZeroArray(box->pref_size);
MemoryZeroStruct(&box->draw_bucket);
}
@@ -2809,7 +2809,7 @@ ui_signal_from_box(UI_Box *box)
{
B32 is_focus_hot = box->flags & UI_BoxFlag_FocusHot && !(box->flags & UI_BoxFlag_FocusHotDisabled);
UI_Signal sig = {box};
sig.event_flags |= os_get_modifiers();
sig.event_flags |= wm_get_modifiers();
//////////////////////////////
//- rjf: calculate possibly-clipped box rectangle
@@ -2858,13 +2858,13 @@ ui_signal_from_box(UI_Box *box)
//- rjf: unpack event
Vec2F32 evt_mouse = evt->pos;
B32 evt_mouse_in_bounds = !contains_2f32(blacklist_rect, evt_mouse) && contains_2f32(rect, evt_mouse);
UI_MouseButtonKind evt_mouse_button_kind = (evt->key == OS_Key_LeftMouseButton ? UI_MouseButtonKind_Left :
evt->key == OS_Key_MiddleMouseButton ? UI_MouseButtonKind_Middle :
evt->key == OS_Key_RightMouseButton ? UI_MouseButtonKind_Right :
UI_MouseButtonKind evt_mouse_button_kind = (evt->key == WM_Key_LeftMouseButton ? UI_MouseButtonKind_Left :
evt->key == WM_Key_MiddleMouseButton ? UI_MouseButtonKind_Middle :
evt->key == WM_Key_RightMouseButton ? UI_MouseButtonKind_Right :
UI_MouseButtonKind_Left);
B32 evt_key_is_mouse = (evt->key == OS_Key_LeftMouseButton ||
evt->key == OS_Key_MiddleMouseButton ||
evt->key == OS_Key_RightMouseButton);
B32 evt_key_is_mouse = (evt->key == WM_Key_LeftMouseButton ||
evt->key == WM_Key_MiddleMouseButton ||
evt->key == WM_Key_RightMouseButton);
sig.event_flags |= evt->modifiers;
//- rjf: mouse presses in box -> set hot/active; mark signal accordingly
@@ -2878,14 +2878,14 @@ ui_signal_from_box(UI_Box *box)
sig.f |= (UI_SignalFlag_LeftPressed<<evt_mouse_button_kind);
ui_state->drag_start_mouse = evt->pos;
if(ui_key_match(box->key, ui_state->press_key_history[evt_mouse_button_kind][0]) &&
evt->timestamp_us-ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] <= 1000000*os_get_gfx_info()->double_click_time)
evt->timestamp_us-ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] <= 1000000*wm_get_system_info()->double_click_time)
{
sig.f |= (UI_SignalFlag_LeftDoubleClicked<<evt_mouse_button_kind);
}
if(ui_key_match(box->key, ui_state->press_key_history[evt_mouse_button_kind][0]) &&
ui_key_match(box->key, ui_state->press_key_history[evt_mouse_button_kind][1]) &&
evt->timestamp_us-ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] <= 1000000*os_get_gfx_info()->double_click_time &&
ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] - ui_state->press_timestamp_history_us[evt_mouse_button_kind][1] <= 1000000*os_get_gfx_info()->double_click_time)
evt->timestamp_us-ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] <= 1000000*wm_get_system_info()->double_click_time &&
ui_state->press_timestamp_history_us[evt_mouse_button_kind][0] - ui_state->press_timestamp_history_us[evt_mouse_button_kind][1] <= 1000000*wm_get_system_info()->double_click_time)
{
sig.f |= (UI_SignalFlag_LeftTripleClicked<<evt_mouse_button_kind);
}
@@ -2980,11 +2980,11 @@ ui_signal_from_box(UI_Box *box)
//- rjf: scrolling
if(box->flags & UI_BoxFlag_Scroll &&
evt->kind == UI_EventKind_Scroll &&
(evt->modifiers == 0 || evt->modifiers == OS_Modifier_Shift) &&
(evt->modifiers == 0 || evt->modifiers == WM_Modifier_Shift) &&
evt_mouse_in_bounds)
{
Vec2F32 delta = evt->delta_2f32;
if(evt->modifiers & OS_Modifier_Shift)
if(evt->modifiers & WM_Modifier_Shift)
{
Swap(F32, delta.x, delta.y);
}
@@ -3001,11 +3001,11 @@ ui_signal_from_box(UI_Box *box)
//- rjf: view scrolling
if(box->flags & UI_BoxFlag_ViewScroll && box->first_touched_build_index != box->last_touched_build_index &&
evt->kind == UI_EventKind_Scroll &&
(evt->modifiers == 0 || evt->modifiers == OS_Modifier_Shift) &&
(evt->modifiers == 0 || evt->modifiers == WM_Modifier_Shift) &&
evt_mouse_in_bounds)
{
Vec2F32 delta = evt->delta_2f32;
if(evt->modifiers & OS_Modifier_Shift)
if(evt->modifiers & WM_Modifier_Shift)
{
Swap(F32, delta.x, delta.y);
}
@@ -3077,7 +3077,7 @@ ui_signal_from_box(UI_Box *box)
if(sig.f & (UI_SignalFlag_LeftDragging<<k) &&
ui_key_match(ui_state->press_key_history[k][0], box->key) &&
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_get_gfx_info()->double_click_time &&
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*wm_get_system_info()->double_click_time &&
length_2f32(sub_2f32(ui_state->press_pos_history[k][0], ui_state->press_pos_history[k][1])) < 10.f)
{
sig.f |= (UI_SignalFlag_LeftDoubleDragging<<k);
@@ -3096,8 +3096,8 @@ ui_signal_from_box(UI_Box *box)
ui_key_match(ui_state->press_key_history[k][0], box->key) &&
ui_key_match(ui_state->press_key_history[k][1], box->key) &&
ui_key_match(ui_state->press_key_history[k][2], box->key) &&
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*os_get_gfx_info()->double_click_time &&
ui_state->press_timestamp_history_us[k][1] - ui_state->press_timestamp_history_us[k][2] <= 1000000*os_get_gfx_info()->double_click_time &&
ui_state->press_timestamp_history_us[k][0] - ui_state->press_timestamp_history_us[k][1] <= 1000000*wm_get_system_info()->double_click_time &&
ui_state->press_timestamp_history_us[k][1] - ui_state->press_timestamp_history_us[k][2] <= 1000000*wm_get_system_info()->double_click_time &&
length_2f32(sub_2f32(ui_state->press_pos_history[k][0], ui_state->press_pos_history[k][1])) < 10.f &&
length_2f32(sub_2f32(ui_state->press_pos_history[k][1], ui_state->press_pos_history[k][2])) < 10.f)
{
+14 -14
View File
@@ -142,8 +142,8 @@ struct UI_Event
UI_EventActionSlot slot;
UI_EventFlags flags;
UI_EventDeltaUnit delta_unit;
OS_Key key;
OS_Modifiers modifiers;
WM_Key key;
WM_Modifiers modifiers;
String8 string;
String8List paths;
Vec2F32 pos;
@@ -389,7 +389,7 @@ struct UI_Box
Vec2F32 min_size;
UI_Size pref_size[Axis2_COUNT];
Axis2 child_layout_axis;
OS_Cursor hover_cursor;
WM_Cursor hover_cursor;
U32 fastpath_codepoint;
UI_Key group_key;
DR_Bucket *draw_bucket;
@@ -524,7 +524,7 @@ typedef struct UI_Signal UI_Signal;
struct UI_Signal
{
UI_Box *box;
OS_Modifiers event_flags;
WM_Modifiers event_flags;
Vec2S16 scroll;
UI_SignalFlags f;
};
@@ -705,7 +705,7 @@ struct UI_State
UI_IconInfo icon_info;
UI_Theme *theme;
UI_AnimationInfo animation_info;
OS_Window window;
WM_Window window;
UI_EventList *events;
Vec2F32 mouse;
F32 animation_dt;
@@ -826,7 +826,7 @@ internal UI_State *ui_get_selected_state(void);
//- rjf: per-frame info
internal Arena * ui_build_arena(void);
internal OS_Window ui_window(void);
internal WM_Window ui_window(void);
internal Vec2F32 ui_mouse(void);
internal FNT_Tag ui_icon_font(void);
internal String8 ui_icon_string_from_kind(UI_IconKind icon_kind);
@@ -837,8 +837,8 @@ internal B32 ui_next_event(UI_Event **ev);
internal void ui_eat_event(UI_Event *ev);
//- rjf: event consumption helpers
internal B32 ui_key_press(OS_Modifiers mods, OS_Key key);
internal B32 ui_key_release(OS_Modifiers mods, OS_Key key);
internal B32 ui_key_press(WM_Modifiers mods, WM_Key key);
internal B32 ui_key_release(WM_Modifiers mods, WM_Key key);
internal B32 ui_text(U32 character);
internal B32 ui_slot_press(UI_EventActionSlot slot);
@@ -873,7 +873,7 @@ internal UI_Box * ui_box_from_key(UI_Key key);
////////////////////////////////
//~ rjf: Top-Level Building API
internal void ui_begin_build(OS_Window window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt);
internal void ui_begin_build(WM_Window window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt);
internal void ui_end_build(void);
internal void ui_calc_sizes_standalone__in_place(UI_Box *root, Axis2 axis);
internal void ui_calc_sizes_upwards_dependent__in_place(UI_Box *root, Axis2 axis);
@@ -985,7 +985,7 @@ internal Vec4F32 ui_top_background_color(void);
internal Vec4F32 ui_top_text_color(void);
internal Vec4F32 ui_top_border_color(void);
internal F32 ui_top_squish(void);
internal OS_Cursor ui_top_hover_cursor(void);
internal WM_Cursor ui_top_hover_cursor(void);
internal FNT_Tag ui_top_font(void);
internal F32 ui_top_font_size(void);
internal FNT_RasterFlags ui_top_text_raster_flags(void);
@@ -1020,7 +1020,7 @@ internal Vec4F32 ui_bottom_background_color(void);
internal Vec4F32 ui_bottom_text_color(void);
internal Vec4F32 ui_bottom_border_color(void);
internal F32 ui_bottom_squish(void);
internal OS_Cursor ui_bottom_hover_cursor(void);
internal WM_Cursor ui_bottom_hover_cursor(void);
internal FNT_Tag ui_bottom_font(void);
internal F32 ui_bottom_font_size(void);
internal FNT_RasterFlags ui_bottom_text_raster_flags(void);
@@ -1055,7 +1055,7 @@ 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 F32 ui_push_squish(F32 v);
internal OS_Cursor ui_push_hover_cursor(OS_Cursor v);
internal WM_Cursor ui_push_hover_cursor(WM_Cursor v);
internal FNT_Tag ui_push_font(FNT_Tag v);
internal F32 ui_push_font_size(F32 v);
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_RasterFlags v);
@@ -1090,7 +1090,7 @@ internal Vec4F32 ui_pop_background_color(void);
internal Vec4F32 ui_pop_text_color(void);
internal Vec4F32 ui_pop_border_color(void);
internal F32 ui_pop_squish(void);
internal OS_Cursor ui_pop_hover_cursor(void);
internal WM_Cursor ui_pop_hover_cursor(void);
internal FNT_Tag ui_pop_font(void);
internal F32 ui_pop_font_size(void);
internal FNT_RasterFlags ui_pop_text_raster_flags(void);
@@ -1125,7 +1125,7 @@ internal Vec4F32 ui_set_next_background_color(Vec4F32 v);
internal Vec4F32 ui_set_next_text_color(Vec4F32 v);
internal Vec4F32 ui_set_next_border_color(Vec4F32 v);
internal F32 ui_set_next_squish(F32 v);
internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v);
internal WM_Cursor ui_set_next_hover_cursor(WM_Cursor v);
internal FNT_Tag ui_set_next_font(FNT_Tag v);
internal F32 ui_set_next_font_size(F32 v);
internal FNT_RasterFlags ui_set_next_text_raster_flags(FNT_RasterFlags v);