updated ParamPanel to be able to be connected with ViewerPanel and TimelinePanel

This commit is contained in:
itsmattkc
2019-12-27 02:41:31 +11:00
parent e32376a8b7
commit 227db9d653
7 changed files with 70 additions and 33 deletions
+6
View File
@@ -27,6 +27,7 @@ ParamPanel::ParamPanel(QWidget* parent) :
setObjectName("ParamPanel");
view_ = new NodeParamView(this);
connect(view_, &NodeParamView::TimeChanged, this, &ParamPanel::TimeChanged);
setWidget(view_);
@@ -50,6 +51,11 @@ void ParamPanel::SetNodes(QList<Node *> nodes)
Retranslate();
}
void ParamPanel::SetTime(const int64_t &timestamp)
{
view_->SetTime(timestamp);
}
void ParamPanel::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
+5
View File
@@ -37,6 +37,11 @@ public:
public slots:
void SetNodes(QList<Node*> nodes);
void SetTime(const int64_t& timestamp);
signals:
void TimeChanged(const int64_t& timestamp);
protected:
virtual void changeEvent(QEvent* e) override;
+8 -2
View File
@@ -26,6 +26,7 @@
#include "common/timecodefunctions.h"
#include "panel/panelmanager.h"
#include "panel/node/node.h"
#include "panel/param/param.h"
#include "panel/timeline/timeline.h"
#include "panel/viewer/viewer.h"
#include "ui/icons/icons.h"
@@ -43,13 +44,18 @@ void Sequence::Open(SequencePtr sequence)
ViewerPanel* viewer_panel = PanelManager::instance()->MostRecentlyFocused<ViewerPanel>();
TimelinePanel* timeline_panel = PanelManager::instance()->MostRecentlyFocused<TimelinePanel>();
NodePanel* node_panel = PanelManager::instance()->MostRecentlyFocused<NodePanel>();
ParamPanel* param_panel = PanelManager::instance()->MostRecentlyFocused<ParamPanel>();
viewer_panel->ConnectViewerNode(sequence->viewer_output_);
timeline_panel->ConnectTimelineNode(sequence->timeline_output_);
node_panel->SetGraph(sequence.get());
connect(timeline_panel, SIGNAL(TimeChanged(const int64_t&)), viewer_panel, SLOT(SetTime(const int64_t&)));
connect(viewer_panel, SIGNAL(TimeChanged(const int64_t&)), timeline_panel, SLOT(SetTime(const int64_t&)));
connect(timeline_panel, &TimelinePanel::TimeChanged, param_panel, &ParamPanel::SetTime);
connect(timeline_panel, &TimelinePanel::TimeChanged, viewer_panel, &ViewerPanel::SetTime);
connect(viewer_panel, &ViewerPanel::TimeChanged, param_panel, &ParamPanel::SetTime);
connect(viewer_panel, &ViewerPanel::TimeChanged, timeline_panel, &TimelinePanel::SetTime);
connect(param_panel, &ParamPanel::TimeChanged, viewer_panel, &ViewerPanel::SetTime);
connect(param_panel, &ParamPanel::TimeChanged, timeline_panel, &TimelinePanel::SetTime);
}
void Sequence::add_default_nodes()
+24 -14
View File
@@ -69,15 +69,18 @@ NodeParamView::NodeParamView(QWidget *parent) :
keyframe_area_layout->addWidget(keyframe_view_);
// Connect ruler and keyframe view together
connect(ruler_, SIGNAL(TimeChanged(const int64_t&)), keyframe_view_, SLOT(SetTime(const int64_t&)));
connect(keyframe_view_, SIGNAL(TimeChanged(const int64_t&)), ruler_, SLOT(SetTime(const int64_t&)));
connect(ruler_, SIGNAL(TimeChanged(const int64_t&)), this, SLOT(RulerTimeChanged(const int64_t&)));
connect(keyframe_view_, SIGNAL(TimeChanged(const int64_t&)), this, SLOT(RulerTimeChanged(const int64_t&)));
connect(ruler_, &TimeRuler::TimeChanged, keyframe_view_, &KeyframeView::SetTime);
connect(keyframe_view_, &KeyframeView::TimeChanged, ruler_, &TimeRuler::SetTime);
connect(ruler_, &TimeRuler::TimeChanged, this, &NodeParamView::RulerTimeChanged);
connect(keyframe_view_, &KeyframeView::TimeChanged, this, &NodeParamView::RulerTimeChanged);
splitter->addWidget(keyframe_area);
// Disable collapsing param view (but collapsing keyframe view is permitted)
splitter->setCollapsible(0, false);
// Set a default scale - FIXME: Hardcoded
SetScale(120);
}
void NodeParamView::SetNodes(QList<Node *> nodes)
@@ -101,9 +104,9 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
// Insert the widget before the stretch
param_layout_->insertWidget(param_layout_->count() - 1, item);
connect(item, SIGNAL(KeyframeAdded(NodeKeyframePtr, int)), keyframe_view_, SLOT(AddKeyframe(NodeKeyframePtr, int)));
connect(item, SIGNAL(KeyframeRemoved(NodeKeyframePtr)), keyframe_view_, SLOT(RemoveKeyframe(NodeKeyframePtr)));
connect(item, SIGNAL(RequestSetTime(const rational&)), this, SLOT(SetTime(const rational&)));
connect(item, &NodeParamViewItem::KeyframeAdded, keyframe_view_, &KeyframeView::AddKeyframe);
connect(item, &NodeParamViewItem::KeyframeRemoved, keyframe_view_, &KeyframeView::RemoveKeyframe);
connect(item, &NodeParamViewItem::RequestSetTime, this, &NodeParamView::ItemRequestedTimeChanged);
items_.append(item);
}
@@ -135,14 +138,12 @@ void NodeParamView::SetScale(const double& scale)
keyframe_view_->SetScale(scale);
}
void NodeParamView::SetTime(const rational &time)
void NodeParamView::SetTime(const int64_t &timestamp)
{
int64_t timestamp = Timecode::time_to_timestamp(time, keyframe_view_->timebase());
ruler_->SetTime(timestamp);
keyframe_view_->SetTime(timestamp);
UpdateItemTime(time);
UpdateItemTime(timestamp);
}
void NodeParamView::SetTimebase(const rational &timebase)
@@ -151,8 +152,10 @@ void NodeParamView::SetTimebase(const rational &timebase)
keyframe_view_->SetTimebase(timebase);
}
void NodeParamView::UpdateItemTime(const rational &time)
void NodeParamView::UpdateItemTime(const int64_t &timestamp)
{
rational time = Timecode::timestamp_to_time(timestamp, keyframe_view_->timebase());
foreach (NodeParamViewItem* item, items_) {
item->SetTime(time);
}
@@ -160,7 +163,14 @@ void NodeParamView::UpdateItemTime(const rational &time)
void NodeParamView::RulerTimeChanged(const int64_t &timestamp)
{
rational time = Timecode::timestamp_to_time(timestamp, keyframe_view_->timebase());
UpdateItemTime(timestamp);
UpdateItemTime(time);
emit TimeChanged(timestamp);
}
void NodeParamView::ItemRequestedTimeChanged(const rational &time)
{
int64_t timestamp = Timecode::time_to_timestamp(time, keyframe_view_->timebase());
SetTime(timestamp);
emit TimeChanged(timestamp);
}
+7 -2
View File
@@ -42,12 +42,15 @@ public:
void SetScale(const double &scale);
public slots:
void SetTime(const rational& time);
void SetTime(const int64_t& timestamp);
signals:
void TimeChanged(const int64_t& timestamp);
private:
void SetTimebase(const rational& timebase);
void UpdateItemTime(const rational& time);
void UpdateItemTime(const int64_t &timestamp);
QVBoxLayout* param_layout_;
@@ -62,6 +65,8 @@ private:
private slots:
void RulerTimeChanged(const int64_t& timestamp);
void ItemRequestedTimeChanged(const rational& time);
};
#endif // NODEPARAMVIEW_H
@@ -54,7 +54,7 @@ NodeParamViewItem::NodeParamViewItem(Node *node, QWidget *parent) :
// FIXME: Revise icon sizing algorithm (share with NodeViewItem)
title_bar_collapse_btn_->setIconSize(QSize(fontMetrics().height()/2, fontMetrics().height()/2));
connect(title_bar_collapse_btn_, SIGNAL(clicked(bool)), this, SLOT(SetExpanded(bool)));
connect(title_bar_collapse_btn_, &QPushButton::clicked, this, &NodeParamViewItem::SetExpanded);
title_bar_layout->addWidget(title_bar_collapse_btn_);
title_bar_lbl_ = new QLabel(title_bar_);
@@ -285,6 +285,11 @@ void NodeParamViewItem::UserToggledKeyframe(bool e)
} else if (!e && key) {
// Remove a keyframe here
new NodeParamRemoveKeyframeCommand(input, key, command);
// If this was the last keyframe, we'll set the standard value to the value at this time too
if (input->keyframes().size() == 1) {
new NodeParamSetStandardValueCommand(input, key->value(), command);
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
@@ -136,7 +136,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
slider->SetMaximum(input_->maximum().toLongLong());
}
connect(slider, SIGNAL(ValueChanged(int64_t)), this, SLOT(WidgetCallback()));
connect(slider, &IntegerSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
widgets_.append(slider);
break;
@@ -153,7 +153,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
slider->SetMaximum(input_->maximum().toDouble());
}
connect(slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
widgets_.append(slider);
break;
@@ -162,45 +162,45 @@ void NodeParamViewWidgetBridge::CreateWidgets()
{
FloatSlider* x_slider = new FloatSlider();
widgets_.append(x_slider);
connect(x_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(x_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* y_slider = new FloatSlider();
widgets_.append(y_slider);
connect(y_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(y_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kVec3:
{
FloatSlider* x_slider = new FloatSlider();
widgets_.append(x_slider);
connect(x_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(x_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* y_slider = new FloatSlider();
widgets_.append(y_slider);
connect(y_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(y_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* z_slider = new FloatSlider();
widgets_.append(z_slider);
connect(z_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(z_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kVec4:
{
FloatSlider* x_slider = new FloatSlider();
widgets_.append(x_slider);
connect(x_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(x_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* y_slider = new FloatSlider();
widgets_.append(y_slider);
connect(y_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(y_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* z_slider = new FloatSlider();
widgets_.append(z_slider);
connect(z_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(z_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
FloatSlider* w_slider = new FloatSlider();
widgets_.append(w_slider);
connect(w_slider, SIGNAL(ValueChanged(double)), this, SLOT(WidgetCallback()));
connect(w_slider, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFile:
@@ -213,14 +213,14 @@ void NodeParamViewWidgetBridge::CreateWidgets()
{
QLineEdit* line_edit = new QLineEdit();
widgets_.append(line_edit);
connect(line_edit, SIGNAL(textEdited(const QString &text)), this, SLOT(WidgetCallback()));
connect(line_edit, &QLineEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kBoolean:
{
QCheckBox* check_box = new QCheckBox();
widgets_.append(check_box);
connect(check_box, SIGNAL(toggled(bool)), this, SLOT(WidgetCallback()));
connect(check_box, &QCheckBox::toggled, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFont:
@@ -234,7 +234,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
FootageComboBox* footage_combobox = new FootageComboBox();
footage_combobox->SetRoot(static_cast<Sequence*>(input_->parentNode()->parent())->project()->root());
connect(footage_combobox, SIGNAL(FootageChanged(StreamPtr)), this, SLOT(WidgetCallback()));
connect(footage_combobox, &FootageComboBox::FootageChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
widgets_.append(footage_combobox);