MCPcopy Create free account
hub / github.com/chrxh/alien / processEvents

Method processEvents

source/Gui/SimulationScrollbar.cpp:48–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void _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
74RealRect _SimulationScrollbar::calcSliderbarRect(RealRect const& scrollbarRect) const
75{

Callers

nothing calls this directly

Calls 3

getCenterInWorldPosMethod · 0.80
getWorldSizeMethod · 0.80
setCenterInWorldPosMethod · 0.80

Tested by

no test coverage detected