From 43abd7a4bfd50d0e27481988c249654468209a21 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Fri, 24 May 2024 01:10:42 +0100 Subject: [PATCH] Added close tab variations close_all_other_tabs, close_all_left_tabs, close_all_right_tabs, close_all_tabs --- src/df/core/df_core.mdesk | 4 + src/df/core/generated/df_core.meta.c | 6 +- src/df/core/generated/df_core.meta.h | 4 + src/df/gfx/df_gfx.c | 114 +++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) diff --git a/src/df/core/df_core.mdesk b/src/df/core/df_core.mdesk index c879873c2..96e814118 100644 --- a/src/df/core/df_core.mdesk +++ b/src/df/core/df_core.mdesk @@ -214,6 +214,10 @@ DF_CoreCmdTable:// | | | {MoveTabLeft 0 Null Nil 0 0 0 0 0 0 LeftArrow "move_tab_left" "Move Tab Left" "Moves the selected tab left one slot." "" } {OpenTab 1 Null Nil 0 0 0 0 0 0 Null "open_tab" "Open Tab" "Opens a new tab with the parameterized view specification." "" } {CloseTab 0 Null Nil 0 0 0 0 0 0 X "close_tab" "Close Tab" "Closes the currently opened tab." "" } + {CloseAllOtherTabs 0 Null Nil 0 0 0 0 0 0 X "close_all_other_tabs" "Close All Others" "Closes all the tabs except this one." "" } + {CloseAllLeftTabs 0 Null Nil 0 0 0 0 0 0 X "close_all_left_tabs" "Close All (Left)" "Closes all the tabs to the left." "" } + {CloseAllRightTabs 0 Null Nil 0 0 0 0 0 0 X "close_all_right_tabs" "Close All (Right)" "Closes the the tabs to the right." "" } + {CloseAllTabs 0 Null Nil 0 0 0 0 0 0 X "close_all_tabs" "Close All" "Closes all the tabs." "" } {MoveTab 1 Null Nil 0 0 0 0 0 0 Null "move_tab" "Move Tab" "Moves a tab to a new panel." "" } {TabBarTop 0 Null Nil 0 0 0 0 0 0 UpArrow "tab_bar_top" "Anchor Tab Bar To Top" "Anchors a panel's tab bar to the top of the panel." "" } {TabBarBottom 0 Null Nil 0 0 0 0 0 0 DownArrow "tab_bar_bottom" "Anchor Tab Bar To Bottom" "Anchors a panel's tab bar to the bottom of the panel." "" } diff --git a/src/df/core/generated/df_core.meta.c b/src/df/core/generated/df_core.meta.c index c2c5f7046..6aa998989 100644 --- a/src/df/core/generated/df_core.meta.c +++ b/src/df/core/generated/df_core.meta.c @@ -207,7 +207,7 @@ DF_CoreCmdKind_Null, DF_CoreCmdKind_Null, }; -DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = +DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[224] = { { 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}, @@ -287,6 +287,10 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = { str8_lit_comp("move_tab_left"), str8_lit_comp("Moves the selected tab left one slot."), str8_lit_comp(""), str8_lit_comp("Move Tab Left"), (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_LeftArrow}, { str8_lit_comp("open_tab"), str8_lit_comp("Opens a new tab with the parameterized view specification."), str8_lit_comp(""), str8_lit_comp("Open Tab"), (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("close_tab"), str8_lit_comp("Closes the currently opened tab."), str8_lit_comp(""), str8_lit_comp("Close Tab"), (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}, +{ str8_lit_comp("close_all_other_tabs"), str8_lit_comp("Closes all the tabs except this one."), str8_lit_comp(""), str8_lit_comp("Close All Others"), (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}, +{ str8_lit_comp("close_all_left_tabs"), str8_lit_comp("Closes all the tabs to the left."), str8_lit_comp(""), str8_lit_comp("Close All (Left)"), (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}, +{ str8_lit_comp("close_all_right_tabs"), str8_lit_comp("Closes the the tabs to the right."), str8_lit_comp(""), str8_lit_comp("Close All (Right)"), (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}, +{ str8_lit_comp("close_all_tabs"), str8_lit_comp("Closes all the tabs."), str8_lit_comp(""), str8_lit_comp("Close All"), (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}, { str8_lit_comp("move_tab"), str8_lit_comp("Moves a tab to a new panel."), str8_lit_comp(""), str8_lit_comp("Move Tab"), (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("tab_bar_top"), str8_lit_comp("Anchors a panel's tab bar to the top of the panel."), str8_lit_comp(""), str8_lit_comp("Anchor Tab Bar To Top"), (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_UpArrow}, { str8_lit_comp("tab_bar_bottom"), str8_lit_comp("Anchors a panel's tab bar to the bottom of the panel."), str8_lit_comp(""), str8_lit_comp("Anchor Tab Bar To Bottom"), (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_DownArrow}, diff --git a/src/df/core/generated/df_core.meta.h b/src/df/core/generated/df_core.meta.h index daf1d7b60..41a87ebf2 100644 --- a/src/df/core/generated/df_core.meta.h +++ b/src/df/core/generated/df_core.meta.h @@ -125,6 +125,10 @@ DF_CoreCmdKind_MoveTabRight, DF_CoreCmdKind_MoveTabLeft, DF_CoreCmdKind_OpenTab, DF_CoreCmdKind_CloseTab, +DF_CoreCmdKind_CloseAllOtherTabs, +DF_CoreCmdKind_CloseAllLeftTabs, +DF_CoreCmdKind_CloseAllRightTabs, +DF_CoreCmdKind_CloseAllTabs, DF_CoreCmdKind_MoveTab, DF_CoreCmdKind_TabBarTop, DF_CoreCmdKind_TabBarBottom, diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 6f1ba7099..b8fae3ba7 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -1965,6 +1965,73 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) df_panel_notify_mutation(ws, panel); } }break; + case DF_CoreCmdKind_CloseAllOtherTabs: + { + DF_Panel *panel = df_panel_from_handle(params.panel); + DF_View *view = df_view_from_handle(params.view); + if(!df_view_is_nil(view)) + { + for(DF_View *v = panel->first_tab_view; !df_view_is_nil(v);) + { + DF_View *temp_view = v; + v = temp_view->next; + if(view != temp_view) + { + df_panel_remove_tab_view(panel, temp_view); + df_view_release(temp_view); + df_panel_notify_mutation(ws, panel); + } + } + } + }break; + case DF_CoreCmdKind_CloseAllLeftTabs: + { + DF_Panel *panel = df_panel_from_handle(params.panel); + DF_View *view = df_view_from_handle(params.view); + if(!df_view_is_nil(view)) + { + for(DF_View *v = view->prev; !df_view_is_nil(v);) + { + DF_View *temp_view = v; + v = temp_view->prev; + df_panel_remove_tab_view(panel, temp_view); + df_view_release(temp_view); + df_panel_notify_mutation(ws, panel); + } + } + }break; + case DF_CoreCmdKind_CloseAllRightTabs: + { + DF_Panel *panel = df_panel_from_handle(params.panel); + DF_View *view = df_view_from_handle(params.view); + if(!df_view_is_nil(view)) + { + for(DF_View *v = view->next; !df_view_is_nil(v);) + { + DF_View *temp_view = v; + v = temp_view->next; + df_panel_remove_tab_view(panel, temp_view); + df_view_release(temp_view); + df_panel_notify_mutation(ws, panel); + } + } + }break; + case DF_CoreCmdKind_CloseAllTabs: + { + DF_Panel *panel = df_panel_from_handle(params.panel); + DF_View *view = df_view_from_handle(params.view); + if(!df_view_is_nil(view)) + { + for(DF_View *v = panel->first_tab_view; !df_view_is_nil(v);) + { + DF_View *temp_view = v; + v = temp_view->next; + df_panel_remove_tab_view(panel, temp_view); + df_view_release(temp_view); + df_panel_notify_mutation(ws, panel); + } + } + }break; case DF_CoreCmdKind_MoveTab: { DF_Panel *src_panel = df_panel_from_handle(params.panel); @@ -4191,6 +4258,53 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_ctx_menu_close(); } + // close all other tabs + if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close All Other Tabs"))) + { + DF_CmdParams params = df_cmd_params_from_window(ws); + { + params.view = df_handle_from_view(view); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_View); + } + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseAllOtherTabs)); + ui_ctx_menu_close(); + } + + // close all (left) tabs + if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close All (Left) Tabs"))) + { + DF_CmdParams params = df_cmd_params_from_window(ws); + { + params.view = df_handle_from_view(view); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_View); + } + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseAllLeftTabs)); + ui_ctx_menu_close(); + } + + // close all (right) tabs + if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close All (Right) Tabs"))) + { + DF_CmdParams params = df_cmd_params_from_window(ws); + { + params.view = df_handle_from_view(view); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_View); + } + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseAllRightTabs)); + ui_ctx_menu_close(); + } + + // close all tabs + if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close All Tabs"))) + { + DF_CmdParams params = df_cmd_params_from_window(ws); + { + params.view = df_handle_from_view(view); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_View); + } + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseAllTabs)); + ui_ctx_menu_close(); + } } scratch_end(scratch);