| 9897 | } |
| 9898 | |
| 9899 | static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) |
| 9900 | { |
| 9901 | ImVec2 scroll = window->Scroll; |
| 9902 | ImVec2 decoration_size(window->DecoOuterSizeX1 + window->DecoInnerSizeX1 + window->DecoOuterSizeX2, window->DecoOuterSizeY1 + window->DecoInnerSizeY1 + window->DecoOuterSizeY2); |
| 9903 | for (int axis = 0; axis < 2; axis++) |
| 9904 | { |
| 9905 | if (window->ScrollTarget[axis] < FLT_MAX) |
| 9906 | { |
| 9907 | float center_ratio = window->ScrollTargetCenterRatio[axis]; |
| 9908 | float scroll_target = window->ScrollTarget[axis]; |
| 9909 | if (window->ScrollTargetEdgeSnapDist[axis] > 0.0f) |
| 9910 | { |
| 9911 | float snap_min = 0.0f; |
| 9912 | float snap_max = window->ScrollMax[axis] + window->SizeFull[axis] - decoration_size[axis]; |
| 9913 | scroll_target = CalcScrollEdgeSnap(scroll_target, snap_min, snap_max, window->ScrollTargetEdgeSnapDist[axis], center_ratio); |
| 9914 | } |
| 9915 | scroll[axis] = scroll_target - center_ratio * (window->SizeFull[axis] - decoration_size[axis]); |
| 9916 | } |
| 9917 | scroll[axis] = IM_FLOOR(ImMax(scroll[axis], 0.0f)); |
| 9918 | if (!window->Collapsed && !window->SkipItems) |
| 9919 | scroll[axis] = ImMin(scroll[axis], window->ScrollMax[axis]); |
| 9920 | } |
| 9921 | return scroll; |
| 9922 | } |
| 9923 | |
| 9924 | void ImGui::ScrollToItem(ImGuiScrollFlags flags) |
| 9925 | { |
no test coverage detected