right click menu in node view for adding nodes

This commit is contained in:
itsmattkc
2019-04-13 15:57:09 +10:00
parent e20b1d35c2
commit 6bf62017ea
18 changed files with 309 additions and 294 deletions
+5 -2
View File
@@ -29,8 +29,8 @@ NodeUI::NodeUI() :
NodeUI::~NodeUI()
{
if (scene() != nullptr) {
scene()->removeItem(proxy_);
if (proxy_ != nullptr) {
proxy_->setParentItem(nullptr);
}
}
@@ -164,6 +164,7 @@ void NodeUI::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (clicked_socket_ > -1) {
bool line_is_touching_node = false;
drag_destination_ = nullptr;
QPointF drag_line_end = event->scenePos();
@@ -234,6 +235,8 @@ void NodeUI::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (clicked_socket_ > -1) {
scene()->removeItem(drag_line_);
delete drag_line_;
event->accept();
if (drag_destination_ != nullptr) {
+8
View File
@@ -4,6 +4,9 @@
#include <QScrollBar>
#include <QDebug>
#include "ui/menu.h"
#include "nodes/node.h"
NodeView::NodeView(QGraphicsScene *scene, QWidget *parent) :
QGraphicsView(scene, parent),
hand_moving_(false)
@@ -20,6 +23,11 @@ void NodeView::mousePressEvent(QMouseEvent *event)
if (event->button() == Qt::MidButton) {
hand_moving_ = true;
drag_start_ = event->pos();
} else if (event->button() == Qt::RightButton && scene()->itemAt(mapToScene(event->pos()), QTransform()) == nullptr) {
// If the user clicked with the right button on empty space, show the context menu
emit RequestContextMenu();
} else {
QGraphicsView::mousePressEvent(event);
}
+5
View File
@@ -3,11 +3,16 @@
#include <QGraphicsView>
#include "timeline/tracktypes.h"
class NodeView : public QGraphicsView {
Q_OBJECT
public:
NodeView(QGraphicsScene *scene, QWidget* parent = nullptr);
signals:
void RequestContextMenu();
protected:
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
+1 -1
View File
@@ -2741,7 +2741,7 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) {
// cursor is hovering over a clip
// check if the clip and transition are both the same sign (meaning video/audio are the same)
if (track_list_->type() == ParentTimeline()->transition_tool_side) {
if (track_list_->type() == olive::node_library[ParentTimeline()->transition_tool_meta]->subtype()) {
// the range within which the transition tool will assume the user wants to make a shared transition
// between two clips rather than just one transition on one clip