From c6a4b9e8d6c55468671a7690cceffe0cfb64f5e1 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 14 Mar 2019 09:35:50 +1100 Subject: [PATCH] fixed the graph editor --- effects/effect.cpp | 10 ++++++++ panels/effectcontrols.cpp | 24 ++++++++++++++---- panels/grapheditor.cpp | 51 +++++++++++++++------------------------ panels/grapheditor.h | 10 ++++---- ui/graphview.cpp | 1 - 5 files changed, 54 insertions(+), 42 deletions(-) diff --git a/effects/effect.cpp b/effects/effect.cpp index c35752b14..6197f7601 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -339,6 +339,16 @@ Effect::~Effect() { if (isOpen) { close(); } + + // Clear graph editor if it's using one of these rows + if (panel_graph_editor != nullptr) { + for (int i=0;iget_row()) { + panel_graph_editor->set_row(nullptr); + break; + } + } + } } void Effect::AddRow(EffectRow *row) diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 1e8708ca8..dacdd7322 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -273,11 +273,6 @@ void EffectControls::Clear(bool clear_cache) { // clear existing clips deselect_all_effects(nullptr); - // clear graph editor - if (panel_graph_editor != nullptr) { - panel_graph_editor->set_row(nullptr); - } - for (int i=0;i &clips, int mode) } void EffectControls::Load() { + bool graph_editor_row_is_still_active = false; + // load in new clips for (int i=0;ieffects.size();j++) { open_effect(layout, c->effects.at(j).get()); + + // Check if one of the open effects contains the row currently active in the graph editor. If not, we'll have + // to clear the graph editor later. + if (!graph_editor_row_is_still_active) { + for (int k=0;keffects.at(j)->row_count();k++) { + EffectRow* row = c->effects.at(j)->row(k); + if (row == panel_graph_editor->get_row()) { + graph_editor_row_is_still_active = true; + break; + } + } + } } } else if (mode_ == kTransitionOpening && c->opening_transition != nullptr) { open_effect(layout, c->opening_transition.get()); @@ -628,6 +637,11 @@ void EffectControls::Load() { QTimer::singleShot(50, this, SLOT(queue_post_update())); } + // If the graph editor's currently active row is not part of the current effects, clear it + if (!graph_editor_row_is_still_active) { + panel_graph_editor->set_row(nullptr); + } + UpdateTitle(); update_keyframes(); } diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index 6f720da10..17897a9ab 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -130,6 +130,11 @@ GraphEditor::GraphEditor(QWidget* parent) : Panel(parent), row(nullptr) { Retranslate(); } +EffectRow *GraphEditor::get_row() +{ + return row; +} + void GraphEditor::Retranslate() { setWindowTitle(tr("Graph Editor")); linear_button->setText(tr("Linear")); @@ -144,11 +149,7 @@ void GraphEditor::update_panel() { for (int i=0;iFieldCount();i++) { EffectField* field = row->Field(i); if (field->type() == EffectField::EFFECT_FIELD_DOUBLE) { - slider_proxies.at(slider_index)->SetValue( - row->Field(i)->GetValueAt( - playhead_to_clip_seconds(field->GetParentRow()->GetParentEffect()->parent_clip, - olive::ActiveSequence->playhead)).toDouble() - ); + field->UpdateWidgetValue(field_sliders_.at(slider_index), field->Now()); slider_index++; } } @@ -160,19 +161,18 @@ void GraphEditor::update_panel() { } void GraphEditor::set_row(EffectRow *r) { - for (int i=0;isetProperty("field", i); slider_button->setIconSize(slider_button->iconSize()*0.5); connect(slider_button, SIGNAL(toggled(bool)), this, SLOT(set_field_visibility(bool))); - slider_proxy_buttons.append(slider_button); + field_enable_buttons.append(slider_button); value_layout->addWidget(slider_button); - LabelSlider* slider = new LabelSlider(); + LabelSlider* slider = static_cast(field->CreateWidget()); slider->SetColor(get_curve_color(i, r->FieldCount()).name()); - connect(slider, SIGNAL(valueChanged()), this, SLOT(passthrough_slider_value())); - slider_proxies.append(slider); + field_sliders_.append(slider); value_layout->addWidget(slider); - //slider_proxy_sources.append(static_cast(field->ui_element)); - found_vals = true; } } @@ -211,9 +208,9 @@ void GraphEditor::set_row(EffectRow *r) { + " :: " + row->name()); header->set_visible_in(r->GetParentEffect()->parent_clip->timeline_in()); - connect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(goto_previous_key())); - connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(toggle_key())); - connect(keyframe_nav, SIGNAL(goto_next_key()), row, SLOT(goto_next_key())); + connect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(GoToPreviousKeyframe())); + connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(ToggleKeyframe())); + connect(keyframe_nav, SIGNAL(goto_next_key()), row, SLOT(GoToNextKeyframe())); } else { row = nullptr; current_row_desc->setText(nullptr); @@ -247,14 +244,6 @@ void GraphEditor::set_key_button_enabled(bool e, int type) { hold_button->setChecked(type == EFFECT_KEYFRAME_HOLD); } -void GraphEditor::passthrough_slider_value() { - for (int i=0;iSetValue(slider_proxies.at(i)->value()); - } - } -} - void GraphEditor::set_keyframe_type() { linear_button->setChecked(linear_button == sender()); bezier_button->setChecked(bezier_button == sender()); diff --git a/panels/grapheditor.h b/panels/grapheditor.h index 0ba0f3136..d7fb2fdc7 100644 --- a/panels/grapheditor.h +++ b/panels/grapheditor.h @@ -37,8 +37,10 @@ class GraphEditor : public Panel { public: GraphEditor(QWidget* parent = nullptr); - void update_panel(); + EffectRow* get_row(); void set_row(EffectRow* r); + + void update_panel(); bool view_is_focused(); bool view_is_under_mouse(); void delete_selected_keys(); @@ -50,9 +52,8 @@ private: GraphView* view; TimelineHeader* header; QHBoxLayout* value_layout; - QVector slider_proxies; - QVector slider_proxy_buttons; - QVector slider_proxy_sources; + QVector field_sliders_; + QVector field_enable_buttons; QLabel* current_row_desc; EffectRow* row; KeyframeNavigator* keyframe_nav; @@ -61,7 +62,6 @@ private: QPushButton* hold_button; private slots: void set_key_button_enabled(bool e, int type); - void passthrough_slider_value(); void set_keyframe_type(); void set_field_visibility(bool b); }; diff --git a/ui/graphview.cpp b/ui/graphview.cpp index f6b6cd124..7cade8cda 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -38,7 +38,6 @@ #include "ui/rectangleselect.h" #include "global/debug.h" - const double kGraphZoomSpeed = 0.05; const int kGraphSize = 100; const int kBezierHandleSize = 3;