mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Docking: Removed seemingly unnecessary test in TabItemEx() for undocking tab leading to window move. Added ImGuiDockNode::IsFloatingNode() helper to clarify code intent in various places.
This commit is contained in:
parent
9cda3035fd
commit
6f8d34768d
@ -11216,7 +11216,7 @@ void ImGui::DockContextUpdateDocking(ImGuiContext* ctx)
|
|||||||
// We can have NULL pointers when we delete nodes, but because ID are recycled this should amortize nicely (and our node count will never be very high)
|
// We can have NULL pointers when we delete nodes, but because ID are recycled this should amortize nicely (and our node count will never be very high)
|
||||||
for (int n = 0; n < dc->Nodes.Data.Size; n++)
|
for (int n = 0; n < dc->Nodes.Data.Size; n++)
|
||||||
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
||||||
if (node->IsRootNode() && !node->IsDockSpace())
|
if (node->IsFloatingNode())
|
||||||
DockNodeUpdate(node);
|
DockNodeUpdate(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11702,7 +11702,7 @@ static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, b
|
|||||||
|
|
||||||
// When reactivating a node with one or two loose window, the window pos/size/viewport are authoritative over the node storage.
|
// When reactivating a node with one or two loose window, the window pos/size/viewport are authoritative over the node storage.
|
||||||
// In particular it is important we init the viewport from the first window so we don't create two viewports and drop one.
|
// In particular it is important we init the viewport from the first window so we don't create two viewports and drop one.
|
||||||
if (node->HostWindow == NULL && !node->IsDockSpace() && node->IsRootNode())
|
if (node->HostWindow == NULL && node->IsFloatingNode())
|
||||||
{
|
{
|
||||||
if (node->AuthorityForPos == ImGuiDataAuthority_Auto)
|
if (node->AuthorityForPos == ImGuiDataAuthority_Auto)
|
||||||
node->AuthorityForPos = ImGuiDataAuthority_Window;
|
node->AuthorityForPos = ImGuiDataAuthority_Window;
|
||||||
@ -12026,7 +12026,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
|
|||||||
DockNodeRemoveTabBar(node);
|
DockNodeRemoveTabBar(node);
|
||||||
|
|
||||||
// Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId)
|
// Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId)
|
||||||
if (node->Windows.Size <= 1 && node->IsRootNode() && node->IsLeafNode() && !node->IsDockSpace() && !g.IO.ConfigDockingTabBarOnSingleWindows)
|
if (node->Windows.Size <= 1 && node->IsFloatingNode() && node->IsLeafNode() && !g.IO.ConfigDockingTabBarOnSingleWindows)
|
||||||
{
|
{
|
||||||
if (node->Windows.Size == 1)
|
if (node->Windows.Size == 1)
|
||||||
{
|
{
|
||||||
@ -13219,6 +13219,7 @@ ImGuiDockNode* ImGui::DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos)
|
|||||||
// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
|
// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// [Internal] Called via SetNextWindowDockID()
|
||||||
void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond)
|
void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond)
|
||||||
{
|
{
|
||||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||||
@ -14156,7 +14157,7 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings
|
|||||||
if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_settings->ID))
|
if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_settings->ID))
|
||||||
{
|
{
|
||||||
buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything
|
buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything
|
||||||
if (node->IsDockSpace && node->HostWindow && node->HostWindow->ParentWindow)
|
if (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow)
|
||||||
buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name);
|
buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name);
|
||||||
int contains_window = 0;
|
int contains_window = 0;
|
||||||
for (int window_n = 0; window_n < ctx->SettingsWindows.Size; window_n++)
|
for (int window_n = 0; window_n < ctx->SettingsWindows.Size; window_n++)
|
||||||
|
2
imgui.h
2
imgui.h
@ -1612,7 +1612,7 @@ struct ImGuiWindowClass
|
|||||||
ImGuiID ParentViewportId; // Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows. Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not.
|
ImGuiID ParentViewportId; // Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows. Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not.
|
||||||
ImGuiViewportFlags ViewportFlagsOverrideMask; // Viewport flags to override when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
|
ImGuiViewportFlags ViewportFlagsOverrideMask; // Viewport flags to override when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
|
||||||
ImGuiViewportFlags ViewportFlagsOverrideValue; // Viewport flags values to override when a window of this class owns a viewport.
|
ImGuiViewportFlags ViewportFlagsOverrideValue; // Viewport flags values to override when a window of this class owns a viewport.
|
||||||
bool DockingAllowUnclassed; // true = can be docked/merged with an unclassed window
|
bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window.
|
||||||
|
|
||||||
ImGuiWindowClass() { ClassId = 0; ParentViewportId = 0; ViewportFlagsOverrideMask = ViewportFlagsOverrideValue = 0x00; DockingAllowUnclassed = true; }
|
ImGuiWindowClass() { ClassId = 0; ParentViewportId = 0; ViewportFlagsOverrideMask = ViewportFlagsOverrideValue = 0x00; DockingAllowUnclassed = true; }
|
||||||
};
|
};
|
||||||
|
@ -963,6 +963,7 @@ struct ImGuiDockNode
|
|||||||
~ImGuiDockNode();
|
~ImGuiDockNode();
|
||||||
bool IsRootNode() const { return ParentNode == NULL; }
|
bool IsRootNode() const { return ParentNode == NULL; }
|
||||||
bool IsDockSpace() const { return (LocalFlags & ImGuiDockNodeFlags_DockSpace) != 0; }
|
bool IsDockSpace() const { return (LocalFlags & ImGuiDockNodeFlags_DockSpace) != 0; }
|
||||||
|
bool IsFloatingNode() const { return ParentNode == NULL && (LocalFlags & ImGuiDockNodeFlags_DockSpace) == 0; }
|
||||||
bool IsCentralNode() const { return (LocalFlags & ImGuiDockNodeFlags_CentralNode) != 0; }
|
bool IsCentralNode() const { return (LocalFlags & ImGuiDockNodeFlags_CentralNode) != 0; }
|
||||||
bool IsHiddenTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_HiddenTabBar) != 0; } // Hidden tab bar can be shown back by clicking the small triangle
|
bool IsHiddenTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_HiddenTabBar) != 0; } // Hidden tab bar can be shown back by clicking the small triangle
|
||||||
bool IsNoTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_NoTabBar) != 0; } // Never show a tab bar
|
bool IsNoTabBar() const { return (LocalFlags & ImGuiDockNodeFlags_NoTabBar) != 0; } // Never show a tab bar
|
||||||
|
@ -6979,10 +6979,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
SetItemAllowOverlap();
|
SetItemAllowOverlap();
|
||||||
|
|
||||||
// Drag and drop a single floating window node moves it
|
// Drag and drop a single floating window node moves it
|
||||||
// FIXME-DOCK: In theory we shouldn't test for the ConfigDockingNodifySingleWindows flag here.
|
|
||||||
// When our single window node and OnlyNodeWithWindows are working properly we may remove this check here.
|
|
||||||
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
|
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
|
||||||
const bool single_floating_window_node = node && node->IsRootNode() && !node->IsDockSpace() && node->Windows.Size == 1 && g.IO.ConfigDockingTabBarOnSingleWindows;
|
const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
|
||||||
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
|
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
|
||||||
{
|
{
|
||||||
// Move
|
// Move
|
||||||
|
Loading…
Reference in New Issue
Block a user