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

Hope this doesn't feel spammy?
This commit is contained in:
ocornut 2023-08-30 17:36:09 +02:00
parent 7d6e83efca
commit 300464a487
3 changed files with 20 additions and 3 deletions

View File

@ -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)

View File

@ -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()
@ -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))
@ -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);

View File

@ -1862,6 +1862,7 @@ enum ImGuiLocKey : int
ImGuiLocKey_WindowingPopup,
ImGuiLocKey_WindowingUntitled,
ImGuiLocKey_DockingHideTabBar,
ImGuiLocKey_DockingHoldShiftToDock,
ImGuiLocKey_COUNT
};