| 11584 | } |
| 11585 | |
| 11586 | static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) |
| 11587 | { |
| 11588 | ImVec2 scroll = window->Scroll; |
| 11589 | ImVec2 decoration_size(window->DecoOuterSizeX1 + window->DecoInnerSizeX1 + window->DecoOuterSizeX2, window->DecoOuterSizeY1 + window->DecoInnerSizeY1 + window->DecoOuterSizeY2); |
| 11590 | for (int axis = 0; axis < 2; axis++) |
| 11591 | { |
| 11592 | if (window->ScrollTarget[axis] < FLT_MAX) |
| 11593 | { |
| 11594 | float center_ratio = window->ScrollTargetCenterRatio[axis]; |
| 11595 | float scroll_target = window->ScrollTarget[axis]; |
| 11596 | if (window->ScrollTargetEdgeSnapDist[axis] > 0.0f) |
| 11597 | { |
| 11598 | float snap_min = 0.0f; |
| 11599 | float snap_max = window->ScrollMax[axis] + window->SizeFull[axis] - decoration_size[axis]; |
| 11600 | scroll_target = CalcScrollEdgeSnap(scroll_target, snap_min, snap_max, window->ScrollTargetEdgeSnapDist[axis], center_ratio); |
| 11601 | } |
| 11602 | scroll[axis] = scroll_target - center_ratio * (window->SizeFull[axis] - decoration_size[axis]); |
| 11603 | } |
| 11604 | scroll[axis] = ImRound64(ImMax(scroll[axis], 0.0f)); |
| 11605 | if (!window->Collapsed && !window->SkipItems) |
| 11606 | scroll[axis] = ImMin(scroll[axis], window->ScrollMax[axis]); |
| 11607 | } |
| 11608 | return scroll; |
| 11609 | } |
| 11610 | |
| 11611 | void ImGui::ScrollToItem(ImGuiScrollFlags flags) |
| 11612 | { |
no test coverage detected