mirror of
https://github.com/Drezil/imgui.git
synced 2025-01-11 16:26:35 +00:00
Begin: Factored out a bit of code to CalcSizeContents()
This commit is contained in:
parent
f658edc72a
commit
ca0bb000ad
12
imgui.cpp
12
imgui.cpp
@ -4149,6 +4149,14 @@ static ImVec2 CalcSizeFullWithConstraint(ImGuiWindow* window, ImVec2 new_size)
|
|||||||
return new_size;
|
return new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ImVec2 CalcSizeContents(ImGuiWindow* window)
|
||||||
|
{
|
||||||
|
ImVec2 sz;
|
||||||
|
sz.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : (window->DC.CursorMaxPos.x - window->Pos.x + window->Scroll.x));
|
||||||
|
sz.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : (window->DC.CursorMaxPos.y - window->Pos.y + window->Scroll.y));
|
||||||
|
return sz + window->WindowPadding;
|
||||||
|
}
|
||||||
|
|
||||||
static ImVec2 CalcSizeAutoFit(ImGuiWindow* window)
|
static ImVec2 CalcSizeAutoFit(ImGuiWindow* window)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -4418,9 +4426,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// SIZE
|
// SIZE
|
||||||
|
|
||||||
// Update contents size from last frame for auto-fitting (unless explicitly specified)
|
// Update contents size from last frame for auto-fitting (unless explicitly specified)
|
||||||
window->SizeContents.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : (window->DC.CursorMaxPos.x - window->Pos.x + window->Scroll.x));
|
window->SizeContents = CalcSizeContents(window);
|
||||||
window->SizeContents.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : (window->DC.CursorMaxPos.y - window->Pos.y + window->Scroll.y));
|
|
||||||
window->SizeContents += window->WindowPadding;
|
|
||||||
|
|
||||||
// Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
// Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
||||||
if (window->HiddenFrames > 0)
|
if (window->HiddenFrames > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user