Skip to content
/ imgui Public
forked from ocornut/imgui

Commit

Permalink
Docking: when io.ConfigDockingWithShift is enabled, staying stationar…
Browse files Browse the repository at this point in the history
…y while moving a window displays an help tooltip to increase affordance. (ocornut#6709, ocornut#4643)

Hope this doesn't feel spammy?
  • Loading branch information
ocornut committed Aug 30, 2023
1 parent 7d6e83e commit 300464a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Other changes:
for consistency (matching GLFW backend) and as most initialization paths don't actually
need to care about rendering backend.

Docking+Viewports Branch:

- Docking: when io.ConfigDockingWithShift is enabled, staying stationary while moving
a window displays an help tooltip to increase affordance. (#6709, #4643)


-----------------------------------------------------------------------
VERSION 1.89.8 (Released 2023-08-01)
Expand Down
17 changes: 14 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3639,6 +3639,7 @@ static const ImGuiLocEntry GLocalizationEntriesEnUS[] =
{ ImGuiLocKey_WindowingPopup, "(Popup)" },
{ ImGuiLocKey_WindowingUntitled, "(Untitled)" },
{ ImGuiLocKey_DockingHideTabBar, "Hide tab bar###HideTabBar" },
{ ImGuiLocKey_DockingHoldShiftToDock, "Hold SHIFT to enable Docking window."},
};

void ImGui::Initialize()
Expand Down Expand Up @@ -7314,9 +7315,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
// Docking: Dragging a dockable window (or any of its child) turns it into a drag and drop source.
// We need to do this _before_ we overwrite window->DC.LastItemId below because BeginDockableDragDropSource() also overwrites it.
if ((g.MovingWindow == window) && (g.IO.ConfigDockingWithShift == g.IO.KeyShift))
if ((window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0)
BeginDockableDragDropSource(window);
if (g.MovingWindow == window && (window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0)
BeginDockableDragDropSource(window);

// Docking: Any dockable window can act as a target. For dock node hosts we call BeginDockableDragDropTarget() in DockNodeUpdate() instead.
if (g.DragDropActive && !(flags & ImGuiWindowFlags_NoDocking))
Expand Down Expand Up @@ -18554,6 +18554,17 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window)
IM_ASSERT(g.MovingWindow == window);
IM_ASSERT(g.CurrentWindow == window);

// 0: Hold SHIFT to disable docking, 1: Hold SHIFT to enable docking.
if (g.IO.ConfigDockingWithShift != g.IO.KeyShift)
{
// When ConfigDockingWithShift is set, display a tooltip to increase UI affordance.
// We cannot set for HoveredWindowUnderMovingWindow != NULL here, as it is only valid/useful when drag and drop is already active
// (because of the 'is_mouse_dragging_with_an_expected_destination' logic in UpdateViewportsNewFrame() function)
if (g.IO.ConfigDockingWithShift && g.MouseStationaryTimer >= 1.0f && g.ActiveId >= 1.0f)
SetTooltip("%s", LocalizeGetMsg(ImGuiLocKey_DockingHoldShiftToDock));
return;
}

g.LastItemData.ID = window->MoveId;
window = window->RootWindowDockTree;
IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
Expand Down
1 change: 1 addition & 0 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,7 @@ enum ImGuiLocKey : int
ImGuiLocKey_WindowingPopup,
ImGuiLocKey_WindowingUntitled,
ImGuiLocKey_DockingHideTabBar,
ImGuiLocKey_DockingHoldShiftToDock,
ImGuiLocKey_COUNT
};

Expand Down

0 comments on commit 300464a

Please sign in to comment.