Fixed SetScrollX() handling of center ratio (which actually wasn't exposed publicly). (#323, #246)

This commit is contained in:
ocornut 2016-07-18 16:55:20 +02:00
parent e10ecfe28a
commit c816e6c742

View File

@ -4113,7 +4113,8 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
// Apply scrolling // Apply scrolling
if (window->ScrollTarget.x < FLT_MAX) if (window->ScrollTarget.x < FLT_MAX)
{ {
window->Scroll.x = window->ScrollTarget.x; float center_ratio = window->ScrollTargetCenterRatio.x;
window->Scroll.x = window->ScrollTarget.x - (center_ratio * window->SizeFull.x);
window->ScrollTarget.x = FLT_MAX; window->ScrollTarget.x = FLT_MAX;
} }
if (window->ScrollTarget.y < FLT_MAX) if (window->ScrollTarget.y < FLT_MAX)