mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-22 14:19:04 +00:00
Merge branch 'master' into docking
This commit is contained in:
@@ -507,7 +507,7 @@ static void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Win
|
|||||||
viewport->PlatformHandleRaw = nullptr;
|
viewport->PlatformHandleRaw = nullptr;
|
||||||
#if defined(_WIN32) && !defined(__WINRT__)
|
#if defined(_WIN32) && !defined(__WINRT__)
|
||||||
viewport->PlatformHandleRaw = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
viewport->PlatformHandleRaw = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
||||||
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
#elif defined(__APPLE__)
|
||||||
viewport->PlatformHandleRaw = SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
|
viewport->PlatformHandleRaw = SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,17 +73,22 @@ Breaking changes:
|
|||||||
Platform_GetWindowFramebufferScale() handler in 'docking' branch.
|
Platform_GetWindowFramebufferScale() handler in 'docking' branch.
|
||||||
- Fonts: **IMPORTANT** on Font Sizing:
|
- Fonts: **IMPORTANT** on Font Sizing:
|
||||||
- Before 1.92, fonts were of a single size. They can now be dynamically sized.
|
- Before 1.92, fonts were of a single size. They can now be dynamically sized.
|
||||||
- PushFont() API now has an optional size parameter. PushFontSize() was also added.
|
- PushFont() API now has a REQUIRED size parameter.
|
||||||
void PushFont(ImFont* font) --> void PushFont(ImFont* font, float size = 0.0f);
|
void PushFont(ImFont* font) --> void PushFont(ImFont* font, float size);
|
||||||
- Before 1.92: ImGui::PushFont() always used font "default" size specified in AddFont() call.
|
- PushFont(font, 0.0f) // Change font and keep current size
|
||||||
- Since 1.92: ImGui::PushFont() preserve the current font size which is a shared value.
|
- PushFont(NULL, 20.0f) // Keep font and change current size
|
||||||
- To use old behavior:
|
- PushFont(font, 20.0f) // Change font and set size to 20.0f
|
||||||
- use 'ImGui::PushFont(font, font->LegacySize)' at call site (preferred).
|
- PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size.
|
||||||
- or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' in AddFont() call
|
- PushFont(font, font->LegacySize) // Change font and set size to size passed to AddFontXXX() function. Same as pre-1.92 behavor, for fixed size fonts.
|
||||||
(not desirable as it requires e.g. all third-party code to be aware of it).
|
- To use old behavior use 'ImGui::PushFont(font, font->LegacySize)' at call site.
|
||||||
|
We intentionally didn't add a default parameter because it would make the long-term
|
||||||
|
transition more difficult.
|
||||||
|
- Kept inline redirection font. Will obsolete.
|
||||||
|
- External scale factors may be applied over the provided size.
|
||||||
|
This is why it is called 'FontSizeBase' in the style structure.
|
||||||
- ImFont::FontSize was removed and does not make sense anymore.
|
- ImFont::FontSize was removed and does not make sense anymore.
|
||||||
ImFont::LegacySize is the size passed to AddFont().
|
ImFont::LegacySize is the size passed to AddFont().
|
||||||
- Removed support for PushFont(NULL) which was a shortcut for "default font".
|
- Removed support for old PushFont(NULL) which was a shortcut for "revert to default font".
|
||||||
- Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'.
|
- Renamed/moved 'io.FontGlobalScale' to 'style.FontScaleMain'.
|
||||||
- Fonts: **IMPORTANT** on Font Merging:
|
- Fonts: **IMPORTANT** on Font Merging:
|
||||||
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in order
|
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in order
|
||||||
@@ -142,7 +147,7 @@ Breaking changes:
|
|||||||
ImGuiContext to create one, you'll need to call ImFontAtlasUpdateNewFrame() yourself.
|
ImGuiContext to create one, you'll need to call ImFontAtlasUpdateNewFrame() yourself.
|
||||||
An assert will trigger if you don't.
|
An assert will trigger if you don't.
|
||||||
- Fonts: obsolete ImGui::SetWindowFontScale() which is not useful anymore. Prefer using
|
- Fonts: obsolete ImGui::SetWindowFontScale() which is not useful anymore. Prefer using
|
||||||
PushFontSize(style.FontSizeBase * factor) or to manipulate other scaling factors.
|
PushFont(NULL, style.FontSizeBase * factor) or to manipulate other scaling factors.
|
||||||
- Fonts: obsoleted ImFont::Scale which is not useful anymore.
|
- Fonts: obsoleted ImFont::Scale which is not useful anymore.
|
||||||
- Fonts: changed ImFont::CalcWordWrapPositionA() to ImFont::CalcWordWrapPosition():
|
- Fonts: changed ImFont::CalcWordWrapPositionA() to ImFont::CalcWordWrapPosition():
|
||||||
- old: const char* CalcWordWrapPositionA(float scale, const char* text, ....);
|
- old: const char* CalcWordWrapPositionA(float scale, const char* text, ....);
|
||||||
@@ -265,7 +270,6 @@ Other changes:
|
|||||||
- Fonts: ImFontAtlas::AddFontXXX() functions may be called at any time during the frame.
|
- Fonts: ImFontAtlas::AddFontXXX() functions may be called at any time during the frame.
|
||||||
- Fonts: ImFontAtlas::AddFontXXX() can fail more gracefully if error handling is configured
|
- Fonts: ImFontAtlas::AddFontXXX() can fail more gracefully if error handling is configured
|
||||||
to not assert (this will be better exposed via future font flags).
|
to not assert (this will be better exposed via future font flags).
|
||||||
- Fonts: added ImGui::PushFontSize()/PopFontSize() functions.
|
|
||||||
- Fonts: added style.FontScaleBase scaling factor (previously called io.FontGlobalScale).
|
- Fonts: added style.FontScaleBase scaling factor (previously called io.FontGlobalScale).
|
||||||
- Fonts: added style.FontScaleDpi scaling factor. This is designed to be be changed on
|
- Fonts: added style.FontScaleDpi scaling factor. This is designed to be be changed on
|
||||||
per-monitor/per-viewport basis, which `io.ConfigDpiScaleFonts` does automatically.
|
per-monitor/per-viewport basis, which `io.ConfigDpiScaleFonts` does automatically.
|
||||||
@@ -286,8 +290,6 @@ Other changes:
|
|||||||
window and other locations).
|
window and other locations).
|
||||||
- Fonts: added ImFontFlags (currently needs to be passed through ImFontConfig until
|
- Fonts: added ImFontFlags (currently needs to be passed through ImFontConfig until
|
||||||
we revamp font loading API):
|
we revamp font loading API):
|
||||||
- ImFontFlags_DefaultToLegacySize: for legacy compatibility: make PushFont() calls
|
|
||||||
without explicit size use font->LegacySize instead of current font size.
|
|
||||||
- ImFontFlags_NoLoadError: disable erroring/assert when calling AddFontXXX()
|
- ImFontFlags_NoLoadError: disable erroring/assert when calling AddFontXXX()
|
||||||
with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
||||||
- ImFontFlags_NoLoadGlyphs: disable loading new glyphs.
|
- ImFontFlags_NoLoadGlyphs: disable loading new glyphs.
|
||||||
@@ -448,6 +450,8 @@ Other changes:
|
|||||||
memory ownership change. (#8530, #7801) [@Green-Sky]
|
memory ownership change. (#8530, #7801) [@Green-Sky]
|
||||||
- Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative
|
- Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative
|
||||||
way to call SDL_StartTextInput(), without IME being necessarily visible. (#8584)
|
way to call SDL_StartTextInput(), without IME being necessarily visible. (#8584)
|
||||||
|
- Backends: SDL3: fixed pulling SDL_PROP_WINDOW_COCOA_WINDOW_POINTER into
|
||||||
|
viewport->PlatformHandleRaw. (#8725, #8726) [@eertbleyen]
|
||||||
- Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing
|
- Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing
|
||||||
our view. (#8644) [@BingoXuan]
|
our view. (#8644) [@BingoXuan]
|
||||||
- Examples:
|
- Examples:
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ Since 1.92 (June 2025) fonts may be dynamically used at any size.
|
|||||||
|
|
||||||
To change font size:
|
To change font size:
|
||||||
```cpp
|
```cpp
|
||||||
ImGui::PushFontSize(42.0f);
|
ImGui::PushFont(NULL, 42.0f);
|
||||||
```
|
```
|
||||||
To change font and font size:
|
To change font and font size:
|
||||||
```cpp
|
```cpp
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ Future versions of Dear ImGui should solve this problem.
|
|||||||
|
|
||||||
v1.92 introduces a newer, dynamic font system. It requires backend to support the `ImGuiBackendFlags_HasTextures` feature:
|
v1.92 introduces a newer, dynamic font system. It requires backend to support the `ImGuiBackendFlags_HasTextures` feature:
|
||||||
- Users of icons, Asian and non-English languages do not need to pre-build all glyphs ahead of time. Saving on loading time, memory, and also reducing issues with missing glyphs. Specifying glyph ranges is not needed anymore.
|
- Users of icons, Asian and non-English languages do not need to pre-build all glyphs ahead of time. Saving on loading time, memory, and also reducing issues with missing glyphs. Specifying glyph ranges is not needed anymore.
|
||||||
- `PushFontSize()` may be used anytime to change font size.
|
- `PushFont(NULL, new_size)` may be used anytime to change font size.
|
||||||
- Packing custom rectangles is more convenient as pixels may be written to immediately.
|
- Packing custom rectangles is more convenient as pixels may be written to immediately.
|
||||||
- Any update to fonts previously required backend specific calls to re-upload the texture, and said calls were not portable across backends. It is now possible to scale fonts etc. in a way that doesn't require you to make backend-specific calls.
|
- Any update to fonts previously required backend specific calls to re-upload the texture, and said calls were not portable across backends. It is now possible to scale fonts etc. in a way that doesn't require you to make backend-specific calls.
|
||||||
- It is possible to plug a custom loader/backend to any font source.
|
- It is possible to plug a custom loader/backend to any font source.
|
||||||
|
|||||||
@@ -277,7 +277,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
||||||
- font: remove ID from CustomRect registration, it seems unnecessary!
|
- font: remove ID from CustomRect registration, it seems unnecessary!
|
||||||
- font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575)
|
- font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575)
|
||||||
- font: PushFontSize API (#1018)
|
|
||||||
- font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
|
- font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
|
||||||
- font: storing MinAdvanceX per font would allow us to skip calculating line width (under a threshold of character count) in loops looking for block width
|
- font: storing MinAdvanceX per font would allow us to skip calculating line width (under a threshold of character count) in loops looking for block width
|
||||||
- font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs.
|
- font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs.
|
||||||
|
|||||||
44
imgui.cpp
44
imgui.cpp
@@ -480,10 +480,11 @@ CODE
|
|||||||
- With a legacy backend (< 1.92): Instead of setting io.FontGlobalScale = 1.0f/N -> set ImFontCfg::RasterizerDensity = N. This already worked before, but is now pretty much required.
|
- With a legacy backend (< 1.92): Instead of setting io.FontGlobalScale = 1.0f/N -> set ImFontCfg::RasterizerDensity = N. This already worked before, but is now pretty much required.
|
||||||
- With a new backend (1.92+): This should be all automatic. FramebufferScale is automatically used to set current font RasterizerDensity. FramebufferScale is a per-viewport property provided by backend through the Platform_GetWindowFramebufferScale() handler in 'docking' branch.
|
- With a new backend (1.92+): This should be all automatic. FramebufferScale is automatically used to set current font RasterizerDensity. FramebufferScale is a per-viewport property provided by backend through the Platform_GetWindowFramebufferScale() handler in 'docking' branch.
|
||||||
- Fonts: **IMPORTANT** on Font Sizing: Before 1.92, fonts were of a single size. They can now be dynamically sized.
|
- Fonts: **IMPORTANT** on Font Sizing: Before 1.92, fonts were of a single size. They can now be dynamically sized.
|
||||||
- PushFont() API now has an optional size parameter. PushFontSize() was also added.
|
- PushFont() API now has a REQUIRED size parameter.
|
||||||
- Before 1.92: ImGui::PushFont() always used font "default" size specified in AddFont() call.
|
- Before 1.92: PushFont() always used font "default" size specified in AddFont() call. It is equivalent to calling PushFont(font, font->LegacySize).
|
||||||
- Since 1.92: ImGui::PushFont() preserve the current font size which is a shared value.
|
- Since 1.92: PushFont(font, 0.0f) preserve the current font size which is a shared value.
|
||||||
- To use old behavior: (A) use 'ImGui::PushFont(font, font->LegacySize)' at call site (preferred). (B) Set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' in AddFont() call (not desirable as it requires e.g. third-party code to be aware of it).
|
- To use old behavior: use 'ImGui::PushFont(font, font->LegacySize)' at call site.
|
||||||
|
- Kept inline single parameter function. Will obsolete.
|
||||||
- Fonts: **IMPORTANT** on Font Merging:
|
- Fonts: **IMPORTANT** on Font Merging:
|
||||||
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in orderfor the first font input which the desired glyph. This is technically a different behavior than before!
|
- When searching for a glyph in multiple merged fonts: font inputs are now scanned in orderfor the first font input which the desired glyph. This is technically a different behavior than before!
|
||||||
- e.g. If you are merging fonts you may have glyphs that you expected to load from Font Source 2 which exists in Font Source 1. After the update and when using a new backend, those glyphs may now loaded from Font Source 1!
|
- e.g. If you are merging fonts you may have glyphs that you expected to load from Font Source 2 which exists in Font Source 1. After the update and when using a new backend, those glyphs may now loaded from Font Source 1!
|
||||||
@@ -507,7 +508,7 @@ CODE
|
|||||||
- 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: 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: 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 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: obsolete ImGui::SetWindowFontScale() which is not useful anymore. Prefer using 'PushFont(NULL, style.FontSizeBase * factor)' or to manipulate other scaling factors.
|
||||||
- Fonts: obsoleted ImFont::Scale which is not useful anymore.
|
- 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:
|
- 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:
|
||||||
- ImDrawCmd::TextureId has been changed to ImDrawCmd::TexRef.
|
- ImDrawCmd::TextureId has been changed to ImDrawCmd::TexRef.
|
||||||
@@ -9161,7 +9162,7 @@ ImVec2 ImGui::GetFontTexUvWhitePixel()
|
|||||||
return GImGui->DrawListSharedData.TexUvWhitePixel;
|
return GImGui->DrawListSharedData.TexUvWhitePixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer using PushFontSize(style.FontSizeBase * factor), or use style.FontScaleMain to scale all windows.
|
// Prefer using PushFont(NULL, style.FontSizeBase * factor), or use style.FontScaleMain to scale all windows.
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
void ImGui::SetWindowFontScale(float scale)
|
void ImGui::SetWindowFontScale(float scale)
|
||||||
{
|
{
|
||||||
@@ -9342,8 +9343,6 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
|||||||
// - SetFontRasterizerDensity() [Internal]
|
// - SetFontRasterizerDensity() [Internal]
|
||||||
// - PushFont()
|
// - PushFont()
|
||||||
// - PopFont()
|
// - PopFont()
|
||||||
// - PushFontSize()
|
|
||||||
// - PopFontSize()
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ImGui::UpdateFontsNewFrame()
|
void ImGui::UpdateFontsNewFrame()
|
||||||
@@ -9464,7 +9463,7 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
|
|||||||
if (g.CurrentTable == NULL || g.CurrentTable->CurrentColumn != -1) // See 8465#issuecomment-2951509561. Ideally the SkipItems=true in tables would be amended with extra data.
|
if (g.CurrentTable == NULL || g.CurrentTable->CurrentColumn != -1) // See 8465#issuecomment-2951509561. Ideally the SkipItems=true in tables would be amended with extra data.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Restoring is pretty much only used by PopFont()/PopFontSize()
|
// Restoring is pretty much only used by PopFont()
|
||||||
float final_size = (restore_font_size_after_scaling > 0.0f) ? restore_font_size_after_scaling : 0.0f;
|
float final_size = (restore_font_size_after_scaling > 0.0f) ? restore_font_size_after_scaling : 0.0f;
|
||||||
if (final_size == 0.0f)
|
if (final_size == 0.0f)
|
||||||
{
|
{
|
||||||
@@ -9512,24 +9511,18 @@ void ImGui::SetFontRasterizerDensity(float rasterizer_density)
|
|||||||
UpdateCurrentFontSize(0.0f);
|
UpdateCurrentFontSize(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you want to scale an existing font size:
|
// If you want to scale an existing font size! Read comments in imgui.h!
|
||||||
// - Use e.g. PushFontSize(style.FontSizeBase * factor) (= value before external scale factors applied).
|
|
||||||
// - Do NOT use PushFontSize(GetFontSize() * factor) (= value after external scale factors applied).
|
|
||||||
void ImGui::PushFont(ImFont* font, float font_size_base)
|
void ImGui::PushFont(ImFont* font, float font_size_base)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
//if (font == NULL) // Before 1.92 (June 2025), PushFont(NULL) == PushFont(GetDefaultFont())
|
//if (font == NULL) // Before 1.92 (June 2025), PushFont(NULL) == PushFont(GetDefaultFont())
|
||||||
// font = g.Font;
|
// font = g.Font;
|
||||||
IM_ASSERT(font != NULL);
|
IM_ASSERT(font != NULL);
|
||||||
|
IM_ASSERT(font_size_base >= 0.0f);
|
||||||
|
|
||||||
g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize });
|
g.FontStack.push_back({ g.Font, g.FontSizeBase, g.FontSize });
|
||||||
if (font_size_base <= 0.0f)
|
if (font_size_base == 0.0f)
|
||||||
{
|
font_size_base = g.FontSizeBase; // Keep current font size
|
||||||
if (font->Flags & ImFontFlags_DefaultToLegacySize)
|
|
||||||
font_size_base = font->LegacySize; // Legacy: use AddFont() specified font size. Same as doing PushFont(font, font->LegacySize)
|
|
||||||
else
|
|
||||||
font_size_base = g.FontSizeBase; // Keep current font size
|
|
||||||
}
|
|
||||||
SetCurrentFont(font, font_size_base, 0.0f);
|
SetCurrentFont(font, font_size_base, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9546,17 +9539,6 @@ void ImGui::PopFont()
|
|||||||
g.FontStack.pop_back();
|
g.FontStack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::PushFontSize(float font_size_base)
|
|
||||||
{
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
PushFont(g.Font, font_size_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::PopFontSize()
|
|
||||||
{
|
|
||||||
PopFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] ID STACK
|
// [SECTION] ID STACK
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -22751,7 +22733,7 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||||||
Indent();
|
Indent();
|
||||||
if (cfg->ShowFontPreview)
|
if (cfg->ShowFontPreview)
|
||||||
{
|
{
|
||||||
PushFont(font);
|
PushFont(font, 0.0f);
|
||||||
Text("The quick brown fox jumps over the lazy dog");
|
Text("The quick brown fox jumps over the lazy dog");
|
||||||
PopFont();
|
PopFont();
|
||||||
}
|
}
|
||||||
|
|||||||
33
imgui.h
33
imgui.h
@@ -501,21 +501,24 @@ namespace ImGui
|
|||||||
IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
|
IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
|
||||||
|
|
||||||
// Parameters stacks (font)
|
// Parameters stacks (font)
|
||||||
|
// - PushFont(font, 0.0f) // Change font and keep current size
|
||||||
|
// - PushFont(NULL, 20.0f) // Keep font and change current size
|
||||||
|
// - PushFont(font, 20.0f) // Change font and set size to 20.0f
|
||||||
|
// - PushFont(font, style.FontSizeBase * 2.0f) // Change font and set size to be twice bigger than current size.
|
||||||
|
// - PushFont(font, font->LegacySize) // Change font and set size to size passed to AddFontXXX() function. Same as pre-1.92 behavior.
|
||||||
// *IMPORTANT* before 1.92, fonts had a single size. They can now be dynamically be adjusted.
|
// *IMPORTANT* before 1.92, fonts had a single size. They can now be dynamically be adjusted.
|
||||||
// - Before 1.92: PushFont() always used font default size.
|
// - In 1.92 we have REMOVED the single parameter version of PushFont() because it seems like the easiest way to provide an error-proof transition.
|
||||||
// - Since 1.92: PushFont() preserve the current shared font size.
|
// - PushFont(font) before 1.92 = PushFont(font, font->LegacySize) after 1.92 // Use default font size as passed to AddFontXXX() function.
|
||||||
// - To use old behavior (single size font, size specified in AddFontXXX() call:
|
// *IMPORTANT* external scale factors are applied over the provided size. If you want to scale an *existing* font size:
|
||||||
// - Use 'PushFont(font, font->LegacySize)' at call site
|
// - External scale factors are: 'style.FontScaleMain * style.FontScaleDpi' and maybe more.
|
||||||
// - Or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' before calling AddFont(), and then 'PushFont(font)' will use this size.
|
// - CORRECT: PushFont(NULL, style.FontSizeBase) // use current unscaled size == does nothing
|
||||||
// *IMPORTANT* External scale factors are applied over the provided value. If you want to scale an existing font size:
|
// - CORRECT: PushFont(NULL, style.FontSizeBase * 2.0f) // use current unscaled size x2 == make text twice bigger
|
||||||
// - OK: PushFontSize(style.FontSizeBase * 2.0f) (= value before external scale factors applied).
|
// - INCORRECT: PushFont(NULL, GetFontSize()) // INCORRECT! use size after external factors applied == EXTERNAL SCALING FACTORS WILL APPLY TWICE!
|
||||||
// - NOT OK: PushFontSize(GetFontSize() * 2.0f) (= value after external scale factors applied. External scale factors are: 'style.FontScaleMain * style.FontScaleDpi * maybe more').
|
// - INCORRECT: PushFont(NULL, GetFontSize() * 2.0f) // INCORRECT! use size after external factors applied == EXTERNAL SCALING FACTORS WILL APPLY TWICE!
|
||||||
IMGUI_API void PushFont(ImFont* font, float font_size_base = -1); // use NULL as a shortcut to push default font. Use <0.0f to keep current font size.
|
IMGUI_API void PushFont(ImFont* font, float font_size_base_unscaled); // Use NULL as a shortcut to keep current font. Use 0.0f to keep current size.
|
||||||
IMGUI_API void PopFont();
|
IMGUI_API void PopFont();
|
||||||
IMGUI_API void PushFontSize(float font_size_base); // keep current font, change its size. Final 'font size = font_size_base * external scale factors'.
|
|
||||||
IMGUI_API void PopFontSize();
|
|
||||||
IMGUI_API ImFont* GetFont(); // get current font
|
IMGUI_API ImFont* GetFont(); // get current font
|
||||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) AFTER external scale factors applied. *IMPORTANT* DO NOT PASS THIS VALUE TO PushFont()/PushFontSize()! Use ImGui::GetStyle().FontSizeBase to get value before external scale factors.
|
IMGUI_API float GetFontSize(); // get current scaled font size (= height in pixels). AFTER external scale factors applied. *IMPORTANT* DO NOT PASS THIS VALUE TO PushFont()! Use ImGui::GetStyle().FontSizeBase to get value before external scale factors.
|
||||||
IMGUI_API ImFontBaked* GetFontBaked(); // get current font bound at current size // == GetFont()->GetFontBaked(GetFontSize())
|
IMGUI_API ImFontBaked* GetFontBaked(); // get current font bound at current size // == GetFont()->GetFontBaked(GetFontSize())
|
||||||
|
|
||||||
// Parameters stacks (shared)
|
// Parameters stacks (shared)
|
||||||
@@ -2304,7 +2307,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|||||||
struct ImGuiStyle
|
struct ImGuiStyle
|
||||||
{
|
{
|
||||||
// ImGui::GetFontSize() == FontSizeBase * (FontScaleMain * FontScaleDpi * other_scaling_factors)
|
// ImGui::GetFontSize() == FontSizeBase * (FontScaleMain * FontScaleDpi * other_scaling_factors)
|
||||||
float FontSizeBase; // Current base font size before external scaling factors are applied. Use PushFont()/PushFontSize() to modify. Use ImGui::GetFontSize() to obtain scaled value.
|
float FontSizeBase; // Current base font size before external scaling factors are applied. Use PushFont(NULL, size) to modify. Use ImGui::GetFontSize() to obtain scaled value.
|
||||||
float FontScaleMain; // Main scale factor. May be set by application once, or exposed to end-user.
|
float FontScaleMain; // Main scale factor. May be set by application once, or exposed to end-user.
|
||||||
float FontScaleDpi; // Additional scale factor from viewport/monitor contents scale. When io.ConfigDpiScaleFonts is enabled, this is automatically overwritten when changing monitor DPI.
|
float FontScaleDpi; // Additional scale factor from viewport/monitor contents scale. When io.ConfigDpiScaleFonts is enabled, this is automatically overwritten when changing monitor DPI.
|
||||||
|
|
||||||
@@ -3876,7 +3879,6 @@ struct ImFontBaked
|
|||||||
enum ImFontFlags_
|
enum ImFontFlags_
|
||||||
{
|
{
|
||||||
ImFontFlags_None = 0,
|
ImFontFlags_None = 0,
|
||||||
ImFontFlags_DefaultToLegacySize = 1 << 0, // Legacy compatibility: make PushFont() calls without explicit size use font->LegacySize instead of current font size.
|
|
||||||
ImFontFlags_NoLoadError = 1 << 1, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
ImFontFlags_NoLoadError = 1 << 1, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
||||||
ImFontFlags_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs.
|
ImFontFlags_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs.
|
||||||
ImFontFlags_LockBakedSizes = 1 << 3, // [Internal] Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size. Important: if you use this to preload given sizes, consider the possibility of multiple font density used on Retina display.
|
ImFontFlags_LockBakedSizes = 1 << 3, // [Internal] Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size. Important: if you use this to preload given sizes, consider the possibility of multiple font density used on Retina display.
|
||||||
@@ -4207,7 +4209,8 @@ struct ImGuiPlatformImeData
|
|||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
// OBSOLETED in 1.92.0 (from June 2025)
|
// OBSOLETED in 1.92.0 (from June 2025)
|
||||||
IMGUI_API void SetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFontSize(style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
|
static inline void PushFont(ImFont* font) { IM_ASSERT(font != NULL); PushFont(font, font->LegacySize); }
|
||||||
|
IMGUI_API void SetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFont(NULL, style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
|
||||||
// OBSOLETED in 1.91.9 (from February 2025)
|
// OBSOLETED in 1.91.9 (from February 2025)
|
||||||
IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
||||||
// OBSOLETED in 1.91.0 (from July 2024)
|
// OBSOLETED in 1.91.0 (from July 2024)
|
||||||
|
|||||||
@@ -5233,7 +5233,7 @@ ImFontBaked* ImFont::GetFontBaked(float size, float density)
|
|||||||
ImFontBaked* baked = LastBaked;
|
ImFontBaked* baked = LastBaked;
|
||||||
|
|
||||||
// Round font size
|
// Round font size
|
||||||
// - ImGui::PushFontSize() will already round, but other paths calling GetFontBaked() directly also needs it (e.g. ImFontAtlasBuildPreloadAllGlyphRanges)
|
// - ImGui::PushFont() will already round, but other paths calling GetFontBaked() directly also needs it (e.g. ImFontAtlasBuildPreloadAllGlyphRanges)
|
||||||
size = ImGui::GetRoundedFontSize(size);
|
size = ImGui::GetRoundedFontSize(size);
|
||||||
|
|
||||||
if (density < 0.0f)
|
if (density < 0.0f)
|
||||||
@@ -5711,7 +5711,7 @@ begin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Edge case: calling RenderText() with unloaded glyphs triggering texture change. It doesn't happen via ImGui:: calls because CalcTextSize() is always used.
|
// Edge case: calling RenderText() with unloaded glyphs triggering texture change. It doesn't happen via ImGui:: calls because CalcTextSize() is always used.
|
||||||
if (cmd_count != draw_list->CmdBuffer.Size)
|
if (cmd_count != draw_list->CmdBuffer.Size) //-V547
|
||||||
{
|
{
|
||||||
IM_ASSERT(draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount == 0);
|
IM_ASSERT(draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount == 0);
|
||||||
draw_list->CmdBuffer.pop_back();
|
draw_list->CmdBuffer.pop_back();
|
||||||
|
|||||||
@@ -2338,7 +2338,7 @@ struct ImGuiContext
|
|||||||
ImFont* Font; // Currently bound font. (== FontStack.back().Font)
|
ImFont* Font; // Currently bound font. (== FontStack.back().Font)
|
||||||
ImFontBaked* FontBaked; // Currently bound font at currently bound size. (== Font->GetFontBaked(FontSize))
|
ImFontBaked* FontBaked; // Currently bound font at currently bound size. (== Font->GetFontBaked(FontSize))
|
||||||
float FontSize; // Currently bound font size == line height (== FontSizeBase + externals scales applied in the UpdateCurrentFontSize() function).
|
float FontSize; // Currently bound font size == line height (== FontSizeBase + externals scales applied in the UpdateCurrentFontSize() function).
|
||||||
float FontSizeBase; // Font size before scaling == style.FontSizeBase == value passed to PushFont() / PushFontSize() when specified.
|
float FontSizeBase; // Font size before scaling == style.FontSizeBase == value passed to PushFont() when specified.
|
||||||
float FontBakedScale; // == FontBaked->Size / FontSize. Scale factor over baked size. Rarely used nowadays, very often == 1.0f.
|
float FontBakedScale; // == FontBaked->Size / FontSize. Scale factor over baked size. Rarely used nowadays, very often == 1.0f.
|
||||||
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
||||||
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
||||||
|
|||||||
Reference in New Issue
Block a user