Windows, Menus: Fixed an issue where the size of sub-menu in their own viewport would be erroneously clamped to the size of main viewport. (#7730)
Amend #7287, #7063
This commit is contained in:
parent
10a5a857f5
commit
a028c2df2a
@ -93,6 +93,8 @@ Other changes:
|
||||
|
||||
Docking+Viewports Branch:
|
||||
|
||||
- Windows, Menus: Fixed an issue where the size of sub-menu in their own viewport
|
||||
would be erroneously clamped to the size of main viewport. (#7730)
|
||||
- Backends: SDL3: Update for introduction of SDL_GLContext from void*. (#7701, #7702)
|
||||
[@bcsanches]
|
||||
- Backends: Win32: Secondary viewports WndProc handler retrieve/set imgui context from
|
||||
|
16
imgui.cpp
16
imgui.cpp
@ -6173,10 +6173,18 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont
|
||||
{
|
||||
// Maximum window size is determined by the viewport size or monitor size
|
||||
ImVec2 size_min = CalcWindowMinSize(window);
|
||||
ImVec2 size_max = (window->ViewportOwned || ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup))) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
|
||||
if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0)
|
||||
size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
ImVec2 size_max = ImVec2(FLT_MAX, FLT_MAX);
|
||||
|
||||
// Child windows are layed within their parent (unless they are also popups/menus) and thus have no restriction
|
||||
if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || (window->Flags & ImGuiWindowFlags_Popup) != 0)
|
||||
{
|
||||
if (!window->ViewportOwned)
|
||||
size_max = ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
|
||||
if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size)
|
||||
size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
}
|
||||
|
||||
ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, size_max));
|
||||
|
||||
// FIXME: CalcWindowAutoFitSize() doesn't take into account that only one axis may be auto-fit when calculating scrollbars,
|
||||
|
Loading…
Reference in New Issue
Block a user