mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Added SetScrollXHere, SetScrollFromPosX: Changelog, demo, comments (#1580).
This commit is contained in:
18
imgui.cpp
18
imgui.cpp
@ -6857,15 +6857,6 @@ void ImGui::SetScrollY(float scroll_y)
|
||||
window->ScrollTargetCenterRatio.y = 0.0f;
|
||||
}
|
||||
|
||||
void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
|
||||
{
|
||||
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
|
||||
window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
|
||||
window->ScrollTargetCenterRatio.y = center_y_ratio;
|
||||
}
|
||||
|
||||
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
||||
{
|
||||
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
||||
@ -6875,6 +6866,15 @@ void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
||||
window->ScrollTargetCenterRatio.x = center_x_ratio;
|
||||
}
|
||||
|
||||
void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
|
||||
{
|
||||
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
|
||||
window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
|
||||
window->ScrollTargetCenterRatio.y = center_y_ratio;
|
||||
}
|
||||
|
||||
// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
|
||||
void ImGui::SetScrollHereX(float center_x_ratio)
|
||||
{
|
||||
|
Reference in New Issue
Block a user