allow nodeui to modify several node values at once
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "nodeparamviewwidgetbridge.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
@@ -80,6 +79,8 @@ void NodeParamViewItem::AttachNode(Node *n)
|
||||
// If the added node was the first node, set up the UI
|
||||
if (nodes_.size() == 1) {
|
||||
SetupUI();
|
||||
} else {
|
||||
AddAdditionalNode(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +119,9 @@ void NodeParamViewItem::SetupUI()
|
||||
content_layout_->addWidget(param_label, row_count, 0);
|
||||
|
||||
// Create a widget/input bridge for this input
|
||||
NodeParamViewWidgetBridge* bridge = new NodeParamViewWidgetBridge(this, static_cast<NodeInput*>(param));
|
||||
NodeParamViewWidgetBridge* bridge = new NodeParamViewWidgetBridge(this);
|
||||
bridge->AddInput(static_cast<NodeInput*>(param));
|
||||
bridges_.append(bridge);
|
||||
|
||||
// Add widgets for this parameter ot the layout
|
||||
const QList<QWidget*>& widgets_for_param = bridge->widgets();
|
||||
@@ -131,6 +134,21 @@ void NodeParamViewItem::SetupUI()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItem::AddAdditionalNode(Node *n)
|
||||
{
|
||||
int bridge_count = 0;
|
||||
|
||||
for (int i=0;i<n->ParameterCount();i++) {
|
||||
NodeParam* param = n->ParamAt(i);
|
||||
|
||||
if (param->type() == NodeParam::kInput) {
|
||||
bridges_.at(bridge_count)->AddInput(static_cast<NodeInput*>(param));
|
||||
|
||||
bridge_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItem::SetExpanded(bool e)
|
||||
{
|
||||
expanded_ = e;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "node/node.h"
|
||||
#include "nodeparamviewwidgetbridge.h"
|
||||
|
||||
class NodeParamViewItemTitleBar : public QWidget {
|
||||
public:
|
||||
@@ -53,6 +54,8 @@ protected:
|
||||
private:
|
||||
void SetupUI();
|
||||
|
||||
void AddAdditionalNode(Node* n);
|
||||
|
||||
bool expanded_;
|
||||
|
||||
NodeParamViewItemTitleBar* title_bar_;
|
||||
@@ -67,6 +70,8 @@ private:
|
||||
|
||||
QList<Node*> nodes_;
|
||||
|
||||
QList<NodeParamViewWidgetBridge*> bridges_;
|
||||
|
||||
private slots:
|
||||
void SetExpanded(bool e);
|
||||
};
|
||||
|
||||
@@ -12,13 +12,19 @@
|
||||
#include "panel/project/project.h"
|
||||
// End test code
|
||||
|
||||
NodeParamViewWidgetBridge::NodeParamViewWidgetBridge(QObject* parent, NodeInput* input) :
|
||||
QObject(parent),
|
||||
input_(input)
|
||||
NodeParamViewWidgetBridge::NodeParamViewWidgetBridge(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
Q_ASSERT(parent != nullptr && input_ != nullptr);
|
||||
}
|
||||
|
||||
CreateWidgets();
|
||||
void NodeParamViewWidgetBridge::AddInput(NodeInput *input)
|
||||
{
|
||||
inputs_.append(input);
|
||||
|
||||
// If this was the first input, create the widgets
|
||||
if (inputs_.size() == 1) {
|
||||
CreateWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
const QList<QWidget *> &NodeParamViewWidgetBridge::widgets()
|
||||
@@ -28,13 +34,15 @@ const QList<QWidget *> &NodeParamViewWidgetBridge::widgets()
|
||||
|
||||
void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
{
|
||||
NodeInput* base_input = inputs_.first();
|
||||
|
||||
// Return empty list if the NodeInput has no actual input data types
|
||||
if (input_->inputs().isEmpty()) {
|
||||
if (base_input->inputs().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We assume the first data type is the "primary" type
|
||||
switch (input_->inputs().first()) {
|
||||
switch (base_input->inputs().first()) {
|
||||
// None of these inputs have applicable UI widgets
|
||||
case NodeParam::kNone:
|
||||
case NodeParam::kAny:
|
||||
@@ -80,7 +88,10 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
// Pretty hacky way of getting the root folder for this node's sequence
|
||||
ProjectPanel* pp = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
|
||||
footage_combobox->SetRoot(pp->project()->root());
|
||||
footage_combobox->SetFootage(Node::ValueToPtr<Footage>(input_->get_value(Now())));
|
||||
|
||||
// Use multiple values
|
||||
footage_combobox->SetFootage(Node::ValueToPtr<Footage>(base_input->get_value(Now())));
|
||||
|
||||
connect(footage_combobox, SIGNAL(FootageChanged(Footage*)), this, SLOT(WidgetCallback()));
|
||||
// End test code
|
||||
|
||||
@@ -99,50 +110,52 @@ rational NodeParamViewWidgetBridge::Now()
|
||||
|
||||
void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
{
|
||||
switch (input_->inputs().first()) {
|
||||
// None of these inputs have applicable UI widgets
|
||||
case NodeParam::kNone:
|
||||
case NodeParam::kAny:
|
||||
case NodeParam::kBlock:
|
||||
case NodeParam::kTexture:
|
||||
case NodeParam::kMatrix:
|
||||
break;
|
||||
case NodeParam::kInt:
|
||||
// FIXME: LabelSlider in INTEGER mode
|
||||
break;
|
||||
case NodeParam::kFloat:
|
||||
// FIXME: LabelSlider in FLOAT mode
|
||||
break;
|
||||
case NodeParam::kFile:
|
||||
// FIXME: File selector
|
||||
break;
|
||||
case NodeParam::kColor:
|
||||
// FIXME: Color selector
|
||||
break;
|
||||
case NodeParam::kString:
|
||||
{
|
||||
// Sender is a QLineEdit
|
||||
//QLineEdit* line_edit = static_cast<QLineEdit*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kBoolean:
|
||||
{
|
||||
// Widget is a QCheckBox
|
||||
//QCheckBox* check_box = static_cast<QCheckBox*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFont:
|
||||
{
|
||||
// Widget is a QFontComboBox
|
||||
//QFontComboBox* font_combobox = static_cast<QFontComboBox*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFootage:
|
||||
{
|
||||
// Widget is a FootageComboBox
|
||||
FootageComboBox* footage_combobox = static_cast<FootageComboBox*>(sender());
|
||||
input_->set_value(Now(), Node::PtrToValue(footage_combobox->SelectedFootage()));
|
||||
break;
|
||||
}
|
||||
foreach (NodeInput* input, inputs_) {
|
||||
switch (input->inputs().first()) {
|
||||
// None of these inputs have applicable UI widgets
|
||||
case NodeParam::kNone:
|
||||
case NodeParam::kAny:
|
||||
case NodeParam::kBlock:
|
||||
case NodeParam::kTexture:
|
||||
case NodeParam::kMatrix:
|
||||
break;
|
||||
case NodeParam::kInt:
|
||||
// FIXME: LabelSlider in INTEGER mode
|
||||
break;
|
||||
case NodeParam::kFloat:
|
||||
// FIXME: LabelSlider in FLOAT mode
|
||||
break;
|
||||
case NodeParam::kFile:
|
||||
// FIXME: File selector
|
||||
break;
|
||||
case NodeParam::kColor:
|
||||
// FIXME: Color selector
|
||||
break;
|
||||
case NodeParam::kString:
|
||||
{
|
||||
// Sender is a QLineEdit
|
||||
//QLineEdit* line_edit = static_cast<QLineEdit*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kBoolean:
|
||||
{
|
||||
// Widget is a QCheckBox
|
||||
//QCheckBox* check_box = static_cast<QCheckBox*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFont:
|
||||
{
|
||||
// Widget is a QFontComboBox
|
||||
//QFontComboBox* font_combobox = static_cast<QFontComboBox*>(sender());
|
||||
break;
|
||||
}
|
||||
case NodeParam::kFootage:
|
||||
{
|
||||
// Widget is a FootageComboBox
|
||||
FootageComboBox* footage_combobox = static_cast<FootageComboBox*>(sender());
|
||||
input->set_value(Now(), Node::PtrToValue(footage_combobox->SelectedFootage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,14 @@ class NodeParamViewWidgetBridge : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeParamViewWidgetBridge(QObject* parent, NodeInput* input);
|
||||
NodeParamViewWidgetBridge(QObject* parent);
|
||||
|
||||
void AddInput(NodeInput* input);
|
||||
|
||||
const QList<QWidget*>& widgets();
|
||||
|
||||
private:
|
||||
NodeInput* input_;
|
||||
QList<NodeInput*> inputs_;
|
||||
|
||||
QList<QWidget*> widgets_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user