refactor: change pan method
This commit is contained in:
@@ -7,6 +7,10 @@
|
|||||||
NetworkGraphicsScene::NetworkGraphicsScene()
|
NetworkGraphicsScene::NetworkGraphicsScene()
|
||||||
: QGraphicsScene()
|
: QGraphicsScene()
|
||||||
{
|
{
|
||||||
|
sceneWidth_ = 64000;
|
||||||
|
sceneHeight_ = 64000;
|
||||||
|
|
||||||
|
setSceneRect(sceneWidth_/-2.0f, sceneHeight_/-2.0f, sceneWidth_, sceneHeight_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ class NetworkGraphicsScene
|
|||||||
public:
|
public:
|
||||||
NetworkGraphicsScene();
|
NetworkGraphicsScene();
|
||||||
private:
|
private:
|
||||||
|
uint sceneWidth_;
|
||||||
|
uint sceneHeight_;
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user