implemented "value hints" for choosing output values to use
This commit is contained in:
@@ -33,6 +33,7 @@ add_subdirectory(nodecombobox)
|
||||
add_subdirectory(nodeparamview)
|
||||
add_subdirectory(nodetableview)
|
||||
add_subdirectory(nodetreeview)
|
||||
add_subdirectory(nodevaluetree)
|
||||
add_subdirectory(nodeview)
|
||||
add_subdirectory(panel)
|
||||
add_subdirectory(path)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "common/qtutils.h"
|
||||
#include "core.h"
|
||||
#include "node/node.h"
|
||||
#include "widget/collapsebutton/collapsebutton.h"
|
||||
#include "widget/menu/menu.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
|
||||
@@ -35,20 +36,29 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
input_(input),
|
||||
connected_node_(nullptr)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setSpacing(QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")));
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
||||
layout->addWidget(new QLabel(tr("Connected to")));
|
||||
// Set up label area
|
||||
QHBoxLayout *label_layout = new QHBoxLayout();
|
||||
label_layout->setSpacing(QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")));
|
||||
label_layout->setMargin(0);
|
||||
layout->addLayout(label_layout);
|
||||
|
||||
CollapseButton *collapse_btn = new CollapseButton();
|
||||
collapse_btn->setChecked(false);
|
||||
label_layout->addWidget(collapse_btn);
|
||||
|
||||
label_layout->addWidget(new QLabel(tr("Connected to")));
|
||||
|
||||
connected_to_lbl_ = new ClickableLabel();
|
||||
connected_to_lbl_->setCursor(Qt::PointingHandCursor);
|
||||
connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this, &NodeParamViewConnectedLabel::ConnectionClicked);
|
||||
connect(connected_to_lbl_, &ClickableLabel::customContextMenuRequested, this, &NodeParamViewConnectedLabel::ShowLabelContextMenu);
|
||||
layout->addWidget(connected_to_lbl_);
|
||||
label_layout->addWidget(connected_to_lbl_);
|
||||
|
||||
layout->addStretch();
|
||||
label_layout->addStretch();
|
||||
|
||||
// Set up "link" font
|
||||
QFont link_font = connected_to_lbl_->font();
|
||||
@@ -64,6 +74,21 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
|
||||
connect(input_.node(), &Node::InputConnected, this, &NodeParamViewConnectedLabel::InputConnected);
|
||||
connect(input_.node(), &Node::InputDisconnected, this, &NodeParamViewConnectedLabel::InputDisconnected);
|
||||
|
||||
// Set up table area
|
||||
value_tree_ = new NodeValueTree();
|
||||
value_tree_->setVisible(false);
|
||||
layout->addWidget(value_tree_);
|
||||
connect(collapse_btn, &CollapseButton::toggled, this, &NodeParamViewConnectedLabel::SetValueTreeVisible);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetTime(const rational &time)
|
||||
{
|
||||
time_ = time;
|
||||
|
||||
if (value_tree_->isVisible()) {
|
||||
UpdateValueTree();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::InputConnected(Node *output, const NodeInput& input)
|
||||
@@ -122,4 +147,18 @@ void NodeParamViewConnectedLabel::UpdateLabel()
|
||||
connected_to_lbl_->setText(s);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::UpdateValueTree()
|
||||
{
|
||||
value_tree_->SetNode(input_, time_);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e)
|
||||
{
|
||||
value_tree_->setVisible(e);
|
||||
|
||||
if (e) {
|
||||
UpdateValueTree();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "node/param.h"
|
||||
#include "widget/clickablelabel/clickablelabel.h"
|
||||
#include "widget/nodevaluetree/nodevaluetree.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -31,6 +32,8 @@ class NodeParamViewConnectedLabel : public QWidget {
|
||||
public:
|
||||
NodeParamViewConnectedLabel(const NodeInput& input, QWidget* parent = nullptr);
|
||||
|
||||
void SetTime(const rational &time);
|
||||
|
||||
signals:
|
||||
void RequestSelectNode(const QVector<Node*>& node);
|
||||
|
||||
@@ -46,12 +49,21 @@ private slots:
|
||||
private:
|
||||
void UpdateLabel();
|
||||
|
||||
void UpdateValueTree();
|
||||
|
||||
ClickableLabel* connected_to_lbl_;
|
||||
|
||||
NodeInput input_;
|
||||
|
||||
Node *connected_node_;
|
||||
|
||||
NodeValueTree *value_tree_;
|
||||
|
||||
rational time_;
|
||||
|
||||
private slots:
|
||||
void SetValueTreeVisible(bool e);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -383,6 +383,10 @@ void NodeParamViewItemBody::SetTime(const rational &time)
|
||||
ui_obj.key_control->SetTime(time);
|
||||
}
|
||||
|
||||
if (ui_obj.connected_label) {
|
||||
ui_obj.connected_label->SetTime(time);
|
||||
}
|
||||
|
||||
ui_obj.widget_bridge->SetTime(time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2021 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/nodevaluetree/nodevaluetree.cpp
|
||||
widget/nodevaluetree/nodevaluetree.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "nodevaluetree.h"
|
||||
|
||||
#include <QEvent>
|
||||
|
||||
#include "node/traverser.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super QTreeWidget
|
||||
|
||||
NodeValueTree::NodeValueTree(QWidget *parent) :
|
||||
super(parent)
|
||||
{
|
||||
setColumnWidth(0, 0);
|
||||
setColumnCount(4);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
static const int kMinimumRows = 10;
|
||||
setMinimumHeight(fontMetrics().height() * kMinimumRows);
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void NodeValueTree::SetNode(const NodeInput &input, const rational &time)
|
||||
{
|
||||
clear();
|
||||
|
||||
NodeTraverser traverser;
|
||||
|
||||
Node *connected_node = input.GetConnectedOutput();
|
||||
Node::ValueHint value_hint = input.node()->GetValueHintForInput(input.input(), input.element());
|
||||
|
||||
NodeValueTable table = traverser.GenerateTable(connected_node, value_hint, TimeRange(time, time));
|
||||
|
||||
int index = traverser.GenerateRowValueElementIndex(input.node(), input.input(), input.element(), &table);
|
||||
|
||||
for (int i=0; i<table.Count(); i++) {
|
||||
const NodeValue &value = table.at(i);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
||||
|
||||
Node::ValueHint hint = {{value.type()}, table.Count()-1-i, value.tag()};
|
||||
|
||||
QRadioButton *radio = new QRadioButton(this);
|
||||
radio->setProperty("input", QVariant::fromValue(input));
|
||||
radio->setProperty("hint", QVariant::fromValue(hint));
|
||||
if (i == index) {
|
||||
radio->setChecked(true);
|
||||
}
|
||||
connect(radio, &QRadioButton::clicked, this, &NodeValueTree::RadioButtonChecked);
|
||||
|
||||
setItemWidget(item, 0, radio);
|
||||
item->setText(1, NodeValue::GetPrettyDataTypeName(value.type()));
|
||||
item->setText(2, NodeValue::ValueToString(value.type(), value.data(), false));
|
||||
item->setText(3, value.source()->GetLabelAndName());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeValueTree::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
super::changeEvent(event);
|
||||
}
|
||||
|
||||
void NodeValueTree::Retranslate()
|
||||
{
|
||||
setHeaderLabels({QString(), tr("Type"), tr("Value"), tr("Source")});
|
||||
}
|
||||
|
||||
void NodeValueTree::RadioButtonChecked(bool e)
|
||||
{
|
||||
if (e) {
|
||||
QRadioButton *btn = static_cast<QRadioButton*>(sender());
|
||||
Node::ValueHint hint = btn->property("hint").value<Node::ValueHint>();
|
||||
NodeInput input = btn->property("input").value<NodeInput>();
|
||||
|
||||
input.node()->SetValueHintForInput(input.input(), input.element(), hint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef NODEVALUETREE_H
|
||||
#define NODEVALUETREE_H
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class NodeValueTree : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeValueTree(QWidget *parent = nullptr);
|
||||
|
||||
void SetNode(const NodeInput &input, const rational &time);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
private slots:
|
||||
void RadioButtonChecked(bool e);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVALUETREE_H
|
||||
@@ -79,6 +79,11 @@ public:
|
||||
|
||||
void ZoomOut();
|
||||
|
||||
const QVector<Node*> &GetCurrentContexts() const
|
||||
{
|
||||
return filter_nodes_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetMiniMapEnabled(bool e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user