mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-21 21:00:13 +01:00
Nav: Renamed internal field.
This commit is contained in:
parent
9712a81f85
commit
8a5a29f0be
22
imgui.cpp
22
imgui.cpp
@ -1848,7 +1848,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
|||||||
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
|
|
||||||
NavLastIds[0] = NavLastIds[1] = 0;
|
NavLastIds[0] = NavLastIds[1] = 0;
|
||||||
NavRefRectRel[0] = NavRefRectRel[1] = ImRect();
|
NavRectRel[0] = NavRectRel[1] = ImRect();
|
||||||
|
|
||||||
LastFrameActive = -1;
|
LastFrameActive = -1;
|
||||||
ItemWidthDefault = 0.0f;
|
ItemWidthDefault = 0.0f;
|
||||||
@ -2225,7 +2225,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
|
|||||||
// Update window-relative bounding box of navigated item
|
// Update window-relative bounding box of navigated item
|
||||||
if (g.NavId == *id)
|
if (g.NavId == *id)
|
||||||
{
|
{
|
||||||
window->NavRefRectRel[window->DC.NavLayerCurrent] = nav_bb_rel;
|
window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel;
|
||||||
g.NavIdIsAlive = true;
|
g.NavIdIsAlive = true;
|
||||||
g.NavIdTabCounter = window->FocusIdxTabCounter;
|
g.NavIdTabCounter = window->FocusIdxTabCounter;
|
||||||
}
|
}
|
||||||
@ -2461,7 +2461,7 @@ static void SetNavIdAndMoveMouse(ImGuiID id, int nav_layer, const ImRect& rect_r
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
SetNavId(id, nav_layer);
|
SetNavId(id, nav_layer);
|
||||||
g.NavWindow->NavRefRectRel[nav_layer] = rect_rel;
|
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
||||||
g.NavMousePosDirty = true;
|
g.NavMousePosDirty = true;
|
||||||
g.NavDisableHighlight = false;
|
g.NavDisableHighlight = false;
|
||||||
g.NavDisableMouseHover = true;
|
g.NavDisableMouseHover = true;
|
||||||
@ -2492,8 +2492,8 @@ static ImVec2 NavCalcPreferredMousePos()
|
|||||||
ImGuiWindow* window = g.NavWindow;
|
ImGuiWindow* window = g.NavWindow;
|
||||||
if (!window)
|
if (!window)
|
||||||
return g.IO.MousePos;
|
return g.IO.MousePos;
|
||||||
const ImRect& ref_rect_rel = window->NavRefRectRel[g.NavLayer];
|
const ImRect& rect_rel = window->NavRectRel[g.NavLayer];
|
||||||
ImVec2 pos = g.NavWindow->Pos + ImVec2(ref_rect_rel.Min.x + ImMin(g.Style.FramePadding.x*4, ref_rect_rel.GetWidth()), ref_rect_rel.Max.y - ImMin(g.Style.FramePadding.y, ref_rect_rel.GetHeight()));
|
ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x*4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
|
||||||
ImRect visible_rect = GetVisibleRect();
|
ImRect visible_rect = GetVisibleRect();
|
||||||
return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
|
return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
|
||||||
}
|
}
|
||||||
@ -2584,7 +2584,7 @@ static void NavUpdate()
|
|||||||
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
||||||
IM_ASSERT(g.NavWindow);
|
IM_ASSERT(g.NavWindow);
|
||||||
SetNavId(g.NavInitDefaultResultId, g.NavLayer);
|
SetNavId(g.NavInitDefaultResultId, g.NavLayer);
|
||||||
g.NavWindow->NavRefRectRel[g.NavLayer] = g.NavInitDefaultResultRectRel;
|
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitDefaultResultRectRel;
|
||||||
if (g.NavDisableMouseHover)
|
if (g.NavDisableMouseHover)
|
||||||
g.NavMousePosDirty = true;
|
g.NavMousePosDirty = true;
|
||||||
}
|
}
|
||||||
@ -2838,18 +2838,18 @@ static void NavUpdate()
|
|||||||
{
|
{
|
||||||
// When we have manually scrolled and NavId is out of bounds, we clamp its bounding box (used for search) to the visible area to restart navigation within visible items
|
// When we have manually scrolled and NavId is out of bounds, we clamp its bounding box (used for search) to the visible area to restart navigation within visible items
|
||||||
ImRect window_rect_rel(g.NavWindow->InnerRect.Min - g.NavWindow->Pos - ImVec2(1,1), g.NavWindow->InnerRect.Max - g.NavWindow->Pos + ImVec2(1,1));
|
ImRect window_rect_rel(g.NavWindow->InnerRect.Min - g.NavWindow->Pos - ImVec2(1,1), g.NavWindow->InnerRect.Max - g.NavWindow->Pos + ImVec2(1,1));
|
||||||
if (!window_rect_rel.Contains(g.NavWindow->NavRefRectRel[g.NavLayer]))
|
if (!window_rect_rel.Contains(g.NavWindow->NavRectRel[g.NavLayer]))
|
||||||
{
|
{
|
||||||
float pad = g.NavWindow->CalcFontSize() * 0.5f;
|
float pad = g.NavWindow->CalcFontSize() * 0.5f;
|
||||||
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intend of starting navigation from first fully visible item
|
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intend of starting navigation from first fully visible item
|
||||||
g.NavWindow->NavRefRectRel[g.NavLayer].ClipWith(window_rect_rel);
|
g.NavWindow->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
|
||||||
g.NavId = 0;
|
g.NavId = 0;
|
||||||
}
|
}
|
||||||
g.NavMoveFromClampedRefRect = false;
|
g.NavMoveFromClampedRefRect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
||||||
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + g.NavWindow->NavRefRectRel[g.NavLayer].Min, g.NavWindow->Pos + g.NavWindow->NavRefRectRel[g.NavLayer].Max) : ImRect();
|
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[g.NavLayer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[g.NavLayer].Max) : ImRect();
|
||||||
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
||||||
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
||||||
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||||
@ -5514,7 +5514,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|||||||
g.NavLayer = 0;
|
g.NavLayer = 0;
|
||||||
if (window && g.NavDisableMouseHover)
|
if (window && g.NavDisableMouseHover)
|
||||||
g.NavMousePosDirty = true;
|
g.NavMousePosDirty = true;
|
||||||
window->NavRefRectRel[0].Min = window->NavRefRectRel[1].Max = window ? (window->DC.CursorStartPos - window->Pos) : ImVec2(0,0);
|
window->NavRectRel[0].Min = window->NavRectRel[1].Max = window ? (window->DC.CursorStartPos - window->Pos) : ImVec2(0,0);
|
||||||
g.NavWindow = window;
|
g.NavWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11627,7 +11627,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
ImGui::BulletText("Scroll: (%.2f,%.2f)", window->Scroll.x, window->Scroll.y);
|
ImGui::BulletText("Scroll: (%.2f,%.2f)", window->Scroll.x, window->Scroll.y);
|
||||||
ImGui::BulletText("Active: %d, Accessed: %d", window->Active, window->Accessed);
|
ImGui::BulletText("Active: %d, Accessed: %d", window->Active, window->Accessed);
|
||||||
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
||||||
ImGui::BulletText("NavRefRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRefRectRel[0].Min.x, window->NavRefRectRel[0].Min.y, window->NavRefRectRel[0].Max.x, window->NavRefRectRel[0].Max.y);
|
ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
|
||||||
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
|
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
|
||||||
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
|
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
|
||||||
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
|
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
|
||||||
|
@ -776,7 +776,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
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)
|
ImGuiID NavLastIds[2]; // Last known NavId for this window, per layer (0/1)
|
||||||
ImRect NavRefRectRel[2]; // Reference rectangle, in window space
|
ImRect NavRectRel[2]; // Reference rectangle, in window 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user