Merge branch 'master' into nodeviewredux

This commit is contained in:
itsmattkc
2020-04-29 05:01:11 +10:00
9 changed files with 211 additions and 113 deletions
+17 -4
View File
@@ -27,10 +27,12 @@
#include "node/factory.h"
#include "widget/menu/menushared.h"
#define super HandMovableView
OLIVE_NAMESPACE_ENTER
NodeView::NodeView(QWidget *parent) :
QGraphicsView(parent),
HandMovableView(parent),
graph_(nullptr),
attached_item_(nullptr),
drop_edge_(nullptr)
@@ -198,7 +200,7 @@ void NodeView::ItemsChanged()
void NodeView::keyPressEvent(QKeyEvent *event)
{
QGraphicsView::keyPressEvent(event);
super::keyPressEvent(event);
if (event->key() == Qt::Key_Escape && attached_item_) {
DetachItemFromCursor();
@@ -211,6 +213,8 @@ void NodeView::keyPressEvent(QKeyEvent *event)
void NodeView::mousePressEvent(QMouseEvent *event)
{
if (HandPress(event)) return;
if (attached_item_) {
Node* dropping_node = attached_item_->GetNode();
@@ -235,12 +239,14 @@ void NodeView::mousePressEvent(QMouseEvent *event)
drop_edge_ = nullptr;
}
QGraphicsView::mousePressEvent(event);
super::mousePressEvent(event);
}
void NodeView::mouseMoveEvent(QMouseEvent *event)
{
QGraphicsView::mouseMoveEvent(event);
if (HandMove(event)) return;
super::mouseMoveEvent(event);
if (attached_item_) {
attached_item_->setPos(mapToScene(event->pos()));
@@ -299,6 +305,13 @@ void NodeView::mouseMoveEvent(QMouseEvent *event)
}
}
void NodeView::mouseReleaseEvent(QMouseEvent *event)
{
if (HandRelease(event)) return;
super::mouseReleaseEvent(event);
}
void NodeView::wheelEvent(QWheelEvent *event)
{
if (event->modifiers() & Qt::ControlModifier) {
+3 -2
View File
@@ -26,6 +26,7 @@
#include "node/graph.h"
#include "nodeviewscene.h"
#include "widget/timelinewidget/view/handmovableview.h"
#include "widget/nodecopypaste/nodecopypaste.h"
OLIVE_NAMESPACE_ENTER
@@ -36,7 +37,7 @@ OLIVE_NAMESPACE_ENTER
* This widget takes a NodeGraph object and constructs a QGraphicsScene representing its data, viewing and allowing
* the user to make modifications to it.
*/
class NodeView : public QGraphicsView, public NodeCopyPasteWidget
class NodeView : public HandMovableView, public NodeCopyPasteWidget
{
Q_OBJECT
public:
@@ -73,8 +74,8 @@ protected:
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void wheelEvent(QWheelEvent* event) override;