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?
features/sdl_renderer3_multiviewports
ocornut ago%!(EXTRA string=2 years)
parent 7d6e83efca
commit 300464a487
  1. 5
      docs/CHANGELOG.txt
  2. 17
      imgui.cpp
  3. 1
      imgui_internal.h

@ -73,6 +73,11 @@ Other changes:
for consistency (matching GLFW backend) and as most initialization paths don't actually for consistency (matching GLFW backend) and as most initialization paths don't actually
need to care about rendering backend. 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) VERSION 1.89.8 (Released 2023-08-01)

@ -3639,6 +3639,7 @@ static const ImGuiLocEntry GLocalizationEntriesEnUS[] =
{ ImGuiLocKey_WindowingPopup, "(Popup)" }, { ImGuiLocKey_WindowingPopup, "(Popup)" },
{ ImGuiLocKey_WindowingUntitled, "(Untitled)" }, { ImGuiLocKey_WindowingUntitled, "(Untitled)" },
{ ImGuiLocKey_DockingHideTabBar, "Hide tab bar###HideTabBar" }, { ImGuiLocKey_DockingHideTabBar, "Hide tab bar###HideTabBar" },
{ ImGuiLocKey_DockingHoldShiftToDock, "Hold SHIFT to enable Docking window."},
}; };
void ImGui::Initialize() 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. // 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. // 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 (g.MovingWindow == window && (window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0)
if ((window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoDocking) == 0) BeginDockableDragDropSource(window);
BeginDockableDragDropSource(window);
// Docking: Any dockable window can act as a target. For dock node hosts we call BeginDockableDragDropTarget() in DockNodeUpdate() instead. // 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)) if (g.DragDropActive && !(flags & ImGuiWindowFlags_NoDocking))
@ -18554,6 +18554,17 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window)
IM_ASSERT(g.MovingWindow == window); IM_ASSERT(g.MovingWindow == window);
IM_ASSERT(g.CurrentWindow == 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; g.LastItemData.ID = window->MoveId;
window = window->RootWindowDockTree; window = window->RootWindowDockTree;
IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0); IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);

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

Loading…
Cancel
Save