diff --git a/app/widget/nodeparamview/nodeparamview.cpp b/app/widget/nodeparamview/nodeparamview.cpp index 5a6254bd5..b0d6f1618 100644 --- a/app/widget/nodeparamview/nodeparamview.cpp +++ b/app/widget/nodeparamview/nodeparamview.cpp @@ -76,7 +76,7 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) : // Create contexts for three different types context_items_.resize(Track::kCount + 1); for (int i=0; isetVisible(false); connect(c, &NodeParamViewContext::AboutToDeleteItem, this, &NodeParamView::ItemAboutToBeRemoved, Qt::DirectConnection); @@ -245,8 +245,6 @@ void NodeParamView::DeselectNodes(const QVector &nodes) void NodeParamView::UpdateContexts() { - //TIME_THIS_FUNCTION; - bool changes_made = false; foreach (Node *ctx, current_contexts_) { @@ -735,7 +733,7 @@ void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context) return; } - NodeParamViewItem* item = new NodeParamViewItem(n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes, context); + NodeParamViewItem* item = new NodeParamViewItem(n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes, context->GetDockArea()); connect(item, &NodeParamViewItem::RequestSetTime, this, &NodeParamView::SetTimeAndSignal); connect(item, &NodeParamViewItem::RequestSelectNode, this, &NodeParamView::SelectNodeFromConnectedLink); diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp index 824452f4b..937037219 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp @@ -50,13 +50,13 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, label_layout->setMargin(0); layout->addLayout(label_layout); - CollapseButton *collapse_btn = new CollapseButton(); + CollapseButton *collapse_btn = new CollapseButton(this); collapse_btn->setChecked(false); label_layout->addWidget(collapse_btn); - label_layout->addWidget(new QLabel(tr("Connected to"))); + label_layout->addWidget(new QLabel(tr("Connected to"), this)); - connected_to_lbl_ = new ClickableLabel(); + connected_to_lbl_ = new ClickableLabel(this); connected_to_lbl_->setCursor(Qt::PointingHandCursor); connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu); connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this, &NodeParamViewConnectedLabel::ConnectionClicked); @@ -80,18 +80,23 @@ 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_); + // Creating the tree is expensive, hold off until the user specifically requests it + value_tree_ = nullptr; connect(collapse_btn, &CollapseButton::toggled, this, &NodeParamViewConnectedLabel::SetValueTreeVisible); } +void NodeParamViewConnectedLabel::CreateTree() +{ + // Set up table area + value_tree_ = new NodeValueTree(this); + layout()->addWidget(value_tree_); +} + void NodeParamViewConnectedLabel::SetTime(const rational &time) { time_ = time; - if (value_tree_->isVisible()) { + if (value_tree_ && value_tree_->isVisible()) { UpdateValueTree(); } } @@ -154,14 +159,22 @@ void NodeParamViewConnectedLabel::UpdateLabel() void NodeParamViewConnectedLabel::UpdateValueTree() { - value_tree_->SetNode(input_, time_); + if (value_tree_) { + value_tree_->SetNode(input_, time_); + } } void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e) { - value_tree_->setVisible(e); + if (value_tree_) { + value_tree_->setVisible(e); + } if (e) { + if (!value_tree_) { + CreateTree(); + } + UpdateValueTree(); } } diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.h b/app/widget/nodeparamview/nodeparamviewconnectedlabel.h index 183ff633b..9a7a81ee7 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.h +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.h @@ -51,6 +51,8 @@ private: void UpdateValueTree(); + void CreateTree(); + ClickableLabel* connected_to_lbl_; NodeInput input_; diff --git a/app/widget/nodeparamview/nodeparamviewitem.cpp b/app/widget/nodeparamview/nodeparamviewitem.cpp index 7b0e82fd3..a27cbe824 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.cpp +++ b/app/widget/nodeparamview/nodeparamviewitem.cpp @@ -88,7 +88,7 @@ void NodeParamViewItem::RecreateBody() body_->deleteLater(); } - body_ = new NodeParamViewItemBody(node_, create_checkboxes_); + body_ = new NodeParamViewItemBody(node_, create_checkboxes_, this); connect(body_, &NodeParamViewItemBody::RequestSelectNode, this, &NodeParamViewItem::RequestSelectNode); connect(body_, &NodeParamViewItemBody::RequestSetTime, this, &NodeParamViewItem::RequestSetTime); connect(body_, &NodeParamViewItemBody::ArrayExpandedChanged, this, &NodeParamViewItem::ArrayExpandedChanged); @@ -148,7 +148,7 @@ NodeParamViewItemBody::NodeParamViewItemBody(Node* node, NodeParamViewCheckBoxBe if (n->InputIsArray(input)) { // Insert here - QWidget* array_widget = new QWidget(); + QWidget* array_widget = new QWidget(this); QGridLayout* array_layout = new QGridLayout(array_widget); array_layout->setContentsMargins(QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")), 0, 0, 0); @@ -160,7 +160,7 @@ NodeParamViewItemBody::NodeParamViewItemBody(Node* node, NodeParamViewCheckBoxBe int arr_sz = 0; // Add one last add button for appending to the array - NodeParamViewArrayButton* append_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd); + NodeParamViewArrayButton* append_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd, this); connect(append_btn, &NodeParamViewArrayButton::clicked, this, &NodeParamViewItemBody::ArrayAppendClicked); array_layout->addWidget(append_btn, arr_sz, kArrayInsertColumn); @@ -186,7 +186,7 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const // Create optional checkbox if requested if (create_checkboxes_) { - ui_objects.optional_checkbox = new QCheckBox(); + ui_objects.optional_checkbox = new QCheckBox(this); connect(ui_objects.optional_checkbox, &QCheckBox::clicked, this, &NodeParamViewItemBody::OptionalCheckBoxClicked); layout->addWidget(ui_objects.optional_checkbox, row, kOptionalCheckBox); @@ -196,7 +196,7 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const } // Add descriptor label - ui_objects.main_label = new QLabel(); + ui_objects.main_label = new QLabel(this); // Create input label layout->addWidget(ui_objects.main_label, row, kLabelColumn); @@ -205,7 +205,7 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const if (element == -1) { // Create a collapse toggle for expanding/collapsing the array - CollapseButton* array_collapse_btn = new CollapseButton(); + CollapseButton* array_collapse_btn = new CollapseButton(this); // Default to collapsed array_collapse_btn->setChecked(false); @@ -220,8 +220,8 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const } else { - NodeParamViewArrayButton* insert_element_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd); - NodeParamViewArrayButton* remove_element_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kRemove); + NodeParamViewArrayButton* insert_element_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd, this); + NodeParamViewArrayButton* remove_element_btn = new NodeParamViewArrayButton(NodeParamViewArrayButton::kRemove, this); layout->addWidget(insert_element_btn, row, kArrayInsertColumn); layout->addWidget(remove_element_btn, row, kArrayRemoveColumn); @@ -249,14 +249,14 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const if (node->IsInputConnectable(input)) { // Create clickable label used when an input is connected - ui_objects.connected_label = new NodeParamViewConnectedLabel(resolved); + ui_objects.connected_label = new NodeParamViewConnectedLabel(resolved, this); connect(ui_objects.connected_label, &NodeParamViewConnectedLabel::RequestSelectNode, this, &NodeParamViewItemBody::RequestSelectNode); layout->addWidget(ui_objects.connected_label, row, kWidgetStartColumn, 1, kKeyControlColumn - kWidgetStartColumn); } // Add keyframe control to this layout if parameter is keyframable if (node->IsInputKeyframable(input)) { - ui_objects.key_control = new NodeParamViewKeyframeControl(); + ui_objects.key_control = new NodeParamViewKeyframeControl(this); ui_objects.key_control->SetInput(resolved); layout->addWidget(ui_objects.key_control, row, kKeyControlColumn); connect(ui_objects.key_control, &NodeParamViewKeyframeControl::RequestSetTime, this, &NodeParamViewItemBody::RequestSetTime); diff --git a/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp b/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp index 0e9aa6b32..ea51f647b 100644 --- a/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp +++ b/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp @@ -33,31 +33,31 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent) : { QHBoxLayout* layout = new QHBoxLayout(this); - collapse_btn_ = new CollapseButton(); + collapse_btn_ = new CollapseButton(this); connect(collapse_btn_, &QPushButton::clicked, this, &NodeParamViewItemTitleBar::ExpandedStateChanged); layout->addWidget(collapse_btn_); - lbl_ = new QLabel(); + lbl_ = new QLabel(this); layout->addWidget(lbl_); // Place next buttons on the far side layout->addStretch(); - add_fx_btn_ = new QPushButton(); + add_fx_btn_ = new QPushButton(this); add_fx_btn_->setIcon(icon::AddEffect); add_fx_btn_->setFixedSize(add_fx_btn_->sizeHint().height(), add_fx_btn_->sizeHint().height()); add_fx_btn_->setVisible(false); layout->addWidget(add_fx_btn_); connect(add_fx_btn_, &QPushButton::clicked, this, &NodeParamViewItemTitleBar::AddEffectButtonClicked); - pin_btn_ = new QPushButton(QStringLiteral("P")); + pin_btn_ = new QPushButton(QStringLiteral("P"), this); pin_btn_->setCheckable(true); pin_btn_->setFixedSize(pin_btn_->sizeHint().height(), pin_btn_->sizeHint().height()); pin_btn_->setVisible(false); layout->addWidget(pin_btn_); connect(pin_btn_, &QPushButton::clicked, this, &NodeParamViewItemTitleBar::PinToggled); - enabled_checkbox_ = new QCheckBox(); + enabled_checkbox_ = new QCheckBox(this); enabled_checkbox_->setVisible(false); layout->addWidget(enabled_checkbox_); connect(enabled_checkbox_, &QCheckBox::clicked, this, &NodeParamViewItemTitleBar::EnabledCheckBoxClicked); diff --git a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h index c11b206e0..0f8ffab7d 100644 --- a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h +++ b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h @@ -33,7 +33,11 @@ class NodeParamViewKeyframeControl : public QWidget, public TimeTargetObject { Q_OBJECT public: - NodeParamViewKeyframeControl(bool right_align = true, QWidget* parent = nullptr); + NodeParamViewKeyframeControl(bool right_align, QWidget* parent = nullptr); + NodeParamViewKeyframeControl(QWidget* parent = nullptr) : + NodeParamViewKeyframeControl(true, parent) + { + } const NodeInput& GetConnectedInput() const { diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 9f0ae6ac8..dd33a7659 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -71,9 +71,11 @@ int GetSliderCount(NodeValue::Type type) void NodeParamViewWidgetBridge::CreateWidgets() { + QWidget *parent = dynamic_cast(this->parent()); + if (GetInnerInput().IsArray() && GetInnerInput().element() == -1) { - NodeParamViewArrayWidget* w = new NodeParamViewArrayWidget(GetInnerInput().node(), GetInnerInput().input()); + NodeParamViewArrayWidget* w = new NodeParamViewArrayWidget(GetInnerInput().node(), GetInnerInput().input(), parent); connect(w, &NodeParamViewArrayWidget::DoubleClicked, this, &NodeParamViewWidgetBridge::ArrayWidgetDoubleClicked); widgets_.append(w); @@ -94,12 +96,12 @@ void NodeParamViewWidgetBridge::CreateWidgets() break; case NodeValue::kInt: { - CreateSliders(1); + CreateSliders(1, parent); break; } case NodeValue::kRational: { - CreateSliders(1); + CreateSliders(1, parent); break; } case NodeValue::kFloat: @@ -107,12 +109,12 @@ void NodeParamViewWidgetBridge::CreateWidgets() case NodeValue::kVec3: case NodeValue::kVec4: { - CreateSliders(GetSliderCount(t)); + CreateSliders(GetSliderCount(t), parent); break; } case NodeValue::kCombo: { - QComboBox* combobox = new QComboBox(); + QComboBox* combobox = new QComboBox(parent); QStringList items = GetInnerInput().GetComboBoxStrings(); foreach (const QString& s, items) { @@ -125,21 +127,21 @@ void NodeParamViewWidgetBridge::CreateWidgets() } case NodeValue::kFile: { - FileField* file_field = new FileField(); + FileField* file_field = new FileField(parent); widgets_.append(file_field); connect(file_field, &FileField::FilenameChanged, this, &NodeParamViewWidgetBridge::WidgetCallback); break; } case NodeValue::kColor: { - ColorButton* color_button = new ColorButton(GetInnerInput().node()->project()->color_manager()); + ColorButton* color_button = new ColorButton(GetInnerInput().node()->project()->color_manager(), parent); widgets_.append(color_button); connect(color_button, &ColorButton::ColorChanged, this, &NodeParamViewWidgetBridge::WidgetCallback); break; } case NodeValue::kText: { - NodeParamViewTextEdit* line_edit = new NodeParamViewTextEdit(); + NodeParamViewTextEdit* line_edit = new NodeParamViewTextEdit(parent); widgets_.append(line_edit); connect(line_edit, &NodeParamViewTextEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback); connect(line_edit, &NodeParamViewTextEdit::RequestEditInViewer, this, &NodeParamViewWidgetBridge::RequestEditTextInViewer); @@ -147,21 +149,21 @@ void NodeParamViewWidgetBridge::CreateWidgets() } case NodeValue::kBoolean: { - QCheckBox* check_box = new QCheckBox(); + QCheckBox* check_box = new QCheckBox(parent); widgets_.append(check_box); connect(check_box, &QCheckBox::clicked, this, &NodeParamViewWidgetBridge::WidgetCallback); break; } case NodeValue::kFont: { - QFontComboBox* font_combobox = new QFontComboBox(); + QFontComboBox* font_combobox = new QFontComboBox(parent); widgets_.append(font_combobox); connect(font_combobox, &QFontComboBox::currentFontChanged, this, &NodeParamViewWidgetBridge::WidgetCallback); break; } case NodeValue::kBezier: { - BezierWidget *bezier = new BezierWidget(); + BezierWidget *bezier = new BezierWidget(parent); widgets_.append(bezier); connect(bezier->x_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback); @@ -384,10 +386,10 @@ void NodeParamViewWidgetBridge::WidgetCallback() } template -void NodeParamViewWidgetBridge::CreateSliders(int count) +void NodeParamViewWidgetBridge::CreateSliders(int count, QWidget *parent) { for (int i=0;iSliderBase::SetDefaultValue(GetInnerInput().GetSplitDefaultValueForTrack(i)); fs->SetLadderElementCount(2); diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.h b/app/widget/nodeparamview/nodeparamviewwidgetbridge.h index 98a71d5d7..772febbde 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.h +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.h @@ -75,7 +75,7 @@ private: void SetProperty(const QString &key, const QVariant &value); template - void CreateSliders(int count); + void CreateSliders(int count, QWidget *parent); void UpdateWidgetValues();