1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-19 01:24:20 +00:00

Merge branch 'master' into docking

# Conflicts:
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
This commit is contained in:
ocornut 2025-02-26 21:08:45 +01:00
commit 3fb14b50f8
16 changed files with 267 additions and 193 deletions

100
imgui.cpp
View file

@ -1226,6 +1226,7 @@ static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool j
// Navigation
static void NavUpdate();
static void NavUpdateWindowing();
static void NavUpdateWindowingApplyFocus(ImGuiWindow* window);
static void NavUpdateWindowingOverlay();
static void NavUpdateCancelRequest();
static void NavUpdateCreateMoveRequest();
@ -1492,6 +1493,7 @@ ImGuiIO::ImGuiIO()
ConfigMemoryCompactTimer = 60.0f;
ConfigDebugIsDebuggerPresent = false;
ConfigDebugHighlightIdConflicts = true;
ConfigDebugHighlightIdConflictsShowItemPicker = true;
ConfigDebugBeginReturnValueOnce = false;
ConfigDebugBeginReturnValueLoop = false;
@ -11109,15 +11111,24 @@ void ImGui::ErrorCheckEndFrameFinalizeErrorTooltip()
//BulletText("Code intending to use duplicate ID may use e.g. PushItemFlag(ImGuiItemFlags_AllowDuplicateId, true); ... PopItemFlag()"); // Not making this too visible for fear of it being abused.
BulletText("Set io.ConfigDebugHighlightIdConflicts=false to disable this warning in non-programmers builds.");
Separator();
Text("(Hold CTRL to: use");
SameLine();
if (SmallButton("Item Picker"))
DebugStartItemPicker();
SameLine();
Text("to break in item call-stack, or");
SameLine();
if (g.IO.ConfigDebugHighlightIdConflictsShowItemPicker)
{
Text("(Hold CTRL to: use ");
SameLine(0.0f, 0.0f);
if (SmallButton("Item Picker"))
DebugStartItemPicker();
SameLine(0.0f, 0.0f);
Text(" to break in item call-stack, or ");
}
else
{
Text("(Hold CTRL to ");
}
SameLine(0.0f, 0.0f);
if (SmallButton("Open FAQ->About ID Stack System") && g.PlatformIO.Platform_OpenInShellFn != NULL)
g.PlatformIO.Platform_OpenInShellFn(&g, "https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#qa-usage");
SameLine(0.0f, 0.0f);
Text(")");
EndErrorTooltip();
}
@ -14348,6 +14359,40 @@ static void NavUpdateWindowingTarget(int focus_change_dir)
g.NavWindowingToggleLayer = false;
}
// Apply focus and close overlay
static void ImGui::NavUpdateWindowingApplyFocus(ImGuiWindow* apply_focus_window)
{
// FIXME: Many actions here could be part of a higher-level/reused function. Why aren't they in FocusWindow() ?
// Investigate for each of them: ClearActiveID(), NavRestoreHighlightAfterMove(), NavRestoreLastChildNavWindow(), ClosePopupsOverWindow(), NavInitWindow()
ImGuiContext& g = *GImGui;
if (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)
{
ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
ClearActiveID();
SetNavCursorVisibleAfterMove();
ClosePopupsOverWindow(apply_focus_window, false);
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
apply_focus_window = g.NavWindow;
if (apply_focus_window->NavLastIds[0] == 0)
NavInitWindow(apply_focus_window, false);
// If the window has ONLY a menu layer (no main layer), select it directly
// Use NavLayersActiveMaskNext since windows didn't have a chance to be Begin()-ed on this frame,
// so CTRL+Tab where the keys are only held for 1 frame will be able to use correct layers mask since
// the target window as already been previewed once.
// FIXME-NAV: This should be done in NavInit.. or in FocusWindow... However in both of those cases,
// we won't have a guarantee that windows has been visible before and therefore NavLayersActiveMask*
// won't be valid.
if (apply_focus_window->DC.NavLayersActiveMaskNext == (1 << ImGuiNavLayer_Menu))
g.NavLayer = ImGuiNavLayer_Menu;
// Request OS level focus
if (apply_focus_window->Viewport != previous_viewport && g.PlatformIO.Platform_SetWindowFocus)
g.PlatformIO.Platform_SetWindowFocus(apply_focus_window->Viewport);
}
g.NavWindowingTarget = NULL;
}
// Windowing management mode
// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer)
// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
@ -14499,35 +14544,8 @@ static void ImGui::NavUpdateWindowing()
}
// Apply final focus
if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
{
// FIXME: Many actions here could be part of a higher-level/reused function. Why aren't they in FocusWindow()
// Investigate for each of them: ClearActiveID(), NavRestoreHighlightAfterMove(), NavRestoreLastChildNavWindow(), ClosePopupsOverWindow(), NavInitWindow()
ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
ClearActiveID();
SetNavCursorVisibleAfterMove();
ClosePopupsOverWindow(apply_focus_window, false);
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
apply_focus_window = g.NavWindow;
if (apply_focus_window->NavLastIds[0] == 0)
NavInitWindow(apply_focus_window, false);
// If the window has ONLY a menu layer (no main layer), select it directly
// Use NavLayersActiveMaskNext since windows didn't have a chance to be Begin()-ed on this frame,
// so CTRL+Tab where the keys are only held for 1 frame will be able to use correct layers mask since
// the target window as already been previewed once.
// FIXME-NAV: This should be done in NavInit.. or in FocusWindow... However in both of those cases,
// we won't have a guarantee that windows has been visible before and therefore NavLayersActiveMask*
// won't be valid.
if (apply_focus_window->DC.NavLayersActiveMaskNext == (1 << ImGuiNavLayer_Menu))
g.NavLayer = ImGuiNavLayer_Menu;
// Request OS level focus
if (apply_focus_window->Viewport != previous_viewport && g.PlatformIO.Platform_SetWindowFocus)
g.PlatformIO.Platform_SetWindowFocus(apply_focus_window->Viewport);
}
if (apply_focus_window)
g.NavWindowingTarget = NULL;
NavUpdateWindowingApplyFocus(apply_focus_window);
// Apply menu/layer toggle
if (apply_toggle_layer && g.NavWindow)
@ -22031,7 +22049,7 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
void ImGui::DebugNodeFont(ImFont* font)
{
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
// Display preview text
if (!opened)
@ -22064,14 +22082,14 @@ void ImGui::DebugNodeFont(ImFont* font)
Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
if (font->ConfigData)
for (int config_i = 0; config_i < font->SourcesCount; config_i++)
if (font->Sources)
{
const ImFontConfig* cfg = &font->ConfigData[config_i];
const ImFontConfig* src = &font->Sources[config_i];
int oversample_h, oversample_v;
ImFontAtlasBuildGetOversampleFactors(cfg, &oversample_h, &oversample_v);
ImFontAtlasBuildGetOversampleFactors(src, &oversample_h, &oversample_v);
BulletText("Input %d: \'%s\', Oversample: (%d=>%d,%d=>%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
config_i, cfg->Name, cfg->OversampleH, oversample_h, cfg->OversampleV, oversample_v, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
config_i, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y);
}
// Display all glyphs of the fonts in separate pages of 256 characters