Skip to content

Commit 3ed07a8

Browse files
committed
Docking: removed io.ConfigDockingWithShift option. (ocornut#2109)
1 parent 0e0a783 commit 3ed07a8

File tree

5 files changed

+16
-23
lines changed

5 files changed

+16
-23
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Other Changes:
128128

129129
Docking Branch:
130130

131+
- [Breaking] Removed io.ConfigDockingWithShift config option. Behavior always equivalent to having the
132+
option set to false (dock/undock by default, hold shift to avoid docking). (#2109)
131133
- Docking: DockSpace() returns its node ID.
132134
- Docking: Dockspace() never draws a background. (#3924)
133135
- Docking: undocking nodes/windows covering most of the monitor max their size down to 90% to ease further manipulations.

imgui.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ ImGuiIO::ImGuiIO()
11011101

11021102
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
11031103
ConfigDockingNoSplit = false;
1104-
ConfigDockingWithShift = false;
11051104
ConfigDockingAlwaysTabBar = false;
11061105
ConfigDockingTransparentPayload = false;
11071106

@@ -6784,7 +6783,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
67846783
{
67856784
// Docking: Dragging a dockable window (or any of its child) turns it into a drag and drop source.
67866785
// We need to do this _before_ we overwrite window->DC.LastItemId below because BeginDockableDragDropSource() also overwrites it.
6787-
if ((g.MovingWindow == window) && (g.IO.ConfigDockingWithShift == g.IO.KeyShift))
6786+
if (g.MovingWindow == window && g.IO.KeyShift == false)
67886787
if ((window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0)
67896788
BeginDockableDragDropSource(window);
67906789

@@ -14200,9 +14199,9 @@ static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockN
1420014199
}
1420114200
}
1420214201

14203-
// When docking without holding Shift, we only allow and preview docking when hovering over a drop rect or over the title bar
14202+
// We only allow and preview docking when hovering over a drop rect or over the title bar
1420414203
data->IsDropAllowed = (data->SplitDir != ImGuiDir_None) || (data->IsCenterAvailable);
14205-
if (!is_explicit_target && !data->IsSplitDirExplicit && !g.IO.ConfigDockingWithShift)
14204+
if (!is_explicit_target && !data->IsSplitDirExplicit)
1420614205
data->IsDropAllowed = false;
1420714206

1420814207
// Calculate split area
@@ -15472,7 +15471,7 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window)
1547215471
window->DC.LastItemId = window->MoveId;
1547315472
window = window->RootWindowDockTree;
1547415473
IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
15475-
bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset);
15474+
bool is_drag_docking = ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset); // FIXME-DOCKING: Need to make this stateful and explicit
1547615475
if (is_drag_docking && BeginDragDropSource(ImGuiDragDropFlags_SourceNoPreviewTooltip | ImGuiDragDropFlags_SourceNoHoldToOpenOthers | ImGuiDragDropFlags_SourceAutoExpirePayload))
1547715476
{
1547815477
SetDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, &window, sizeof(window));
@@ -15533,7 +15532,7 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window)
1553315532
}
1553415533

1553515534
const ImRect explicit_target_rect = (node && node->TabBar && !node->IsHiddenTabBar() && !node->IsNoTabBar()) ? node->TabBar->BarRect : ImRect(window->Pos, window->Pos + ImVec2(window->Size.x, GetFrameHeight()));
15536-
const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
15535+
const bool is_explicit_target = IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
1553715536

1553815537
// Preview docking request and find out split direction/ratio
1553915538
//const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window.

imgui.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,8 @@ namespace ImGui
759759
// Docking
760760
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
761761
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
762-
// - To dock windows: if io.ConfigDockingWithShift == false (default) drag window from their title bar.
763-
// - To dock windows: if io.ConfigDockingWithShift == true: hold SHIFT anywhere while moving windows.
762+
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
763+
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
764764
// About DockSpace:
765765
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
766766
// - DockSpace() needs to be submitted _before_ any window they can host. If you use a dockspace, submit it early in your app.
@@ -1854,7 +1854,6 @@ struct ImGuiIO
18541854

18551855
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
18561856
bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
1857-
bool ConfigDockingWithShift; // = false // Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
18581857
bool ConfigDockingAlwaysTabBar; // = false // [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead] Make every single floating window display within a docking node.
18591858
bool ConfigDockingTransparentPayload;// = false // [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
18601859

imgui_demo.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,12 @@ void ImGui::ShowDemoWindow(bool* p_open)
456456
ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.");
457457

458458
ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", &io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
459-
ImGui::SameLine(); HelpMarker(io.ConfigDockingWithShift ? "[beta] Use SHIFT to dock window into each others." : "[beta] Drag from title bar to dock windows into each others.");
459+
ImGui::SameLine(); HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).");
460460
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
461461
{
462462
ImGui::Indent();
463463
ImGui::Checkbox("io.ConfigDockingNoSplit", &io.ConfigDockingNoSplit);
464464
ImGui::SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.");
465-
ImGui::Checkbox("io.ConfigDockingWithShift", &io.ConfigDockingWithShift);
466-
ImGui::SameLine(); HelpMarker("Enable docking when holding Shift only (allows to drop in wider space, reduce visual noise)");
467465
ImGui::Checkbox("io.ConfigDockingAlwaysTabBar", &io.ConfigDockingAlwaysTabBar);
468466
ImGui::SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.");
469467
ImGui::Checkbox("io.ConfigDockingTransparentPayload", &io.ConfigDockingTransparentPayload);
@@ -5741,7 +5739,6 @@ void ImGui::ShowAboutWindow(bool* p_open)
57415739
if (io.ConfigViewportsNoDecoration) ImGui::Text("io.ConfigViewportsNoDecoration");
57425740
if (io.ConfigViewportsNoDefaultParent) ImGui::Text("io.ConfigViewportsNoDefaultParent");
57435741
if (io.ConfigDockingNoSplit) ImGui::Text("io.ConfigDockingNoSplit");
5744-
if (io.ConfigDockingWithShift) ImGui::Text("io.ConfigDockingWithShift");
57455742
if (io.ConfigDockingAlwaysTabBar) ImGui::Text("io.ConfigDockingAlwaysTabBar");
57465743
if (io.ConfigDockingTransparentPayload) ImGui::Text("io.ConfigDockingTransparentPayload");
57475744
if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
@@ -7463,7 +7460,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
74637460

74647461
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
74657462
// Note that you dock windows into each others _without_ a dockspace, by just clicking on
7466-
// a window title bar and moving it (+ hold SHIFT if io.ConfigDockingWithShift is set).
7463+
// a window title bar or tab and moving it.
74677464
// DockSpace() and DockSpaceOverViewport() are only useful to construct a central docking
74687465
// location for your application.
74697466
void ShowExampleAppDockSpace(bool* p_open)
@@ -7556,11 +7553,10 @@ void ShowExampleAppDockSpace(bool* p_open)
75567553
ImGui::EndMenu();
75577554
}
75587555
HelpMarker(
7559-
"When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n\n"
7560-
" > if io.ConfigDockingWithShift==false (default):" "\n"
7561-
" drag windows from title bar to dock" "\n"
7562-
" > if io.ConfigDockingWithShift==true:" "\n"
7563-
" drag windows from anywhere and hold Shift to dock" "\n\n"
7556+
"When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n"
7557+
"- Drag from window title bar or their tab to dock/undock." "\n"
7558+
"- Drag from window menu button (upper-left button) to undock an entire node (all windows)." "\n"
7559+
"- Hold SHIFT to disable docking." "\n"
75647560
"This demo app has nothing to do with it!" "\n\n"
75657561
"This demo app only demonstrate the use of ImGui::DockSpace() which allows you to manually create a docking node _within_ another window. This is useful so you can decorate your main application window (e.g. with a menu bar)." "\n\n"
75667562
"ImGui::DockSpace() comes with one hard constraint: it needs to be submitted _before_ any window which may be docked into it. Therefore, if you use a dock spot as the central point of your application, you'll probably want it to be part of the very first window you are submitting to imgui every frame." "\n\n"

imgui_widgets.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -7920,20 +7920,17 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
79207920
else if (held && !tab_appearing && IsMouseDragging(0))
79217921
{
79227922
// Drag and drop: re-order tabs
7923-
int drag_dir = 0;
79247923
float drag_distance_from_edge_x = 0.0f;
79257924
if (!g.DragDropActive && ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (docked_window != NULL)))
79267925
{
79277926
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
79287927
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
79297928
{
7930-
drag_dir = -1;
79317929
drag_distance_from_edge_x = bb.Min.x - g.IO.MousePos.x;
79327930
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
79337931
}
79347932
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
79357933
{
7936-
drag_dir = +1;
79377934
drag_distance_from_edge_x = g.IO.MousePos.x - bb.Max.x;
79387935
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
79397936
}
@@ -7955,7 +7952,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
79557952
if (distance_from_edge_y >= threshold_y)
79567953
undocking_tab = true;
79577954
if (drag_distance_from_edge_x > threshold_x)
7958-
if ((drag_dir < 0 && tab_bar->GetTabOrder(tab) == 0) || (drag_dir > 0 && tab_bar->GetTabOrder(tab) == tab_bar->Tabs.Size - 1))
7955+
if ((tab_bar->GetTabOrder(tab) == 0) || (tab_bar->GetTabOrder(tab) == tab_bar->Tabs.Size - 1))
79597956
undocking_tab = true;
79607957
}
79617958

0 commit comments

Comments
 (0)