auto-close panels if final tabs are closed; simplify empty panel view, move 'helper' stuff to dedicated 'getting started' tab

This commit is contained in:
Ryan Fleury
2024-05-10 08:48:31 -07:00
parent ef175baae4
commit 6660446bdd
8 changed files with 84 additions and 5 deletions
+1
View File
@@ -363,6 +363,7 @@ DF_CoreCmdTable:// | | |
{ClearFilter 0 Null Nil 0 0 0 0 0 0 Find "clear_filter" "Clear Filter" "Clears the filter applied to the active view." "sort,search,filter,find,clear" }
//- rjf: view drivers
{GettingStarted 0 Null Nil 0 0 0 0 0 0 QuestionMark "getting_started" "Getting Started" "Opens the menu for information on getting started." "tutorial,help" }
{Commands 1 Null Nil 0 0 0 0 0 0 List "commands" "Commands" "Opens the list of all commands." "" }
{Target 1 Null Nil 0 0 0 0 0 0 Target "target" "Target" "Opens the editor for a target." "" }
{Targets 0 Null Nil 0 0 0 0 0 0 Target "targets" "Targets" "Opens the list of all targets." "" }
+2 -1
View File
@@ -216,7 +216,7 @@ DF_CoreCmdKind_Null,
DF_CoreCmdKind_Null,
};
DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[212] =
DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[213] =
{
{ str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), (DF_CmdSpecFlag_OmitFromLists*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null},
{ str8_lit_comp("exit"), str8_lit_comp("Exits the debugger."), str8_lit_comp("quit,close,abort"), str8_lit_comp("Exit"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_X},
@@ -400,6 +400,7 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[212] =
{ str8_lit_comp("filter"), str8_lit_comp("Begins filtering the active view."), str8_lit_comp("sort,search,filter,find"), str8_lit_comp("Filter"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Find},
{ str8_lit_comp("apply_filter"), str8_lit_comp("Applies the typed filter to the active view."), str8_lit_comp("sort,search,filter,find,apply"), str8_lit_comp("Apply Filter"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Find},
{ str8_lit_comp("clear_filter"), str8_lit_comp("Clears the filter applied to the active view."), str8_lit_comp("sort,search,filter,find,clear"), str8_lit_comp("Clear Filter"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Find},
{ str8_lit_comp("getting_started"), str8_lit_comp("Opens the menu for information on getting started."), str8_lit_comp("tutorial,help"), str8_lit_comp("Getting Started"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_QuestionMark},
{ str8_lit_comp("commands"), str8_lit_comp("Opens the list of all commands."), str8_lit_comp(""), str8_lit_comp("Commands"), (DF_CmdSpecFlag_OmitFromLists*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_List},
{ str8_lit_comp("target"), str8_lit_comp("Opens the editor for a target."), str8_lit_comp(""), str8_lit_comp("Target"), (DF_CmdSpecFlag_OmitFromLists*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Target},
{ str8_lit_comp("targets"), str8_lit_comp("Opens the list of all targets."), str8_lit_comp(""), str8_lit_comp("Targets"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Target},
+1
View File
@@ -231,6 +231,7 @@ DF_CoreCmdKind_FindCodeLocation,
DF_CoreCmdKind_Filter,
DF_CoreCmdKind_ApplyFilter,
DF_CoreCmdKind_ClearFilter,
DF_CoreCmdKind_GettingStarted,
DF_CoreCmdKind_Commands,
DF_CoreCmdKind_Target,
DF_CoreCmdKind_Targets,
+40 -2
View File
@@ -1825,8 +1825,13 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
{
df_panel_remove_tab_view(panel, view);
df_view_release(view);
df_panel_notify_mutation(ws, panel);
if(df_view_is_nil(panel->first_tab_view))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ClosePanel));
}
}
df_panel_notify_mutation(ws, panel);
}break;
case DF_CoreCmdKind_MoveTab:
{
@@ -6677,7 +6682,6 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
}
// rjf: space for next tab
if(!df_view_is_nil(view->next))
{
ui_spacer(ui_em(0.15f, 1.f));
}
@@ -6688,6 +6692,40 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
drop_site_max_p = Max(tab_column_box->rect.x1, drop_site_max_p);
}
// rjf: build add-new-tab button
UI_TextAlignment(UI_TextAlign_Center)
UI_PrefWidth(ui_px(tab_bar_vheight, 1.f))
UI_PrefHeight(ui_px(tab_bar_vheight, 1.f))
UI_Column
{
ui_spacer(ui_px(tab_bar_rv_diff/2.f, 1.f));
UI_CornerRadius(tab_bar_vheight/2.f)
UI_Font(df_font_from_slot(DF_FontSlot_Icons))
UI_FontSize(ui_top_font_size()*0.75f)
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText))
UI_HoverCursor(OS_Cursor_HandPoint)
{
UI_Box *add_new_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawText|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects|
UI_BoxFlag_Clickable|
UI_BoxFlag_DisableTextTrunc,
"%S##add_new_tab_button_%p",
df_g_icon_kind_text_table[DF_IconKind_Add],
panel);
UI_Signal sig = ui_signal_from_box(add_new_box);
if(ui_clicked(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));
UI_Key view_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_view_menu_key_"));
ui_ctx_menu_open(view_menu_key, add_new_box->key, v2f32(0, tab_bar_vheight));
}
}
}
scratch_end(scratch);
}
+1
View File
@@ -190,6 +190,7 @@ DF_GfxViewTable:
{
{ Null "null" "" Null Null 0 0 0 0 0 0 0 "" }
{ Empty "empty" "" Null Null 0 0 0 0 0 0 0 "" }
{ GettingStarted "getting_started" "Getting Started" Null QuestionMark 0 1 0 0 0 0 0 "" }
{ Commands "commands" "Commands" Null List 0 0 0 0 0 0 0 "" }
{ FileSystem "file_system" "File System" Null FileOutline 0 0 0 0 0 0 0 "" }
{ SystemProcesses "system_processes" "System Processes" Null Null 0 0 0 0 0 0 0 "" }
+31
View File
@@ -1659,6 +1659,37 @@ DF_VIEW_SETUP_FUNCTION_DEF(Empty) {}
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Empty) { return str8_lit(""); }
DF_VIEW_CMD_FUNCTION_DEF(Empty) {}
DF_VIEW_UI_FUNCTION_DEF(Empty)
{
ui_set_next_flags(UI_BoxFlag_DefaultFocusNav);
UI_Focus(UI_FocusKind_On) UI_WidthFill UI_HeightFill UI_NamedColumn(str8_lit("empty_view")) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText))
UI_Padding(ui_pct(1, 0)) UI_Focus(UI_FocusKind_Null)
{
UI_PrefHeight(ui_em(3.f, 1.f))
UI_Row
UI_Padding(ui_pct(1, 0))
UI_TextAlignment(UI_TextAlign_Center)
UI_PrefWidth(ui_em(15.f, 1.f))
UI_CornerRadius(ui_top_font_size()/2.f)
UI_BackgroundColor(df_rgba_from_theme_color(DF_ThemeColor_FailureBackground))
UI_BorderColor(df_rgba_from_theme_color(DF_ThemeColor_FailureBorder))
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_FailureText))
{
if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close Panel")))
{
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ClosePanel));
}
}
}
}
////////////////////////////////
//~ rjf: GettingStarted @view_hook_impl
DF_VIEW_SETUP_FUNCTION_DEF(GettingStarted) {}
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(GettingStarted) { return str8_lit(""); }
DF_VIEW_CMD_FUNCTION_DEF(GettingStarted) {}
DF_VIEW_UI_FUNCTION_DEF(GettingStarted)
{
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
+2 -1
View File
@@ -739,10 +739,11 @@ DF_ViewSpecInfo df_g_gfx_view_rule_tab_view_spec_info_table[4] =
{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("geo_view_rule"), str8_lit_comp("Geometry"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(geo), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(geo), DF_VIEW_CMD_FUNCTION_NAME(geo), DF_VIEW_UI_FUNCTION_NAME(geo) },
};
DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[30] =
DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[31] =
{
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("null"), str8_lit_comp(""), DF_NameKind_Null, DF_IconKind_Null, DF_VIEW_SETUP_FUNCTION_NAME(Null), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Null), DF_VIEW_CMD_FUNCTION_NAME(Null), DF_VIEW_UI_FUNCTION_NAME(Null)},
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("empty"), str8_lit_comp(""), DF_NameKind_Null, DF_IconKind_Null, DF_VIEW_SETUP_FUNCTION_NAME(Empty), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Empty), DF_VIEW_CMD_FUNCTION_NAME(Empty), DF_VIEW_UI_FUNCTION_NAME(Empty)},
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("getting_started"), str8_lit_comp("Getting Started"), DF_NameKind_Null, DF_IconKind_QuestionMark, DF_VIEW_SETUP_FUNCTION_NAME(GettingStarted), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(GettingStarted), DF_VIEW_CMD_FUNCTION_NAME(GettingStarted), DF_VIEW_UI_FUNCTION_NAME(GettingStarted)},
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("commands"), str8_lit_comp("Commands"), DF_NameKind_Null, DF_IconKind_List, DF_VIEW_SETUP_FUNCTION_NAME(Commands), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Commands), DF_VIEW_CMD_FUNCTION_NAME(Commands), DF_VIEW_UI_FUNCTION_NAME(Commands)},
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("file_system"), str8_lit_comp("File System"), DF_NameKind_Null, DF_IconKind_FileOutline, DF_VIEW_SETUP_FUNCTION_NAME(FileSystem), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(FileSystem), DF_VIEW_CMD_FUNCTION_NAME(FileSystem), DF_VIEW_UI_FUNCTION_NAME(FileSystem)},
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeEntityPath|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("system_processes"), str8_lit_comp("System Processes"), DF_NameKind_Null, DF_IconKind_Null, DF_VIEW_SETUP_FUNCTION_NAME(SystemProcesses), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(SystemProcesses), DF_VIEW_CMD_FUNCTION_NAME(SystemProcesses), DF_VIEW_UI_FUNCTION_NAME(SystemProcesses)},
+6 -1
View File
@@ -17,6 +17,7 @@ typedef enum DF_GfxViewKind
{
DF_GfxViewKind_Null,
DF_GfxViewKind_Empty,
DF_GfxViewKind_GettingStarted,
DF_GfxViewKind_Commands,
DF_GfxViewKind_FileSystem,
DF_GfxViewKind_SystemProcesses,
@@ -123,6 +124,7 @@ DF_ThemePreset_COUNT,
DF_VIEW_SETUP_FUNCTION_DEF(Null);
DF_VIEW_SETUP_FUNCTION_DEF(Empty);
DF_VIEW_SETUP_FUNCTION_DEF(GettingStarted);
DF_VIEW_SETUP_FUNCTION_DEF(Commands);
DF_VIEW_SETUP_FUNCTION_DEF(FileSystem);
DF_VIEW_SETUP_FUNCTION_DEF(SystemProcesses);
@@ -153,6 +155,7 @@ DF_VIEW_SETUP_FUNCTION_DEF(ExceptionFilters);
DF_VIEW_SETUP_FUNCTION_DEF(Theme);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Null);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Empty);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(GettingStarted);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Commands);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(FileSystem);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(SystemProcesses);
@@ -183,6 +186,7 @@ DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(ExceptionFilters);
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Theme);
DF_VIEW_CMD_FUNCTION_DEF(Null);
DF_VIEW_CMD_FUNCTION_DEF(Empty);
DF_VIEW_CMD_FUNCTION_DEF(GettingStarted);
DF_VIEW_CMD_FUNCTION_DEF(Commands);
DF_VIEW_CMD_FUNCTION_DEF(FileSystem);
DF_VIEW_CMD_FUNCTION_DEF(SystemProcesses);
@@ -213,6 +217,7 @@ DF_VIEW_CMD_FUNCTION_DEF(ExceptionFilters);
DF_VIEW_CMD_FUNCTION_DEF(Theme);
DF_VIEW_UI_FUNCTION_DEF(Null);
DF_VIEW_UI_FUNCTION_DEF(Empty);
DF_VIEW_UI_FUNCTION_DEF(GettingStarted);
DF_VIEW_UI_FUNCTION_DEF(Commands);
DF_VIEW_UI_FUNCTION_DEF(FileSystem);
DF_VIEW_UI_FUNCTION_DEF(SystemProcesses);
@@ -295,7 +300,7 @@ extern String8 df_g_cmd_param_slot_2_view_spec_cmd_map[7];
extern DF_StringBindingPair df_g_default_binding_table[97];
extern String8 df_g_binding_version_remap_old_name_table[3];
extern String8 df_g_binding_version_remap_new_name_table[3];
extern DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[30];
extern DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[31];
extern String8 df_g_theme_color_display_string_table[54];
extern String8 df_g_theme_color_cfg_string_table[54];
read_only global U8 df_g_icon_font_bytes__data[] =