refactor: change pan method
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
NetworkGraphicsScene::NetworkGraphicsScene()
|
||||
: QGraphicsScene()
|
||||
{
|
||||
sceneWidth_ = 64000;
|
||||
sceneHeight_ = 64000;
|
||||
|
||||
setSceneRect(sceneWidth_/-2.0f, sceneHeight_/-2.0f, sceneWidth_, sceneHeight_);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,7 @@ class NetworkGraphicsScene
|
||||
public:
|
||||
NetworkGraphicsScene();
|
||||
private:
|
||||
uint sceneWidth_;
|
||||
uint sceneHeight_;
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -58,7 +58,8 @@ void NetworkGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
std::cout << "delta: " << delta.x() << " " << delta.y() << "\n";
|
||||
|
||||
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();
|
||||
mouseEvent->accept();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user