mouse-driven ui path for query completion; show-in-explorer ui for tab ctx menu

This commit is contained in:
Ryan Fleury
2024-06-20 08:02:01 -07:00
parent b76c605eba
commit c60d3aab22
5 changed files with 81 additions and 27 deletions
+33 -16
View File
@@ -4341,6 +4341,18 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
}
}
// rjf: show in explorer
if(entity->kind == DF_EntityKind_File)
{
UI_Signal sig = df_icon_buttonf(DF_IconKind_FolderClosedFilled, 0, "Show In Explorer");
if(ui_clicked(sig))
{
String8 full_path = df_full_path_from_entity(scratch.arena, entity);
os_show_in_filesystem_ui(full_path);
ui_ctx_menu_close();
}
}
// rjf: filter controls
if(view->spec->info.flags & DF_ViewSpecFlag_CanFilter)
{
@@ -5770,6 +5782,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
}
//- rjf: build query text input
B32 query_completed = 0;
UI_Parent(query_container_box)
UI_WidthFill UI_PrefHeight(ui_px(query_line_edit_height, 1.f))
UI_Focus(UI_FocusKind_On)
@@ -5807,6 +5820,13 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
ws->query_view_selected = 1;
}
}
UI_PrefWidth(ui_em(5.f, 1.f)) UI_Focus(UI_FocusKind_Off)
{
if(ui_clicked(df_icon_buttonf(DF_IconKind_RightArrow, 0, "##complete_query")))
{
query_completed = 1;
}
}
}
}
@@ -5825,25 +5845,22 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
DF_CmdParams params = df_cmd_params_from_window(ws);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CancelQuery));
}
if(ui_is_focus_active())
if((ui_is_focus_active() && ui_slot_press(UI_EventActionSlot_Accept)) || query_completed)
{
if(ui_slot_press(UI_EventActionSlot_Accept))
Temp scratch = scratch_begin(&arena, 1);
DF_View *view = ws->query_view_stack_top;
DF_CmdParams params = df_cmd_params_from_window(ws);
DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view);
String8 error = df_cmd_params_apply_spec_query(scratch.arena, &ctrl_ctx, &params, ws->query_cmd_spec, str8(view->query_buffer, view->query_string_size));
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CompleteQuery));
if(error.size != 0)
{
Temp scratch = scratch_begin(&arena, 1);
DF_View *view = ws->query_view_stack_top;
DF_CmdParams params = df_cmd_params_from_window(ws);
DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view);
String8 error = df_cmd_params_apply_spec_query(scratch.arena, &ctrl_ctx, &params, ws->query_cmd_spec, str8(view->query_buffer, view->query_string_size));
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CompleteQuery));
if(error.size != 0)
{
DF_CmdParams p = df_cmd_params_from_window(ws);
p.string = error;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error));
}
scratch_end(scratch);
DF_CmdParams p = df_cmd_params_from_window(ws);
p.string = error;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error));
}
scratch_end(scratch);
}
//- rjf: take fallthrough interaction in query view
+6 -1
View File
@@ -170,8 +170,13 @@ internal F32 os_caret_blink_time(void);
internal F32 os_default_refresh_rate(void);
////////////////////////////////
//~ rjf: @os_hooks Native Messages & Panics (Implemented Per-OS)
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void os_graphical_message(B32 error, String8 title, String8 message);
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
internal void os_show_in_filesystem_ui(String8 path);
#endif // OS_GRAPHICAL_H
+9 -1
View File
@@ -240,9 +240,17 @@ os_granular_sleep_enabled(void)
}
////////////////////////////////
//~ rjf: @os_hooks Native Messages & Panics (Implemented Per-OS)
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void
os_graphical_message(B32 error, String8 title, String8 message)
{
}
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
internal void
os_show_in_filesystem_ui(String8 path)
{
}
+28 -1
View File
@@ -1421,7 +1421,7 @@ os_default_refresh_rate(void)
}
////////////////////////////////
//~ rjf: @os_hooks Native Messages & Panics (Implemented Per-OS)
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void
os_graphical_message(B32 error, String8 title, String8 message)
@@ -1432,3 +1432,30 @@ os_graphical_message(B32 error, String8 title, String8 message)
MessageBoxW(0, (WCHAR *)message16.str, (WCHAR *)title16.str, MB_OK|(!!error*MB_ICONERROR));
scratch_end(scratch);
}
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
internal void
os_show_in_filesystem_ui(String8 path)
{
Temp scratch = scratch_begin(0, 0);
String8 path_copy = push_str8_copy(scratch.arena, path);
for(U64 idx = 0; idx < path_copy.size; idx += 1)
{
if(path_copy.str[idx] == '/')
{
path_copy.str[idx] = '\\';
}
}
String16 path16 = str16_from_8(scratch.arena, path_copy);
SFGAOF flags = 0;
PIDLIST_ABSOLUTE list = 0;
if(path16.size != 0 && SUCCEEDED(SHParseDisplayName(path16.str, 0, &list, 0, &flags)))
{
HRESULT hr = SHOpenFolderAndSelectItems(list, 0, 0, 0);
CoTaskMemFree(list);
(void)hr;
}
scratch_end(scratch);
}
+5 -8
View File
@@ -4,11 +4,6 @@
////////////////////////////////
//~ rjf: Frontend/UI Pass Tasks
//
// [ ] mouse-driven way to complete file/folder selection, or more generally
// query completion
// [ ] display threads at their last exception address, rather than current
// rip, if applicable
//
// [ ] editing multiple bindings for commands
// [ ] n-row table selection, in watch window & other UIs, multi-selection
// ctrl+C
@@ -16,6 +11,7 @@
// [ ] theme colors -> more explicit about e.g. opaque backgrounds vs. floating
// & scrollbars etc.
// [ ] target/breakpoint/watch-pin reordering
//
// [ ] visualize remapped files (via path map)
// [ ] theme lister -> fonts & font sizes
// [ ] font lister
@@ -31,9 +27,6 @@
// that you use to tag them. Just some way that would make it easier to
// focus on your own threads.
//
// [ ] it would be nice to have "show in explorer" for right click on source
// file tab (opens explorer & selects the file)
//
// [ ] what's up with decimal number coloring where every group of 3 are in
// different color? can I turn it off? And why sometimes digits in number
// start with brighter color, but sometimes with darker - shouldn't it
@@ -388,6 +381,10 @@
// path - must invalidate naturally when new filetime occurs)
// [x] rdi file regeneration too strict
// [x] raddbg jai.exe my_file.jai -- foobar -> raddbg consumes `--` incorrectly
// [x] mouse-driven way to complete file/folder selection, or more generally
// query completion
// [x] it would be nice to have "show in explorer" for right click on source
// file tab (opens explorer & selects the file)
#ifndef RADDBG_H
#define RADDBG_H