mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: Internals: Renamed RootNavWindow to NavRootWindow (#787)
This commit is contained in:
parent
72485a5d04
commit
c8d8dc7f0a
23
imgui.cpp
23
imgui.cpp
@ -1906,9 +1906,6 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||||||
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
|
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
|
||||||
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
|
|
||||||
NavLastIds[0] = NavLastIds[1] = 0;
|
|
||||||
NavRectRel[0] = NavRectRel[1] = ImRect();
|
|
||||||
|
|
||||||
LastFrameActive = -1;
|
LastFrameActive = -1;
|
||||||
ItemWidthDefault = 0.0f;
|
ItemWidthDefault = 0.0f;
|
||||||
FontWindowScale = 1.0f;
|
FontWindowScale = 1.0f;
|
||||||
@ -1918,7 +1915,10 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||||||
ParentWindow = NULL;
|
ParentWindow = NULL;
|
||||||
RootWindow = NULL;
|
RootWindow = NULL;
|
||||||
RootNonPopupWindow = NULL;
|
RootNonPopupWindow = NULL;
|
||||||
RootNavWindow = NULL;
|
|
||||||
|
NavRootWindow = NULL;
|
||||||
|
NavLastIds[0] = NavLastIds[1] = 0;
|
||||||
|
NavRectRel[0] = NavRectRel[1] = ImRect();
|
||||||
|
|
||||||
FocusIdxAllCounter = FocusIdxTabCounter = -1;
|
FocusIdxAllCounter = FocusIdxTabCounter = -1;
|
||||||
FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX;
|
FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX;
|
||||||
@ -2235,7 +2235,7 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|||||||
// Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
|
// Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
|
||||||
// are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
|
// are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
|
||||||
// This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
|
// This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
|
||||||
// 2017/09/29: FIXME: This now currently only enabled inside menubars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
|
// 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
|
||||||
// Disabling it may however lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
|
// Disabling it may however lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
|
||||||
if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
|
if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
|
||||||
if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
|
if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
|
||||||
@ -2333,7 +2333,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
|||||||
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
|
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
|
||||||
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
|
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
|
||||||
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
|
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
|
||||||
if (g.NavWindow == window->RootNavWindow)
|
if (g.NavWindow == window->NavRootWindow)
|
||||||
if (g.NavId == id || g.NavAnyRequest)
|
if (g.NavId == id || g.NavAnyRequest)
|
||||||
NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
|
NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
|
||||||
}
|
}
|
||||||
@ -2885,9 +2885,10 @@ static void ImGui::NavUpdate()
|
|||||||
// Process navigation move request
|
// Process navigation move request
|
||||||
if (g.NavMoveRequest && g.NavMoveResult.ID != 0)
|
if (g.NavMoveRequest && g.NavMoveResult.ID != 0)
|
||||||
{
|
{
|
||||||
// Scroll to keep newly navigated item fully into view
|
|
||||||
ImGuiNavMoveResult* result = &g.NavMoveResult;
|
ImGuiNavMoveResult* result = &g.NavMoveResult;
|
||||||
IM_ASSERT(g.NavWindow && result->Window);
|
IM_ASSERT(g.NavWindow && result->Window);
|
||||||
|
|
||||||
|
// Scroll to keep newly navigated item fully into view
|
||||||
if (g.NavLayer == 0)
|
if (g.NavLayer == 0)
|
||||||
NavScrollToBringItemIntoView(result->Window, result->RectRel);
|
NavScrollToBringItemIntoView(result->Window, result->RectRel);
|
||||||
|
|
||||||
@ -5527,9 +5528,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->RootWindow = parent_window->RootWindow;
|
window->RootWindow = parent_window->RootWindow;
|
||||||
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
||||||
window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
|
window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
|
||||||
window->RootNavWindow = window;
|
window->NavRootWindow = window;
|
||||||
//while (window->RootNavWindow->Flags & ImGuiWindowFlags_NavFlattened)
|
//while (window->NavRootWindow->Flags & ImGuiWindowFlags_NavFlattened)
|
||||||
// window->RootNavWindow = window->RootNavWindow->ParentWindow;
|
// window->NavRootWindow = window->NavRootWindow->ParentWindow;
|
||||||
|
|
||||||
window->Active = true;
|
window->Active = true;
|
||||||
window->BeginOrderWithinParent = 0;
|
window->BeginOrderWithinParent = 0;
|
||||||
@ -7036,7 +7037,7 @@ void ImGui::SetItemDefaultFocus()
|
|||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
if (!window->Appearing)
|
if (!window->Appearing)
|
||||||
return;
|
return;
|
||||||
if (g.NavWindow == window->RootNavWindow && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
|
if (g.NavWindow == window->NavRootWindow && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
|
||||||
{
|
{
|
||||||
g.NavInitRequest = false;
|
g.NavInitRequest = false;
|
||||||
g.NavInitResultExplicit = true;
|
g.NavInitResultExplicit = true;
|
||||||
|
@ -511,7 +511,7 @@ struct ImGuiNavMoveResult
|
|||||||
ImGuiWindow* Window; // Best candidate window
|
ImGuiWindow* Window; // Best candidate window
|
||||||
float DistBox; // Best candidate box distance to current NavId
|
float DistBox; // Best candidate box distance to current NavId
|
||||||
float DistCenter; // Best candidate center distance to current NavId
|
float DistCenter; // Best candidate center distance to current NavId
|
||||||
float DistAxial; // Best candidate selected distance (box/center) to current NavId
|
float DistAxial;
|
||||||
ImRect RectRel; // Best candidate bounding box in window relative space
|
ImRect RectRel; // Best candidate bounding box in window relative space
|
||||||
|
|
||||||
ImGuiNavMoveResult() { ID = ParentID = 0; Window = NULL; DistBox = DistCenter = DistAxial = 0.0f; }
|
ImGuiNavMoveResult() { ID = ParentID = 0; Window = NULL; DistBox = DistCenter = DistAxial = 0.0f; }
|
||||||
@ -921,9 +921,6 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
||||||
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
|
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
|
||||||
|
|
||||||
ImGuiID NavLastIds[2]; // Last known NavId for this window, per layer (0/1)
|
|
||||||
ImRect NavRectRel[2]; // Reference rectangle, in window relative space
|
|
||||||
|
|
||||||
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
||||||
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
||||||
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||||
@ -939,7 +936,10 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
|
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
|
||||||
ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
|
ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
|
||||||
ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
||||||
ImGuiWindow* RootNavWindow; // Generally point to ourself. If we are a child window with the ImGuiWindowFlags_NavFlattenedChild flag, point to parent. Used to display TitleBgActive color and for selecting which window to use for NavWindowing.
|
|
||||||
|
ImGuiWindow* NavRootWindow; // Generally point to ourself. If we are a child window with the NavFlattened flag, point to a parent window.
|
||||||
|
ImGuiID NavLastIds[2]; // Last known NavId for this window, per layer (0/1)
|
||||||
|
ImRect NavRectRel[2]; // Reference rectangle, in window relative space
|
||||||
|
|
||||||
// Navigation / Focus
|
// Navigation / Focus
|
||||||
// FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
|
// FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
|
||||||
|
Loading…
Reference in New Issue
Block a user