refactor: change pan method

This commit is contained in:
parker
2025-06-20 02:07:11 +01:00
parent 9a7458f2c0
commit b829ba639b
3 changed files with 8 additions and 1 deletions

View File

@@ -7,6 +7,10 @@
NetworkGraphicsScene::NetworkGraphicsScene() NetworkGraphicsScene::NetworkGraphicsScene()
: QGraphicsScene() : QGraphicsScene()
{ {
sceneWidth_ = 64000;
sceneHeight_ = 64000;
setSceneRect(sceneWidth_/-2.0f, sceneHeight_/-2.0f, sceneWidth_, sceneHeight_);
} }

View File

@@ -8,5 +8,7 @@ class NetworkGraphicsScene
public: public:
NetworkGraphicsScene(); NetworkGraphicsScene();
private: private:
uint sceneWidth_;
uint sceneHeight_;
protected: protected:
}; };

View File

@@ -58,7 +58,8 @@ void NetworkGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent)
std::cout << "delta: " << delta.x() << " " << delta.y() << "\n"; std::cout << "delta: " << delta.x() << " " << delta.y() << "\n";
float speed = 1.0f; float speed = 1.0f;
setSceneRect(sceneRect().translated(-delta.x()*speed, -delta.y()*speed)); horizontalScrollBar()->setValue(horizontalScrollBar()->value() - delta.x());
verticalScrollBar()->setValue(verticalScrollBar()->value() - delta.y());
panStartPos = mouseEvent->pos(); panStartPos = mouseEvent->pos();
mouseEvent->accept(); mouseEvent->accept();
return; return;