mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-25 17:16:35 +00:00
Docking: Comments + maiintain LastFrameFocused per node + using bitfiield for docking bools.
This commit is contained in:
parent
3f51c831de
commit
4575354bc0
@ -133,7 +133,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- dock: B- single visible node part of a hidden split hierarchy (OnlyNodeWithWindows != NULL) should show a normal title bar (not a tab bar)
|
- dock: B- single visible node part of a hidden split hierarchy (OnlyNodeWithWindows != NULL) should show a normal title bar (not a tab bar)
|
||||||
- dock: B~ SetNextWindowDock() calls (with conditional) -> defer everything to DockContextUpdate (repro: Documents->[X]Windows->Dock 1 elsewhere->Click Redock All
|
- dock: B~ SetNextWindowDock() calls (with conditional) -> defer everything to DockContextUpdate (repro: Documents->[X]Windows->Dock 1 elsewhere->Click Redock All
|
||||||
- dock: B~ tidy up tab list popup buttons features (available with manual tab-bar, see ImGuiTabBarFlags_NoTabListPopupButton code, not used by docking nodes)
|
- dock: B~ tidy up tab list popup buttons features (available with manual tab-bar, see ImGuiTabBarFlags_NoTabListPopupButton code, not used by docking nodes)
|
||||||
- dock: B- DockSpace() border issues
|
- dock: B- SetNextWindowDockId(0) with a second Begin() in the frame will asserts
|
||||||
- dock: B- inconsistent clipping/border 1-pixel issue (#2)
|
- dock: B- inconsistent clipping/border 1-pixel issue (#2)
|
||||||
- dock: B- fix/disable auto-resize grip on split host nodes (~#2)
|
- dock: B- fix/disable auto-resize grip on split host nodes (~#2)
|
||||||
- dock: B- SetNextWindowFocus() doesn't seem to apply if the window is hidden this frame, need repro (#4)
|
- dock: B- SetNextWindowFocus() doesn't seem to apply if the window is hidden this frame, need repro (#4)
|
||||||
|
38
imgui.cpp
38
imgui.cpp
@ -10351,7 +10351,7 @@ ImGuiDockNode::ImGuiDockNode(ImGuiID id)
|
|||||||
|
|
||||||
HostWindow = VisibleWindow = NULL;
|
HostWindow = VisibleWindow = NULL;
|
||||||
CentralNode = OnlyNodeWithWindows = NULL;
|
CentralNode = OnlyNodeWithWindows = NULL;
|
||||||
LastFrameAlive = LastFrameActive = -1;
|
LastFrameAlive = LastFrameActive = LastFrameFocused = -1;
|
||||||
LastFocusedNodeID = 0;
|
LastFocusedNodeID = 0;
|
||||||
SelectedTabID = 0;
|
SelectedTabID = 0;
|
||||||
WantCloseTabID = 0;
|
WantCloseTabID = 0;
|
||||||
@ -10565,10 +10565,10 @@ static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node)
|
|||||||
|
|
||||||
struct ImGuiDockNodeUpdateScanResults
|
struct ImGuiDockNodeUpdateScanResults
|
||||||
{
|
{
|
||||||
ImGuiDockNode* CentralNode;
|
ImGuiDockNode* CentralNode;
|
||||||
ImGuiDockNode* FirstNodeWithWindows;
|
ImGuiDockNode* FirstNodeWithWindows;
|
||||||
int CountNodesWithWindows;
|
int CountNodesWithWindows;
|
||||||
ImGuiDockFamily DockFamilyForMerges;
|
//ImGuiDockFamily DockFamilyForMerges;
|
||||||
|
|
||||||
ImGuiDockNodeUpdateScanResults() { CentralNode = FirstNodeWithWindows = NULL; CountNodesWithWindows = 0; }
|
ImGuiDockNodeUpdateScanResults() { CentralNode = FirstNodeWithWindows = NULL; CountNodesWithWindows = 0; }
|
||||||
};
|
};
|
||||||
@ -10594,6 +10594,8 @@ static void DockNodeUpdateScanRec(ImGuiDockNode* node, ImGuiDockNodeUpdateScanRe
|
|||||||
DockNodeUpdateScanRec(node->ChildNodes[1], results);
|
DockNodeUpdateScanRec(node->ChildNodes[1], results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - Remove inactive windows/nodes.
|
||||||
|
// - Update visibility flag.
|
||||||
static void ImGui::DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node)
|
static void ImGui::DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -10679,7 +10681,9 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
|
|||||||
{
|
{
|
||||||
DockNodeUpdateVisibleFlagAndInactiveChilds(node);
|
DockNodeUpdateVisibleFlagAndInactiveChilds(node);
|
||||||
|
|
||||||
// Find if there's only a single visible window in the hierarchy (in which case we need to display a regular title bar -> FIXME-DOCK: that last part is not done yet!)
|
// FIXME-DOCK: Merge this scan into the one above.
|
||||||
|
// - Setup central node pointers
|
||||||
|
// - Find if there's only a single visible window in the hierarchy (in which case we need to display a regular title bar -> FIXME-DOCK: that last part is not done yet!)
|
||||||
ImGuiDockNodeUpdateScanResults results;
|
ImGuiDockNodeUpdateScanResults results;
|
||||||
DockNodeUpdateScanRec(node, &results);
|
DockNodeUpdateScanRec(node, &results);
|
||||||
node->CentralNode = results.CentralNode;
|
node->CentralNode = results.CentralNode;
|
||||||
@ -10756,7 +10760,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
|
|||||||
node->HasCollapseButton = (node->Windows.Size > 0);
|
node->HasCollapseButton = (node->Windows.Size > 0);
|
||||||
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
|
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
|
||||||
{
|
{
|
||||||
// FIXME: Setting DockIsActive here means that for single active window in a leaf node, DockIsActive will be cleared until the next Begin() call.
|
// FIXME-DOCK: Setting DockIsActive here means that for single active window in a leaf node, DockIsActive will be cleared until the next Begin() call.
|
||||||
ImGuiWindow* window = node->Windows[window_n];
|
ImGuiWindow* window = node->Windows[window_n];
|
||||||
window->DockIsActive = (node->Windows.Size > 1);
|
window->DockIsActive = (node->Windows.Size > 1);
|
||||||
node->HasCloseButton |= window->HasCloseButton;
|
node->HasCloseButton |= window->HasCloseButton;
|
||||||
@ -10938,6 +10942,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
|||||||
{
|
{
|
||||||
node->VisibleWindow = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
|
node->VisibleWindow = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
|
||||||
node->IsFocused = is_focused;
|
node->IsFocused = is_focused;
|
||||||
|
if (is_focused)
|
||||||
|
node->LastFrameFocused = g.FrameCount;
|
||||||
|
|
||||||
// Notify root of visible window (used to display title in OS task bar)
|
// Notify root of visible window (used to display title in OS task bar)
|
||||||
if (node->VisibleWindow)
|
if (node->VisibleWindow)
|
||||||
@ -10997,6 +11003,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
|||||||
|
|
||||||
// Title bar
|
// Title bar
|
||||||
node->IsFocused = is_focused;
|
node->IsFocused = is_focused;
|
||||||
|
if (is_focused)
|
||||||
|
node->LastFrameFocused = g.FrameCount;
|
||||||
ImRect title_bar_rect = ImRect(node->Pos, node->Pos + ImVec2(node->Size.x, g.FontSize + style.FramePadding.y * 2.0f));
|
ImRect title_bar_rect = ImRect(node->Pos, node->Pos + ImVec2(node->Size.x, g.FontSize + style.FramePadding.y * 2.0f));
|
||||||
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
|
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
|
||||||
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, ImDrawCornerFlags_Top);
|
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, ImDrawCornerFlags_Top);
|
||||||
@ -11850,15 +11858,15 @@ ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags
|
|||||||
char label[32];
|
char label[32];
|
||||||
ImFormatString(label, IM_ARRAYSIZE(label), "DockspaceViewport_%08X", viewport->ID);
|
ImFormatString(label, IM_ARRAYSIZE(label), "DockspaceViewport_%08X", viewport->ID);
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
ImGui::Begin(label, NULL, host_window_flags);
|
Begin(label, NULL, host_window_flags);
|
||||||
ImGui::PopStyleVar(3);
|
PopStyleVar(3);
|
||||||
|
|
||||||
ImGuiID dockspace_id = ImGui::GetID("Dockspace");
|
ImGuiID dockspace_id = GetID("Dockspace");
|
||||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, dock_family);
|
DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, dock_family);
|
||||||
ImGui::End();
|
End();
|
||||||
|
|
||||||
return dockspace_id;
|
return dockspace_id;
|
||||||
}
|
}
|
||||||
|
@ -752,19 +752,19 @@ struct ImGuiTabBarSortItem
|
|||||||
float Width;
|
float Width;
|
||||||
};
|
};
|
||||||
|
|
||||||
// sizeof() 108~144
|
// sizeof() 116~160
|
||||||
struct ImGuiDockNode
|
struct ImGuiDockNode
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImGuiDockNodeFlags Flags;
|
ImGuiDockNodeFlags Flags;
|
||||||
ImGuiDockNode* ParentNode;
|
ImGuiDockNode* ParentNode;
|
||||||
ImGuiDockNode* ChildNodes[2]; // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
|
ImGuiDockNode* ChildNodes[2]; // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
|
||||||
ImVector<ImGuiWindow*> Windows; // Note: unordered list! Iterate TabBar->Tabs for user-order.
|
ImVector<ImGuiWindow*> Windows; // Note: unordered list! Iterate TabBar->Tabs for user-order.
|
||||||
ImGuiTabBar* TabBar;
|
ImGuiTabBar* TabBar;
|
||||||
ImVec2 Pos; // Current position
|
ImVec2 Pos; // Current position
|
||||||
ImVec2 Size; // Current size
|
ImVec2 Size; // Current size
|
||||||
ImVec2 SizeRef; // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
|
ImVec2 SizeRef; // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
|
||||||
int SplitAxis; // [Split node only] Split axis (X or Y)
|
int SplitAxis; // [Split node only] Split axis (X or Y)
|
||||||
ImGuiDockFamily DockFamily;
|
ImGuiDockFamily DockFamily;
|
||||||
|
|
||||||
ImGuiWindow* HostWindow;
|
ImGuiWindow* HostWindow;
|
||||||
@ -773,6 +773,7 @@ struct ImGuiDockNode
|
|||||||
ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
|
ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
|
||||||
int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
|
int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
|
||||||
int LastFrameActive; // Last frame number the node was updated.
|
int LastFrameActive; // Last frame number the node was updated.
|
||||||
|
int LastFrameFocused; // Last frame number the node was focused.
|
||||||
ImGuiID LastFocusedNodeID; // [Root node only] Which of our child node (any ancestor in the hierarchy) was last focused.
|
ImGuiID LastFocusedNodeID; // [Root node only] Which of our child node (any ancestor in the hierarchy) was last focused.
|
||||||
ImGuiID SelectedTabID; // [Tab node only] Which of our tab is selected.
|
ImGuiID SelectedTabID; // [Tab node only] Which of our tab is selected.
|
||||||
ImGuiID WantCloseTabID; // [Tab node only] Set when closing a specific tab.
|
ImGuiID WantCloseTabID; // [Tab node only] Set when closing a specific tab.
|
||||||
@ -1274,9 +1275,9 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiItemStatusFlags DockTabItemStatusFlags;
|
ImGuiItemStatusFlags DockTabItemStatusFlags;
|
||||||
ImRect DockTabItemRect;
|
ImRect DockTabItemRect;
|
||||||
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
|
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
|
||||||
bool DockIsActive; // =~ (DockNode != NULL) && (DockNode->Windows.Size > 1)
|
bool DockIsActive :1; // =~ (DockNode != NULL) && (DockNode->Windows.Size > 1)
|
||||||
bool DockTabIsVisible; // Is the window visible this frame? =~ is the corresponding tab selected?
|
bool DockTabIsVisible :1; // Is the window visible this frame? =~ is the corresponding tab selected?
|
||||||
bool DockTabWantClose;
|
bool DockTabWantClose :1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImGuiWindow(ImGuiContext* context, const char* name);
|
ImGuiWindow(ImGuiContext* context, const char* name);
|
||||||
|
Loading…
Reference in New Issue
Block a user