| 72 | } |
| 73 | |
| 74 | RealRect _SimulationScrollbar::calcSliderbarRect(RealRect const& scrollbarRect) const |
| 75 | { |
| 76 | auto size2d = scrollbarRect.bottomRight - scrollbarRect.topLeft; |
| 77 | auto worldSize = |
| 78 | Orientation::Horizontal == _orientation ? _simulationFacade->getWorldSize().x : _simulationFacade->getWorldSize().y; |
| 79 | auto size = Orientation::Horizontal == _orientation ? size2d.x : size2d.y; |
| 80 | |
| 81 | auto worldRect = Viewport::get().getVisibleWorldRect(); |
| 82 | auto startWorldPos = Orientation::Horizontal == _orientation ? worldRect.topLeft.x : worldRect.topLeft.y; |
| 83 | auto endWorldPos = Orientation::Horizontal == _orientation ? worldRect.bottomRight.x : worldRect.bottomRight.y; |
| 84 | |
| 85 | auto sliderBarStartPos = std::min(std::max(startWorldPos / worldSize * size, 0.0f), size); |
| 86 | auto sliderBarEndPos = std::min(std::max(endWorldPos / worldSize * size, 0.0f), size); |
| 87 | if (sliderBarEndPos < sliderBarStartPos) { |
| 88 | sliderBarEndPos = sliderBarStartPos; |
| 89 | } |
| 90 | auto sliderBarPos = |
| 91 | Orientation::Horizontal == _orientation ? ImVec2{4 + sliderBarStartPos, 4} : ImVec2{4, 4 + sliderBarStartPos}; |
| 92 | auto sliderBarSize = Orientation::Horizontal == _orientation ? ImVec2{sliderBarEndPos - sliderBarStartPos - 8, 10} |
| 93 | : ImVec2{10, sliderBarEndPos - sliderBarStartPos - 8}; |
| 94 | |
| 95 | sliderBarSize = {std::max(10.0f, sliderBarSize.x), std::max(10.0f, sliderBarSize.y)}; |
| 96 | |
| 97 | return { |
| 98 | {sliderBarPos.x, sliderBarPos.y}, {sliderBarPos.x + sliderBarSize.x - 1, sliderBarPos.y + sliderBarSize.y - 1}}; |
| 99 | } |
| 100 | |
| 101 | bool _SimulationScrollbar::doesMouseCursorIntersectSliderBar(RealRect const& rect) const |
| 102 | { |
nothing calls this directly
no test coverage detected