MCPcopy Create free account
hub / github.com/RenderKit/embree / CalcNextScrollFromScrollTargetAndClamp

Function CalcNextScrollFromScrollTargetAndClamp

tutorials/common/imgui/imgui.cpp:9452–9489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9450}
9451
9452static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
9453{
9454 ImVec2 scroll = window->Scroll;
9455 if (window->ScrollTarget.x < FLT_MAX)
9456 {
9457 float decoration_total_width = window->ScrollbarSizes.x;
9458 float center_x_ratio = window->ScrollTargetCenterRatio.x;
9459 float scroll_target_x = window->ScrollTarget.x;
9460 if (window->ScrollTargetEdgeSnapDist.x > 0.0f)
9461 {
9462 float snap_x_min = 0.0f;
9463 float snap_x_max = window->ScrollMax.x + window->SizeFull.x - decoration_total_width;
9464 scroll_target_x = CalcScrollEdgeSnap(scroll_target_x, snap_x_min, snap_x_max, window->ScrollTargetEdgeSnapDist.x, center_x_ratio);
9465 }
9466 scroll.x = scroll_target_x - center_x_ratio * (window->SizeFull.x - decoration_total_width);
9467 }
9468 if (window->ScrollTarget.y < FLT_MAX)
9469 {
9470 float decoration_total_height = window->TitleBarHeight() + window->MenuBarHeight() + window->ScrollbarSizes.y;
9471 float center_y_ratio = window->ScrollTargetCenterRatio.y;
9472 float scroll_target_y = window->ScrollTarget.y;
9473 if (window->ScrollTargetEdgeSnapDist.y > 0.0f)
9474 {
9475 float snap_y_min = 0.0f;
9476 float snap_y_max = window->ScrollMax.y + window->SizeFull.y - decoration_total_height;
9477 scroll_target_y = CalcScrollEdgeSnap(scroll_target_y, snap_y_min, snap_y_max, window->ScrollTargetEdgeSnapDist.y, center_y_ratio);
9478 }
9479 scroll.y = scroll_target_y - center_y_ratio * (window->SizeFull.y - decoration_total_height);
9480 }
9481 scroll.x = IM_FLOOR(ImMax(scroll.x, 0.0f));
9482 scroll.y = IM_FLOOR(ImMax(scroll.y, 0.0f));
9483 if (!window->Collapsed && !window->SkipItems)
9484 {
9485 scroll.x = ImMin(scroll.x, window->ScrollMax.x);
9486 scroll.y = ImMin(scroll.y, window->ScrollMax.y);
9487 }
9488 return scroll;
9489}
9490
9491void ImGui::ScrollToItem(ImGuiScrollFlags flags)
9492{

Callers 3

BeginMethod · 0.85
ScrollToRectExMethod · 0.85

Calls 3

CalcScrollEdgeSnapFunction · 0.85
ImMaxFunction · 0.85
ImMinFunction · 0.85

Tested by

no test coverage detected