Merge branch 'master' into docking

# Conflicts:
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_wgpu.cpp
#	backends/imgui_impl_wgpu.h
This commit is contained in:
ocornut
2025-06-13 17:43:30 +02:00
10 changed files with 202 additions and 120 deletions

View File

@@ -21,9 +21,10 @@
// - Issues & support ........... https://github.com/ocornut/imgui/issues
// - Test Engine & Automation ... https://github.com/ocornut/imgui_test_engine (test suite, test engine to automate your apps)
// For first-time users having issues compiling/linking/running/loading fonts:
// For first-time users having issues compiling/linking/running:
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
// Since 1.92, we encourage font loading question to also be posted in 'Issues'.
// Copyright (c) 2014-2025 Omar Cornut
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
@@ -348,12 +349,12 @@ CODE
ImGui::Render();
// Update textures
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
ImDrawData* draw_data = ImGui::GetDrawData();
for (ImTextureData* tex : *draw_data->Textures)
if (tex->Status != ImTextureStatus_OK)
MyImGuiBackend_UpdateTexture(tex);
// Render dear imgui contents, swap buffers
ImDrawData* draw_data = ImGui::GetDrawData();
MyImGuiBackend_RenderDrawData(draw_data);
SwapBuffers();
}
@@ -373,25 +374,32 @@ CODE
{
if (tex->Status == ImTextureStatus_WantCreate)
{
// create texture based on tex->Width/Height/Pixels
// call tex->SetTexID() to specify backend-specific identifiers
// tex->Status = ImTextureStatus_OK;
// <create texture based on tex->Width/Height/Pixels>
tex->SetTexID(xxxx); // specify backend-specific ImTextureID identifier
tex->SetStatus(ImTextureStatus_OK);
tex->BackendUserData = xxxx; // store more backend data
}
if (tex->Status == ImTextureStatus_WantUpdates)
{
// update texture blocks based on tex->UpdateRect
// tex->Status = ImTextureStatus_OK;
// <update texture blocks based on tex->UpdateRect>
tex->SetStatus(ImTextureStatus_OK);
}
if (tex->Status == ImTextureStatus_WantDestroy)
{
// destroy texture
// call tex->SetTexID(ImTextureID_Invalid)
// tex->Status = ImTextureStatus_Destroyed;
// <destroy texture>
tex->SetTexID(ImTextureID_Invalid);
tex->SetStatus(ImTextureStatus_Destroyed);
}
}
void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
{
if (draw_data->Textures != nullptr)
for (ImTextureData* tex : *draw_data->Textures)
if (tex->Status != ImTextureStatus_OK)
MyImGuiBackend_UpdateTexture(tex);
// TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
// TODO: Setup texture sampling state: sample with bilinear filtering (NOT point/nearest filtering). Use 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines;' to allow point/nearest filtering.
// TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
@@ -408,7 +416,10 @@ CODE
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
MyEngineResetRenderState();
else
pcmd->UserCallback(cmd_list, pcmd);
}
else
{
@@ -480,7 +491,7 @@ CODE
- Fonts: ImFontConfig::OversampleH/OversampleV default to automatic (== 0) since v1.91.8. It is quite important you keep it automatic until we decide if we want to provide a way to express finer policy, otherwise you will likely waste texture space when using large glyphs. Note that the imgui_freetype backend doesn't use and does not need oversampling.
- Fonts: specifying glyph ranges is now unnecessary. The value of ImFontConfig::GlyphRanges[] is only useful for legacy backends. All GetGlyphRangesXXXX() functions are now marked obsolete: GetGlyphRangesDefault(), GetGlyphRangesGreek(), GetGlyphRangesKorean(), GetGlyphRangesJapanese(), GetGlyphRangesChineseSimplifiedCommon(), GetGlyphRangesChineseFull(), GetGlyphRangesCyrillic(), GetGlyphRangesThai(), GetGlyphRangesVietnamese().
- Fonts: removed ImFontAtlas::TexDesiredWidth to enforce a texture width. (#327)
- Fonts: if you create and manage ImFontAtlas instances yourself (instead of relying on ImGuiContext to create one, you'll need to set the atlas->RendererHasTextures field and call ImFontAtlasUpdateNewFrame() yourself. An assert will trigger if you don't.
- Fonts: if you create and manage ImFontAtlas instances yourself (instead of relying on ImGuiContext to create one, you'll need to call ImFontAtlasUpdateNewFrame() yourself. An assert will trigger if you don't.
- Fonts: obsolete ImGui::SetWindowFontScale() which is not useful anymore. Prefer using 'PushFontSize(style.FontSizeBase * factor)' or to manipulate other scaling factors.
- Fonts: obsoleted ImFont::Scale which is not useful anymore.
- Fonts: generally reworked Internals of ImFontAtlas and ImFont. While in theory a vast majority of users shouldn't be affected, some use cases or extensions might be. Among other things:
@@ -4567,12 +4578,15 @@ static void SetCurrentWindow(ImGuiWindow* window)
g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL;
if (window)
{
bool backup_skip_items = window->SkipItems;
window->SkipItems = false;
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures)
{
ImGuiViewport* viewport = window->Viewport;
g.FontRasterizerDensity = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale.x : g.IO.DisplayFramebufferScale.x; // == SetFontRasterizerDensity()
}
ImGui::UpdateCurrentFontSize(0.0f);
window->SkipItems = backup_skip_items;
ImGui::NavUpdateCurrentWindowIsScrollPushableX();
}
}
@@ -5467,13 +5481,16 @@ static void ImGui::UpdateTexturesNewFrame()
{
if (atlas->OwnerContext == &g)
{
atlas->RendererHasTextures = has_textures;
ImFontAtlasUpdateNewFrame(atlas, g.FrameCount);
ImFontAtlasUpdateNewFrame(atlas, g.FrameCount, has_textures);
}
else
{
IM_ASSERT(atlas->Builder != NULL && atlas->Builder->FrameCount != -1 && "If you manage font atlases yourself you need to call ImFontAtlasUpdateNewFrame() on it.");
IM_ASSERT(atlas->RendererHasTextures == has_textures && "If you manage font atlases yourself make sure atlas->RendererHasTextures is set consistently with all contexts using it.");
// (1) If you manage font atlases yourself, e.g. create a ImFontAtlas yourself you need to call ImFontAtlasUpdateNewFrame() on it.
// Otherwise, calling ImGui::CreateContext() without parameter will create an atlas owned by the context.
// (2) If you have multiple font atlases, make sure the 'atlas->RendererHasTextures' as specified in the ImFontAtlasUpdateNewFrame() call matches for that.
// (3) If you have multiple imgui contexts, they also need to have a matching value for ImGuiBackendFlags_RendererHasTextures.
IM_ASSERT(atlas->Builder != NULL && atlas->Builder->FrameCount != -1);
IM_ASSERT(atlas->RendererHasTextures == has_textures);
}
}
}
@@ -7482,8 +7499,12 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
// Close button
if (has_close_button)
{
g.CurrentItemFlags |= ImGuiItemFlags_NoFocus;
if (CloseButton(window->GetID("#CLOSE"), close_button_pos))
*p_open = false;
g.CurrentItemFlags &= ~ImGuiItemFlags_NoFocus;
}
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
g.CurrentItemFlags = item_flags_backup;
@@ -9292,6 +9313,21 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
// Most of the relevant font logic is in imgui_draw.cpp.
// Those are high-level support functions.
//-----------------------------------------------------------------------------
// - UpdateFontsNewFrame() [Internal]
// - UpdateFontsEndFrame() [Internal]
// - GetDefaultFont() [Internal]
// - RegisterUserTexture() [Internal]
// - UnregisterUserTexture() [Internal]
// - RegisterFontAtlas() [Internal]
// - UnregisterFontAtlas() [Internal]
// - SetCurrentFont() [Internal]
// - UpdateCurrentFontSize() [Internal]
// - SetFontRasterizerDensity() [Internal]
// - PushFont()
// - PopFont()
// - PushFontSize()
// - PopFontSize()
//-----------------------------------------------------------------------------
void ImGui::UpdateFontsNewFrame()
{
@@ -9404,12 +9440,10 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
// Early out to avoid hidden window keeping bakes referenced and out of GC reach.
// However this would leave a pretty subtle and damning error surface area if g.FontBaked was mismatching, so for now we null it.
// FIXME: perhaps g.FontSize should be updated?
if (window != NULL && window->SkipItems)
if (g.CurrentTable == NULL || g.CurrentTable->CurrentColumn != -1) // See 8465#issuecomment-2951509561. Ideally the SkipItems=true in tables would be amended with extra data.
{
g.FontBaked = NULL;
return;
}
// Restoring is pretty much only used by PopFont()/PopFontSize()
float final_size = (restore_font_size_after_scaling > 0.0f) ? restore_font_size_after_scaling : 0.0f;
@@ -22799,7 +22833,7 @@ void ImGui::DebugNodeFont(ImFont* font)
if (baked->ContainerFont != font)
continue;
PushID(baked_n);
if (TreeNode("Glyphs", "Baked at { %.2fpx, d.%.1f }: %d glyphs%s", baked->Size, baked->RasterizerDensity, baked->Glyphs.Size, (baked->LastUsedFrame < atlas->Builder->FrameCount - 1) ? " *Unused*" : ""))
if (TreeNode("Glyphs", "Baked at { %.2fpx, d.%.2f }: %d glyphs%s", baked->Size, baked->RasterizerDensity, baked->Glyphs.Size, (baked->LastUsedFrame < atlas->Builder->FrameCount - 1) ? " *Unused*" : ""))
{
if (SmallButton("Load all"))
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base++)