mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-27 16:49:18 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdlgpu3.cpp # imgui.cpp
This commit is contained in:
60
imgui.cpp
60
imgui.cpp
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.0 WIP
|
||||
// dear imgui, v1.92.0
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -468,7 +468,15 @@ CODE
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2025/06/11 (1.92.0) - Renamed/moved ImGuiConfigFlags_DpiEnableScaleFonts -> bool io.ConfigDpiScaleFonts.
|
||||
- 2025/06/25 (1.92.0) - layout: commented out legacy ErrorCheckUsingSetCursorPosToExtendParentBoundaries() fallback obsoleted in 1.89 (August 2022) which allowed a SetCursorPos()/SetCursorScreenPos() call WITHOUT AN ITEM
|
||||
to extend parent window/cell boundaries. Replaced with assert/tooltip that would already happens if previously using IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#5548, #4510, #3355, #1760, #1490, #4152, #150)
|
||||
- Incorrect way to make a window content size 200x200:
|
||||
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End();
|
||||
- Correct ways to make a window content size 200x200:
|
||||
Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + Dummy(ImVec2(0,0)) + End();
|
||||
Begin(...) + Dummy(ImVec2(200,200)) + End();
|
||||
- TL;DR; if the assert triggers, you can add a Dummy({0,0}) call to validate extending parent boundaries.
|
||||
>- 2025/06/11 (1.92.0) - Renamed/moved ImGuiConfigFlags_DpiEnableScaleFonts -> bool io.ConfigDpiScaleFonts.
|
||||
- Renamed/moved ImGuiConfigFlags_DpiEnableScaleViewports -> bool io.ConfigDpiScaleViewports. **Neither of those flags are very useful in current code. They will be useful once we merge font changes.**
|
||||
- 2025/06/11 (1.92.0) - THIS VERSION CONTAINS THE LARGEST AMOUNT OF BREAKING CHANGES SINCE 2015! I TRIED REALLY HARD TO KEEP THEM TO A MINIMUM, REDUCE THE AMOUNT OF INTERFERENCES, BUT INEVITABLY SOME USERS WILL BE AFFECTED.
|
||||
IN ORDER TO HELP US IMPROVE THE TRANSITION PROCESS, INCL. DOCUMENTATION AND COMMENTS, PLEASE REPORT **ANY** DOUBT, CONFUSION, QUESTIONS, FEEDBACK TO: https://github.com/ocornut/imgui/issues/
|
||||
@@ -9151,7 +9159,9 @@ ImFontBaked* ImGui::GetFontBaked()
|
||||
return GImGui->FontBaked;
|
||||
}
|
||||
|
||||
// Get current font size (= height in pixels) of current font, with external scale factors applied. Use ImGui::GetStyle().FontSizeBase to get value before external scale factors.
|
||||
// Get current font size (= height in pixels) of current font, with global scale factors applied.
|
||||
// - Use style.FontSizeBase to get value before global scale factors.
|
||||
// - recap: ImGui::GetFontSize() == style.FontSizeBase * (style.FontScaleMain * style.FontScaleDpi * other_scaling_factors)
|
||||
float ImGui::GetFontSize()
|
||||
{
|
||||
return GImGui->FontSize;
|
||||
@@ -9469,7 +9479,7 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
|
||||
{
|
||||
final_size = g.FontSizeBase;
|
||||
|
||||
// External scale factors
|
||||
// Global scale factors
|
||||
final_size *= g.Style.FontScaleMain; // Main global scale factor
|
||||
final_size *= g.Style.FontScaleDpi; // Per-monitor/viewport DPI scale factor, automatically updated when io.ConfigDpiScaleFonts is enabled.
|
||||
|
||||
@@ -9515,8 +9525,8 @@ void ImGui::SetFontRasterizerDensity(float rasterizer_density)
|
||||
void ImGui::PushFont(ImFont* font, float font_size_base)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
//if (font == NULL) // Before 1.92 (June 2025), PushFont(NULL) == PushFont(GetDefaultFont())
|
||||
// font = g.Font;
|
||||
if (font == NULL) // Before 1.92 (June 2025), PushFont(NULL) == PushFont(GetDefaultFont())
|
||||
font = g.Font;
|
||||
IM_ASSERT(font != NULL);
|
||||
IM_ASSERT(font_size_base >= 0.0f);
|
||||
|
||||
@@ -11200,36 +11210,44 @@ bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, si
|
||||
return !error;
|
||||
}
|
||||
|
||||
// Until 1.89 (IMGUI_VERSION_NUM < 18814) it was legal to use SetCursorPos() to extend the boundary of a parent (e.g. window or table cell)
|
||||
// This is causing issues and ambiguity and we need to retire that.
|
||||
// See https://github.com/ocornut/imgui/issues/5548 for more details.
|
||||
// [Scenario 1]
|
||||
// Until 1.89 (August 2022, IMGUI_VERSION_NUM < 18814) it was legal to use SetCursorPos()/SetCursorScreenPos()
|
||||
// to extend contents size of our parent container (e.g. window contents size, which is used for auto-resizing
|
||||
// windows, table column contents size used for auto-resizing columns, group size).
|
||||
// This was causing issues and ambiguities and we needed to retire that.
|
||||
// From 1.89, extending contents size boundaries REQUIRES AN ITEM TO BE SUBMITTED.
|
||||
//
|
||||
// Previously this would make the window content size ~200x200:
|
||||
// Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End(); // NOT OK
|
||||
// Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End(); // NOT OK ANYMORE
|
||||
// Instead, please submit an item:
|
||||
// Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + Dummy(ImVec2(0,0)) + End(); // OK
|
||||
// Alternative:
|
||||
// Begin(...) + Dummy(ImVec2(200,200)) + End(); // OK
|
||||
// [Scenario 2]
|
||||
// For reference this is one of the issue what we aim to fix with this change:
|
||||
// BeginGroup() + SomeItem("foobar") + SetCursorScreenPos(GetCursorScreenPos()) + EndGroup()
|
||||
// The previous logic made SetCursorScreenPos(GetCursorScreenPos()) have a side-effect! It would erroneously incorporate ItemSpacing.y after the item into content size, making the group taller!
|
||||
// While this code is a little twisted, no-one would expect SetXXX(GetXXX()) to have a side-effect. Using vertical alignment patterns could trigger this issue.
|
||||
//
|
||||
// The assert below detects when the _last_ call in a window was a SetCursorPos() not followed by an Item,
|
||||
// and with a position that would grow the parent contents size.
|
||||
//
|
||||
// Advanced:
|
||||
// - For reference, old logic was causing issues because it meant that SetCursorScreenPos(GetCursorScreenPos())
|
||||
// had a side-effect on layout! In particular this caused problem to compute group boundaries.
|
||||
// e.g. BeginGroup() + SomeItem() + SetCursorScreenPos(GetCursorScreenPos()) + EndGroup() would cause the
|
||||
// group to be taller because auto-sizing generally adds padding on bottom and right side.
|
||||
// - While this code is a little twisted, no-one would expect SetXXX(GetXXX()) to have a side-effect.
|
||||
// Using vertical alignment patterns would frequently trigger this sorts of issue.
|
||||
// - See https://github.com/ocornut/imgui/issues/5548 for more details.
|
||||
void ImGui::ErrorCheckUsingSetCursorPosToExtendParentBoundaries()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
IM_ASSERT(window->DC.IsSetPos);
|
||||
window->DC.IsSetPos = false;
|
||||
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
if (window->DC.CursorPos.x <= window->DC.CursorMaxPos.x && window->DC.CursorPos.y <= window->DC.CursorMaxPos.y)
|
||||
return;
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
IM_ASSERT(0 && "Code uses SetCursorPos()/SetCursorScreenPos() to extend window/parent boundaries. Please submit an item e.g. Dummy() to validate extent.");
|
||||
#else
|
||||
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
|
||||
#endif
|
||||
IM_ASSERT_USER_ERROR(0, "Code uses SetCursorPos()/SetCursorScreenPos() to extend window/parent boundaries.\nPlease submit an item e.g. Dummy() afterwards in order to grow window/parent boundaries.");
|
||||
|
||||
// For reference, the old behavior was essentially:
|
||||
//window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
|
||||
}
|
||||
|
||||
static void ImGui::ErrorCheckNewFrameSanityChecks()
|
||||
|
||||
Reference in New Issue
Block a user