mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Fixed scrollbar enable/disable calculation when size is modified programmatically. This is the generalization of the fix in 2df8fa95df
.
This commit is contained in:
parent
ecacaf7f2d
commit
beda5fc5a0
21
imgui.cpp
21
imgui.cpp
@ -4064,12 +4064,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
window->Flags = flags;
|
||||
g.WindowsById.SetVoidPtr(window->ID, window);
|
||||
|
||||
if (flags & ImGuiWindowFlags_NoSavedSettings)
|
||||
{
|
||||
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
||||
window->Size = window->SizeFull = size;
|
||||
}
|
||||
else
|
||||
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
// Retrieve settings from .ini file
|
||||
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||
@ -4085,8 +4081,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
if (ImLengthSqr(settings->Size) > 0.00001f)
|
||||
size = settings->Size;
|
||||
}
|
||||
window->Size = window->SizeFull = size;
|
||||
}
|
||||
window->Size = window->SizeFull = window->SizeFullAtLastBegin = size;
|
||||
|
||||
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
|
||||
{
|
||||
@ -4468,13 +4464,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// SCROLLBAR STATUS
|
||||
|
||||
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size). We need to do this before manual resize (below) is effective.
|
||||
// Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).
|
||||
if (!window->Collapsed)
|
||||
{
|
||||
window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFull.y) && !(flags & ImGuiWindowFlags_NoScrollbar));
|
||||
window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFull.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
|
||||
window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFullAtLastBegin.y) && !(flags & ImGuiWindowFlags_NoScrollbar));
|
||||
window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFullAtLastBegin.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
|
||||
if (window->ScrollbarX && !window->ScrollbarY)
|
||||
window->ScrollbarY = (window->SizeContents.y > window->SizeFull.y + style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
|
||||
window->ScrollbarY = (window->SizeContents.y > window->SizeFullAtLastBegin.y + style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
|
||||
window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
|
||||
}
|
||||
|
||||
@ -4710,6 +4706,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DrawList->AddLine(title_bar_rect.GetBL()+ImVec2(1,-1), title_bar_rect.GetBR()+ImVec2(-1,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
|
||||
}
|
||||
|
||||
// Store a backup of SizeFull which we will use next frame to decide if we need scrollbars.
|
||||
window->SizeFullAtLastBegin = window->SizeFull;
|
||||
|
||||
// Update ContentsRegionMax. All the variable it depends on are set above in this function.
|
||||
window->ContentsRegionRect.Min.x = -window->Scroll.x + window->WindowPadding.x;
|
||||
window->ContentsRegionRect.Min.y = -window->Scroll.y + window->WindowPadding.y + window->TitleBarHeight() + window->MenuBarHeight();
|
||||
|
@ -701,6 +701,7 @@ struct IMGUI_API ImGuiWindow
|
||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
ImVec2 SizeFull; // Size when non collapsed
|
||||
ImVec2 SizeFullAtLastBegin; // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
|
||||
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
|
||||
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
|
||||
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
|
||||
|
Loading…
Reference in New Issue
Block a user