mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
commit
71bcf350bd
8 changed files with 129 additions and 79 deletions
91
imgui.cpp
91
imgui.cpp
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.90.2 WIP
|
||||
// dear imgui, v1.90.2
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
|
|
@ -3519,22 +3519,22 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
|
|||
float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding;
|
||||
ImRect display_rect = bb;
|
||||
display_rect.ClipWith(window->ClipRect);
|
||||
if (flags & ImGuiNavHighlightFlags_TypeDefault)
|
||||
const float thickness = 2.0f;
|
||||
if (flags & ImGuiNavHighlightFlags_Compact)
|
||||
{
|
||||
const float THICKNESS = 2.0f;
|
||||
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
|
||||
display_rect.Expand(ImVec2(DISTANCE, DISTANCE));
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, thickness);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float distance = 3.0f + thickness * 0.5f;
|
||||
display_rect.Expand(ImVec2(distance, distance));
|
||||
bool fully_visible = window->ClipRect.Contains(display_rect);
|
||||
if (!fully_visible)
|
||||
window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
|
||||
window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), display_rect.Max - ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, 0, THICKNESS);
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, thickness);
|
||||
if (!fully_visible)
|
||||
window->DrawList->PopClipRect();
|
||||
}
|
||||
if (flags & ImGuiNavHighlightFlags_TypeThin)
|
||||
{
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
|
||||
|
|
@ -5675,7 +5675,7 @@ ImVec2 ImGui::GetItemRectSize()
|
|||
}
|
||||
|
||||
// Prior to v1.90 2023/10/16, the BeginChild() function took a 'bool border = false' parameter instead of 'ImGuiChildFlags child_flags = 0'.
|
||||
// ImGuiChildFlags_Border is defined as always == 1 in order to allow old code passing 'true'.
|
||||
// ImGuiChildFlags_Border is defined as always == 1 in order to allow old code passing 'true'. Read comments in imgui.h for details!
|
||||
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
|
||||
{
|
||||
ImGuiID id = GetCurrentWindow()->GetID(str_id);
|
||||
|
|
@ -5817,7 +5817,7 @@ void ImGui::EndChild()
|
|||
|
||||
// When browsing a window that has no activable items (scroll only) we keep a highlight on the child (pass g.NavId to trick into always displaying)
|
||||
if (child_window->DC.NavLayersActiveMask == 0 && child_window == g.NavWindow)
|
||||
RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_TypeThin);
|
||||
RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_Compact);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -6841,7 +6841,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window_stack_data.StackSizesOnBegin.SetToContextState(&g);
|
||||
g.CurrentWindowStack.push_back(window_stack_data);
|
||||
if (flags & ImGuiWindowFlags_ChildMenu)
|
||||
g.BeginMenuCount++;
|
||||
g.BeginMenuDepth++;
|
||||
|
||||
// Update ->RootWindow and others pointers (before any possible call to FocusWindow)
|
||||
if (first_begin_of_the_frame)
|
||||
|
|
@ -7658,7 +7658,7 @@ void ImGui::End()
|
|||
// Pop from window stack
|
||||
g.LastItemData = g.CurrentWindowStack.back().ParentLastItemDataBackup;
|
||||
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
||||
g.BeginMenuCount--;
|
||||
g.BeginMenuDepth--;
|
||||
if (window->Flags & ImGuiWindowFlags_Popup)
|
||||
g.BeginPopupStack.pop_back();
|
||||
g.CurrentWindowStack.back().StackSizesOnBegin.CompareWithContextState(&g);
|
||||
|
|
@ -11445,16 +11445,22 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
|
||||
// would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
|
||||
// situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
|
||||
if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
|
||||
// Gently handle the user mistakenly calling OpenPopup() every frames: it is likely a programming mistake!
|
||||
// However, if we were to run the regular code path, the ui would become completely unusable because the popup will always be
|
||||
// in hidden-while-calculating-size state _while_ claiming focus. Which is extremely confusing situation for the programmer.
|
||||
// Instead, for successive frames calls to OpenPopup(), we silently avoid reopening even if ImGuiPopupFlags_NoReopen is not specified.
|
||||
bool keep_existing = false;
|
||||
if (g.OpenPopupStack[current_stack_size].PopupId == id)
|
||||
if ((g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) || (popup_flags & ImGuiPopupFlags_NoReopen))
|
||||
keep_existing = true;
|
||||
if (keep_existing)
|
||||
{
|
||||
// No reopen
|
||||
g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Close child popups if any, then flag popup for open/reopen
|
||||
// Reopen: close child popups if any, then flag popup for open/reopen (set position, focus, init navigation)
|
||||
ClosePopupToLevel(current_stack_size, false);
|
||||
g.OpenPopupStack.push_back(popup_ref);
|
||||
}
|
||||
|
|
@ -11485,14 +11491,15 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
|
|||
if (!popup.Window)
|
||||
continue;
|
||||
IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
|
||||
if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||
continue;
|
||||
|
||||
// Trim the stack unless the popup is a direct parent of the reference window (the reference window is often the NavWindow)
|
||||
// - With this stack of window, clicking/focusing Popup1 will close Popup2 and Popup3:
|
||||
// Window -> Popup1 -> Popup2 -> Popup3
|
||||
// - Clicking/Focusing Window2 won't close Popup1:
|
||||
// Window -> Popup1 -> Window2(Ref)
|
||||
// - Clicking/focusing Popup1 will close Popup2 and Popup3:
|
||||
// Window -> Popup1(Ref) -> Popup2 -> Popup3
|
||||
// - Each popups may contain child windows, which is why we compare ->RootWindowDockTree!
|
||||
// Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child
|
||||
// We step through every popup from bottom to top to validate their position relative to reference window.
|
||||
bool ref_window_is_descendent_of_popup = false;
|
||||
for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++)
|
||||
if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window)
|
||||
|
|
@ -11592,7 +11599,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
|||
|
||||
char name[20];
|
||||
if (flags & ImGuiWindowFlags_ChildMenu)
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginMenuCount); // Recycle windows based on depth
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginMenuDepth); // Recycle windows based on depth
|
||||
else
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
||||
|
||||
|
|
@ -12186,7 +12193,7 @@ static void ImGui::NavProcessItem()
|
|||
|
||||
// Process Move Request (scoring for navigation)
|
||||
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
|
||||
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
||||
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0 && (window->Flags & ImGuiWindowFlags_NoNavInputs) == 0)
|
||||
{
|
||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
|
||||
if (is_tabbing)
|
||||
|
|
@ -19578,7 +19585,7 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport*, ImGuiPlatformImeDat
|
|||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] METRICS/DEBUGGER WINDOW
|
||||
//-----------------------------------------------------------------------------
|
||||
// - RenderViewportThumbnail() [Internal]
|
||||
// - DebugRenderViewportThumbnail() [Internal]
|
||||
// - RenderViewportsThumbnails() [Internal]
|
||||
// - DebugTextEncoding()
|
||||
// - MetricsHelpMarker() [Internal]
|
||||
|
|
@ -19620,7 +19627,7 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP*
|
|||
ImRect thumb_r = thumb_window->Rect();
|
||||
ImRect title_r = thumb_window->TitleBarRect();
|
||||
thumb_r = ImRect(ImTrunc(off + thumb_r.Min * scale), ImTrunc(off + thumb_r.Max * scale));
|
||||
title_r = ImRect(ImTrunc(off + title_r.Min * scale), ImTrunc(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height
|
||||
title_r = ImRect(ImTrunc(off + title_r.Min * scale), ImTrunc(off + ImVec2(title_r.Max.x, title_r.Min.y + title_r.GetHeight() * 3.0f) * scale)); // Exaggerate title bar height
|
||||
thumb_r.ClipWithFull(bb);
|
||||
title_r.ClipWithFull(bb);
|
||||
const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight);
|
||||
|
|
@ -19630,6 +19637,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP*
|
|||
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), thumb_window->Name, FindRenderedTextEnd(thumb_window->Name));
|
||||
}
|
||||
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul));
|
||||
if (viewport->ID == g.DebugMetricsConfig.HighlightViewportID)
|
||||
window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
|
||||
}
|
||||
|
||||
static void RenderViewportsThumbnails()
|
||||
|
|
@ -19637,13 +19646,12 @@ static void RenderViewportsThumbnails()
|
|||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
// We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
|
||||
float SCALE = 1.0f / 8.0f;
|
||||
ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
bb_full.Add(viewport->GetMainRect());
|
||||
ImRect bb_full(g.Viewports[0]->Pos, g.Viewports[0]->Pos + g.Viewports[0]->Size);
|
||||
ImVec2 p = window->DC.CursorPos;
|
||||
ImVec2 off = p - bb_full.Min * SCALE;
|
||||
|
||||
// Draw viewports
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
{
|
||||
ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
|
||||
|
|
@ -19893,7 +19901,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
|
||||
if (Checkbox("Show Item Picker", &g.DebugItemPickerActive) && g.DebugItemPickerActive)
|
||||
DebugStartItemPicker();
|
||||
Checkbox("Show \"Debug Break\" buttons in other sections", &g.IO.ConfigDebugIsDebuggerPresent);
|
||||
Checkbox("Show \"Debug Break\" buttons in other sections (io.ConfigDebugIsDebuggerPresent)", &g.IO.ConfigDebugIsDebuggerPresent);
|
||||
|
||||
SeparatorText("Visualize");
|
||||
|
||||
|
|
@ -20037,10 +20045,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
// Viewports
|
||||
if (TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size))
|
||||
{
|
||||
Indent(GetTreeNodeToLabelSpacing());
|
||||
RenderViewportsThumbnails();
|
||||
Unindent(GetTreeNodeToLabelSpacing());
|
||||
|
||||
bool open = TreeNode("Monitors", "Monitors (%d)", g.PlatformIO.Monitors.Size);
|
||||
SameLine();
|
||||
MetricsHelpMarker("Dear ImGui uses monitor data:\n- to query DPI settings on a per monitor basis\n- to position popup/tooltips so they don't straddle monitors.");
|
||||
|
|
@ -20057,6 +20061,14 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
TreePop();
|
||||
}
|
||||
|
||||
SetNextItemOpen(true, ImGuiCond_Once);
|
||||
if (TreeNode("Windows Minimap"))
|
||||
{
|
||||
RenderViewportsThumbnails();
|
||||
TreePop();
|
||||
}
|
||||
cfg->HighlightViewportID = 0;
|
||||
|
||||
BulletText("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport ? g.MouseViewport->ID : 0, g.IO.MouseHoveredViewport, g.MouseLastHoveredViewport ? g.MouseLastHoveredViewport->ID : 0);
|
||||
if (TreeNode("Inferred Z order (front-to-back)"))
|
||||
{
|
||||
|
|
@ -20072,6 +20084,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
viewport->Window ? viewport->Window->Name : "N/A");
|
||||
TreePop();
|
||||
}
|
||||
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
DebugNodeViewport(viewport);
|
||||
TreePop();
|
||||
|
|
@ -20909,8 +20922,12 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
|
|||
|
||||
void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetNextItemOpen(true, ImGuiCond_Once);
|
||||
if (TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A"))
|
||||
bool open = TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A");
|
||||
if (IsItemHovered())
|
||||
g.DebugMetricsConfig.HighlightViewportID = viewport->ID;
|
||||
if (open)
|
||||
{
|
||||
ImGuiWindowFlags flags = viewport->Flags;
|
||||
BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nWorkArea Offset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue