rewrite ui box -> signal path for less lossy event processing & correctness; also extend to use all 3 mouse buttons. eliminate ui signal bitfields, just use flags & helper macros everywhere.

This commit is contained in:
Ryan Fleury
2024-02-07 16:46:57 -08:00
parent b9cec99cd4
commit c637ad6ede
7 changed files with 655 additions and 285 deletions
+139 -136
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -546,7 +546,7 @@ DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(rgba)
//- rjf: hover color box -> show components
UI_Signal sig = ui_signal_from_box(color_box);
if(sig.hovering)
if(ui_hovering(sig))
{
ui_do_color_tooltip_hsva(hsva);
}
@@ -587,12 +587,12 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(rgba)
UI_PrefWidth(ui_px(dim.y, 1.f))
{
UI_Signal sv_sig = ui_sat_val_pickerf(hsva.x, &hsva.y, &hsva.z, "sat_val_picker");
commit = commit || sv_sig.released;
commit = commit || ui_released(sv_sig);
}
UI_PrefWidth(ui_em(3.f, 1.f))
{
UI_Signal h_sig = ui_hue_pickerf(&hsva.x, hsva.y, hsva.z, "hue_picker");
commit = commit || h_sig.released;
commit = commit || ui_released(h_sig);
}
UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText))
{
@@ -916,7 +916,7 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(bitmap)
draw_data->texture = texture;
draw_data->src = r2f32(v2f32(0, 0), v2f32((F32)topology_info.width, (F32)topology_info.height));
draw_data->loaded_t = state->loaded_t;
draw_data->hovered = sig.hovering;
draw_data->hovered = ui_hovering(sig);
draw_data->mouse_px = mouse_bitmap_px_off;
draw_data->ui_per_bmp_px = ui_per_bmp_px;
ui_box_equip_custom_draw(box, df_view_rule_hooks__bitmap_box_draw, draw_data);
@@ -933,11 +933,11 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(bitmap)
df_gfx_request_frame();
}
}
if(sig.hovering && r_handle_match(texture, r_handle_zero())) UI_Tooltip
if(ui_hovering(sig) && r_handle_match(texture, r_handle_zero())) UI_Tooltip
{
ui_labelf("Texture not loaded.");
}
if(sig.hovering && !r_handle_match(texture, r_handle_zero()))
if(ui_hovering(sig) && !r_handle_match(texture, r_handle_zero()))
{
if(dim.y > (F32)topology_info.height)
{
@@ -1169,9 +1169,9 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(geo)
{
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground|UI_BoxFlag_Clickable, "geo_box");
UI_Signal sig = ui_signal_from_box(box);
if(sig.dragging)
if(ui_dragging(sig))
{
if(sig.pressed)
if(ui_pressed(sig))
{
Vec2F32 data = v2f32(state->yaw_target, state->pitch_target);
ui_store_drag_struct(&data);
+106 -106
View File
@@ -1228,7 +1228,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
}
UI_Signal sig = ui_signal_from_box(vector);
if(sig.pressed)
if(ui_pressed(sig))
{
edit_commit = edit_commit || (!row_selected && ewv->input_editing);
next_cursor_tbl = v2s64(DF_EvalWatchViewColumnKind_Expr, (semantic_idx+1));
@@ -1340,8 +1340,8 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
row->expr,
"###row_%I64x", row_hash);
}
edit_commit = edit_commit || sig.commit;
if(sig.hovering && is_inherited) UI_Tooltip
edit_commit = edit_commit || ui_committed(sig);
if(is_inherited && ui_hovering(sig)) UI_Tooltip
{
String8List inheritance_chain_type_names = {0};
for(TG_KeyNode *n = row->inherited_type_key_chain.first; n != 0; n = n->next)
@@ -1360,13 +1360,13 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1.f, df_rgba_from_theme_color(DF_ThemeColor_CodeType), inheritance_type);
}
}
if(sig.hovering && DEV_eval_watch_key_tooltips) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Code))
if(DEV_eval_watch_key_tooltips && ui_hovering(sig)) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Code))
{
ui_labelf("Parent Key: %I64x, %I64x", row->parent_key.parent_hash, row->parent_key.child_num);
ui_labelf("Hover Key: %I64x, %I64x", row->key.parent_hash, row->key.child_num);
ui_labelf("Cursor Key: %I64x, %I64x", ewv->cursor.key.parent_hash, ewv->cursor.key.child_num);
}
if(sig.hovering && row->depth == 0 && DEV_eval_compiler_tooltips) UI_Tooltip
if(DEV_eval_compiler_tooltips && row->depth == 0 && ui_hovering(sig)) UI_Tooltip
{
Temp scratch = scratch_begin(0, 0);
String8 string = row->expr;
@@ -1415,7 +1415,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
// rjf: press -> commit if editing & select
if(sig.pressed)
if(ui_pressed(sig))
{
edit_commit = edit_commit || (!cell_selected && ewv->input_editing);
next_cursor_tbl = v2s64(DF_EvalWatchViewColumnKind_Expr, (semantic_idx+1));
@@ -1429,7 +1429,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
// rjf: double-click -> start editing
if(sig.double_clicked && !ewv->input_editing && can_edit_expr)
if(ui_double_clicked(sig) && !ewv->input_editing && can_edit_expr)
{
ui_kill_action();
ewv->input_editing = 1;
@@ -1515,18 +1515,18 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
if(value_is_simple)
{
sig = df_line_editf(DF_LineEditFlag_CodeContents|DF_LineEditFlag_NoBackground, 0, 0, &ewv->input_cursor, &ewv->input_mark, ewv->input_buffer, sizeof(ewv->input_buffer), &ewv->input_size, 0, row->display_value, "%S###val_%I64x", row->display_value, row_hash);
edit_commit = (edit_commit || sig.commit);
edit_commit = (edit_commit || ui_committed(sig));
}
}
// rjf: bad & hovering -> display
if(row_is_bad && sig.hovering) UI_Tooltip
if(row_is_bad && ui_hovering(sig)) UI_Tooltip
{
UI_PrefWidth(ui_children_sum(1)) df_error_label(str8_lit("Could not read process memory successfully."));
}
// rjf: press -> focus & commit if editing & not selected
if(sig.pressed)
if(ui_pressed(sig))
{
pressed = 1;
edit_commit = edit_commit || (ewv->input_editing && !cell_selected);
@@ -1534,7 +1534,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
// rjf: double-click -> start editing
if(sig.double_clicked && value_is_simple)
if(ui_double_clicked(sig) && value_is_simple)
{
ui_kill_action();
ewv->input_editing = 1;
@@ -1562,7 +1562,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeType), string);
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
pressed = 1;
edit_commit = edit_commit || (ewv->input_editing && !cell_selected);
@@ -1596,11 +1596,11 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
{
rule_editing_active = ui_is_focus_active();
sig = df_line_editf(DF_LineEditFlag_CodeContents|DF_LineEditFlag_NoBackground, 0, 0, &ewv->input_cursor, &ewv->input_mark, ewv->input_buffer, sizeof(ewv->input_buffer), &ewv->input_size, 0, view_rule, "###view_rule_%I64x", row_hash);
edit_commit = edit_commit || sig.commit;
edit_commit = edit_commit || ui_committed(sig);
}
// rjf: press -> commit if not selected, select this cell
if(sig.pressed)
if(ui_pressed(sig))
{
pressed = 1;
edit_commit = edit_commit || (ewv->input_editing && !cell_selected);
@@ -1608,7 +1608,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
// rjf: double-click -> begin editing
if(sig.double_clicked && !ewv->input_editing)
if(ui_double_clicked(sig) && !ewv->input_editing)
{
ui_kill_action();
ewv->input_editing = 1;
@@ -1832,7 +1832,7 @@ DF_VIEW_UI_FUNCTION_DEF(Empty)
UI_BackgroundColor(df_rgba_from_theme_color(DF_ThemeColor_ActionBackground))
UI_BorderColor(df_rgba_from_theme_color(DF_ThemeColor_ActionBorder))
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_ActionText))
if(df_icon_buttonf(DF_IconKind_Add, 0, "Add Target").clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Add, 0, "Add Target")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_AddTarget);
@@ -1857,7 +1857,7 @@ DF_VIEW_UI_FUNCTION_DEF(Empty)
UI_BorderColor(df_rgba_from_theme_color(DF_ThemeColor_ActionBorder))
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_ActionText))
{
if(df_icon_buttonf(DF_IconKind_Play, 0, "Launch %S", target_name).clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Play, 0, "Launch %S", target_name)))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.entity = df_handle_from_entity(target);
@@ -1865,7 +1865,7 @@ DF_VIEW_UI_FUNCTION_DEF(Empty)
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_LaunchAndRun));
}
ui_spacer(ui_em(1.5f, 1));
if(df_icon_buttonf(DF_IconKind_Play, 0, "Step Into %S", target_name).clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Play, 0, "Step Into %S", target_name)))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.entity = df_handle_from_entity(target);
@@ -2082,14 +2082,14 @@ DF_VIEW_UI_FUNCTION_DEF(Commands)
//- rjf: interact
UI_Signal sig = ui_signal_from_box(box);
if(sig.clicked)
if(ui_clicked(sig))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = item->cmd_spec;
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_CmdSpec);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CompleteQuery));
}
if(sig.right_clicked)
if(ui_right_clicked(sig))
{
ui_ctx_menu_open(item_ctx_menu_key, ui_key_zero(), sub_2f32(ui_mouse(), v2f32(2, 2)));
}
@@ -2382,7 +2382,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
UI_Signal sig = ui_sort_header(sorting,
fs->cached_files_sort_side == Side_Min,
kinds[idx].string);
if(sig.clicked)
if(ui_clicked(sig))
{
if(fs->sort_kind != kinds[idx].kind)
{
@@ -2454,7 +2454,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
}
// rjf: click => up one directory
if(sig.clicked)
if(ui_clicked(sig))
{
String8 new_path = str8_chop_last_slash(str8_chop_last_slash(path_query.path));
if(new_path.size != 0)
@@ -2536,7 +2536,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
}
// rjf: click => activate this file
if(file_sig.clicked)
if(ui_clicked(file_sig))
{
String8 existing_path = str8_chop_last_slash(path_query.path);
String8 new_path = push_str8f(scratch.arena, "%S/%S/", existing_path, file->filename);
@@ -2704,7 +2704,7 @@ DF_VIEW_UI_FUNCTION_DEF(SystemProcesses)
}
// rjf: click => activate this specific process
if(sig.clicked)
if(ui_clicked(sig))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.id = info->info.pid;
@@ -2854,7 +2854,7 @@ DF_VIEW_UI_FUNCTION_DEF(EntityLister)
UI_Box *name_label = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S##label_%p", display_string, ent);
ui_box_equip_fuzzy_match_ranges(name_label, &item.name_match_ranges);
}
if(ui_signal_from_box(box).clicked)
if(ui_clicked(ui_signal_from_box(box)))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.entity = df_handle_from_entity(ent);
@@ -2992,14 +2992,14 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
}
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.clicked)
if(ui_clicked(sig))
{
DF_CmdParams p = df_cmd_params_from_view(ws, panel, view);
p.string = name;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CompleteQuery));
}
if(sig.hovering) UI_Tooltip
if(ui_hovering(sig)) UI_Tooltip
{
U64 binary_voff = df_voff_from_binary_symbol_name(binary, name);
DF_TextLineDasm2SrcInfo dasm2src_info = df_text_line_dasm2src_info_from_binary_voff(binary, binary_voff);
@@ -3246,18 +3246,18 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
UI_FocusActive((value_selected && tv->input_editing) ? UI_FocusKind_On : UI_FocusKind_Off)
{
sig = df_line_editf(DF_LineEditFlag_NoBackground, 0, 0, &tv->input_cursor, &tv->input_mark, tv->input_buffer, sizeof(tv->input_buffer), &tv->input_size, 0, kv_info[idx].current_text, "###kv_editor_%i", (S32)idx);
edit_commit = edit_commit || sig.commit;
edit_commit = edit_commit || ui_committed(sig);
}
// rjf: focus panel on press
if(sig.pressed)
if(ui_pressed(sig))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
// rjf: begin editing on double-click
if(!tv->input_editing && sig.double_clicked)
if(!tv->input_editing && ui_double_clicked(sig))
{
ui_kill_action();
tv->input_editing = 1;
@@ -3268,7 +3268,7 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
}
// rjf: press on non-selected => commit edit, change selected cell
if(sig.pressed && !value_selected)
if(ui_pressed(sig) && !value_selected)
{
edit_end = 1;
edit_commit = tv->input_editing;
@@ -3276,7 +3276,7 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
}
// rjf: apply commit deltas
if(sig.commit)
if(ui_committed(sig))
{
next_cursor.y += 1;
}
@@ -3293,7 +3293,7 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
{
UI_FocusHot((row_selected && next_cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off)
UI_TextAlignment(UI_TextAlign_Center)
if(ui_buttonf("Browse...").clicked)
if(ui_clicked(ui_buttonf("Browse...")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(kv_info[idx].fill_with_file ? DF_CoreCmdKind_PickFile : DF_CoreCmdKind_PickFolder);
@@ -3427,7 +3427,7 @@ DF_VIEW_UI_FUNCTION_DEF(Targets)
UI_Signal add_sig = {0};
UI_FocusHot(cursor.y == 1 ? UI_FocusKind_On : UI_FocusKind_Off)
add_sig = df_icon_buttonf(DF_IconKind_Add, 0, "Add New Target");
if(add_sig.clicked)
if(ui_clicked(add_sig))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_AddTarget);
@@ -3450,13 +3450,13 @@ DF_VIEW_UI_FUNCTION_DEF(Targets)
UI_FocusHot((row_selected && cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
{
UI_Signal sig = df_icon_buttonf(target->b32 ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, 0, "###ebl_%p", target);
if(sig.clicked && sig.event_flags == 0)
if(ui_clicked(sig) && sig.event_flags == 0)
{
DF_CmdParams p = df_cmd_params_from_view(ws, panel, view);
p.entity = df_handle_from_entity(target);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectTarget));
}
else if(sig.clicked && sig.event_flags == OS_EventFlag_Ctrl)
else if(ui_clicked(sig) && sig.event_flags == OS_EventFlag_Ctrl)
{
DF_CmdParams p = df_cmd_params_from_view(ws, panel, view);
p.entity = df_handle_from_entity(target);
@@ -3493,11 +3493,11 @@ DF_VIEW_UI_FUNCTION_DEF(Targets)
{
sig = df_icon_buttonf(ctrls[ctrl_idx].icon, 0, "###%p_ctrl_%i", target, (int)ctrl_idx);
}
if(sig.hovering) UI_Tooltip
if(ui_hovering(sig)) UI_Tooltip
{
ui_label(ctrls[ctrl_idx].text);
}
if(sig.clicked)
if(ui_clicked(sig))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.entity = df_handle_from_entity(target);
@@ -3700,18 +3700,18 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
UI_FocusActive((value_selected && fpms->input_editing) ? UI_FocusKind_On : UI_FocusKind_Off)
{
sig = df_line_editf(DF_LineEditFlag_NoBackground, 0, 0, &fpms->input_cursor, &fpms->input_mark, fpms->input_buffer, sizeof(fpms->input_buffer), &fpms->input_size, 0, map_src_path, "###src_editor_%p", map);
edit_commit = edit_commit || sig.commit;
edit_commit = edit_commit || ui_committed(sig);
}
// rjf: focus panel on press
if(sig.pressed)
if(ui_pressed(sig))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
// rjf: begin editing on double-click
if(!fpms->input_editing && sig.double_clicked)
if(!fpms->input_editing && ui_double_clicked(sig))
{
fpms->input_editing = 1;
fpms->input_size = Min(sizeof(fpms->input_buffer), map_src_path.size);
@@ -3721,7 +3721,7 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
}
// rjf: press on non-selected => commit edit, change selected cell
if(sig.pressed && !value_selected)
if(ui_pressed(sig) && !value_selected)
{
edit_end = 1;
edit_commit = fpms->input_editing;
@@ -3740,7 +3740,7 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
//- rjf: browse button
UI_FocusHot((row_selected && fpms->cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off)
UI_PrefWidth(ui_text_dim(10, 1))
if(ui_buttonf("Browse...").clicked)
if(ui_clicked(ui_buttonf("Browse...")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFileOrFolder);
@@ -3774,18 +3774,18 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
UI_FocusActive((value_selected && fpms->input_editing) ? UI_FocusKind_On : UI_FocusKind_Off)
{
sig = df_line_editf(DF_LineEditFlag_NoBackground, 0, 0, &fpms->input_cursor, &fpms->input_mark, fpms->input_buffer, sizeof(fpms->input_buffer), &fpms->input_size, 0, map_dst_path, "###dst_editor_%p", map);
edit_commit = edit_commit || sig.commit;
edit_commit = edit_commit || ui_committed(sig);
}
// rjf: focus panel on press
if(sig.pressed)
if(ui_pressed(sig))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
// rjf: begin editing on double-click
if(!fpms->input_editing && sig.double_clicked)
if(!fpms->input_editing && ui_double_clicked(sig))
{
fpms->input_editing = 1;
fpms->input_size = Min(sizeof(fpms->input_buffer), map_dst_path.size);
@@ -3795,7 +3795,7 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
}
// rjf: press on non-selected => commit edit, change selected cell
if(sig.pressed && !value_selected)
if(ui_pressed(sig) && !value_selected)
{
edit_end = 1;
edit_commit = fpms->input_editing;
@@ -3815,7 +3815,7 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
{
UI_FocusHot((row_selected && fpms->cursor.x == 3) ? UI_FocusKind_On : UI_FocusKind_Off)
UI_PrefWidth(ui_text_dim(10, 1))
if(ui_buttonf("Browse...").clicked)
if(ui_clicked(ui_buttonf("Browse...")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFileOrFolder);
@@ -4009,11 +4009,11 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler)
}
sig = df_icon_buttonf(frozen ? DF_IconKind_Locked : DF_IconKind_Unlocked, 0, "###lock_%p", entity);
}
if(frozen_by_solo_mode && sig.hovering) UI_Tooltip
if(frozen_by_solo_mode && ui_hovering(sig)) UI_Tooltip
{
ui_label(str8_lit("This thread is frozen during stepping operations because it isn't selected, and Solo Stepping Mode is enabled."));
}
if(sig.clicked)
if(ui_clicked(sig))
{
DF_CoreCmdKind cmd_kind = frozen ? DF_CoreCmdKind_ThawEntity : DF_CoreCmdKind_FreezeEntity;
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
@@ -4040,7 +4040,7 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler)
{
UI_PrefWidth(ui_text_dim(10, 1))
UI_TextAlignment(UI_TextAlign_Center)
if(ui_buttonf("Detach").clicked)
if(ui_clicked(ui_buttonf("Detach")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.entity = df_handle_from_entity(entity);
@@ -4052,7 +4052,7 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler)
}
UI_TableCellSized(ui_em(2.25f, 1.f)) UI_FocusHot((row_is_selected && cursor.x == 3) ? UI_FocusKind_On : UI_FocusKind_Off)
{
if(df_icon_buttonf(DF_IconKind_Redo, 0, "###retry").clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Redo, 0, "###retry")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_handle_list_push(scratch.arena, &params.entity_list, df_handle_from_entity(entity));
@@ -4065,7 +4065,7 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler)
UI_BackgroundColor(df_rgba_from_theme_color(DF_ThemeColor_FailureBackground))
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_FailureText))
UI_BorderColor(df_rgba_from_theme_color(DF_ThemeColor_FailureBorder))
if(df_icon_buttonf(DF_IconKind_X, 0, "###kill").clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "###kill")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_handle_list_push(scratch.arena, &params.entity_list, df_handle_from_entity(entity));
@@ -4220,13 +4220,13 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, "%S###selection_%i", selected_string,
(int)frame_idx);
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(0, (S64)frame_idx+1);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
if(sig.double_clicked || sig.keyboard_clicked)
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.index = frame_idx;
@@ -4242,7 +4242,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
{
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "(No Module)###moduleless_frame_%I64x", frame_idx);
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(1, (S64)frame_idx+1);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
@@ -4271,13 +4271,13 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
}
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, symbol);
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(2, (S64)frame_idx+1);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
if(sig.double_clicked || sig.keyboard_clicked)
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.index = frame_idx;
@@ -4292,13 +4292,13 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
{
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "0x%I64x", rip_vaddr);
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(3, (S64)frame_idx+1);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
if(sig.double_clicked || sig.keyboard_clicked)
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.index = frame_idx;
@@ -4532,7 +4532,7 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
{
UI_Box *range_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, "[0x%I64x, 0x%I64x)###vaddr_range_%p", entity->vaddr_rng.min, entity->vaddr_rng.max, entity);
UI_Signal sig = ui_signal_from_box(range_box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(1, (S64)idx+1);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
@@ -4567,11 +4567,11 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
{
UI_TextColor(!dbgi_is_valid ? df_rgba_from_theme_color(DF_ThemeColor_FailureBackground) : ui_top_text_color())
sig = df_line_editf(DF_LineEditFlag_NoBackground, 0, 0, &mv->txt_cursor, &mv->txt_mark, mv->txt_buffer, sizeof(mv->txt_buffer), &mv->txt_size, 0, dbgi->dbg_path, "###dbg_path_%p", entity);
edit_commit = (edit_commit || sig.commit);
edit_commit = (edit_commit || ui_committed(sig));
}
// rjf: press -> focus
if(sig.pressed)
if(ui_pressed(sig))
{
edit_commit = (mv->txt_editing && !txt_is_selected);
next_cursor = v2s64(2, (S64)idx+1);
@@ -4580,7 +4580,7 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
}
// rjf: double-click -> begin editing
if(sig.double_clicked && !mv->txt_editing)
if(ui_double_clicked(sig) && !mv->txt_editing)
{
ui_kill_action();
mv->txt_editing = 1;
@@ -4599,7 +4599,7 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
// rjf: build browse button
UI_FocusHot(brw_is_selected ? UI_FocusKind_On : UI_FocusKind_Off) UI_PrefWidth(ui_text_dim(10, 1))
{
if(ui_buttonf("Browse...").clicked || (brw_is_selected && edit_begin))
if(ui_clicked(ui_buttonf("Browse...")) || (brw_is_selected && edit_begin))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFile);
@@ -4800,7 +4800,7 @@ DF_VIEW_UI_FUNCTION_DEF(PendingEntity)
UI_CornerRadius(ui_top_font_size()/3)
UI_PrefWidth(ui_text_dim(10, 1))
UI_Focus(UI_FocusKind_On)
if(ui_buttonf("Find alternative...").clicked)
if(ui_clicked(ui_buttonf("Find alternative...")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFile);
@@ -5242,7 +5242,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
UI_CornerRadius(ui_top_font_size()/3)
UI_PrefWidth(ui_text_dim(10, 1))
UI_Focus(UI_FocusKind_On)
if(ui_buttonf("Find alternative...").clicked)
if(ui_clicked(ui_buttonf("Find alternative...")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFile);
@@ -5461,7 +5461,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
}
//- rjf: hover eval
if(!sig.base.dragging && sig.mouse_expr_rng.min.line != 0 && sig.base.event_flags == 0)
if(!ui_dragging(sig.base) && sig.mouse_expr_rng.min.line != 0 && sig.base.event_flags == 0)
{
TxtRng expr_rng = sig.mouse_expr_rng;
String8 expr = txti_string_from_handle_txt_rng(scratch.arena, txti_handle, expr_rng);
@@ -5476,20 +5476,20 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
}
//- rjf: press code slice? -> focus panel
if(sig.base.pressed)
if(ui_pressed(sig.base))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
//- rjf: dragging? -> contain cursor
if(sig.base.dragging && sig.base.event_flags == 0)
if(ui_dragging(sig.base) && sig.base.event_flags == 0)
{
tv->contain_cursor = 1;
}
//- rjf: ctrl+pressed? -> go to name
if(sig.base.pressed && sig.base.event_flags & OS_EventFlag_Ctrl)
if(ui_pressed(sig.base) && sig.base.event_flags & OS_EventFlag_Ctrl)
{
ui_kill_action();
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
@@ -5826,7 +5826,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "%S###file_ood_warning", df_g_icon_kind_text_table[DF_IconKind_WarningBig]);
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.hovering) UI_Tooltip
if(ui_hovering(sig)) UI_Tooltip
{
UI_PrefWidth(ui_children_sum(1)) UI_Row UI_PrefWidth(ui_text_dim(1, 1))
{
@@ -6369,7 +6369,7 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly)
}
//- rjf: hover eval
if(!sig.base.dragging && sig.mouse_expr_rng.min.line != 0 && contains_1s64(visible_line_num_range, sig.mouse_expr_rng.min.line) && sig.mouse_expr_rng.max.line == sig.mouse_expr_rng.min.line && sig.base.event_flags == 0)
if(!ui_dragging(sig.base) && sig.mouse_expr_rng.min.line != 0 && contains_1s64(visible_line_num_range, sig.mouse_expr_rng.min.line) && sig.mouse_expr_rng.max.line == sig.mouse_expr_rng.min.line && sig.base.event_flags == 0)
{
U64 line_idx = sig.mouse_expr_rng.min.line-visible_line_num_range.min;
String8 expr = str8_substr(code_slice_params.line_text[line_idx], r1u64(sig.mouse_expr_rng.min.column-1, sig.mouse_expr_rng.max.column-1));
@@ -6386,14 +6386,14 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly)
}
//- rjf: press code slice? -> focus panel
if(sig.base.pressed)
if(ui_pressed(sig.base))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
//- rjf: dragging? -> contain cursor
if(sig.base.dragging && sig.base.event_flags == 0)
if(ui_dragging(sig.base) && sig.base.event_flags == 0)
{
dv->contain_cursor = 1;
}
@@ -7264,7 +7264,7 @@ DF_VIEW_UI_FUNCTION_DEF(Output)
}
//- rjf: hover eval
if(!sig.base.dragging && sig.mouse_expr_rng.min.line != 0)
if(!ui_dragging(sig.base) && sig.mouse_expr_rng.min.line != 0)
{
TxtRng expr_rng = sig.mouse_expr_rng;
String8 expr = txti_string_from_handle_txt_rng(scratch.arena, txti_handle, expr_rng);
@@ -7279,14 +7279,14 @@ DF_VIEW_UI_FUNCTION_DEF(Output)
}
//- rjf: press code slice? -> focus panel
if(sig.base.pressed)
if(ui_pressed(sig.base))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
//- rjf: dragging? -> contain cursor
if(sig.base.dragging)
if(ui_dragging(sig.base))
{
tv->contain_cursor = 1;
}
@@ -8040,7 +8040,7 @@ DF_VIEW_UI_FUNCTION_DEF(Memory)
UI_Signal sig = ui_signal_from_box(row_container_box);
// rjf: calculate hovered byte
if(sig.hovering || sig.dragging)
if(ui_hovering(sig) || ui_dragging(sig))
{
Vec2F32 mouse_rel = sub_2f32(ui_mouse(), row_container_box->rect.p0);
U64 row_idx = ClampBot(0, mouse_rel.y) / row_height_px;
@@ -8067,25 +8067,25 @@ DF_VIEW_UI_FUNCTION_DEF(Memory)
}
// rjf: press -> focus panel
if(sig.pressed)
if(ui_pressed(sig))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
// rjf: click & drag -> select
if(sig.dragging && mouse_hover_byte_num != 0)
if(ui_dragging(sig) && mouse_hover_byte_num != 0)
{
mv->contain_cursor = 1;
mv->cursor = mouse_hover_byte_num-1;
if(sig.pressed)
if(ui_pressed(sig))
{
mv->mark = mv->cursor;
}
}
// rjf: ctrl+scroll -> change font size
if(sig.hovering)
if(ui_hovering(sig))
{
for(OS_Event *event = ui_events()->first, *next = 0; event != 0; event = next)
{
@@ -8429,7 +8429,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
{
UI_TableCell UI_FocusHot((row_is_selected && cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
{
if(df_icon_buttonf(entity->b32 ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, 0, "###ebl_%p", entity).clicked)
if(ui_clicked(df_icon_buttonf(entity->b32 ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, 0, "###ebl_%p", entity)))
{
df_entity_equip_b32(entity, !entity->b32);
}
@@ -8467,7 +8467,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
}
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.double_clicked || sig.keyboard_clicked)
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{
DF_CmdParams params = df_cmd_params_from_window(ws);
params.file_path = df_full_path_from_entity(scratch.arena, file_parent);
@@ -8476,7 +8476,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_TextPoint);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
}
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(2, (S64)(idx));
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
@@ -8492,7 +8492,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), hit_count_string);
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(3, (S64)(idx));
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
@@ -8501,7 +8501,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
}
UI_TableCell UI_FocusHot((row_is_selected && cursor.x == 4) ? UI_FocusKind_On : UI_FocusKind_Off)
{
if(df_icon_buttonf(DF_IconKind_Trash, 0, "###del_%p", entity).clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Trash, 0, "###del_%p", entity)))
{
df_entity_mark_for_deletion(entity);
}
@@ -8613,7 +8613,7 @@ DF_VIEW_UI_FUNCTION_DEF(WatchPins)
}
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, "%S###loc_%p", loc_string, entity);
UI_Signal sig = ui_signal_from_box(box);
if(sig.double_clicked || sig.keyboard_clicked)
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{
DF_CmdParams params = df_cmd_params_from_window(ws);
params.file_path = df_full_path_from_entity(scratch.arena, file_parent);
@@ -8622,7 +8622,7 @@ DF_VIEW_UI_FUNCTION_DEF(WatchPins)
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_TextPoint);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
}
if(sig.pressed)
if(ui_pressed(sig))
{
next_cursor = v2s64(1, (S64)(idx));
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
@@ -8631,7 +8631,7 @@ DF_VIEW_UI_FUNCTION_DEF(WatchPins)
}
UI_TableCell UI_FocusHot((row_is_selected && cursor.x == 2) ? UI_FocusKind_On : UI_FocusKind_Off)
{
if(df_icon_buttonf(DF_IconKind_Trash, 0, "###del_%p", entity).clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_Trash, 0, "###del_%p", entity)))
{
df_entity_mark_for_deletion(entity);
}
@@ -8760,7 +8760,7 @@ DF_VIEW_UI_FUNCTION_DEF(ExceptionFilters)
{
DF_ExceptionFiltersOption *opt = &opts.v[row];
UI_Signal sig = df_icon_buttonf(opt->is_enabled ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, &opt->matches, "%S", opt->name);
if(sig.clicked)
if(ui_clicked(sig))
{
if(opt->exception_code_kind != CTRL_ExceptionCodeKind_Null)
{
@@ -8884,7 +8884,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
ui_set_next_background_color(bg_color);
ui_set_next_text_color(tx_color);
ui_set_next_border_color(bd_color);
if(ui_buttonf("%S", df_g_theme_preset_display_string_table[preset]).clicked)
if(ui_clicked(ui_buttonf("%S", df_g_theme_preset_display_string_table[preset])))
{
MemoryCopy(df_gfx_state->cfg_theme_target.colors, colors, sizeof(df_gfx_state->cfg_theme_target.colors));
}
@@ -8966,7 +8966,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("Hex");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, hex_string, "###hex_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_rgba = rgba_from_hex_string_4f32(string);
@@ -8979,7 +8979,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("R");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, r_string, "###r_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_rgba = v4f32((F32)f64_from_str8(string), rgba.y, rgba.z, rgba.w);
@@ -8991,7 +8991,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("G");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, g_string, "###g_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_rgba = v4f32(rgba.x, (F32)f64_from_str8(string), rgba.z, rgba.w);
@@ -9003,7 +9003,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("B");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, b_string, "###b_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_rgba = v4f32(rgba.x, rgba.y, (F32)f64_from_str8(string), rgba.w);
@@ -9016,7 +9016,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("H");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, h_string, "###h_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_hsva = v4f32((F32)f64_from_str8(string), hsva.y, hsva.z, hsva.w);
@@ -9027,7 +9027,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("S");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, s_string, "###s_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_hsva = v4f32(hsva.x, (F32)f64_from_str8(string), hsva.z, hsva.w);
@@ -9038,7 +9038,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("V");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, v_string, "###v_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_hsva = v4f32(hsva.x, hsva.y, (F32)f64_from_str8(string), hsva.w);
@@ -9050,7 +9050,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
{
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("A");
UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, a_string, "###a_edit");
if(sig.commit)
if(ui_committed(sig))
{
String8 string = str8(sv->txt_buffer, sv->txt_size);
Vec4F32 new_hsva = v4f32(hsva.x, hsva.y, hsva.z, (F32)f64_from_str8(string));
@@ -9075,7 +9075,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
UI_FocusHot((sv->cursor.y == 1 && sv->cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
{
UI_Signal preset_sig = df_icon_buttonf(DF_IconKind_Palette, 0, "Apply Preset");
if(preset_sig.clicked)
if(ui_clicked(preset_sig))
{
ui_ctx_menu_open(preset_ctx_menu_key, preset_sig.box->key, v2f32(0, dim_2f32(preset_sig.box->rect).y));
}
@@ -9084,7 +9084,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
// rjf: load-from-file
UI_FocusHot((sv->cursor.y == 1 && sv->cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off)
{
if(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Load From File").clicked)
if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Load From File")))
{
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
params.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PickFile);
@@ -9147,7 +9147,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
ui_set_next_corner_radius_11(ui_top_font_size()/4.f);
UI_Box *color_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground, "###color_box");
UI_Signal color_sig = ui_signal_from_box(color_box);
if(color_sig.hovering)
if(ui_hovering(color_sig))
{
ui_do_color_tooltip_hsva(hsva);
}
@@ -9155,7 +9155,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
ui_spacer(ui_em(0.3f, 1));
}
UI_Signal color_row_sig = ui_signal_from_box(color_row);
if(color_row_sig.clicked || color_row_sig.right_clicked)
if(ui_clicked(color_row_sig) || ui_right_clicked(color_row_sig))
{
ui_ctx_menu_open(color_ctx_menu_keys[color], color_row->key, v2f32(0, color_row->rect.y1-color_row->rect.y0));
sv->color_ctx_menu_color = color;
@@ -9163,7 +9163,7 @@ DF_VIEW_UI_FUNCTION_DEF(Theme)
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
}
if(color_row_sig.hovering) UI_Tooltip
if(ui_hovering(color_row_sig)) UI_Tooltip
{
ui_label(df_g_theme_color_display_string_table[color]);
}
+4
View File
@@ -440,6 +440,8 @@ w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
S16 wheel_delta = HIWORD(wParam);
OS_Event *event = w32_push_event(OS_EventKind_Scroll, window);
event->pos.x = (F32)LOWORD(lParam);
event->pos.y = (F32)HIWORD(lParam);
event->delta = v2f32(0.f, -(F32)wheel_delta);
}break;
@@ -447,6 +449,8 @@ w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
S16 wheel_delta = HIWORD(wParam);
OS_Event *event = w32_push_event(OS_EventKind_Scroll, window);
event->pos.x = (F32)LOWORD(lParam);
event->pos.y = (F32)HIWORD(lParam);
event->delta = v2f32((F32)wheel_delta, 0.f);
}break;
+15 -15
View File
@@ -96,7 +96,7 @@ ui_hover_label(String8 string)
{
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, string);
UI_Signal interact = ui_signal_from_box(box);
if(interact.hovering)
if(ui_hovering(interact))
{
box->flags |= UI_BoxFlag_DrawBorder;
}
@@ -271,7 +271,7 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
//- rjf: interact
UI_Signal sig = ui_signal_from_box(box);
if(!is_focus_active && (sig.double_clicked || sig.keyboard_clicked))
if(!is_focus_active && sig.f&(UI_SignalFlag_DoubleClicked|UI_SignalFlag_KeyboardPressed))
{
String8 edit_string = pre_edit_value;
edit_string.size = Min(edit_buffer_size, pre_edit_value.size);
@@ -282,14 +282,14 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
*cursor = txt_pt(1, edit_string.size+1);
*mark = txt_pt(1, 1);
}
if(is_focus_active && sig.keyboard_clicked)
if(is_focus_active && sig.f&UI_SignalFlag_KeyboardPressed)
{
ui_set_auto_focus_active_key(ui_key_zero());
sig.commit = 1;
sig.f |= UI_SignalFlag_Commit;
}
if(is_focus_active && sig.dragging)
if(is_focus_active && ui_dragging(sig))
{
if(sig.pressed)
if(ui_pressed(sig))
{
*mark = mouse_pt;
}
@@ -565,7 +565,7 @@ ui_sat_val_picker(F32 hue, F32 *out_sat, F32 *out_val, String8 string)
UI_Signal sig = ui_signal_from_box(box);
// rjf: click+draw behavior
if(sig.dragging)
if(ui_dragging(sig))
{
Vec2F32 dim = dim_2f32(box->rect);
*out_sat = (ui_mouse().x - box->rect.x0) / dim.x;
@@ -662,7 +662,7 @@ ui_hue_picker(F32 *out_hue, F32 sat, F32 val, String8 string)
UI_Signal sig = ui_signal_from_box(box);
// rjf: click+draw behavior
if(sig.dragging)
if(ui_dragging(sig))
{
Vec2F32 dim = dim_2f32(box->rect);
*out_hue = (ui_mouse().y - box->rect.y0) / dim.y;
@@ -740,7 +740,7 @@ ui_alpha_picker(F32 *out_alpha, String8 string)
UI_Signal sig = ui_signal_from_box(box);
// rjf: click+draw behavior
if(sig.dragging)
if(ui_dragging(sig))
{
Vec2F32 dim = dim_2f32(box->rect);
F32 drag_pct = (ui_mouse().y - box->rect.y0) / dim.y;
@@ -889,9 +889,9 @@ ui_table_begin(U64 column_pct_count, F32 **column_pcts, String8 string)
// rjf: boundary dragging
UI_Signal interact = ui_signal_from_box(box);
if(interact.dragging)
if(ui_dragging(interact))
{
if(interact.pressed)
if(ui_pressed(interact))
{
Vec2F32 v = v2f32(*left_pct_ptr, *right_pct_ptr);
ui_store_drag_struct(&v);
@@ -1228,9 +1228,9 @@ ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_ran
UI_ScrollPt start_pt;
F32 scroll_space_px;
};
if(scroller_sig.dragging)
if(ui_dragging(scroller_sig))
{
if(scroller_sig.pressed)
if(ui_pressed(scroller_sig))
{
UI_ScrollBarDragData drag_data = {pt, (floor_f32(dim_2f32(scroll_area_box->rect).v[axis])-floor_f32(dim_2f32(scroller_box->rect).v[axis]))};
ui_store_drag_struct(&drag_data);
@@ -1244,13 +1244,13 @@ ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_ran
ui_scroll_pt_target_idx(&new_pt, new_idx);
new_pt.off = 0;
}
if(min_scroll_sig.dragging || space_before_sig.dragging)
if(ui_dragging(min_scroll_sig) || ui_dragging(space_before_sig))
{
S64 new_idx = new_pt.idx-1;
new_idx = Clamp(idx_range.min, new_idx, idx_range.max);
ui_scroll_pt_target_idx(&new_pt, new_idx);
}
if(max_scroll_sig.dragging || space_after_sig.dragging)
if(ui_dragging(max_scroll_sig) || ui_dragging(space_after_sig))
{
S64 new_idx = new_pt.idx+1;
new_idx = Clamp(idx_range.min, new_idx, idx_range.max);
+316 -8
View File
@@ -1012,12 +1012,6 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
break;
}
}
//- rjf: tick click timers
for(Side side = (Side)0; side < Side_COUNT; side = (Side)(side + 1))
{
ui_state->time_since_last_click[side] += real_dt;
}
}
internal void
@@ -2378,8 +2372,321 @@ internal UI_Signal
ui_signal_from_box(UI_Box *box)
{
ProfBeginFunction();
UI_Signal result = {0};
result.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_event_flags();
//////////////////////////////
//- rjf: calculate possibly-clipped box rectangle
//
Rng2F32 rect = box->rect;
for(UI_Box *b = box->parent; !ui_box_is_nil(b); b = b->parent)
{
if(b->flags & UI_BoxFlag_Clip)
{
rect = intersect_2f32(rect, b->rect);
}
}
//////////////////////////////
//- rjf: determine if we're under the context menu or not
//
B32 ctx_menu_is_ancestor = 0;
ProfScope("check context menu ancestor")
{
for(UI_Box *parent = box; !ui_box_is_nil(parent); parent = parent->parent)
{
if(parent == ui_state->ctx_menu_root)
{
ctx_menu_is_ancestor = 1;
break;
}
}
}
//////////////////////////////
//- rjf: calculate blacklist rectangles
//
Rng2F32 blacklist_rect = {0};
if(!ctx_menu_is_ancestor && ui_state->ctx_menu_open)
{
blacklist_rect = ui_state->ctx_menu_root->rect;
}
//////////////////////////////
//- rjf: process events related to this box
//
B32 view_scrolled = 0;
for(OS_Event *evt = ui_state->events->first, *next = 0;
evt != 0;
evt = next)
{
B32 taken = 0;
next = evt->next;
//- rjf: skip disqualified events
if(!os_handle_match(evt->window, ui_state->window)) {continue;}
//- 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_Left);
B32 evt_key_is_mouse = (evt->key == OS_Key_LeftMouseButton ||
evt->key == OS_Key_MiddleMouseButton ||
evt->key == OS_Key_RightMouseButton);
sig.event_flags |= evt->flags;
//- rjf: mouse presses in box -> set hot/active; mark signal accordingly
if(box->flags & UI_BoxFlag_MouseClickable &&
evt->kind == OS_EventKind_Press &&
evt_mouse_in_bounds &&
evt_key_is_mouse)
{
ui_state->hot_box_key = box->key;
ui_state->active_box_key[evt_mouse_button_kind] = box->key;
sig.f |= (UI_SignalFlag_LeftPressed<<evt_mouse_button_kind);
ui_state->drag_start_mouse = evt->pos;
if(ui_key_match(box->key, ui_state->last_press_key[evt_mouse_button_kind]) &&
evt->timestamp_us-ui_state->last_press_timestamp_us[evt_mouse_button_kind] <= 1000000*os_double_click_time())
{
sig.f |= (UI_SignalFlag_LeftDoubleClicked<<evt_mouse_button_kind);
}
ui_state->last_press_key[evt_mouse_button_kind] = box->key;
ui_state->last_press_timestamp_us[evt_mouse_button_kind] = evt->timestamp_us;
taken = 1;
}
//- rjf: mouse releases in active box -> unset active; mark signal accordingly
if(box->flags & UI_BoxFlag_MouseClickable &&
evt->kind == OS_EventKind_Release &&
ui_key_match(ui_state->active_box_key[evt_mouse_button_kind], box->key) &&
evt_mouse_in_bounds &&
evt_key_is_mouse)
{
ui_state->active_box_key[evt_mouse_button_kind] = ui_key_zero();
sig.f |= (UI_SignalFlag_LeftReleased<<evt_mouse_button_kind);
sig.f |= (UI_SignalFlag_LeftClicked<<evt_mouse_button_kind);
taken = 1;
}
//- rjf: mouse releases outside active box -> unset hot/active
if(box->flags & UI_BoxFlag_MouseClickable &&
evt->kind == OS_EventKind_Release &&
ui_key_match(ui_state->active_box_key[evt_mouse_button_kind], box->key) &&
!evt_mouse_in_bounds &&
evt_key_is_mouse)
{
ui_state->hot_box_key = ui_key_zero();
ui_state->active_box_key[evt_mouse_button_kind] = ui_key_zero();
sig.f |= (UI_SignalFlag_LeftReleased<<evt_mouse_button_kind);
taken = 1;
}
//- rjf: focus is hot & keyboard click -> mark signal
if(box->flags & UI_BoxFlag_KeyboardClickable &&
is_focus_hot &&
evt->kind == OS_EventKind_Press &&
evt->key == OS_Key_Return)
{
sig.f |= UI_SignalFlag_KeyboardPressed;
taken = 1;
}
//- rjf: scrolling
if(box->flags & UI_BoxFlag_Scroll &&
evt->kind == OS_EventKind_Scroll &&
evt->flags != OS_EventFlag_Ctrl &&
evt_mouse_in_bounds)
{
Vec2F32 delta = evt->delta;
if(evt->flags & OS_EventFlag_Shift)
{
Swap(F32, delta.x, delta.y);
}
sig.scroll.x += (S16)(delta.x/30.f);
sig.scroll.y += (S16)(delta.y/30.f);
taken = 1;
}
//- rjf: view scrolling
if(box->flags & UI_BoxFlag_ViewScroll && box->first_touched_build_index != box->last_touched_build_index &&
evt->kind == OS_EventKind_Scroll &&
evt->flags != OS_EventFlag_Ctrl &&
evt_mouse_in_bounds)
{
Vec2F32 delta = evt->delta;
if(evt->flags & OS_EventFlag_Shift)
{
Swap(F32, delta.x, delta.y);
}
if(!(box->flags & UI_BoxFlag_ViewScrollX))
{
delta.x = 0;
}
if(!(box->flags & UI_BoxFlag_ViewScrollY))
{
delta.y = 0;
}
os_eat_event(ui_state->events, evt);
box->view_off_target.x += delta.x;
box->view_off_target.y += delta.y;
view_scrolled = 1;
taken = 1;
}
//- rjf: taken -> eat event
if(taken)
{
os_eat_event(ui_state->events, evt);
}
}
//////////////////////////////
//- rjf: process nav actions related to this box
//
{
for(UI_NavActionNode *n = ui_state->nav_actions->first, *next = 0;
n != 0;
n = next)
{
next = n->next;
UI_NavAction *action = &n->v;
B32 taken = 0;
if(is_focus_hot && box->flags & UI_BoxFlag_KeyboardClickable && action->flags & UI_NavActionFlag_Copy)
{
ui_state->clipboard_copy_key = box->key;
taken = 1;
}
if(box->flags & UI_BoxFlag_Clickable && box->fastpath_codepoint != 0)
{
B32 ancestor_is_focused = 0;
for(UI_Box *parent = box->parent; !ui_box_is_nil(parent); parent = parent->parent)
{
if(parent->flags & UI_BoxFlag_FocusActive)
{
ancestor_is_focused = 1;
if(parent->flags & UI_BoxFlag_FocusActiveDisabled ||
!ui_key_match(parent->default_nav_focus_active_key, ui_key_zero()))
{
ancestor_is_focused = 0;
break;
}
}
}
if(ancestor_is_focused && action->insertion.size != 0)
{
Temp scratch = scratch_begin(0, 0);
String32 insertion32 = str32_from_8(scratch.arena, action->insertion);
if(insertion32.size == 1 && insertion32.str[0] == box->fastpath_codepoint)
{
taken = 1;
sig.f |= UI_SignalFlag_Clicked|UI_SignalFlag_Pressed;
}
scratch_end(scratch);
}
}
if(taken)
{
ui_nav_eat_action_node(ui_nav_actions(), n);
}
}
}
//////////////////////////////
//- rjf: clamp view scrolling
//
if(view_scrolled && box->flags & UI_BoxFlag_ViewClamp)
{
Vec2F32 max_view_off_target =
{
ClampBot(0, box->view_bounds.x - box->fixed_size.x),
ClampBot(0, box->view_bounds.y - box->fixed_size.y),
};
if(box->flags & UI_BoxFlag_ViewClampX) { box->view_off_target.x = Clamp(0, box->view_off_target.x, max_view_off_target.x); }
if(box->flags & UI_BoxFlag_ViewClampY) { box->view_off_target.y = Clamp(0, box->view_off_target.y, max_view_off_target.y); }
}
//////////////////////////////
//- rjf: active -> dragging
//
for(EachEnumVal(UI_MouseButtonKind, k))
{
if(ui_key_match(ui_state->active_box_key[k], box->key))
{
sig.f |= (UI_SignalFlag_LeftDragging<<k);
}
}
//////////////////////////////
//- rjf: mouse is over this box's rect -> always mark mouse-over
//
{
if(contains_2f32(rect, ui_state->mouse) &&
!contains_2f32(blacklist_rect, ui_state->mouse))
{
sig.f |= UI_SignalFlag_MouseOver;
}
}
//////////////////////////////
//- rjf: mouse is over this box's rect, no other hot key? -> set hot key, mark hovering
//
{
if(contains_2f32(rect, ui_state->mouse) &&
!contains_2f32(blacklist_rect, ui_state->mouse) &&
(ui_key_match(ui_state->hot_box_key, ui_key_zero()) || ui_key_match(ui_state->hot_box_key, box->key)) &&
(ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Left], ui_key_zero()) || ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Left], box->key)) &&
(ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Middle], ui_key_zero()) || ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Middle], box->key)) &&
(ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Right], ui_key_zero()) || ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Right], box->key)))
{
ui_state->hot_box_key = box->key;
sig.f |= UI_SignalFlag_Hovering;
}
}
//////////////////////////////
//- rjf: clicking on something outside the context menu kills the context menu
//
if(!ctx_menu_is_ancestor && sig.f & (UI_SignalFlag_LeftPressed|UI_SignalFlag_RightPressed|UI_SignalFlag_MiddlePressed))
{
ui_ctx_menu_close();
}
//////////////////////////////
//- rjf: get default nav ancestor
//
UI_Box *default_nav_parent = &ui_g_nil_box;
for(UI_Box *p = ui_top_parent(); !ui_box_is_nil(p); p = p->parent)
{
if(p->flags & UI_BoxFlag_DefaultFocusNav)
{
default_nav_parent = p;
break;
}
}
//////////////////////////////
//- rjf: clicking in default nav -> set navigation state to this box
//
if(box->flags & UI_BoxFlag_ClickToFocus && sig.f&UI_SignalFlag_Pressed && !ui_box_is_nil(default_nav_parent))
{
default_nav_parent->default_nav_focus_next_hot_key = box->key;
if(!ui_key_match(default_nav_parent->default_nav_focus_active_key, box->key))
{
default_nav_parent->default_nav_focus_next_active_key = ui_key_zero();
}
}
ProfEnd();
return sig;
#if 0
ProfBeginFunction();
UI_Signal result = {box};
result.event_flags = os_get_event_flags();
B32 disabled = !!(box->flags & UI_BoxFlag_Disabled);
B32 is_focused = !!(box->flags & UI_BoxFlag_FocusHot) && !(box->flags & UI_BoxFlag_FocusHotDisabled);
@@ -2745,6 +3052,7 @@ ui_signal_from_box(UI_Box *box)
ProfEnd();
return result;
#endif
}
////////////////////////////////
+67 -12
View File
@@ -351,24 +351,79 @@ struct UI_BoxList
U64 count;
};
typedef U32 UI_SignalFlags;
enum
{
// rjf: mouse press -> box was pressed while hovering
UI_SignalFlag_LeftPressed = (1<<0),
UI_SignalFlag_MiddlePressed = (1<<1),
UI_SignalFlag_RightPressed = (1<<2),
// rjf: dragging -> box was previously pressed, user is still holding button
UI_SignalFlag_LeftDragging = (1<<3),
UI_SignalFlag_MiddleDragging = (1<<4),
UI_SignalFlag_RightDragging = (1<<5),
// rjf: released -> box was previously pressed & user released, in or out of bounds
UI_SignalFlag_LeftReleased = (1<<6),
UI_SignalFlag_MiddleReleased = (1<<7),
UI_SignalFlag_RightReleased = (1<<8),
// rjf: clicked -> box was previously pressed & user released, in bounds
UI_SignalFlag_LeftClicked = (1<<9),
UI_SignalFlag_MiddleClicked = (1<<10),
UI_SignalFlag_RightClicked = (1<<11),
// rjf: double clicked -> box was previously clicked, pressed again
UI_SignalFlag_LeftDoubleClicked = (1<<12),
UI_SignalFlag_MiddleDoubleClicked = (1<<13),
UI_SignalFlag_RightDoubleClicked = (1<<14),
// rjf: triple clicked -> box was previously clicked twice, pressed again
UI_SignalFlag_LeftTripleClicked = (1<<15),
UI_SignalFlag_MiddleTripleClicked = (1<<16),
UI_SignalFlag_RightTripleClicked = (1<<17),
// rjf: keyboard pressed -> box had focus, user activated via their keyboard
UI_SignalFlag_KeyboardPressed = (1<<18),
// rjf: passive mouse info
UI_SignalFlag_Hovering = (1<<19), // hovering specifically this box
UI_SignalFlag_MouseOver = (1<<20), // mouse is over, but may be occluded
// rjf: committing state changes via user interaction
UI_SignalFlag_Commit = (1<<21),
// rjf: high-level combos
UI_SignalFlag_Pressed = UI_SignalFlag_LeftPressed|UI_SignalFlag_KeyboardPressed,
UI_SignalFlag_Released = UI_SignalFlag_LeftReleased,
UI_SignalFlag_Clicked = UI_SignalFlag_LeftClicked|UI_SignalFlag_KeyboardPressed,
UI_SignalFlag_DoubleClicked = UI_SignalFlag_LeftDoubleClicked,
UI_SignalFlag_TripleClicked = UI_SignalFlag_LeftTripleClicked,
UI_SignalFlag_Dragging = UI_SignalFlag_LeftDragging,
};
typedef struct UI_Signal UI_Signal;
struct UI_Signal
{
UI_Box *box;
OS_EventFlags event_flags;
Vec2S16 scroll;
B8 clicked :1;
B8 keyboard_clicked :1;
B8 double_clicked :1;
B8 right_clicked :1;
B8 pressed :1;
B8 released :1;
B8 dragging :1;
B8 hovering :1;
B8 mouse_over :1;
B8 commit :1;
UI_SignalFlags f;
};
#define ui_pressed(s) !!((s).f&UI_SignalFlag_Pressed)
#define ui_clicked(s) !!((s).f&UI_SignalFlag_Clicked)
#define ui_released(s) !!((s).f&UI_SignalFlag_Released)
#define ui_double_clicked(s) !!((s).f&UI_SignalFlag_DoubleClicked)
#define ui_triple_clicked(s) !!((s).f&UI_SignalFlag_TripleClicked)
#define ui_middle_clicked(s) !!((s).f&UI_SignalFlag_MiddleClicked)
#define ui_right_clicked(s) !!((s).f&UI_SignalFlag_RightClicked)
#define ui_dragging(s) !!((s).f&UI_SignalFlag_Dragging)
#define ui_hovering(s) !!((s).f&UI_SignalFlag_Hovering)
#define ui_mouse_over(s) !!((s).f&UI_SignalFlag_MouseOver)
#define ui_committed(s) !!((s).f&UI_SignalFlag_Commit)
typedef struct UI_Nav UI_Nav;
struct UI_Nav
{
@@ -429,8 +484,8 @@ struct UI_State
UI_Key hot_box_key;
UI_Key active_box_key[UI_MouseButtonKind_COUNT];
UI_Key clipboard_copy_key;
F32 time_since_last_click[UI_MouseButtonKind_COUNT];
UI_Key last_click_key[UI_MouseButtonKind_COUNT];
U64 last_press_timestamp_us[UI_MouseButtonKind_COUNT];
UI_Key last_press_key[UI_MouseButtonKind_COUNT];
Vec2F32 drag_start_mouse;
Arena *drag_state_arena;
String8 drag_state_data;