diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 5adc9838..e629835e 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -2992,7 +2992,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D case DF_EntityKind_Module: { DF_Entity *bin_file = df_binary_file_from_module(entity); - if(df_icon_buttonf(DF_IconKind_Module, 0, "Inspect Binary File Memory").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Module, 0, "Inspect Binary File Memory"))) { DF_CmdParams params = df_cmd_params_from_panel(ws, panel); params.entity = df_handle_from_entity(bin_file); @@ -3000,7 +3000,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PendingEntity)); ui_ctx_menu_close(); } - if(df_icon_buttonf(DF_IconKind_Module, 0, "View Binary File Disassembly").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Module, 0, "View Binary File Disassembly"))) { DF_CmdParams params = df_cmd_params_from_panel(ws, panel); params.entity = df_handle_from_entity(bin_file); @@ -3011,7 +3011,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D }break; case DF_EntityKind_Process: { - if(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Process Log").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Process Log"))) { DF_Entity *log = df_log_from_entity(entity); DF_CmdParams params = df_cmd_params_from_panel(ws, panel); @@ -3023,7 +3023,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D }break; case DF_EntityKind_Thread: { - if(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Thread Log").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Thread Log"))) { DF_Entity *log = df_log_from_entity(entity); DF_CmdParams params = df_cmd_params_from_panel(ws, panel); @@ -3047,7 +3047,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D //- rjf: toggles for(U64 idx = 0; idx < ArrayCount(DEV_toggle_table); idx += 1) { - if(df_icon_button(*DEV_toggle_table[idx].value_ptr ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, 0, DEV_toggle_table[idx].name).clicked) + if(ui_clicked(df_icon_button(*DEV_toggle_table[idx].value_ptr ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow, 0, DEV_toggle_table[idx].name))) { *DEV_toggle_table[idx].value_ptr ^= 1; } @@ -3194,7 +3194,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(op_flags & DF_EntityOpFlag_Rename) { UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &ws->entity_ctx_menu_input_cursor, &ws->entity_ctx_menu_input_mark, ws->entity_ctx_menu_input_buffer, sizeof(ws->entity_ctx_menu_input_buffer), &ws->entity_ctx_menu_input_size, 0, entity->name, "%S###entity_name_edit_%p", df_g_entity_kind_name_label_table[entity->kind], entity); - if(sig.commit) + if(ui_committed(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3210,7 +3210,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { DF_Entity *condition = df_entity_child_from_kind(entity, DF_EntityKind_Condition); UI_Signal sig = df_line_editf(DF_LineEditFlag_Border|DF_LineEditFlag_CodeContents, 0, 0, &ws->entity_ctx_menu_input_cursor, &ws->entity_ctx_menu_input_mark, ws->entity_ctx_menu_input_buffer, sizeof(ws->entity_ctx_menu_input_buffer), &ws->entity_ctx_menu_input_size, 0, condition->name, "Condition###entity_cond_edit_%p", entity); - if(sig.commit) + if(ui_committed(sig)) { String8 new_string = str8(ws->entity_ctx_menu_input_buffer, ws->entity_ctx_menu_input_size); if(new_string.size != 0) @@ -3239,7 +3239,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { DF_Entity *exe = df_entity_child_from_kind(entity, DF_EntityKind_Executable); UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &ws->entity_ctx_menu_input_cursor, &ws->entity_ctx_menu_input_mark, ws->entity_ctx_menu_input_buffer, sizeof(ws->entity_ctx_menu_input_buffer), &ws->entity_ctx_menu_input_size, 0, exe->name, "Executable###entity_exe_edit_%p", entity); - if(sig.commit) + if(ui_committed(sig)) { String8 new_string = str8(ws->entity_ctx_menu_input_buffer, ws->entity_ctx_menu_input_size); if(new_string.size != 0) @@ -3268,7 +3268,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { DF_Entity *args = df_entity_child_from_kind(entity, DF_EntityKind_Arguments); UI_Signal sig = df_line_editf(DF_LineEditFlag_Border, 0, 0, &ws->entity_ctx_menu_input_cursor, &ws->entity_ctx_menu_input_mark, ws->entity_ctx_menu_input_buffer, sizeof(ws->entity_ctx_menu_input_buffer), &ws->entity_ctx_menu_input_size, 0, args->name, "Arguments###entity_args_edit_%p", entity); - if(sig.commit) + if(ui_committed(sig)) { String8 new_string = str8(ws->entity_ctx_menu_input_buffer, ws->entity_ctx_menu_input_size); if(new_string.size != 0) @@ -3293,20 +3293,20 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: copy name - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Name").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Name"))) { os_set_clipboard_text(display_name); ui_ctx_menu_close(); } // rjf: is command line only? -> make permanent - if(entity->cfg_src == DF_CfgSrc_CommandLine && df_icon_buttonf(DF_IconKind_Save, 0, "Save To Profile").clicked) + if(entity->cfg_src == DF_CfgSrc_CommandLine && ui_clicked(df_icon_buttonf(DF_IconKind_Save, 0, "Save To Profile"))) { df_entity_equip_cfg_src(entity, DF_CfgSrc_Profile); } // rjf: duplicate - if(op_flags & DF_EntityOpFlag_Duplicate && df_icon_buttonf(DF_IconKind_XSplit, 0, "Duplicate").clicked) + if(op_flags & DF_EntityOpFlag_Duplicate && ui_clicked(df_icon_buttonf(DF_IconKind_XSplit, 0, "Duplicate"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3316,7 +3316,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: edit - if(op_flags & DF_EntityOpFlag_Edit && df_icon_buttonf(DF_IconKind_Pencil, 0, "Edit").clicked) + if(op_flags & DF_EntityOpFlag_Edit && ui_clicked(df_icon_buttonf(DF_IconKind_Pencil, 0, "Edit"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3326,7 +3326,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: deletion - if(op_flags & DF_EntityOpFlag_Delete && df_icon_buttonf(DF_IconKind_Trash, 0, "Delete").clicked) + if(op_flags & DF_EntityOpFlag_Delete && ui_clicked(df_icon_buttonf(DF_IconKind_Trash, 0, "Delete"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3339,14 +3339,14 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(op_flags & DF_EntityOpFlag_Enable) { B32 is_enabled = entity->b32; - if(!is_enabled && df_icon_buttonf(DF_IconKind_CheckHollow, 0, "Enable###enabler").clicked) + if(!is_enabled && ui_clicked(df_icon_buttonf(DF_IconKind_CheckHollow, 0, "Enable###enabler"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_EnableEntity)); } - if(is_enabled && df_icon_buttonf(DF_IconKind_CheckFilled, 0, "Disable###enabler").clicked) + if(is_enabled && ui_clicked(df_icon_buttonf(DF_IconKind_CheckFilled, 0, "Disable###enabler"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3364,14 +3364,14 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D color.y *= 0.7f; color.z *= 0.7f; ui_set_next_background_color(color); - if(is_frozen && df_icon_buttonf(DF_IconKind_Locked, 0, "Thaw###freeze_thaw").clicked) + if(is_frozen && ui_clicked(df_icon_buttonf(DF_IconKind_Locked, 0, "Thaw###freeze_thaw"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_Entity); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ThawEntity)); } - if(!is_frozen && df_icon_buttonf(DF_IconKind_Unlocked, 0, "Freeze###freeze_thaw").clicked) + if(!is_frozen && ui_clicked(df_icon_buttonf(DF_IconKind_Unlocked, 0, "Freeze###freeze_thaw"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3384,7 +3384,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(entity->flags & DF_EntityFlag_HasTextPoint) { DF_Entity *file_ancestor = df_entity_ancestor_from_kind(entity, DF_EntityKind_File); - if(!df_entity_is_nil(file_ancestor) && df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To Location").clicked) + if(!df_entity_is_nil(file_ancestor) && ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To Location"))) { Temp scratch = scratch_begin(&arena, 1); DF_CmdParams params = df_cmd_params_from_window(ws); @@ -3403,7 +3403,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { DF_CtrlCtx ctrl_ctx = df_ctrl_ctx(); DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread); - if(entity->vaddr != 0 && !df_entity_is_nil(thread) && df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To Location").clicked) + if(entity->vaddr != 0 && !df_entity_is_nil(thread) && ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To Location"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(df_entity_ancestor_from_kind(thread, DF_EntityKind_Process)); @@ -3425,7 +3425,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D case DF_EntityKind_File: { if(entity->flags & DF_EntityFlag_IsFolder && - df_icon_buttonf(DF_IconKind_FolderOpenOutline, 0, "Open File In Folder").clicked) + ui_clicked(df_icon_buttonf(DF_IconKind_FolderOpenOutline, 0, "Open File In Folder"))) { String8 path = df_full_path_from_entity(scratch.arena, entity); String8 path_w_slash = push_str8f(scratch.arena, "%S/", path); @@ -3445,7 +3445,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } if(!(entity->flags & DF_EntityFlag_IsFolder) && !(entity->flags & DF_EntityFlag_IsMissing) && - df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To File").clicked) + ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To File"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.file_path = df_full_path_from_entity(scratch.arena, entity); @@ -3468,7 +3468,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { df_icon_buttonf(DF_IconKind_Thread, 0, "[Selected]###select_entity"); } - else if(df_icon_buttonf(DF_IconKind_Thread, 0, "Select###select_entity").clicked) + else if(ui_clicked(df_icon_buttonf(DF_IconKind_Thread, 0, "Select###select_entity"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3478,7 +3478,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } } - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy ID").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy ID"))) { U32 ctrl_id = entity->ctrl_id; String8 string = push_str8f(scratch.arena, "%i", (int)ctrl_id); @@ -3488,7 +3488,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(entity->kind == DF_EntityKind_Thread) { - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Instruction Pointer Address").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Instruction Pointer Address"))) { U64 rip = df_query_cached_rip_from_thread(entity); String8 string = push_str8f(scratch.arena, "0x%I64x", rip); @@ -3499,7 +3499,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(entity->kind == DF_EntityKind_Thread) { - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Call Stack").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Call Stack"))) { DF_Entity *process = df_entity_ancestor_from_kind(entity, DF_EntityKind_Process); CTRL_Unwind unwind = df_query_cached_unwind_from_thread(entity); @@ -3531,7 +3531,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(entity->kind == DF_EntityKind_Thread) { - if(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Find").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Find"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3545,25 +3545,25 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D case DF_EntityKind_Module: { UI_Signal copy_full_path_sig = df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Full Path"); - if(copy_full_path_sig.clicked) + if(ui_clicked(copy_full_path_sig)) { String8 string = entity->name; os_set_clipboard_text(string); ui_ctx_menu_close(); } - if(copy_full_path_sig.hovering) UI_Tooltip + if(ui_hovering(copy_full_path_sig)) UI_Tooltip { String8 string = entity->name; ui_label(string); } - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Base Address").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Base Address"))) { Rng1U64 vaddr_rng = entity->vaddr_rng; String8 string = push_str8f(scratch.arena, "0x%I64x", vaddr_rng.min); os_set_clipboard_text(string); ui_ctx_menu_close(); } - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Address Range Size").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Address Range Size"))) { Rng1U64 vaddr_rng = entity->vaddr_rng; String8 string = push_str8f(scratch.arena, "0x%I64x", dim_1u64(vaddr_rng)); @@ -3574,7 +3574,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D case DF_EntityKind_Target: { - if(df_icon_buttonf(DF_IconKind_Play, 0, "Launch And Run").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Play, 0, "Launch And Run"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3582,7 +3582,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_LaunchAndRun)); ui_ctx_menu_close(); } - if(df_icon_buttonf(DF_IconKind_PlayStepForward, 0, "Launch And Initialize").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_PlayStepForward, 0, "Launch And Initialize"))) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -3627,7 +3627,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_BoxFlag_DrawActiveEffects, "###color_preset_%i", (int)preset_idx); UI_Signal sig = ui_signal_from_box(box); - if(sig.clicked) + if(ui_clicked(sig)) { Vec3F32 hsv = hsv_from_rgb(v3f32(presets[preset_idx].x, presets[preset_idx].y, presets[preset_idx].z)); Vec4F32 hsva = v4f32(hsv.x, hsv.y, hsv.z, 1); @@ -3653,7 +3653,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_Row UI_Padding(ui_pct(1, 0)) UI_PrefWidth(ui_em(12.f, 1.f)) UI_CornerRadius(8.f) { - if(df_icon_buttonf(DF_IconKind_Trash, 0, "Remove Color").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Trash, 0, "Remove Color###color_toggle"))) { entity->flags &= ~DF_EntityFlag_HasColor; } @@ -3661,7 +3661,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_spacer(ui_em(1.5f, 1.f)); } - if(!entity_has_color && df_icon_buttonf(DF_IconKind_Palette, 0, "Equip With Color").clicked) + if(!entity_has_color && ui_clicked(df_icon_buttonf(DF_IconKind_Palette, 0, "Apply Color###color_toggle"))) { df_entity_equip_color_rgba(entity, v4f32(1, 1, 1, 1)); } @@ -3701,7 +3701,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: copy name - if(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Name").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Name"))) { os_set_clipboard_text(display_name); ui_ctx_menu_close(); @@ -3712,12 +3712,12 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { UI_Signal copy_full_path_sig = df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Full Path"); String8 full_path = df_full_path_from_entity(scratch.arena, entity); - if(copy_full_path_sig.clicked) + if(ui_clicked(copy_full_path_sig)) { os_set_clipboard_text(full_path); ui_ctx_menu_close(); } - if(copy_full_path_sig.hovering) UI_Tooltip + if(ui_hovering(copy_full_path_sig)) UI_Tooltip { ui_label(full_path); } @@ -3726,7 +3726,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D // rjf: filter controls if(view->spec->info.flags & DF_ViewSpecFlag_CanFilter) { - if(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Filter)).clicked) + if(ui_clicked(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Filter)))) { DF_CmdParams params = df_cmd_params_from_window(ws); { @@ -3736,7 +3736,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Filter)); ui_ctx_menu_close(); } - if(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ClearFilter)).clicked) + if(ui_clicked(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ClearFilter)))) { DF_CmdParams params = df_cmd_params_from_window(ws); { @@ -3749,7 +3749,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: close tab - if(df_icon_buttonf(DF_IconKind_X, 0, "Close Tab").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close Tab"))) { DF_CmdParams params = df_cmd_params_from_window(ws); { @@ -3793,7 +3793,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { UI_CornerRadius00(ui_top_font_size()*0.25f) UI_CornerRadius01(ui_top_font_size()*0.25f) - if(ui_buttonf("Cancel").clicked || os_key_press(ui_events(), ui_window(), 0, OS_Key_Esc)) + if(ui_clicked(ui_buttonf("Cancel")) || os_key_press(ui_events(), ui_window(), 0, OS_Key_Esc)) { DF_CmdParams p = df_cmd_params_zero(); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ConfirmCancel)); @@ -3803,7 +3803,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_BackgroundColor(df_rgba_from_theme_color(DF_ThemeColor_ActionBackground)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_ActionText)) UI_BorderColor(df_rgba_from_theme_color(DF_ThemeColor_ActionBorder)) - if(ui_buttonf("OK").clicked || os_key_press(ui_events(), ui_window(), 0, OS_Key_Return)) + if(ui_clicked(ui_buttonf("OK")) || os_key_press(ui_events(), ui_window(), 0, OS_Key_Return)) { DF_CmdParams p = df_cmd_params_zero(); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ConfirmAccept)); @@ -3989,7 +3989,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_label(item->kind_string); } UI_Signal item_sig = ui_signal_from_box(item_box); - if(item_sig.clicked) + if(ui_clicked(item_sig)) { UI_NavAction autocomp_action = {UI_NavActionFlag_ReplaceAndCommit, {0}, (UI_NavDeltaUnit)0, push_str8_copy(ui_build_arena(), item->string)}; ui_nav_action_list_push(ui_build_arena(), ui_nav_actions(), autocomp_action); @@ -4185,7 +4185,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_Signal sig = {0}; UI_TextColor(color) sig = df_icon_buttonf(DF_IconKind_Target, 0, "%S##%p", target_name, target); - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(target); @@ -4254,11 +4254,11 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_TextAlignment(UI_TextAlign_Center) { UI_Signal url_sig = ui_buttonf("github.com/EpicGames/raddebugger"); - if(url_sig.hovering) UI_Tooltip + if(ui_hovering(url_sig)) UI_Tooltip { ui_labelf("Copy To Clipboard"); } - if(url_sig.clicked) + if(ui_clicked(url_sig)) { os_set_clipboard_text(str8_lit("https://github.com/EpicGames/raddebugger")); } @@ -4346,12 +4346,12 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_Signal sig = df_menu_bar_button(items[idx].name); if(menu_open) { - if((sig.hovering && !ui_ctx_menu_is_open(items[idx].menu_key)) || (open_menu_idx_prime == idx && open_menu_idx_prime != open_menu_idx)) + if((ui_hovering(sig) && !ui_ctx_menu_is_open(items[idx].menu_key)) || (open_menu_idx_prime == idx && open_menu_idx_prime != open_menu_idx)) { ui_ctx_menu_open(items[idx].menu_key, sig.box->key, v2f32(0, sig.box->rect.y1-sig.box->rect.y0)); } } - else if(sig.pressed || alt_fastpath_key) + else if(ui_pressed(sig) || alt_fastpath_key) { if(ui_ctx_menu_is_open(items[idx].menu_key)) { @@ -4382,7 +4382,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_Key key = ui_key_from_stringf(ui_key_zero(), "task_%p", task); UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawHotEffects|UI_BoxFlag_DrawText|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground|UI_BoxFlag_Clickable, key); UI_Signal sig = ui_signal_from_box(box); - if(sig.hovering) UI_Tooltip + if(ui_hovering(sig)) UI_Tooltip { ui_label(raddbg_path); } @@ -4412,7 +4412,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_label(str8_skip_last_slash(user_path)); } UI_Signal user_sig = ui_signal_from_box(user_box); - if(user_sig.clicked) + if(ui_clicked(user_sig)) { DF_CmdParams p = df_cmd_params_from_window(ws); p.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenUser); @@ -4442,7 +4442,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_label(str8_skip_last_slash(prof_path)); } UI_Signal prof_sig = ui_signal_from_box(prof_box); - if(prof_sig.clicked) + if(ui_clicked(prof_sig)) { DF_CmdParams p = df_cmd_params_from_window(ws); p.cmd_spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenProfile); @@ -4470,14 +4470,14 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(can_play || !have_targets) UI_TextAlignment(UI_TextAlign_Center) UI_Flags((can_play ? 0 : UI_BoxFlag_Disabled)) { UI_Signal sig = ui_button(df_g_icon_kind_text_table[DF_IconKind_Play]); - if(sig.hovering && can_play == 0) + if(ui_hovering(sig) && !can_play) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) ui_labelf("Disabled: %s", have_targets ? "Targets are currently running" : "No active targets exist"); } - if(sig.hovering && can_play) + if(ui_hovering(sig) && can_play) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) @@ -4497,7 +4497,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } } } - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Run)); @@ -4507,7 +4507,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(!can_play && have_targets && !can_send_signal) UI_TextAlignment(UI_TextAlign_Center) { UI_Signal sig = ui_button(df_g_icon_kind_text_table[DF_IconKind_Redo]); - if(sig.hovering) + if(ui_hovering(sig)) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) @@ -4528,7 +4528,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } } } - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Restart)); @@ -4538,21 +4538,21 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_TextAlignment(UI_TextAlign_Center) UI_Flags(can_pause ? 0 : UI_BoxFlag_Disabled) { UI_Signal sig = ui_button(df_g_icon_kind_text_table[DF_IconKind_Pause]); - if(sig.hovering && can_pause == 0) + if(ui_hovering(sig) && !can_pause) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) ui_labelf("Disabled: Already halted"); } - if(sig.hovering && can_pause) + if(ui_hovering(sig) && can_pause) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) ui_labelf("Halt all target processes"); } - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Halt)); @@ -4565,21 +4565,21 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { sig = ui_button(df_g_icon_kind_text_table[DF_IconKind_Stop]); } - if(sig.hovering && can_stop == 0) + if(ui_hovering(sig) && !can_stop) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) ui_labelf("Disabled: No processes are running"); } - if(sig.hovering && can_stop) + if(ui_hovering(sig) && can_stop) { UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) ui_labelf("Kill all target processes"); } - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Kill)); @@ -4975,7 +4975,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D 0, str8(view->query_buffer, view->query_string_size), str8_lit("###query_text_input")); - if(sig.pressed) + if(ui_pressed(sig)) { ws->query_view_selected = 1; } @@ -5022,7 +5022,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D //- rjf: take fallthrough interaction in query view { UI_Signal sig = ui_signal_from_box(query_container_box); - if(sig.pressed) + if(ui_pressed(sig)) { ws->query_view_selected = 1; } @@ -5221,7 +5221,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D B32 row_is_expanded = df_expand_key_is_set(&eval_view->expand_tree_table, row->key); if(row->flags & DF_EvalVizRowFlag_CanExpand) UI_PrefWidth(ui_em(1.5f, 1)) UI_Flags(UI_BoxFlag_DrawSideLeft*(row->depth>0)) - if(ui_expanderf(row_is_expanded, "###%I64x_%I64x_is_expanded", row->key.parent_hash, row->key.child_num).pressed) + if(ui_pressed(ui_expanderf(row_is_expanded, "###%I64x_%I64x_is_expanded", row->key.parent_hash, row->key.child_num))) { df_expand_set_expansion(eval_view->arena, &eval_view->expand_tree_table, row->parent_key, row->key, !row_is_expanded); } @@ -5250,7 +5250,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D DF_LineEditFlag_PreferDisplayString| DF_LineEditFlag_Border, 0, 0, &ws->hover_eval_txt_cursor, &ws->hover_eval_txt_mark, ws->hover_eval_txt_buffer, sizeof(ws->hover_eval_txt_buffer), &ws->hover_eval_txt_size, 0, row->edit_value, "%S###val_%I64x", row->display_value, row_hash); - if(sig.commit) + if(ui_committed(sig)) { String8 commit_string = str8(ws->hover_eval_txt_buffer, ws->hover_eval_txt_size); DF_Eval write_eval = df_eval_from_string(scratch.arena, scope, &ctrl_ctx, &parse_ctx, &eval_string2expr_map_nil, commit_string); @@ -5285,11 +5285,11 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_CornerRadius11(0) { UI_Signal watch_sig = df_icon_buttonf(DF_IconKind_List, 0, "###watch_hover_eval"); - if(watch_sig.hovering) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) + if(ui_hovering(watch_sig)) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) { ui_labelf("Add the hovered expression to an opened watch view."); } - if(watch_sig.clicked) + if(ui_clicked(watch_sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.string = expr; @@ -5303,7 +5303,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_CornerRadius11(corner_radius) { UI_Signal pin_sig = df_icon_buttonf(DF_IconKind_Pin, 0, "###pin_hover_eval"); - if(pin_sig.hovering) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) + if(ui_hovering(pin_sig)) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Main)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) UI_CornerRadius00(0) UI_CornerRadius01(0) UI_CornerRadius10(0) @@ -5311,7 +5311,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { ui_labelf("Pin the hovered expression to this code location."); } - if(pin_sig.clicked) + if(ui_clicked(pin_sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); if(ws->hover_eval_vaddr != 0) @@ -5340,7 +5340,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D //- rjf: interact { UI_Signal hover_eval_sig = ui_signal_from_box(hover_eval_box); - if(hover_eval_sig.mouse_over) + if(ui_mouse_over(hover_eval_sig)) { ws->hover_eval_last_frame_idx = df_frame_index(); } @@ -5395,19 +5395,19 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_set_next_hover_cursor(split_axis == Axis2_X ? OS_Cursor_LeftRight : OS_Cursor_UpDown); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "###%p_%p", min_child, max_child); UI_Signal sig = ui_signal_from_box(box); - if(sig.double_clicked) + if(ui_double_clicked(sig)) { ui_kill_action(); F32 sum_pct = min_child->size_pct_of_parent_target.v[split_axis] + max_child->size_pct_of_parent_target.v[split_axis]; min_child->size_pct_of_parent_target.v[split_axis] = 0.5f * sum_pct; max_child->size_pct_of_parent_target.v[split_axis] = 0.5f * sum_pct; } - else if(sig.pressed) + else if(ui_pressed(sig)) { Vec2F32 v = {min_child->size_pct_of_parent_target.v[split_axis], max_child->size_pct_of_parent_target.v[split_axis]}; ui_store_drag_struct(&v); } - else if(sig.dragging) + else if(ui_dragging(sig)) { Vec2F32 v = *ui_get_drag_struct(Vec2F32); Vec2F32 mouse_delta = ui_drag_delta(); @@ -5435,7 +5435,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D max_child->size_pct_of_parent.v[split_axis] = max_child->size_pct_of_parent_target.v[split_axis] = max_pct__after; is_changing_panel_boundaries = 1; } - if(sig.released || sig.double_clicked) + if(ui_released(sig) || ui_double_clicked(sig)) { df_panel_notify_mutation(ws, min_child); } @@ -5536,7 +5536,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D 0, str8(view->query_buffer, view->query_string_size), str8_lit("###filter_text_input")); - 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)); @@ -5747,7 +5747,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D //- rjf: consume panel fallthrough interaction events // UI_Signal panel_sig = ui_signal_from_box(panel_box); - if(panel_sig.pressed) + if(ui_pressed(panel_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)); @@ -5827,7 +5827,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ui_label(label); } UI_Signal sig = ui_signal_from_box(tab_list_item_box); - if(sig.clicked) + if(ui_clicked(sig)) { next_selected_tab_view = view; DF_CmdParams p = df_cmd_params_from_panel(ws, panel); @@ -5840,7 +5840,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D if(panel->tab_view_count > 5) UI_PrefWidth(ui_em(2.25f, 1.f)) UI_PrefHeight(ui_px(tab_bar_vheight, 1)) { UI_Signal sig = df_icon_buttonf(DF_IconKind_List, 0, "###tab_list_%p", panel); - if(sig.clicked) + if(ui_clicked(sig)) { if(ui_ctx_menu_is_open(tab_list_ctx_menu_key)) { @@ -5922,7 +5922,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D UI_BackgroundColor(v4f32(0, 0, 0, 0)) UI_CornerRadius00(0) UI_CornerRadius01(0) - if(ui_buttonf("%S###close_view_%p", df_g_icon_kind_text_table[DF_IconKind_X], view).clicked) + if(ui_clicked(ui_buttonf("%S###close_view_%p", df_g_icon_kind_text_table[DF_IconKind_X], view))) { DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseTab)); @@ -5932,13 +5932,13 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D // rjf: consume events for tab clicking { UI_Signal sig = ui_signal_from_box(tab_box); - if(sig.pressed) + if(ui_pressed(sig)) { next_selected_tab_view = view; 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)); } - else if(sig.dragging && !df_drag_is_active() && length_2f32(ui_drag_delta()) > 10.f) + else if(ui_dragging(sig) && !df_drag_is_active() && length_2f32(ui_drag_delta()) > 10.f) { DF_DragDropPayload payload = {0}; { @@ -5948,12 +5948,12 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } df_drag_begin(&payload); } - else if(sig.right_clicked) + else if(ui_right_clicked(sig)) { ui_ctx_menu_open(ws->tab_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0)); ws->tab_ctx_menu_view = df_handle_from_view(view); } - if(sig.released) + if(ui_released(sig)) { df_panel_notify_mutation(ws, panel); } @@ -8504,26 +8504,26 @@ df_cmd_binding_button(DF_CmdSpec *spec) UI_Signal sig = ui_signal_from_box(box); { // rjf: hover => visualize clickability - if(sig.hovering) + if(ui_hovering(sig)) { box->flags |= UI_BoxFlag_DrawBorder; box->flags |= UI_BoxFlag_DrawBackground; } // rjf: click => toggle activity - if(!df_gfx_state->bind_change_active && sig.clicked) + if(!df_gfx_state->bind_change_active && ui_clicked(sig)) { df_gfx_state->bind_change_active = 1; df_gfx_state->bind_change_cmd_spec = spec; df_gfx_state->bind_change_binding = binding; } - else if(df_gfx_state->bind_change_active && sig.clicked) + else if(df_gfx_state->bind_change_active && ui_clicked(sig)) { df_gfx_state->bind_change_active = 0; } // rjf: hover w/ conflicts => show conflicts - if(sig.hovering && has_conflicts) UI_Tooltip + if(ui_hovering(sig) && has_conflicts) UI_Tooltip { ui_labelf("This binding conflicts with others:"); for(DF_CmdSpecNode *n = specs_with_binding.first; n != 0; n = n->next) @@ -8608,7 +8608,7 @@ df_cmd_list_menu_buttons(DF_Window *ws, U64 count, DF_CoreCmdKind *cmds, U32 *fa DF_CmdSpec *spec = df_cmd_spec_from_core_cmd_kind(cmds[idx]); ui_set_next_fastpath_codepoint(fastpath_codepoints[idx]); UI_Signal sig = df_cmd_spec_button(spec); - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.cmd_spec = spec; @@ -8885,7 +8885,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam info_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "%S###%p_temp_info", df_g_icon_kind_text_table[DF_IconKind_Info], entity); } UI_Signal info_sig = ui_signal_from_box(info_box); - if(info_sig.hovering) UI_Tooltip + if(ui_hovering(info_sig)) UI_Tooltip { ui_labelf("Specified via command line; not saved in profile."); } @@ -8959,7 +8959,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam } // rjf: click => fastpath or dropdown for this entity - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(entity); @@ -8968,7 +8968,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam } // rjf: right-click => context menu for this entity - else if(sig.right_clicked) + else if(ui_right_clicked(sig)) { DF_Handle handle = df_handle_from_entity(entity); if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle)) @@ -8983,7 +8983,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam } // rjf: drag+drop - else if(sig.dragging && !contains_2f32(box->rect, ui_mouse())) + else if(ui_dragging(sig) && !contains_2f32(box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.key = box->key; @@ -9025,7 +9025,7 @@ df_entity_src_loc_button(DF_Window *ws, DF_Entity *entity, TxtPt point) } // rjf: click => find code location - if(sig.clicked) + if(ui_clicked(sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.file_path = full_path; @@ -9036,7 +9036,7 @@ df_entity_src_loc_button(DF_Window *ws, DF_Entity *entity, TxtPt point) } // rjf: drag+drop - else if(sig.dragging && !contains_2f32(box->rect, ui_mouse())) + else if(ui_dragging(sig) && !contains_2f32(box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.key = box->key; @@ -9046,7 +9046,7 @@ df_entity_src_loc_button(DF_Window *ws, DF_Entity *entity, TxtPt point) } // rjf: hover => show full path - else if(sig.hovering && !sig.dragging) UI_Tooltip + else if(ui_hovering(sig) && !ui_dragging(sig)) UI_Tooltip { ui_labelf("%S:%I64d:%I64d", full_path, point.line, point.column); } @@ -9245,28 +9245,28 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ DF_TextLineDasm2SrcInfoList *line_dasm2src_list = ¶ms->line_dasm2src[line_idx]; //- rjf: copy selection - if(!txt_pt_match(*cursor, *mark) && df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Copy)).clicked) + if(!txt_pt_match(*cursor, *mark) && ui_clicked(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Copy)))) { result.copy_range = txt_rng(*cursor, *mark); ui_ctx_menu_close(); } //- rjf: watch selection - if(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpressionAtCursor)).clicked) + if(ui_clicked(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpressionAtCursor)))) { result.toggle_cursor_watch = 1; ui_ctx_menu_close(); } //- rjf: set-next-statement - if(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetNextStatement)).clicked) + if(ui_clicked(df_cmd_spec_button(df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetNextStatement)))) { result.set_next_statement_line_num = line_num; ui_ctx_menu_close(); } //- rjf: run-to-line - if(df_icon_buttonf(DF_IconKind_Play, 0, "Run To Line").clicked) + if(ui_clicked(df_icon_buttonf(DF_IconKind_Play, 0, "Run To Line"))) { result.run_to_line_num = line_num; ui_ctx_menu_close(); @@ -9274,9 +9274,9 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ //- rjf: breakpoint placing if((params->line_bps[line_idx].count == 0 && - df_icon_buttonf(DF_IconKind_CircleFilled, 0, "Place Breakpoint").clicked) || + ui_clicked(df_icon_buttonf(DF_IconKind_CircleFilled, 0, "Place Breakpoint"))) || (params->line_bps[line_idx].count != 0 && - df_icon_buttonf(DF_IconKind_CircleFilled, 0, "Remove Breakpoint").clicked)) + ui_clicked(df_icon_buttonf(DF_IconKind_CircleFilled, 0, "Remove Breakpoint")))) { result.clicked_margin_line_num = line_num; ui_ctx_menu_close(); @@ -9284,7 +9284,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ //- rjf: go from src -> disasm if(line_src2dasm_list->first != 0 && - df_icon_buttonf(DF_IconKind_Find, 0, "Go To Disassembly").clicked) + ui_clicked(df_icon_buttonf(DF_IconKind_Find, 0, "Go To Disassembly"))) { result.goto_disasm_line_num = line_num; ui_ctx_menu_close(); @@ -9292,7 +9292,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ //- rjf: go from disasm -> src if(line_dasm2src_list->first != 0 && - df_icon_buttonf(DF_IconKind_Find, 0, "Go To Source").clicked) + ui_clicked(df_icon_buttonf(DF_IconKind_Find, 0, "Go To Source"))) { result.goto_src_line_num = line_num; ui_ctx_menu_close(); @@ -9421,13 +9421,13 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: hover tooltips - if(thread_sig.hovering) + if(ui_hovering(thread_sig)) { df_entity_tooltips(thread); } // rjf: ip right-click menu - if(thread_sig.right_clicked) + if(ui_right_clicked(thread_sig)) { DF_Handle handle = df_handle_from_entity(thread); if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle)) @@ -9442,7 +9442,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: double click => select - if(thread_sig.double_clicked) + if(ui_double_clicked(thread_sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(thread); @@ -9451,7 +9451,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: drag start - if(thread_sig.dragging && !contains_2f32(thread_box->rect, ui_mouse())) + if(ui_dragging(thread_sig) && !contains_2f32(thread_box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.key = thread_box->key; @@ -9511,13 +9511,13 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_Signal bp_sig = ui_signal_from_box(bp_box); // rjf: bp hovering - if(bp_sig.hovering) + if(ui_hovering(bp_sig)) { df_entity_tooltips(bp); } // rjf: click => remove breakpoint - if(bp_sig.clicked) + if(ui_clicked(bp_sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(bp); @@ -9526,7 +9526,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: drag start - if(bp_sig.dragging && !contains_2f32(bp_box->rect, ui_mouse())) + if(ui_dragging(bp_sig) && !contains_2f32(bp_box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.entity = df_handle_from_entity(bp); @@ -9534,7 +9534,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: bp right-click menu - if(bp_sig.right_clicked) + if(ui_right_clicked(bp_sig)) { DF_Handle handle = df_handle_from_entity(bp); if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle)) @@ -9578,13 +9578,13 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_Signal pin_sig = ui_signal_from_box(pin_box); // rjf: watch hovering - if(pin_sig.hovering) + if(ui_hovering(pin_sig)) { df_entity_tooltips(pin); } // rjf: click => remove pin - if(pin_sig.clicked) + if(ui_clicked(pin_sig)) { DF_CmdParams params = df_cmd_params_from_window(ws); params.entity = df_handle_from_entity(pin); @@ -9593,7 +9593,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: drag start - if(pin_sig.dragging && !contains_2f32(pin_box->rect, ui_mouse())) + if(ui_dragging(pin_sig) && !contains_2f32(pin_box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.entity = df_handle_from_entity(pin); @@ -9601,7 +9601,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } // rjf: watch right-click menu - if(pin_sig.right_clicked) + if(ui_right_clicked(pin_sig)) { DF_Handle handle = df_handle_from_entity(pin); if(ui_ctx_menu_is_open(ws->entity_ctx_menu_key) && df_handle_match(ws->entity_ctx_menu_entity, handle)) @@ -9617,7 +9617,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } } UI_Signal line_margin_sig = ui_signal_from_box(line_margin_box); - if(line_margin_sig.clicked) + if(ui_clicked(line_margin_sig)) { result.clicked_margin_line_num = line_num; } @@ -9713,13 +9713,13 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_Flags(UI_BoxFlag_DisableTextTrunc) { UI_Signal sig = ui_buttonf("%S###pin_nub", df_g_icon_kind_text_table[DF_IconKind_Pin]); - if(sig.dragging && !contains_2f32(sig.box->rect, ui_mouse())) + if(ui_dragging(sig) && !contains_2f32(sig.box->rect, ui_mouse())) { DF_DragDropPayload payload = {0}; payload.entity = df_handle_from_entity(pin); df_drag_begin(&payload); } - if(sig.clicked || sig.right_clicked) + if(ui_clicked(sig) || ui_right_clicked(sig)) { ui_ctx_menu_open(ws->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1-sig.box->rect.y0)); ws->entity_ctx_menu_entity = df_handle_from_entity(pin); @@ -9790,7 +9790,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ DF_Entity *line_drag_entity = &df_g_nil_entity; { //- rjf: clicking/dragging over the text container - if(!ctrlified && text_container_sig.dragging) + if(!ctrlified && ui_dragging(text_container_sig)) { if(mouse_pt.line == 0) { @@ -9804,7 +9804,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ mouse_pt.line = params->line_num_range.max + 2; } } - if(text_container_sig.pressed) + if(ui_pressed(text_container_sig)) { *mark = mouse_pt; } @@ -9813,7 +9813,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } //- rjf: right-click => active context menu for line - if(text_container_sig.right_clicked) + if(ui_right_clicked(text_container_sig)) { S64 line_idx = mouse_pt.line-params->line_num_range.min; if(0 <= line_idx && line_idx < dim_1s64(params->line_num_range)) @@ -9827,7 +9827,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } //- rjf: hovering text container & ctrl+scroll -> change font size - if(text_container_sig.hovering) + if(ui_hovering(text_container_sig)) { for(OS_Event *event = ui_events()->first; event != 0; event = event->next) { @@ -9879,7 +9879,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ ////////////////////////////// //- rjf: mouse -> expression range info // - if(text_container_sig.hovering && contains_1s64(params->line_num_range, mouse_pt.line)) ProfScope("mouse -> expression range") + if(ui_hovering(text_container_sig) && contains_1s64(params->line_num_range, mouse_pt.line)) ProfScope("mouse -> expression range") { TxtRng selected_rng = txt_rng(*cursor, *mark); if(!txt_pt_match(*cursor, *mark) && cursor->line == mark->line && @@ -9914,7 +9914,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ ////////////////////////////// //- rjf: mouse -> set global frontend hovered line info // - if(text_container_sig.hovering && contains_1s64(params->line_num_range, mouse_pt.line)) + if(ui_hovering(text_container_sig) && contains_1s64(params->line_num_range, mouse_pt.line)) { U64 line_slice_idx = mouse_pt.line-params->line_num_range.min; if(params->line_src2dasm[line_slice_idx].first != 0 && @@ -10615,7 +10615,7 @@ df_help_label(String8 string) UI_Parent(box) { UI_PrefWidth(ui_pct(1, 0)) ui_label(string); - if(sig.hovering) UI_PrefWidth(ui_em(2.25f, 1)) + if(ui_hovering(sig)) UI_PrefWidth(ui_em(2.25f, 1)) { result = 1; ui_set_next_font(ui_icon_font()); @@ -10842,7 +10842,7 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx UI_Focus(UI_FocusKind_Off) { UI_Signal expander_sig = ui_expanderf(*expanded_out, "expander"); - if(expander_sig.pressed) + if(ui_pressed(expander_sig)) { *expanded_out ^= 1; } @@ -10896,13 +10896,16 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx //- rjf: get signal UI_Signal sig = ui_signal_from_box(box); - sig.commit = sig.commit || commit; + if(commit) + { + sig.f |= UI_SignalFlag_Commit; + } //- rjf: do start/end editing interaction B32 focus_started = 0; if(!is_focus_active) { - B32 start_editing_via_sig = (sig.double_clicked || sig.keyboard_clicked); + B32 start_editing_via_sig = (ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed); B32 start_editing_via_typing = 0; if(is_focus_hot) { @@ -10933,10 +10936,10 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx focus_started = 1; } } - else if(is_focus_active && sig.keyboard_clicked) + else 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; } //- rjf: take navigation actions for editing @@ -11081,15 +11084,15 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx } //- rjf: click+drag - if(is_focus_active && sig.dragging) + if(is_focus_active && ui_dragging(sig)) { - if(sig.pressed) + if(ui_pressed(sig)) { *mark = mouse_pt; } *cursor = mouse_pt; } - if(!is_focus_active && is_focus_active_disabled && sig.pressed) + if(!is_focus_active && is_focus_active_disabled && ui_pressed(sig)) { *cursor = *mark = mouse_pt; } diff --git a/src/df/gfx/df_view_rule_hooks.c b/src/df/gfx/df_view_rule_hooks.c index 3e2568b4..87826f35 100644 --- a/src/df/gfx/df_view_rule_hooks.c +++ b/src/df/gfx/df_view_rule_hooks.c @@ -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); diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index 0a0a3fd9..12778ccd 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -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(¶ms, 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(¶ms, DF_CmdParamSlot_CmdSpec); df_push_cmd__root(¶ms, 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, ¶ms.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, ¶ms.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(¶ms, DF_CmdParamSlot_TextPoint); df_push_cmd__root(¶ms, 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(¶ms, DF_CmdParamSlot_TextPoint); df_push_cmd__root(¶ms, 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]); } diff --git a/src/os/gfx/win32/os_gfx_win32.c b/src/os/gfx/win32/os_gfx_win32.c index 12f103d4..740c4936 100644 --- a/src/os/gfx/win32/os_gfx_win32.c +++ b/src/os/gfx/win32/os_gfx_win32.c @@ -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; diff --git a/src/ui/ui_basic_widgets.c b/src/ui/ui_basic_widgets.c index 417abf17..7edbfd2b 100644 --- a/src/ui/ui_basic_widgets.c +++ b/src/ui/ui_basic_widgets.c @@ -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); diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index f5fdc9a1..67ac8d7c 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -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<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<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< 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< 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< 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 } //////////////////////////////// diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 52699667..044e0d2c 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -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;