12 bool should_pan =
false;
14 if (ImGui::IsMouseDragging(ImGuiMouseButton_Middle)) {
16 }
else if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) &&
32 ImVec2 delta = ImGui::GetIO().MouseDelta;
33 float new_scroll_x = ImGui::GetScrollX() - delta.x;
34 float new_scroll_y = ImGui::GetScrollY() - delta.y;
37 float max_scroll_x = ImGui::GetScrollMaxX();
38 float max_scroll_y = ImGui::GetScrollMaxY();
41 new_scroll_x = std::clamp(new_scroll_x, 0.0f, max_scroll_x);
42 new_scroll_y = std::clamp(new_scroll_y, 0.0f, max_scroll_y);
44 ImGui::SetScrollX(new_scroll_x);
45 ImGui::SetScrollY(new_scroll_y);
82 if (scale <= 0.0f) scale = 1.0f;
90 ImVec2 viewport_px = ImGui::GetContentRegionAvail();
96 float scroll_x = center_x - viewport_px.x / 2.0f;
97 float scroll_y = center_y - viewport_px.y / 2.0f;
100 scroll_x = std::clamp(scroll_x, 0.0f, ImGui::GetScrollMaxX());
101 scroll_y = std::clamp(scroll_y, 0.0f, ImGui::GetScrollMaxY());
103 ImGui::SetScrollX(scroll_x);
104 ImGui::SetScrollY(scroll_y);