nodeview: added ctrl+scroll zooming
This commit is contained in:
@@ -41,6 +41,7 @@ NodeView::NodeView(QWidget *parent) :
|
|||||||
connect(this, &NodeView::customContextMenuRequested, this, &NodeView::ShowContextMenu);
|
connect(this, &NodeView::customContextMenuRequested, this, &NodeView::ShowContextMenu);
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
setRenderHint(QPainter::Antialiasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeView::~NodeView()
|
NodeView::~NodeView()
|
||||||
@@ -273,6 +274,18 @@ void NodeView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
// FIXME: Hardcoded divider (0.001)
|
||||||
|
qreal multiplier = 1.0 + (static_cast<qreal>(event->delta()) * 0.001);
|
||||||
|
|
||||||
|
scale(multiplier, multiplier);
|
||||||
|
} else {
|
||||||
|
QWidget::wheelEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NodeView::SceneSelectionChangedSlot()
|
void NodeView::SceneSelectionChangedSlot()
|
||||||
{
|
{
|
||||||
emit SelectionChanged(scene_.GetSelectedNodes());
|
emit SelectionChanged(scene_.GetSelectedNodes());
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ protected:
|
|||||||
|
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
virtual void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PlaceNode(NodeViewItem* n, const QPointF& pos);
|
void PlaceNode(NodeViewItem* n, const QPointF& pos);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user