ui: Use update loop in graph panning and zooming for smooth interaction
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
|
||||
#include <QGraphicsView>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class QtGraphicsView
|
||||
: public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom)
|
||||
|
||||
public:
|
||||
QtGraphicsView(QWidget* parent);
|
||||
@@ -15,26 +16,39 @@ public:
|
||||
float getZoomFactor() const;
|
||||
void setAppZoomFactor(float appZoomFactor);
|
||||
|
||||
qreal zoom() const;
|
||||
void setZoom(qreal zoom);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
signals:
|
||||
void emptySpaceClicked();
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
bool moves() const;
|
||||
|
||||
void updateTransform();
|
||||
void updateZoom(float delta, bool animate);
|
||||
void updateZoom(float delta);
|
||||
|
||||
QPoint m_last;
|
||||
|
||||
float m_zoomFactor;
|
||||
float m_appZoomFactor;
|
||||
|
||||
bool m_up;
|
||||
bool m_down;
|
||||
bool m_left;
|
||||
bool m_right;
|
||||
bool m_shift;
|
||||
|
||||
std::shared_ptr<QTimer> m_timer;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPHICS_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user