diff --git a/src/df/core/df_core.mdesk b/src/df/core/df_core.mdesk index 4f468cc3..3a3e7be0 100644 --- a/src/df/core/df_core.mdesk +++ b/src/df/core/df_core.mdesk @@ -95,6 +95,7 @@ DF_CmdParamSlotTable: {ID id `U64`} {PreferDisassembly prefer_dasm `B32`} {ForceConfirm force_confirm `B32`} + {Dir2 dir2 `Dir2`} } @table(name lister_omit q_slot q_ent_kind q_allow_files q_allow_folders q_keep_oi q_select_oi q_is_code q_required canonical_icon string display_name desc search_tags ) @@ -176,8 +177,11 @@ DF_CoreCmdTable:// | | | //- rjf: panel splitting {ResetToDefaultPanels 0 Null Nil 0 0 0 0 0 0 Window "reset_to_default_panels" "Reset To Default Panel Layout" "Resets the window to the default panel layout." "panel" } - {NewPanelRight 0 Null Nil 0 0 0 0 0 0 XSplit "new_panel_right" "Split Panel Vertically" "Creates a new panel to the right of the active panel." "panel" } - {NewPanelDown 0 Null Nil 0 0 0 0 0 0 YSplit "new_panel_down" "Split Panel Horizontally" "Creates a new panel at the bottom of the active panel." "panel" } + {NewPanelLeft 0 Null Nil 0 0 0 0 0 0 XSplit "new_panel_left" "Split Panel Left" "Creates a new panel to the left of the active panel." "panel" } + {NewPanelUp 0 Null Nil 0 0 0 0 0 0 YSplit "new_panel_up" "Split Panel Up" "Creates a new panel at the top of the active panel." "panel" } + {NewPanelRight 0 Null Nil 0 0 0 0 0 0 XSplit "new_panel_right" "Split Panel Right" "Creates a new panel to the right of the active panel." "panel" } + {NewPanelDown 0 Null Nil 0 0 0 0 0 0 YSplit "new_panel_down" "Split Panel Down" "Creates a new panel at the bottom of the active panel." "panel" } + {SplitPanel 1 Null Nil 0 0 0 0 0 0 Null "split_panel" "Split Panel" "Creates a new panel in a given direction, and moves a tab to it, if specified." "" } //- rjf: panel rotation {RotatePanelColumns 0 Null Nil 0 0 0 0 0 0 Null "rotate_panel_columns" "Rotate Panel Columns" "Rotates all panels at the closest column level of the panel hierarchy." "" } diff --git a/src/df/core/generated/df_core.meta.c b/src/df/core/generated/df_core.meta.c index a0fc19d5..9dcba9f9 100644 --- a/src/df/core/generated/df_core.meta.c +++ b/src/df/core/generated/df_core.meta.c @@ -4,7 +4,7 @@ //- GENERATED CODE C_LINKAGE_BEGIN -Rng1U64 df_g_cmd_param_slot_range_table[20] = +Rng1U64 df_g_cmd_param_slot_range_table[21] = { {0}, {OffsetOf(DF_CmdParams, window), OffsetOf(DF_CmdParams, window) + sizeof(DF_Handle)}, @@ -26,6 +26,7 @@ Rng1U64 df_g_cmd_param_slot_range_table[20] = {OffsetOf(DF_CmdParams, id), OffsetOf(DF_CmdParams, id) + sizeof(U64)}, {OffsetOf(DF_CmdParams, prefer_dasm), OffsetOf(DF_CmdParams, prefer_dasm) + sizeof(B32)}, {OffsetOf(DF_CmdParams, force_confirm), OffsetOf(DF_CmdParams, force_confirm) + sizeof(B32)}, +{OffsetOf(DF_CmdParams, dir2), OffsetOf(DF_CmdParams, dir2) + sizeof(Dir2)}, }; DF_IconKind df_g_entity_kind_icon_kind_table[27] = @@ -215,7 +216,7 @@ DF_CoreCmdKind_Null, DF_CoreCmdKind_Null, }; -DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[209] = +DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[212] = { { 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}, @@ -269,8 +270,11 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[209] = { str8_lit_comp("confirm_accept"), str8_lit_comp("Accepts the active confirmation prompt."), str8_lit_comp(""), str8_lit_comp("Confirm Accept"), (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("confirm_cancel"), str8_lit_comp("Cancels the active confirmation prompt."), str8_lit_comp(""), str8_lit_comp("Confirm Cancel"), (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("reset_to_default_panels"), str8_lit_comp("Resets the window to the default panel layout."), str8_lit_comp("panel"), str8_lit_comp("Reset To Default Panel Layout"), (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_Window}, -{ str8_lit_comp("new_panel_right"), str8_lit_comp("Creates a new panel to the right of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel Vertically"), (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_XSplit}, -{ str8_lit_comp("new_panel_down"), str8_lit_comp("Creates a new panel at the bottom of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel Horizontally"), (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_YSplit}, +{ str8_lit_comp("new_panel_left"), str8_lit_comp("Creates a new panel to the left of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel 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_XSplit}, +{ str8_lit_comp("new_panel_up"), str8_lit_comp("Creates a new panel at the top of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel Up"), (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_YSplit}, +{ str8_lit_comp("new_panel_right"), str8_lit_comp("Creates a new panel to the right of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel 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_XSplit}, +{ str8_lit_comp("new_panel_down"), str8_lit_comp("Creates a new panel at the bottom of the active panel."), str8_lit_comp("panel"), str8_lit_comp("Split Panel Down"), (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_YSplit}, +{ str8_lit_comp("split_panel"), str8_lit_comp("Creates a new panel in a given direction, and moves a tab to it, if specified."), str8_lit_comp(""), str8_lit_comp("Split Panel"), (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("rotate_panel_columns"), str8_lit_comp("Rotates all panels at the closest column level of the panel hierarchy."), str8_lit_comp(""), str8_lit_comp("Rotate Panel Columns"), (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_Null}, { str8_lit_comp("next_panel"), str8_lit_comp("Cycles the active panel forward."), str8_lit_comp(""), str8_lit_comp("Focus Next Panel"), (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_RightArrow}, { str8_lit_comp("prev_panel"), str8_lit_comp("Cycles the active panel backwards."), str8_lit_comp(""), str8_lit_comp("Focus Previous Panel"), (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}, diff --git a/src/df/core/generated/df_core.meta.h b/src/df/core/generated/df_core.meta.h index 470e4a9f..4fd88f55 100644 --- a/src/df/core/generated/df_core.meta.h +++ b/src/df/core/generated/df_core.meta.h @@ -101,8 +101,11 @@ DF_CoreCmdKind_ToggleFullscreen, DF_CoreCmdKind_ConfirmAccept, DF_CoreCmdKind_ConfirmCancel, DF_CoreCmdKind_ResetToDefaultPanels, +DF_CoreCmdKind_NewPanelLeft, +DF_CoreCmdKind_NewPanelUp, DF_CoreCmdKind_NewPanelRight, DF_CoreCmdKind_NewPanelDown, +DF_CoreCmdKind_SplitPanel, DF_CoreCmdKind_RotatePanelColumns, DF_CoreCmdKind_NextPanel, DF_CoreCmdKind_PrevPanel, @@ -379,6 +382,7 @@ DF_CmdParamSlot_Index, DF_CmdParamSlot_ID, DF_CmdParamSlot_PreferDisassembly, DF_CmdParamSlot_ForceConfirm, +DF_CmdParamSlot_Dir2, DF_CmdParamSlot_COUNT, } DF_CmdParamSlot; @@ -405,6 +409,7 @@ U64 index; U64 id; B32 prefer_dasm; B32 force_confirm; +Dir2 dir2; }; DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array); @@ -1515,7 +1520,7 @@ struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] = {&DEV_updating_indicator, str8_lit_comp("updating_indicator")}, }; C_LINKAGE_BEGIN -extern Rng1U64 df_g_cmd_param_slot_range_table[20]; +extern Rng1U64 df_g_cmd_param_slot_range_table[21]; extern DF_IconKind df_g_entity_kind_icon_kind_table[27]; extern String8 df_g_entity_kind_display_string_table[27]; extern String8 df_g_entity_kind_name_label_table[27]; diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index e9c7c293..4b215abf 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -1095,7 +1095,8 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } // rjf: set up data for cases - Axis2 split_axis = Axis2_X; + Dir2 split_dir = Dir2_Invalid; + DF_Panel *split_panel = ws->focused_panel; U64 panel_sib_off = 0; U64 panel_child_off = 0; Vec2S32 panel_change_dir = {0}; @@ -1198,16 +1199,27 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D }break; //- rjf: panel creation - case DF_CoreCmdKind_NewPanelRight: split_axis = Axis2_X; goto split; - case DF_CoreCmdKind_NewPanelDown: split_axis = Axis2_Y; goto split; - split:; + case DF_CoreCmdKind_NewPanelLeft: {split_dir = Dir2_Left;}goto split; + case DF_CoreCmdKind_NewPanelUp: {split_dir = Dir2_Up;}goto split; + case DF_CoreCmdKind_NewPanelRight:{split_dir = Dir2_Right;}goto split; + case DF_CoreCmdKind_NewPanelDown: {split_dir = Dir2_Down;}goto split; + case DF_CoreCmdKind_SplitPanel: { - DF_Panel *panel = ws->focused_panel; + split_dir = params.dir2; + split_panel = df_panel_from_handle(params.dest_panel); + }goto split; + split:; + if(split_dir != Dir2_Invalid && !df_panel_is_nil(split_panel)) + { + DF_Panel *new_panel = &df_g_nil_panel; + Axis2 split_axis = axis2_from_dir2(split_dir); + Side split_side = side_from_dir2(split_dir); + DF_Panel *panel = split_panel; DF_Panel *parent = panel->parent; if(!df_panel_is_nil(parent) && parent->split_axis == split_axis) { DF_Panel *next = df_panel_alloc(ws); - df_panel_insert(parent, panel, next); + df_panel_insert(parent, split_side == Side_Max ? panel : panel->prev, next); next->size_pct_of_parent_target.v[split_axis] = 1.f / parent->child_count; next->size_pct_of_parent.v[axis2_flip(split_axis)] = next->size_pct_of_parent_target.v[axis2_flip(split_axis)] = 1.f; for(DF_Panel *child = parent->first; !df_panel_is_nil(child); child = child->next) @@ -1218,6 +1230,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } } ws->focused_panel = next; + new_panel = next; } else { @@ -1238,6 +1251,10 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D } DF_Panel *left = panel; DF_Panel *right = df_panel_alloc(ws); + if(split_side == Side_Min) + { + Swap(DF_Panel *, left, right); + } df_panel_insert(new_parent, &df_g_nil_panel, left); df_panel_insert(new_parent, left, right); new_parent->split_axis = split_axis; @@ -1250,6 +1267,21 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D right->size_pct_of_parent.v[axis2_flip(split_axis)] = 1.f; right->size_pct_of_parent_target.v[axis2_flip(split_axis)] = 1.f; ws->focused_panel = right; + new_panel = right; + } + DF_Panel *move_tab_panel = df_panel_from_handle(params.panel); + DF_View *move_tab = df_view_from_handle(params.view); + if(!df_panel_is_nil(new_panel) && !df_view_is_nil(move_tab) && !df_panel_is_nil(move_tab_panel) && + core_cmd_kind == DF_CoreCmdKind_SplitPanel) + { + df_panel_remove_tab_view(move_tab_panel, move_tab); + df_panel_insert_tab_view(new_panel, new_panel->last_tab_view, move_tab); + new_panel->selected_tab_view = df_handle_from_view(move_tab); + if(df_view_is_nil(move_tab_panel->first_tab_view) && move_tab_panel != ws->root_panel) + { + DF_CmdParams p = df_cmd_params_from_panel(ws, move_tab_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; @@ -1808,6 +1840,11 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D df_panel_remove_tab_view(src_panel, view); df_panel_insert_tab_view(dst_panel, prev_view, view); ws->focused_panel = dst_panel; + if(df_view_is_nil(src_panel->first_tab_view) && src_panel != ws->root_panel) + { + DF_CmdParams p = df_cmd_params_from_panel(ws, src_panel); + df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ClosePanel)); + } df_panel_notify_mutation(ws, dst_panel); } }break; @@ -5725,7 +5762,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D Rng2F32 rect = sites[idx].rect; Dir2 dir = sites[idx].split_dir; Axis2 split_axis = axis2_from_dir2(dir); - B32 highlighted = contains_2f32(rect, ui_mouse()); + B32 highlighted = contains_2f32(pad_2f32(rect, padding/2), ui_mouse()); { if(highlighted) { @@ -5763,13 +5800,30 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D DF_DragDropPayload payload = {0}; if(highlighted && df_drag_drop(&payload)) { - + if(dir != Dir2_Invalid) + { + DF_CmdParams p = df_cmd_params_from_window(ws); + p.dest_panel = df_handle_from_panel(panel); + p.panel = payload.panel; + p.view = payload.view; + p.dir2 = dir; + df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SplitPanel)); + } + else + { + DF_CmdParams p = df_cmd_params_from_window(ws); + p.dest_panel = df_handle_from_panel(panel); + p.panel = payload.panel; + p.view = payload.view; + p.prev_view = df_handle_from_view(panel->last_tab_view); + df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_MoveTab)); + } } } for(U64 idx = 0; idx < ArrayCount(sites); idx += 1) { Rng2F32 rect = sites[idx].rect; - B32 highlighted = contains_2f32(rect, ui_mouse()); + B32 highlighted = contains_2f32(pad_2f32(rect, padding/2), ui_mouse()); if(highlighted) { split_drop_site_targeted = 1;