nodeview: updated with new node color UI system
This commit is contained in:
+6
-1
@@ -174,7 +174,10 @@ public:
|
||||
*/
|
||||
void SetOverrideColor(int index)
|
||||
{
|
||||
override_color_ = index;
|
||||
if (override_color_ != index) {
|
||||
override_color_ = index;
|
||||
emit ColorChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -473,6 +476,8 @@ signals:
|
||||
*/
|
||||
void LabelChanged(const QString& s);
|
||||
|
||||
void ColorChanged();
|
||||
|
||||
public slots:
|
||||
void InputChanged(const olive::TimeRange &range, int element);
|
||||
|
||||
|
||||
@@ -75,6 +75,11 @@ public:
|
||||
node_view_->Duplicate();
|
||||
}
|
||||
|
||||
virtual void SetColorLabel(int index) override
|
||||
{
|
||||
node_view_->SetColorLabel(index);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void Select(const QVector<Node*>& nodes)
|
||||
{
|
||||
|
||||
@@ -263,6 +263,13 @@ void NodeView::Duplicate()
|
||||
AttachNodesToCursor(duplicated_nodes);
|
||||
}
|
||||
|
||||
void NodeView::SetColorLabel(int index)
|
||||
{
|
||||
foreach (Node* node, selected_nodes_) {
|
||||
node->SetOverrideColor(index);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
super::keyPressEvent(event);
|
||||
@@ -562,6 +569,9 @@ void NodeView::ShowContextMenu(const QPoint &pos)
|
||||
Core::instance()->LabelNodes(scene_.GetSelectedNodes());
|
||||
});
|
||||
|
||||
// Color menu
|
||||
MenuShared::instance()->AddColorCodingMenu(&m);
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
// Auto-position action
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
|
||||
void Duplicate();
|
||||
|
||||
void SetColorLabel(int index);
|
||||
|
||||
signals:
|
||||
void NodesSelected(const QVector<Node*>& nodes);
|
||||
|
||||
|
||||
@@ -167,12 +167,14 @@ void NodeViewScene::AddNode(Node* node)
|
||||
item_map_.insert(node, item);
|
||||
|
||||
connect(node, &Node::PositionChanged, this, &NodeViewScene::NodePositionChanged);
|
||||
connect(node, &Node::LabelChanged, this, &NodeViewScene::NodeLabelChanged);
|
||||
connect(node, &Node::LabelChanged, this, &NodeViewScene::NodeAppearanceChanged);
|
||||
connect(node, &Node::ColorChanged, this, &NodeViewScene::NodeAppearanceChanged);
|
||||
}
|
||||
|
||||
void NodeViewScene::RemoveNode(Node *node)
|
||||
{
|
||||
disconnect(node, &Node::LabelChanged, this, &NodeViewScene::NodeLabelChanged);
|
||||
disconnect(node, &Node::ColorChanged, this, &NodeViewScene::NodeAppearanceChanged);
|
||||
disconnect(node, &Node::LabelChanged, this, &NodeViewScene::NodeAppearanceChanged);
|
||||
disconnect(node, &Node::PositionChanged, this, &NodeViewScene::NodePositionChanged);
|
||||
|
||||
delete item_map_.take(node);
|
||||
@@ -286,7 +288,7 @@ void NodeViewScene::NodePositionChanged(const QPointF &pos)
|
||||
item_map_.value(static_cast<Node*>(sender()))->SetNodePosition(pos);
|
||||
}
|
||||
|
||||
void NodeViewScene::NodeLabelChanged()
|
||||
void NodeViewScene::NodeAppearanceChanged()
|
||||
{
|
||||
// Force item to update
|
||||
item_map_.value(static_cast<Node*>(sender()))->update();
|
||||
|
||||
@@ -129,7 +129,7 @@ private slots:
|
||||
/**
|
||||
* @brief Receiver for when a node's label has changed
|
||||
*/
|
||||
void NodeLabelChanged();
|
||||
void NodeAppearanceChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -705,8 +705,6 @@ void TimelineWidget::SetColorLabel(int index)
|
||||
foreach (Block* b, selected_blocks_) {
|
||||
b->SetOverrideColor(index);
|
||||
}
|
||||
|
||||
UpdateViewports();
|
||||
}
|
||||
|
||||
void TimelineWidget::InsertGapsAt(const rational &earliest_point, const rational &insert_length, QUndoCommand *command)
|
||||
@@ -838,29 +836,31 @@ void TimelineWidget::AddBlock(Block *block)
|
||||
if (!added_blocks_.contains(block)) {
|
||||
connect(block, &Block::LinksChanged, this, &TimelineWidget::BlockUpdated);
|
||||
connect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated);
|
||||
connect(block, &Block::ColorChanged, this, &TimelineWidget::BlockUpdated);
|
||||
connect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated);
|
||||
|
||||
added_blocks_.append(block);
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::RemoveBlock(Block *b)
|
||||
void TimelineWidget::RemoveBlock(Block *block)
|
||||
{
|
||||
// Disconnect all signals
|
||||
disconnect(b, &Block::LinksChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(b, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(b, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(block, &Block::LinksChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(block, &Block::ColorChanged, this, &TimelineWidget::BlockUpdated);
|
||||
disconnect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated);
|
||||
|
||||
// Take item from map
|
||||
added_blocks_.removeOne(b);
|
||||
added_blocks_.removeOne(block);
|
||||
|
||||
// If selected, deselect it
|
||||
int select_index = selected_blocks_.indexOf(b);
|
||||
int select_index = selected_blocks_.indexOf(block);
|
||||
if (select_index > -1) {
|
||||
selected_blocks_.removeAt(select_index);
|
||||
RemoveSelection(b);
|
||||
RemoveSelection(block);
|
||||
|
||||
emit BlocksDeselected({b});
|
||||
emit BlocksDeselected({block});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user