| 46 | } |
| 47 | |
| 48 | void _SimulationScrollbar::processEvents(RealRect const& rect) |
| 49 | { |
| 50 | if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { |
| 51 | if (doesMouseCursorIntersectSliderBar(rect)) { |
| 52 | _worldCenterForDragging = Viewport::get().getCenterInWorldPos(); |
| 53 | } |
| 54 | } |
| 55 | if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) && _worldCenterForDragging) { |
| 56 | auto dragViewDelta = ImGui::GetMouseDragDelta(); |
| 57 | auto scrollbarSize = rect.bottomRight - rect.topLeft; |
| 58 | auto worldSize = _simulationFacade->getWorldSize(); |
| 59 | auto dragWorldDelta = RealVector2D{ |
| 60 | dragViewDelta.x / scrollbarSize.x * worldSize.x, dragViewDelta.y / scrollbarSize.y * worldSize.y}; |
| 61 | auto centerInWorldPos = Viewport::get().getCenterInWorldPos(); |
| 62 | if (Orientation::Horizontal == _orientation) { |
| 63 | centerInWorldPos.x = _worldCenterForDragging->x + dragWorldDelta.x; |
| 64 | } else { |
| 65 | centerInWorldPos.y = _worldCenterForDragging->y + dragWorldDelta.y; |
| 66 | } |
| 67 | Viewport::get().setCenterInWorldPos(centerInWorldPos); |
| 68 | } |
| 69 | if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { |
| 70 | _worldCenterForDragging = std::nullopt; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | RealRect _SimulationScrollbar::calcSliderbarRect(RealRect const& scrollbarRect) const |
| 75 | { |
nothing calls this directly
no test coverage detected