Fixed GetScrollMaxX(), GetScrollMaxY(). Tweak demo to display more data. Using functions in Begin(). (#1271)

This commit is contained in:
omar
2017-08-07 18:35:15 +08:00
parent 6d60e0fc58
commit 233a6efeba
2 changed files with 16 additions and 9 deletions

View File

@ -4205,7 +4205,10 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
}
window->Scroll = ImMax(window->Scroll, ImVec2(0.0f, 0.0f));
if (!window->Collapsed && !window->SkipItems)
window->Scroll = ImMin(window->Scroll, ImMax(ImVec2(0.0f, 0.0f), window->SizeContents - window->SizeFull + window->ScrollbarSizes));
{
window->Scroll.x = ImMin(window->Scroll.x, GetScrollMaxX());
window->Scroll.y = ImMin(window->Scroll.y, GetScrollMaxY());
}
// Modal window darkens what is behind them
if ((flags & ImGuiWindowFlags_Modal) != 0 && window == GetFrontMostModalRootWindow())
@ -5267,13 +5270,13 @@ float ImGui::GetScrollY()
float ImGui::GetScrollMaxX()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->SizeContents.x - window->SizeFull.x - window->ScrollbarSizes.x;
return ImMax(0.0f, window->SizeContents.x - (window->SizeFull.x - window->ScrollbarSizes.x));
}
float ImGui::GetScrollMaxY()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->SizeContents.y - window->SizeFull.y - window->ScrollbarSizes.y;
return ImMax(0.0f, window->SizeContents.y - (window->SizeFull.y - window->ScrollbarSizes.y));
}
void ImGui::SetScrollX(float scroll_x)