From f796c2b3791765c45266d41a5fc798198b79c599 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 11 May 2019 11:38:18 +1000 Subject: [PATCH 1/2] sequence is now a node graph --- nodes/node.cpp | 27 ++++++- nodes/node.h | 15 ++-- nodes/nodegraph.cpp | 18 +++-- nodes/nodegraph.h | 18 ++--- timeline/sequence.cpp | 167 ++++++++++++++++++++++++++++-------------- timeline/sequence.h | 6 +- timeline/track.cpp | 14 ++-- timeline/track.h | 4 +- ui/timelinearea.cpp | 4 +- 9 files changed, 179 insertions(+), 94 deletions(-) diff --git a/nodes/node.cpp b/nodes/node.cpp index a42738023..ec451692a 100644 --- a/nodes/node.cpp +++ b/nodes/node.cpp @@ -1,6 +1,29 @@ #include "node.h" -Node::Node(NodeGraph *graph) -{ +#include "nodegraph.h" +Node::Node(NodeGraph *graph) : + QObject(graph) +{ +} + +void Node::AddParameter(NodeIO *param) +{ + param->setParent(this); + parameters_.append(param); +} + +int Node::IndexOfParameter(NodeIO *param) +{ + return parameters_.indexOf(param); +} + +NodeIO *Node::Parameter(int i) +{ + return parameters_.at(i); +} + +int Node::ParameterCount() +{ + return parameters_.size(); } diff --git a/nodes/node.h b/nodes/node.h index ac63912db..fecb6a56f 100644 --- a/nodes/node.h +++ b/nodes/node.h @@ -3,18 +3,23 @@ #include +#include "nodes/nodeio.h" + class NodeGraph; -class Node; -using NodePtr = std::shared_ptr; - -class Node +class Node : public QObject { + Q_OBJECT public: Node(NodeGraph* parent); + void AddParameter(NodeIO* row); + int IndexOfParameter(NodeIO* row); + NodeIO* Parameter(int i); + int ParameterCount(); + private: - NodeGraph* parent_; + QVector parameters_; }; #endif // NODE_H diff --git a/nodes/nodegraph.cpp b/nodes/nodegraph.cpp index f0fec1c04..5782f20e4 100644 --- a/nodes/nodegraph.cpp +++ b/nodes/nodegraph.cpp @@ -1,20 +1,26 @@ #include "nodegraph.h" +#include #include -NodeGraph::NodeGraph() : - output_node_(nullptr) +NodeGraph::NodeGraph() { } -void NodeGraph::AddNode(NodePtr node) +void NodeGraph::childEvent(QChildEvent *event) { - nodes_.append(node); - emit NodeGraphChanged(); + if (event->type() == QEvent::ChildAdded || event->type() == QEvent::ChildRemoved) { + emit NodeGraphChanged(); + } +} + +void NodeGraph::SetOutputNode(Node *node) +{ + output_node_ = node; } Node *NodeGraph::OutputNode() { - return output_node_.get(); + return output_node_; } diff --git a/nodes/nodegraph.h b/nodes/nodegraph.h index 75202c17d..9d1915994 100644 --- a/nodes/nodegraph.h +++ b/nodes/nodegraph.h @@ -12,15 +12,6 @@ class NodeGraph : public QObject public: NodeGraph(); - /** - * @brief Add a node to this graph - * - * The graph takes ownership of the node. - * - * @param node - */ - void AddNode(NodePtr node); - /** * @brief Process the graph * @@ -43,7 +34,7 @@ public: * * The node to set as the output node. The graph takes ownership of the node and the user cannot delete it. */ - void SetOutputNode(NodePtr node); + void SetOutputNode(Node* node); /** * @brief Returns the currently set output node @@ -53,10 +44,11 @@ public: signals: void NodeGraphChanged(); -private: - NodePtr output_node_; +protected: + virtual void childEvent(QChildEvent *event) override; - QVector nodes_; +private: + Node* output_node_; }; #endif // NODEGRAPH_H diff --git a/timeline/sequence.cpp b/timeline/sequence.cpp index 842d966c0..77b885e40 100644 --- a/timeline/sequence.cpp +++ b/timeline/sequence.cpp @@ -169,8 +169,11 @@ void Sequence::set_audio_layout(const int& l) long Sequence::GetEndFrame() { long end_frame = 0; - for (int i=0;iGetEndFrame(), end_frame); + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i)); + end_frame = qMax(t->GetEndFrame(), end_frame); } return end_frame; @@ -180,9 +183,11 @@ QVector Sequence::GetAllClips() { QVector all_clips; - for (int j=0;jGetAllClips()); + for (int j=0;j(tracks.at(j))->GetAllClips()); } @@ -193,9 +198,12 @@ QVector Sequence::GetTrackList(olive::TrackType type) { QVector tracks; - for (int i=0;itype() == type) { - tracks.append(tracks_.at(i)); + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i)); + if (t->type() == type) { + tracks.append(t); } } @@ -230,8 +238,10 @@ QVector Sequence::SelectedClips(bool containing) { QVector selected_clips; - for (int j=0;j(all_tracks.at(j)); selected_clips.append(t->GetSelectedClips(containing)); } @@ -388,6 +398,8 @@ void Sequence::EditToPoint(bool in, bool ripple) bool push_undo = true; long seek = playhead; + const QObjectList& all_tracks = children(); + if ((in && (playhead_falls_on_out || (playhead_falls_on_in && playhead == 0))) || (!in && (playhead_falls_on_in || (playhead_falls_on_out && playhead == sequence_end)))) { // one frame mode if (ripple) { @@ -400,8 +412,9 @@ void Sequence::EditToPoint(bool in, bool ripple) if (in_point >= 0) { - for (int j=0;j(all_tracks.at(j)); + areas.append(Selection(in_point, in_point+1, t)); } // trim and move clips around the in point @@ -436,8 +449,9 @@ void Sequence::EditToPoint(bool in, bool ripple) } else { - for (int j=0;j(all_tracks.at(j)); + areas.append(Selection(area_in, area_out, t)); } // trim and move clips around the in point @@ -522,8 +536,11 @@ void Sequence::DeleteInToOut(bool ripple) QVector areas_to_delete; - for (int j=0;j(all_tracks.at(j)); + areas_to_delete.append(Selection(workarea_in, workarea_out, t)); } ComboAction* ca = new ComboAction(); @@ -576,8 +593,10 @@ void Sequence::Ripple(ComboAction *ca, long point, long length, const QVector(all_tracks.at(j)); t->set_height(t->height() + diff); } @@ -649,9 +668,12 @@ void Sequence::Split() // If we weren't able to split any selected clips above, see if there are arbitrary selections to split if (!split_occurred) { - Track* track; + const QObjectList& all_tracks = children(); + QObject* obj; - foreach (track, tracks_) { + foreach (obj, all_tracks) { + + Track* track = static_cast(obj); QVector track_selections = track->Selections(); QVector split_positions; @@ -894,8 +916,10 @@ void Sequence::RippleDeleteEmptySpace(ComboAction* ca, Track* track, long point) void Sequence::RippleDeleteArea(ComboAction* ca, long ripple_point, long ripple_length) { - for (int j=0;j(all_tracks.at(j)); // We've already tested `track`, so we don't need to test it again long first_in_point_after_point = LONG_MAX; @@ -982,22 +1006,25 @@ OldEffectNode *Sequence::GetSelectedGizmo() void Sequence::SelectAll() { - for (int i=0;iSelectAll(); + const QObjectList& all_tracks = children(); + for (int i=0;i(all_tracks.at(i))->SelectAll(); } } void Sequence::SelectAtPlayhead() { - for (int i=0;iSelectAtPoint(playhead); + const QObjectList& all_tracks = children(); + for (int i=0;i(all_tracks.at(i))->SelectAtPoint(playhead); } } void Sequence::ClearSelections() { - for (int i=0;iClearSelections(); + const QObjectList& all_tracks = children(); + for (int i=0;i(all_tracks.at(i))->ClearSelections(); } } @@ -1078,8 +1105,10 @@ QVector Sequence::Selections() { QVector selections; - for (int i=0;iSelections()); + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i))->Selections()); } return selections; @@ -1108,12 +1137,15 @@ Track *Sequence::PreviousTrack(Track *t) Track* previous_track = nullptr; // Loop through tracks - for (int i=0;i(all_tracks.at(i)); + + if (comp_track == t) { // If this is the track, we'll know the previous track by now break; - } else if (tracks_.at(i)->type() == t->type()) { + } else if (comp_track->type() == t->type()) { // Otherwise, we'll keep "track" of it previous_track = t; } @@ -1132,14 +1164,18 @@ Track *Sequence::NextTrack(Track *t) Track* next_track = nullptr; - for (int i=tracks_.size()-1;i>=0;i--) { + const QObjectList& all_tracks = children(); - if (tracks_.at(i) == t) { + for (int i=all_tracks.size()-1;i>=0;i--) { + + Track* track = static_cast(all_tracks.at(i)); + + if (track == t) { break; } - if (tracks_.at(i)->type() == t->type()) { - next_track = tracks_.at(i); + if (track->type() == t->type()) { + next_track = track; } } @@ -1161,13 +1197,17 @@ int Sequence::IndexOfTrack(Track *t) { int counter = -1; - for (int i=0;itype() == t->type()) { + for (int i=0;i(all_tracks.at(i)); + + if (track->type() == t->type()) { counter++; } - if (tracks_.at(i) == t) { + if (track == t) { return counter; } } @@ -1177,9 +1217,14 @@ int Sequence::IndexOfTrack(Track *t) Track *Sequence::FirstTrack(olive::TrackType type) { - for (int i=0;itype() == type) { - return tracks_.at(i); + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i)); + + if (track->type() == type) { + return track; } } return nullptr; @@ -1187,9 +1232,14 @@ Track *Sequence::FirstTrack(olive::TrackType type) Track *Sequence::LastTrack(olive::TrackType type) { - for (int i=tracks_.size()-1;i>=0;i--) { - if (tracks_.at(i)->type() == type) { - return tracks_.at(i); + const QObjectList& all_tracks = children(); + + for (int i=all_tracks.size()-1;i>=0;i--) { + + Track* track = static_cast(all_tracks.at(i)); + + if (track->type() == type) { + return track; } } return nullptr; @@ -1199,13 +1249,18 @@ Track *Sequence::TrackAt(olive::TrackType type, int index) { int counter = -1; - for (int i=0;itype() == type) { + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i)); + + if (track->type() == type) { counter++; } if (counter == index) { - return tracks_.at(i); + return track; } } @@ -1223,8 +1278,13 @@ int Sequence::TrackCount(olive::TrackType type) { int counter = 0; - for (int i=0;itype() == type) { + const QObjectList& all_tracks = children(); + + for (int i=0;i(all_tracks.at(i)); + + if (track->type() == type) { counter++; } } @@ -1234,10 +1294,9 @@ int Sequence::TrackCount(olive::TrackType type) Track* Sequence::AddTrack(olive::TrackType type) { - Track* track = new Track(this, type); - tracks_.append(track); - emit TrackCountChanged(); - return track; + Track* t = new Track(nullptr, type); + t->setParent(this); + return t; } ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long frame) diff --git a/timeline/sequence.h b/timeline/sequence.h index 9dbe81027..c4366a059 100644 --- a/timeline/sequence.h +++ b/timeline/sequence.h @@ -28,8 +28,9 @@ #include "marker.h" #include "selection.h" #include "ghost.h" +#include "nodes/nodegraph.h" -class Sequence : public QObject { +class Sequence : public NodeGraph { Q_OBJECT public: Sequence(); @@ -142,11 +143,10 @@ public: QVector markers; signals: void SequenceParametersChanged(); - void TrackCountChanged(); private: Track *AddTrack(olive::TrackType type); - QVector tracks_; + //QVector tracks_; ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame); ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame, long post_in); diff --git a/timeline/track.cpp b/timeline/track.cpp index cfe3f3c86..5749651de 100644 --- a/timeline/track.cpp +++ b/timeline/track.cpp @@ -9,7 +9,7 @@ int olive::timeline::kTrackMinHeight = 30; int olive::timeline::kTrackHeightIncrement = 10; Track::Track(Sequence* parent, olive::TrackType type) : - parent_(parent), + Node(parent), type_(type), muted_(false), soloed_(false), @@ -35,7 +35,7 @@ Track *Track::copy(Sequence *parent) Sequence *Track::sequence() { - return parent_; + return static_cast(parent()); } void Track::Save(QXmlStreamWriter &stream) @@ -204,22 +204,22 @@ bool Track::ContainsClip(Clip *c) Track *Track::Previous() { - return parent_->PreviousTrack(this); + return sequence()->PreviousTrack(this); } Track *Track::Next() { - return parent_->NextTrack(this); + return sequence()->NextTrack(this); } Track *Track::Sibling(int diff) { - return parent_->SiblingTrack(this, diff); + return sequence()->SiblingTrack(this, diff); } int Track::Index() { - return parent_->IndexOfTrack(this); + return sequence()->IndexOfTrack(this); } bool Track::IsClipSelected(int clip_index, bool containing) @@ -378,7 +378,7 @@ bool Track::IsEffectivelyMuted() // Check if any tracks are soloed bool a_track_is_soloed = false; - QVector siblings = parent_->GetTrackList(type_); + QVector siblings = sequence()->GetTrackList(type_); for (int i=0;iIsSoloed()) { a_track_is_soloed = true; diff --git a/timeline/track.h b/timeline/track.h index 7fbbf2fe3..fe79ecbd4 100644 --- a/timeline/track.h +++ b/timeline/track.h @@ -8,6 +8,7 @@ #include "tracktypes.h" #include "undo/comboaction.h" #include "timeline/selection.h" +#include "nodes/node.h" class Sequence; class Transition; @@ -37,7 +38,7 @@ namespace olive { class Sequence; -class Track : public QObject +class Track : public Node { Q_OBJECT public: @@ -107,7 +108,6 @@ signals: private: void ResizeClipArray(int new_size); - Sequence* parent_; olive::TrackType type_; int height_; QVector clips_; diff --git a/ui/timelinearea.cpp b/ui/timelinearea.cpp index 9282a6664..9d6e07989 100644 --- a/ui/timelinearea.cpp +++ b/ui/timelinearea.cpp @@ -52,7 +52,7 @@ TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignm void TimelineArea::SetTrackType(Sequence *sequence, olive::TrackType track_type) { if (sequence_ != nullptr) { - disconnect(sequence_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels())); + disconnect(sequence_, SIGNAL(NodeGraphChanged()), this, SLOT(RefreshLabels())); } sequence_ = sequence; @@ -60,7 +60,7 @@ void TimelineArea::SetTrackType(Sequence *sequence, olive::TrackType track_type) if (sequence_ != nullptr) { - connect(sequence_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels())); + connect(sequence_, SIGNAL(NodeGraphChanged()), this, SLOT(RefreshLabels())); } From 49feb129997ce0a9462cbe551bbf1d187c0ca160 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 13 May 2019 12:00:15 +1000 Subject: [PATCH 2/2] ported functions to new node type --- effects/effectfield.cpp | 59 +++++++++++--------------- effects/effectfield.h | 26 ------------ effects/fields/boolfield.cpp | 4 +- effects/fields/colorfield.cpp | 4 +- effects/fields/combofield.cpp | 4 +- effects/fields/doublefield.cpp | 4 +- effects/fields/filefield.cpp | 4 +- effects/fields/fontfield.cpp | 4 +- effects/fields/stringfield.cpp | 4 +- effects/keyframe.cpp | 6 +-- effects/keyframe.h | 9 ++-- nodes/inputs/boolinput.cpp | 2 +- nodes/inputs/boolinput.h | 2 +- nodes/inputs/colorinput.cpp | 2 +- nodes/inputs/colorinput.h | 2 +- nodes/inputs/comboinput.cpp | 2 +- nodes/inputs/comboinput.h | 2 +- nodes/inputs/fileinput.cpp | 2 +- nodes/inputs/fileinput.h | 2 +- nodes/inputs/fontinput.cpp | 2 +- nodes/inputs/fontinput.h | 2 +- nodes/inputs/stringinput.cpp | 2 +- nodes/inputs/stringinput.h | 2 +- nodes/inputs/vecinput.cpp | 10 ++--- nodes/inputs/vecinput.h | 10 ++--- nodes/node.cpp | 25 +++++++++++ nodes/node.h | 11 +++++ nodes/nodedatatypes.cpp | 8 ++-- nodes/nodedatatypes.h | 4 +- nodes/nodegraph.cpp | 11 +++++ nodes/nodegraph.h | 6 +++ nodes/nodeio.cpp | 23 ++++++---- nodes/nodeio.h | 6 +-- nodes/oldeffectnode.cpp | 58 +++++++------------------ nodes/oldeffectnode.h | 15 +++---- nodes/widgets/buttonwidget.cpp | 2 +- nodes/widgets/buttonwidget.h | 2 +- nodes/widgets/labelwidget.cpp | 2 +- nodes/widgets/labelwidget.h | 2 +- panels/effectspanel.cpp | 4 +- panels/grapheditor.cpp | 8 ++-- panels/nodeeditor.cpp | 4 +- timeline/clip.cpp | 6 +-- ui/effectui.cpp | 24 +++++------ ui/graphview.cpp | 77 ++++++++++++++++++---------------- ui/graphview.h | 4 +- ui/keyframedrawing.cpp | 3 ++ ui/keyframeview.cpp | 10 +++-- ui/nodeedgeui.cpp | 4 +- ui/nodeui.cpp | 36 ++++++++-------- ui/nodeui.h | 10 ++--- undo/undo.cpp | 17 ++++++++ undo/undo.h | 11 +++++ 53 files changed, 296 insertions(+), 269 deletions(-) diff --git a/effects/effectfield.cpp b/effects/effectfield.cpp index 53b00fcdf..0f225594e 100644 --- a/effects/effectfield.cpp +++ b/effects/effectfield.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "rendering/renderfunctions.h" #include "global/config.h" @@ -46,7 +47,7 @@ EffectField::EffectField(NodeIO* parent, EffectFieldType t) : SetValueAt(0, 0); // Connect this field to the effect's changed function - connect(this, SIGNAL(Changed()), parent->GetParentEffect(), SLOT(FieldChanged())); + connect(this, SIGNAL(Changed()), parent->ParentNode(), SLOT(FieldChanged())); } NodeIO *EffectField::GetParentRow() @@ -99,40 +100,40 @@ QVariant EffectField::GetValueAt(double timecode) if (before_key.type == EFFECT_KEYFRAME_BEZIER && after_key.type == EFFECT_KEYFRAME_BEZIER) { // cubic bezier - double t = cubic_t_from_x(SecondsToFrame(timecode), + double t = cubic_t_from_x(timecode, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time); value = cubic_from_t(before_dbl, - before_dbl+before_key.post_handle_y, - after_dbl+after_key.pre_handle_y, + before_dbl+before_key.post_handle.y(), + after_dbl+after_key.pre_handle.y(), after_dbl, t); } else if (after_key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier // last keyframe is the bezier one - double t = quad_t_from_x(SecondsToFrame(timecode), + double t = quad_t_from_x(timecode, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time); value = quad_from_t(before_dbl, - before_dbl+before_key.post_handle_y, + before_dbl+before_key.post_handle.y(), after_dbl, t); } else { // this keyframe is the bezier one - double t = quad_t_from_x(SecondsToFrame(timecode), + double t = quad_t_from_x(timecode, before_key.time, after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time); value = quad_from_t(before_dbl, - after_dbl+after_key.pre_handle_y, + after_dbl+after_key.pre_handle.y(), after_dbl, t); } @@ -182,13 +183,10 @@ void EffectField::SetValueAt(double time, const QVariant &value) // Create keyframe here - // Convert seconds timecode to frame - long frame_timecode = SecondsToFrame(time); - // Check array if a keyframe at this time already exists int keyframe_index = -1; for (int i=0;iGetParentEffect()->NowInFrames(); + key.time = GetParentRow()->ParentNode()->ParentGraph()->Time(); key.data = persistent_data_; key.type = EFFECT_KEYFRAME_LINEAR; @@ -235,7 +233,7 @@ void EffectField::PrepareDataForKeyframing(bool enabled, ComboAction *ca) // Convert keyframes to one "perpetual" keyframe // Set first keyframe to whatever the data is now - ca->append(new SetQVariant(&persistent_data_, persistent_data_, GetValueAt(GetParentRow()->GetParentEffect()->Now()))); + ca->append(new SetQVariant(&persistent_data_, persistent_data_, GetValueAt(GetParentRow()->ParentNode()->ParentGraph()->Time()))); // Delete all keyframes for (int i=0;i relative_comp_handle) - || (!post && keyframes.at(key).pre_handle_x < relative_comp_handle)) { + if ((post && keyframes.at(key).post_handle.x() > relative_comp_handle) + || (!post && keyframes.at(key).pre_handle.x() < relative_comp_handle)) { adjusted_key = (adjusted_key + relative_comp_handle)*0.5; } } @@ -296,31 +294,22 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) { return adjusted_key; } -double EffectField::FrameToSeconds(long frame) { - return (double(frame) / GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate()); -} - -long EffectField::SecondsToFrame(double seconds) { - return qRound(seconds * GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate()); -} - void EffectField::GetKeyframeData(double timecode, int &before, int &after, double &progress) { int before_keyframe_index = -1; int after_keyframe_index = -1; - long before_keyframe_time = LONG_MIN; - long after_keyframe_time = LONG_MAX; - long frame = SecondsToFrame(timecode); + double before_keyframe_time = DBL_MIN; + double after_keyframe_time = DBL_MAX; for (int i=0;i before_keyframe_time) { + } else if (eval_keyframe_time < timecode && eval_keyframe_time > before_keyframe_time) { before_keyframe_index = i; before_keyframe_time = eval_keyframe_time; - } else if (eval_keyframe_time > frame && eval_keyframe_time < after_keyframe_time) { + } else if (eval_keyframe_time > timecode && eval_keyframe_time < after_keyframe_time) { after_keyframe_index = i; after_keyframe_time = eval_keyframe_time; } @@ -331,7 +320,7 @@ void EffectField::GetKeyframeData(double timecode, int &before, int &after, doub // interpolate before = before_keyframe_index; after = after_keyframe_index; - progress = (timecode-FrameToSeconds(before_keyframe_time))/(FrameToSeconds(after_keyframe_time)-FrameToSeconds(before_keyframe_time)); + progress = (timecode-before_keyframe_time)/(after_keyframe_time-before_keyframe_time); } else if (before_keyframe_index > -1) { before = before_keyframe_index; after = before_keyframe_index; diff --git a/effects/effectfield.h b/effects/effectfield.h index 39d3182d2..d2264ab74 100644 --- a/effects/effectfield.h +++ b/effects/effectfield.h @@ -389,32 +389,6 @@ private: */ bool HasKeyframes(); - /** - * @brief Convert clip time in frames to clip time in seconds - * - * @param frame - * - * Clip time in frames - * - * @return - * - * Clip time in seconds - */ - double FrameToSeconds(long frame); - - /** - * @brief Convert clip time in seconds to clip time in frames - * - * @param seconds - * - * Clip time in seconds - * - * @return - * - * Clip time in frames - */ - long SecondsToFrame(double seconds); - /** * @brief Internal function for determining where we are between the available keyframes * diff --git a/effects/fields/boolfield.cpp b/effects/fields/boolfield.cpp index acca67548..494c3f85c 100644 --- a/effects/fields/boolfield.cpp +++ b/effects/fields/boolfield.cpp @@ -22,7 +22,7 @@ #include -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "undo/undo.h" BoolField::BoolField(NodeIO *parent) : @@ -92,7 +92,7 @@ void BoolField::UpdateFromWidget(bool b) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), b); + SetValueAt(GetParentRow()->ParentNode()->Time(), b); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/fields/colorfield.cpp b/effects/fields/colorfield.cpp index ad3d96c04..de04abb71 100644 --- a/effects/fields/colorfield.cpp +++ b/effects/fields/colorfield.cpp @@ -23,7 +23,7 @@ #include #include "ui/colorbutton.h" -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "undo/undo.h" ColorField::ColorField(NodeIO* parent) : @@ -66,7 +66,7 @@ void ColorField::UpdateFromWidget(const QColor& c) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), c); + SetValueAt(GetParentRow()->ParentNode()->Time(), c); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/fields/combofield.cpp b/effects/fields/combofield.cpp index 84f5c574a..0137048de 100644 --- a/effects/fields/combofield.cpp +++ b/effects/fields/combofield.cpp @@ -22,7 +22,7 @@ #include -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "ui/comboboxex.h" #include "undo/undo.h" @@ -86,7 +86,7 @@ void ComboField::UpdateFromWidget(int index) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), items_.at(index).data); + SetValueAt(GetParentRow()->ParentNode()->Time(), items_.at(index).data); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/fields/doublefield.cpp b/effects/fields/doublefield.cpp index 9e4563a3c..b60ee6341 100644 --- a/effects/fields/doublefield.cpp +++ b/effects/fields/doublefield.cpp @@ -20,7 +20,7 @@ #include "doublefield.h" -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "undo/undo.h" DoubleField::DoubleField(NodeIO* parent) : @@ -139,7 +139,7 @@ void DoubleField::UpdateFromWidget(double d) kdc_ = new KeyframeDataChange(this); } - SetValueAt(GetParentRow()->GetParentEffect()->Now(), d); + SetValueAt(GetParentRow()->ParentNode()->Time(), d); if (!ls->IsDragging() && kdc_ != nullptr) { kdc_->SetNewKeyframes(); diff --git a/effects/fields/filefield.cpp b/effects/fields/filefield.cpp index 30414484b..d5dec92d2 100644 --- a/effects/fields/filefield.cpp +++ b/effects/fields/filefield.cpp @@ -23,7 +23,7 @@ #include #include "ui/embeddedfilechooser.h" -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "undo/undo.h" FileField::FileField(NodeIO* parent) : @@ -61,7 +61,7 @@ void FileField::UpdateFromWidget(const QString &s) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), s); + SetValueAt(GetParentRow()->ParentNode()->Time(), s); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/fields/fontfield.cpp b/effects/fields/fontfield.cpp index a6040d149..3e8a26410 100644 --- a/effects/fields/fontfield.cpp +++ b/effects/fields/fontfield.cpp @@ -24,7 +24,7 @@ #include #include "ui/comboboxex.h" -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "undo/undo.h" // NOTE/TODO: This shares a lot of similarity with ComboInput, and could probably be a derived class of it @@ -88,7 +88,7 @@ void FontField::UpdateFromWidget(const QString& s) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), s); + SetValueAt(GetParentRow()->ParentNode()->Time(), s); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/fields/stringfield.cpp b/effects/fields/stringfield.cpp index 11c379fbd..d6cdb09b7 100644 --- a/effects/fields/stringfield.cpp +++ b/effects/fields/stringfield.cpp @@ -23,7 +23,7 @@ #include #include -#include "nodes/oldeffectnode.h" +#include "nodes/node.h" #include "ui/texteditex.h" #include "global/config.h" #include "undo/undo.h" @@ -94,7 +94,7 @@ void StringField::UpdateFromWidget(const QString &s) { KeyframeDataChange* kdc = new KeyframeDataChange(this); - SetValueAt(GetParentRow()->GetParentEffect()->Now(), s); + SetValueAt(GetParentRow()->ParentNode()->Time(), s); kdc->SetNewKeyframes(); olive::undo_stack.push(kdc); diff --git a/effects/keyframe.cpp b/effects/keyframe.cpp index 870de3123..4939fcd87 100644 --- a/effects/keyframe.cpp +++ b/effects/keyframe.cpp @@ -29,10 +29,8 @@ EffectKeyframe::EffectKeyframe() { - pre_handle_x = -40; - pre_handle_y = 0; - post_handle_x = 40; - post_handle_y = 0; + pre_handle = QPointF(-40, 0); + post_handle = QPointF(40, 0); } void delete_keyframes(QVector& selected_key_fields, QVector &selected_keys) { diff --git a/effects/keyframe.h b/effects/keyframe.h index 4a076bc34..5db0a026c 100644 --- a/effects/keyframe.h +++ b/effects/keyframe.h @@ -22,6 +22,7 @@ #define KEYFRAME_H #include +#include class EffectField; @@ -30,14 +31,12 @@ public: EffectKeyframe(); int type; - long time; + double time; QVariant data; // only for bezier type - double pre_handle_x; - double pre_handle_y; - double post_handle_x; - double post_handle_y; + QPointF pre_handle; + QPointF post_handle; }; void delete_keyframes(QVector &selected_key_fields, QVector &selected_keys); diff --git a/nodes/inputs/boolinput.cpp b/nodes/inputs/boolinput.cpp index a9b1d38a2..e7be2f5a0 100644 --- a/nodes/inputs/boolinput.cpp +++ b/nodes/inputs/boolinput.cpp @@ -1,6 +1,6 @@ #include "boolinput.h" -BoolInput::BoolInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable, bool keyframable) : +BoolInput::BoolInput(Node *parent, const QString& id, const QString& name, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { BoolField* bool_field = new BoolField(this); diff --git a/nodes/inputs/boolinput.h b/nodes/inputs/boolinput.h index 1291f3e24..b49d9e36f 100644 --- a/nodes/inputs/boolinput.h +++ b/nodes/inputs/boolinput.h @@ -7,7 +7,7 @@ class BoolInput : public NodeIO { Q_OBJECT public: - BoolInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + BoolInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); /** * @brief Get the boolean value at a given timecode diff --git a/nodes/inputs/colorinput.cpp b/nodes/inputs/colorinput.cpp index fcfb5d62f..f7a57670d 100644 --- a/nodes/inputs/colorinput.cpp +++ b/nodes/inputs/colorinput.cpp @@ -1,6 +1,6 @@ #include "colorinput.h" -ColorInput::ColorInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable, bool keyframable) : +ColorInput::ColorInput(Node *parent, const QString& id, const QString& name, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { AddField(new ColorField(this)); diff --git a/nodes/inputs/colorinput.h b/nodes/inputs/colorinput.h index 69a87fd28..2475ed7fe 100644 --- a/nodes/inputs/colorinput.h +++ b/nodes/inputs/colorinput.h @@ -7,7 +7,7 @@ class ColorInput : public NodeIO { Q_OBJECT public: - ColorInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + ColorInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); /** * @brief Get the color value at a given timecode diff --git a/nodes/inputs/comboinput.cpp b/nodes/inputs/comboinput.cpp index c178ce5c4..3bc7798fb 100644 --- a/nodes/inputs/comboinput.cpp +++ b/nodes/inputs/comboinput.cpp @@ -1,6 +1,6 @@ #include "comboinput.h" -ComboInput::ComboInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable, bool keyframable) : +ComboInput::ComboInput(Node *parent, const QString& id, const QString& name, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { ComboField* combo_field = new ComboField(this); diff --git a/nodes/inputs/comboinput.h b/nodes/inputs/comboinput.h index a0d6ddfb0..c4417d49d 100644 --- a/nodes/inputs/comboinput.h +++ b/nodes/inputs/comboinput.h @@ -7,7 +7,7 @@ class ComboInput : public NodeIO { Q_OBJECT public: - ComboInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + ComboInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); /** * @brief Add an item to this ComboInput diff --git a/nodes/inputs/fileinput.cpp b/nodes/inputs/fileinput.cpp index 04c0633d4..1974289ae 100644 --- a/nodes/inputs/fileinput.cpp +++ b/nodes/inputs/fileinput.cpp @@ -1,6 +1,6 @@ #include "fileinput.h" -FileInput::FileInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable, bool keyframable) : +FileInput::FileInput(Node *parent, const QString& id, const QString& name, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { AddField(new FileField(this)); diff --git a/nodes/inputs/fileinput.h b/nodes/inputs/fileinput.h index dc089affb..e7182b84d 100644 --- a/nodes/inputs/fileinput.h +++ b/nodes/inputs/fileinput.h @@ -7,7 +7,7 @@ class FileInput : public NodeIO { Q_OBJECT public: - FileInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + FileInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); /** * @brief Get the filename at the given timecode diff --git a/nodes/inputs/fontinput.cpp b/nodes/inputs/fontinput.cpp index daadb0d1f..fe1bd7b3c 100644 --- a/nodes/inputs/fontinput.cpp +++ b/nodes/inputs/fontinput.cpp @@ -1,6 +1,6 @@ #include "fontinput.h" -FontInput::FontInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable, bool keyframable) : +FontInput::FontInput(Node *parent, const QString& id, const QString& name, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { AddField(new FontField(this)); diff --git a/nodes/inputs/fontinput.h b/nodes/inputs/fontinput.h index f2a67468f..d238eefef 100644 --- a/nodes/inputs/fontinput.h +++ b/nodes/inputs/fontinput.h @@ -7,7 +7,7 @@ class FontInput : public NodeIO { Q_OBJECT public: - FontInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + FontInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); /** * @brief Get the font family name at the given timecode diff --git a/nodes/inputs/stringinput.cpp b/nodes/inputs/stringinput.cpp index 1e78d5190..1989276b8 100644 --- a/nodes/inputs/stringinput.cpp +++ b/nodes/inputs/stringinput.cpp @@ -1,6 +1,6 @@ #include "stringinput.h" -StringInput::StringInput(OldEffectNode* parent, const QString& id, const QString& name, bool rich_text, bool savable, bool keyframable) : +StringInput::StringInput(Node *parent, const QString& id, const QString& name, bool rich_text, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable) { AddField(new StringField(this, rich_text)); diff --git a/nodes/inputs/stringinput.h b/nodes/inputs/stringinput.h index ad6b01d8e..0f7d4c854 100644 --- a/nodes/inputs/stringinput.h +++ b/nodes/inputs/stringinput.h @@ -7,7 +7,7 @@ class StringInput : public NodeIO { Q_OBJECT public: - StringInput(OldEffectNode* parent, + StringInput(Node* parent, const QString& id, const QString& name, bool rich_text = true, diff --git a/nodes/inputs/vecinput.cpp b/nodes/inputs/vecinput.cpp index 050e208ce..f9415fe87 100644 --- a/nodes/inputs/vecinput.cpp +++ b/nodes/inputs/vecinput.cpp @@ -4,7 +4,7 @@ #include #include -VecInput::VecInput(OldEffectNode* parent, const QString& id, const QString& name, int values, bool savable, bool keyframable) : +VecInput::VecInput(Node *parent, const QString& id, const QString& name, int values, bool savable, bool keyframable) : NodeIO(parent, id, name, savable, keyframable), single_value_mode_(false), values_(values) @@ -79,7 +79,7 @@ void VecInput::SetSingleValueMode(bool on) } } -DoubleInput::DoubleInput(OldEffectNode *parent, const QString &id, const QString &name, bool savable, bool keyframable) : +DoubleInput::DoubleInput(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) : VecInput(parent, id, name, 1, savable, keyframable) { } @@ -89,7 +89,7 @@ double DoubleInput::GetDoubleAt(double timecode) return static_cast(Field(0))->GetDoubleAt(timecode); } -Vec2Input::Vec2Input(OldEffectNode *parent, const QString &id, const QString &name, bool savable, bool keyframable) : +Vec2Input::Vec2Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) : VecInput(parent, id, name, 2, savable, keyframable) { } @@ -121,7 +121,7 @@ void Vec2Input::SetValueAt(double timecode, const QVariant &value) static_cast(Field(1))->SetValueAt(timecode, vec2.y()); } -Vec3Input::Vec3Input(OldEffectNode *parent, const QString &id, const QString &name, bool savable, bool keyframable) : +Vec3Input::Vec3Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) : VecInput(parent, id, name, 3, savable, keyframable) { } @@ -156,7 +156,7 @@ void Vec3Input::SetValueAt(double timecode, const QVariant &value) static_cast(Field(2))->SetValueAt(timecode, vec3.z()); } -Vec4Input::Vec4Input(OldEffectNode *parent, const QString &id, const QString &name, bool savable, bool keyframable) : +Vec4Input::Vec4Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) : VecInput(parent, id, name, 4, savable, keyframable) { } diff --git a/nodes/inputs/vecinput.h b/nodes/inputs/vecinput.h index d1149d235..598e0872e 100644 --- a/nodes/inputs/vecinput.h +++ b/nodes/inputs/vecinput.h @@ -9,7 +9,7 @@ class VecInput : public NodeIO { Q_OBJECT public: - VecInput(OldEffectNode* parent, const QString& id, const QString& name, int values, bool savable = true, bool keyframable = true); + VecInput(Node* parent, const QString& id, const QString& name, int values, bool savable = true, bool keyframable = true); void SetMinimum(double minimum); void SetMaximum(double maximum); @@ -43,14 +43,14 @@ private: class DoubleInput : public VecInput { public: - DoubleInput(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + DoubleInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); double GetDoubleAt(double timecode); }; class Vec2Input : public VecInput { public: - Vec2Input(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + Vec2Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); QVector2D GetVector2DAt(double timecode); virtual QVariant GetValueAt(double timecode) override; @@ -59,7 +59,7 @@ public: class Vec3Input : public VecInput { public: - Vec3Input(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + Vec3Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); QVector3D GetVector3DAt(double timecode); virtual QVariant GetValueAt(double timecode) override; @@ -68,7 +68,7 @@ public: class Vec4Input : public VecInput { public: - Vec4Input(OldEffectNode* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); + Vec4Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true); QVector4D GetVector4DAt(double timecode); virtual QVariant GetValueAt(double timecode) override; diff --git a/nodes/node.cpp b/nodes/node.cpp index ec451692a..591eee1e3 100644 --- a/nodes/node.cpp +++ b/nodes/node.cpp @@ -7,6 +7,11 @@ Node::Node(NodeGraph *graph) : { } +QString Node::name() +{ + return tr("Node"); +} + void Node::AddParameter(NodeIO *param) { param->setParent(this); @@ -27,3 +32,23 @@ int Node::ParameterCount() { return parameters_.size(); } + +NodeGraph *Node::ParentGraph() +{ + return static_cast(parent()); +} + +double Node::Time() +{ + return ParentGraph()->Time(); +} + +const QPointF &Node::pos() +{ + return pos_; +} + +void Node::SetPos(const QPointF &pos) +{ + pos_ = pos; +} diff --git a/nodes/node.h b/nodes/node.h index fecb6a56f..94799c2f9 100644 --- a/nodes/node.h +++ b/nodes/node.h @@ -13,13 +13,24 @@ class Node : public QObject public: Node(NodeGraph* parent); + virtual QString name(); + void AddParameter(NodeIO* row); int IndexOfParameter(NodeIO* row); NodeIO* Parameter(int i); int ParameterCount(); + NodeGraph* ParentGraph(); + double Time(); + + const QPointF& pos(); + +public slots: + void SetPos(const QPointF& pos); + private: QVector parameters_; + QPointF pos_; }; #endif // NODE_H diff --git a/nodes/nodedatatypes.cpp b/nodes/nodedatatypes.cpp index 53636cc7d..5b35d0edf 100644 --- a/nodes/nodedatatypes.cpp +++ b/nodes/nodedatatypes.cpp @@ -30,8 +30,8 @@ QString olive::nodes::DataTypeToString(DataType type) { return "TEXTURE"; case kMatrix: return "MATRIX"; - case kUI: - return "UI"; + case kClip: + return "CLIP"; default: return QString(); } @@ -67,8 +67,8 @@ olive::nodes::DataType olive::nodes::StringToDataType(const QString &s) return kTexture; } else if (s == "MATRIX") { return kMatrix; - } else if (s == "UI") { - return kUI; + } else if (s == "CLIP") { + return kClip; } return kInvalid; } diff --git a/nodes/nodedatatypes.h b/nodes/nodedatatypes.h index 3250457e4..481c6234e 100644 --- a/nodes/nodedatatypes.h +++ b/nodes/nodedatatypes.h @@ -60,8 +60,8 @@ enum DataType { /** Value is a 4x4 matrix. This cannot be an input field, and can only be passed between nodes. */ kMatrix, - /** Values is a UI object with no data. Corresponds to nothing. */ - kUI, + /** Value is a Clip node */ + kClip, /** Total count of valid node data types. Never use this as an actual data type. */ kDataTypeCount diff --git a/nodes/nodegraph.cpp b/nodes/nodegraph.cpp index 5782f20e4..8da807dea 100644 --- a/nodes/nodegraph.cpp +++ b/nodes/nodegraph.cpp @@ -24,3 +24,14 @@ Node *NodeGraph::OutputNode() { return output_node_; } + +double NodeGraph::Time() +{ + return time_; +} + +void NodeGraph::SetTime(double d) +{ + time_ = d; + emit TimeChanged(); +} diff --git a/nodes/nodegraph.h b/nodes/nodegraph.h index 9d1915994..707bba172 100644 --- a/nodes/nodegraph.h +++ b/nodes/nodegraph.h @@ -41,14 +41,20 @@ public: */ Node* OutputNode(); + double Time(); + void SetTime(double d); + signals: void NodeGraphChanged(); + void TimeChanged(); protected: virtual void childEvent(QChildEvent *event) override; private: Node* output_node_; + + double time_; }; #endif // NODEGRAPH_H diff --git a/nodes/nodeio.cpp b/nodes/nodeio.cpp index e215777f8..31a2ec8c5 100644 --- a/nodes/nodeio.cpp +++ b/nodes/nodeio.cpp @@ -37,7 +37,7 @@ #include "ui/keyframenavigator.h" #include "ui/clickablelabel.h" -NodeIO::NodeIO(OldEffectNode *parent, +NodeIO::NodeIO(Node *parent, const QString &id, const QString &name, bool savable, @@ -52,7 +52,7 @@ NodeIO::NodeIO(OldEffectNode *parent, { Q_ASSERT(parent != nullptr); - parent->AddRow(this); + parent->AddParameter(this); } void NodeIO::AddField(EffectField *field) @@ -118,10 +118,12 @@ bool NodeIO::IsKeyframing() { } void NodeIO::SetKeyframingInternal(bool b) { + /* FIXME if (GetParentEffect()->type() != EFFECT_TYPE_TRANSITION) { keyframing_ = b; emit KeyframingSetChanged(keyframing_); } + */ } bool NodeIO::IsSavable() @@ -239,6 +241,7 @@ void NodeIO::SetKeyframingEnabled(bool enabled) { } void NodeIO::GoToPreviousKeyframe() { + /* FIXME long key = LONG_MIN; Clip* c = GetParentEffect()->parent_clip; long sequence_playhead = c->track()->sequence()->playhead; @@ -264,9 +267,11 @@ void NodeIO::GoToPreviousKeyframe() { // If we found a keyframe less than the playhead, jump to it if (key != LONG_MIN) panel_sequence_viewer->seek(key); + */ } void NodeIO::ToggleKeyframe() { + /* FIXME Clip* c = GetParentEffect()->parent_clip; long sequence_playhead = c->track()->sequence()->playhead; @@ -334,9 +339,11 @@ void NodeIO::ToggleKeyframe() { olive::undo_stack.push(ca); update_ui(false); + */ } void NodeIO::GoToNextKeyframe() { + /* FIXME long key = LONG_MAX; Clip* c = GetParentEffect()->parent_clip; for (int i=0;iseek(key); + */ } void NodeIO::FocusRow() { panel_graph_editor->set_row(this); } +Node* NodeIO::ParentNode() { + return static_cast(parent()); +} + void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) { for (int i=0;iSetValueAt(GetParentEffect()->Now(), field->GetValueAt(GetParentEffect()->Now())); + field->SetValueAt(ParentNode()->Time(), field->GetValueAt(ParentNode()->Time())); kdc->SetNewKeyframes(); ca->append(kdc); @@ -370,11 +382,6 @@ void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) { panel_effect_controls->update_keyframes(); } -OldEffectNode *NodeIO::GetParentEffect() -{ - return static_cast(parent()); -} - const QString &NodeIO::name() { return name_; } diff --git a/nodes/nodeio.h b/nodes/nodeio.h index 9c79c3957..9cfbf1390 100644 --- a/nodes/nodeio.h +++ b/nodes/nodeio.h @@ -24,7 +24,7 @@ #include #include -class OldEffectNode; +class Node; class QGridLayout; class EffectField; class QLabel; @@ -84,7 +84,7 @@ public: * Whether keyframing can be enabled on this row or not. This is true by default. Some values you may want to prevent * the user from keyframing (e.g. the filename of a VST plugin), which can be done by setting this to false. */ - NodeIO(OldEffectNode* parent, + NodeIO(Node* parent, const QString& id, const QString& name, bool savable = true, @@ -127,7 +127,7 @@ public: * * @return The parent Effect object that this row is attached to. */ - OldEffectNode* GetParentEffect(); + Node* ParentNode(); /** * @brief Return the row's name diff --git a/nodes/oldeffectnode.cpp b/nodes/oldeffectnode.cpp index e8995243b..067622861 100644 --- a/nodes/oldeffectnode.cpp +++ b/nodes/oldeffectnode.cpp @@ -60,7 +60,8 @@ QVector olive::node_library; -OldEffectNode::OldEffectNode(Clip* c) : +OldEffectNode::OldEffectNode(Clip *c) : + Node(nullptr), parent_clip(c), flags_(0), shader_program_(nullptr), @@ -83,8 +84,8 @@ OldEffectNode::~OldEffectNode() { // Clear graph editor if it's using one of these rows if (panel_graph_editor != nullptr) { - for (int i=0;iget_row()) { + for (int i=0;iget_row()) { panel_graph_editor->set_row(nullptr); break; } @@ -107,21 +108,10 @@ bool OldEffectNode::IsCreatable() return true; } -void OldEffectNode::AddRow(NodeIO *row) -{ - row->setParent(this); - rows.append(row); -} - -int OldEffectNode::IndexOfRow(NodeIO *row) -{ - return rows.indexOf(row); -} - void OldEffectNode::copy_field_keyframes(OldEffectNodePtr e) { - for (int i=0;irows.at(i); + for (int i=0;iParameter(i); copy_row->SetKeyframingInternal(row->IsKeyframing()); for (int j=0;jFieldCount();j++) { // Get field from this (the source) effect @@ -139,14 +129,6 @@ void OldEffectNode::copy_field_keyframes(OldEffectNodePtr e) { } } -NodeIO* OldEffectNode::row(int i) { - return rows.at(i); -} - -int OldEffectNode::row_count() { - return rows.size(); -} - EffectGizmo *OldEffectNode::add_gizmo(int type) { EffectGizmo* gizmo = new EffectGizmo(this, type); gizmos.append(gizmo); @@ -165,8 +147,8 @@ QVector OldEffectNode::GetAllEdges() { QVector edges; - for (int i=0;iedges()); + for (int i=0;iedges()); } return edges; @@ -291,11 +273,6 @@ void OldEffectNode::SetExpanded(bool e) expanded_ = e; } -void OldEffectNode::SetPos(const QPointF &pos) -{ - pos_ = pos; -} - void OldEffectNode::SetEnabled(bool b) { enabled_ = b; emit EnabledChanged(b); @@ -434,8 +411,8 @@ void OldEffectNode::save(QXmlStreamWriter& stream) { void OldEffectNode::load_from_string(const QByteArray &s) { // clear existing keyframe data - for (int i=0;iSetKeyframingInternal(false); for (int j=0;jFieldCount();j++) { EffectField* field = row->Field(j); @@ -601,11 +578,6 @@ void OldEffectNode::setIterations(int i) { iterations = i; } -const QPointF &OldEffectNode::pos() -{ - return pos_; -} - void OldEffectNode::process_image(double, uint8_t *, uint8_t *, int){} OldEffectNodePtr OldEffectNode::copy(Clip *c) { @@ -881,8 +853,8 @@ void OldEffectNode::redraw(double) { bool OldEffectNode::valueHasChanged(double timecode) { if (cachedValues.isEmpty()) { - for (int i=0;iFieldCount();j++) { cachedValues.append(crow->Field(j)->GetValueAt(timecode)); } @@ -893,8 +865,8 @@ bool OldEffectNode::valueHasChanged(double timecode) { bool changed = false; int index = 0; - for (int i=0;iFieldCount();j++) { EffectField* field = crow->Field(j); if (cachedValues.at(index) != field->GetValueAt(timecode)) { diff --git a/nodes/oldeffectnode.h b/nodes/oldeffectnode.h index e4d4760ad..7b9a20105 100644 --- a/nodes/oldeffectnode.h +++ b/nodes/oldeffectnode.h @@ -44,6 +44,7 @@ #include "rendering/qopenglshaderprogramptr.h" #include "inputs.h" #include "effects/effectgizmo.h" +#include "node.h" class EffectGizmo; class KeyframeDataChange; @@ -109,7 +110,7 @@ struct GLTextureCoords { float opacity; }; -class OldEffectNode : public QObject { +class OldEffectNode : public Node { Q_OBJECT public: OldEffectNode(Clip *c); @@ -126,11 +127,6 @@ public: virtual bool IsCreatable(); virtual OldEffectNodePtr Create(Clip *c) = 0; - void AddRow(NodeIO* row); - int IndexOfRow(NodeIO* row); - NodeIO* row(int i); - int row_count(); - EffectGizmo* add_gizmo(int type); EffectGizmo* gizmo(int i); int gizmo_count(); @@ -170,7 +166,7 @@ public: int getIterations(); void setIterations(int i); - const QPointF& pos(); + virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); virtual void process_shader(double timecode, GLTextureCoords&, int iteration); @@ -229,7 +225,7 @@ public slots: void FieldChanged(); void SetEnabled(bool b); void SetExpanded(bool e); - void SetPos(const QPointF& pos); + signals: void EnabledChanged(bool); private slots: @@ -257,7 +253,6 @@ protected: private: bool isOpen; - QVector rows; QVector gizmos; bool bound; int iterations; @@ -269,7 +264,7 @@ private: QVector gizmo_dragging_actions_; - QPointF pos_; + // superimpose functions virtual void redraw(double timecode); diff --git a/nodes/widgets/buttonwidget.cpp b/nodes/widgets/buttonwidget.cpp index 184b21ff1..df4cf7711 100644 --- a/nodes/widgets/buttonwidget.cpp +++ b/nodes/widgets/buttonwidget.cpp @@ -1,6 +1,6 @@ #include "buttonwidget.h" -ButtonWidget::ButtonWidget(OldEffectNode* parent, const QString& name, const QString& text) : +ButtonWidget::ButtonWidget(Node* parent, const QString& name, const QString& text) : NodeIO(parent, nullptr, name, false, false) { ButtonField* button_field = new ButtonField(this, text); diff --git a/nodes/widgets/buttonwidget.h b/nodes/widgets/buttonwidget.h index 2a1e9b707..59474548c 100644 --- a/nodes/widgets/buttonwidget.h +++ b/nodes/widgets/buttonwidget.h @@ -6,7 +6,7 @@ class ButtonWidget : public NodeIO { public: - ButtonWidget(OldEffectNode* parent, const QString& name, const QString& text); + ButtonWidget(Node* parent, const QString& name, const QString& text); /** * @brief Wrapper for ButtonField::SetCheckable. diff --git a/nodes/widgets/labelwidget.cpp b/nodes/widgets/labelwidget.cpp index a5c0acb3b..ac0da1625 100644 --- a/nodes/widgets/labelwidget.cpp +++ b/nodes/widgets/labelwidget.cpp @@ -1,6 +1,6 @@ #include "labelwidget.h" -LabelWidget::LabelWidget(OldEffectNode *parent, const QString &name, const QString &text) : +LabelWidget::LabelWidget(Node *parent, const QString &name, const QString &text) : NodeIO(parent, nullptr, name, false, false) { AddField(new LabelField(this, text)); diff --git a/nodes/widgets/labelwidget.h b/nodes/widgets/labelwidget.h index b3d59776e..36983ef82 100644 --- a/nodes/widgets/labelwidget.h +++ b/nodes/widgets/labelwidget.h @@ -6,7 +6,7 @@ class LabelWidget : public NodeIO { public: - LabelWidget(OldEffectNode* parent, const QString& name, const QString& text); + LabelWidget(Node* parent, const QString& name, const QString& text); }; #endif // LABELWIDGET_H diff --git a/panels/effectspanel.cpp b/panels/effectspanel.cpp index a400b6ba5..3eb81c55b 100644 --- a/panels/effectspanel.cpp +++ b/panels/effectspanel.cpp @@ -120,8 +120,8 @@ void EffectsPanel::Load() { // 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;krow_count();k++) { - NodeIO* row = effects_to_open.at(j)->row(k); + for (int k=0;kParameterCount();k++) { + NodeIO* row = effects_to_open.at(j)->Parameter(k); if (row == panel_graph_editor->get_row()) { graph_editor_row_is_still_active = true; break; diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index f53e0984d..fb5d3d33c 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -150,7 +150,7 @@ void GraphEditor::update_panel() { for (int i=0;iFieldCount();i++) { EffectField* field = row->Field(i); if (field->type() == EffectField::EFFECT_FIELD_DOUBLE) { - field->UpdateWidgetValue(field_sliders_.at(slider_index), row->GetParentEffect()->Now()); + field->UpdateWidgetValue(field_sliders_.at(slider_index), row->ParentNode()->Time()); slider_index++; } } @@ -209,10 +209,12 @@ void GraphEditor::set_row(NodeIO *r) { if (found_vals) { row = r; - current_row_desc->setText(row->GetParentEffect()->parent_clip->name() + /* FIXME + current_row_desc->setText(row->ParentNode()->parent_clip->name() + " :: " + row->GetParentEffect()->name() + " :: " + row->name()); - header->set_visible_in(r->GetParentEffect()->parent_clip->timeline_in()); + header->set_visible_in(r->ParentNode()->parent_clip->timeline_in()); + */ connect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(GoToPreviousKeyframe())); connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(ToggleKeyframe())); diff --git a/panels/nodeeditor.cpp b/panels/nodeeditor.cpp index 4d7c0df29..1727e3b9e 100644 --- a/panels/nodeeditor.cpp +++ b/panels/nodeeditor.cpp @@ -125,8 +125,8 @@ void NodeEditor::LoadEdges() if (n->parent_clip == first_clip) { // Connect all rows to this - for (int j=0;jrow_count();j++) { - ConnectRow(n->row(j)); + for (int j=0;jParameterCount();j++) { + ConnectRow(n->Parameter(j)); } // Get node edges diff --git a/timeline/clip.cpp b/timeline/clip.cpp index 904f16efd..e4562fdc4 100644 --- a/timeline/clip.cpp +++ b/timeline/clip.cpp @@ -518,12 +518,12 @@ void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_t // move keyframes for (int i=0;irow_count();j++) { - NodeIO* r = e->row(j); + for (int j=0;jParameterCount();j++) { + NodeIO* r = e->Parameter(j); for (int l=0;lFieldCount();l++) { EffectField* f = r->Field(l); for (int k=0;kkeyframes.size();k++) { - ca->append(new SetLong(&f->keyframes[k].time, f->keyframes[k].time, qRound(f->keyframes[k].time * multiplier))); + ca->append(new SetDouble(&f->keyframes[k].time, f->keyframes[k].time, qRound(f->keyframes[k].time * multiplier))); } } } diff --git a/ui/effectui.cpp b/ui/effectui.cpp index eb0b1182b..29c63a69a 100644 --- a/ui/effectui.cpp +++ b/ui/effectui.cpp @@ -103,11 +103,11 @@ EffectUI::EffectUI(OldEffectNode* e) : this, SLOT(show_context_menu(const QPoint&))); - widgets_.resize(e->row_count()); - keyframe_navigators_.resize(e->row_count()); + widgets_.resize(e->ParameterCount()); + keyframe_navigators_.resize(e->ParameterCount()); - for (int i=0;irow_count();i++) { - NodeIO* row = e->row(i); + for (int i=0;iParameterCount();i++) { + NodeIO* row = e->Parameter(i); ClickableLabel* row_label = new ClickableLabel(row->name()); connect(row_label, SIGNAL(clicked()), row, SLOT(FocusRow())); @@ -181,17 +181,17 @@ void EffectUI::AddAdditionalEffect(OldEffectNode *e) additional_effects_.append(e); // Attach this UI's widgets to the additional effect - for (int i=0;irow_count();i++) { + for (int i=0;iParameterCount();i++) { - NodeIO* row = effect_->row(i); + NodeIO* row = effect_->Parameter(i); // Attach existing keyframe navigator to this effect's row - AttachKeyframeNavigationToRow(e->row(i), keyframe_navigators_.at(i)); + AttachKeyframeNavigationToRow(e->Parameter(i), keyframe_navigators_.at(i)); for (int j=0;jFieldCount();j++) { // Attach existing field widget to this effect's field - e->row(i)->Field(j)->CreateWidget(Widget(i, j)); + e->Parameter(i)->Field(j)->CreateWidget(Widget(i, j)); } @@ -229,9 +229,9 @@ void EffectUI::UpdateFromEffect() { OldEffectNode* effect = GetEffect(); - for (int j=0;jrow_count();j++) { + for (int j=0;jParameterCount();j++) { - NodeIO* row = effect->row(j); + NodeIO* row = effect->Parameter(j); for (int k=0;kFieldCount();k++) { EffectField* field = row->Field(k); @@ -246,8 +246,8 @@ void EffectUI::UpdateFromEffect() bool same_value = true; for (int i=0;i 0 ? additional_effects_.at(i-1)->row(j)->Field(k) : field; - EffectField* additional_field = additional_effects_.at(i)->row(j)->Field(k); + EffectField* previous_field = i > 0 ? additional_effects_.at(i-1)->Parameter(j)->Field(k) : field; + EffectField* additional_field = additional_effects_.at(i)->Parameter(j)->Field(k); if (additional_field->GetValueAt(additional_effects_.at(i)->Now()) != previous_field->GetValueAt(additional_effects_.at(i)->Now())) { diff --git a/ui/graphview.cpp b/ui/graphview.cpp index 68280c3cc..239f1cced 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -114,8 +114,8 @@ void GraphView::reset_view() { void GraphView::set_view_to_selection() { if (row != nullptr && selected_keys.size() > 0) { - long min_time = LONG_MAX; - long max_time = LONG_MIN; + double min_time = DBL_MAX; + double max_time = DBL_MIN; double min_dbl = DBL_MAX; double max_dbl = DBL_MIN; for (int i=0;iGetParentEffect()->parent_clip->clip_in(); max_time -= row->GetParentEffect()->parent_clip->clip_in(); + */ set_view_to_rect(min_time, min_dbl, max_time, max_dbl); } @@ -137,8 +139,8 @@ void GraphView::set_view_to_all() { if (row != nullptr) { bool can_set = false; - long min_time = LONG_MAX; - long max_time = LONG_MIN; + double min_time = DBL_MAX; + double max_time = DBL_MIN; double min_dbl = DBL_MAX; double max_dbl = DBL_MIN; for (int i=0;iFieldCount();i++) { @@ -152,15 +154,17 @@ void GraphView::set_view_to_all() { } } if (can_set) { + /* FIXME min_time -= row->GetParentEffect()->parent_clip->clip_in(); max_time -= row->GetParentEffect()->parent_clip->clip_in(); + */ set_view_to_rect(min_time, min_dbl, max_time, max_dbl); } } } -void GraphView::set_view_to_rect(int x1, double y1, int x2, double y2) { +void GraphView::set_view_to_rect(double x1, double y1, double x2, double y2) { double padding = 1.5; double x_diff = double(x2 - x1); double y_diff = (y2 - y1); @@ -278,20 +282,20 @@ void GraphView::paintEvent(QPaintEvent *) { if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) { // cubic bezier bezier_path.cubicTo( - QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom), - QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom), + QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom), + QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom), QPointF(key_x, key_y) ); } else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier // last keyframe is the bezier one bezier_path.quadTo( - QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom), + QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom), QPointF(key_x, key_y) ); } else { // this keyframe is the bezier one bezier_path.quadTo( - QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom), + QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom), QPointF(key_x, key_y) ); } @@ -317,12 +321,12 @@ void GraphView::paintEvent(QPaintEvent *) { p.setPen(Qt::gray); // pre handle line - QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom); + QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom); p.drawLine(pre_point, QPointF(key_x, key_y)); p.drawEllipse(pre_point, kBezierHandleSize, kBezierHandleSize); // post handle line - QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom); + QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom); p.drawLine(post_point, QPointF(key_x, key_y)); p.drawEllipse(post_point, kBezierHandleSize, kBezierHandleSize); } @@ -400,8 +404,8 @@ void GraphView::mousePressEvent(QMouseEvent *event) { break; } else { // selecting a handle - QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom); - QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom); + QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom); + QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom); if (event->pos().x() > pre_point.x()-kBezierHandleSize && event->pos().x() < pre_point.x()+kBezierHandleSize && event->pos().y() > pre_point.y()-kBezierHandleSize @@ -419,10 +423,10 @@ void GraphView::mousePressEvent(QMouseEvent *event) { sel_key_field = i; handle_index = j; handle_field = i; - old_pre_handle_x = key.pre_handle_x; - old_pre_handle_y = key.pre_handle_y; - old_post_handle_x = key.post_handle_x; - old_post_handle_y = key.post_handle_y; + old_pre_handle_x = key.pre_handle.x(); + old_pre_handle_y = key.pre_handle.y(); + old_post_handle_x = key.post_handle.x(); + old_post_handle_y = key.post_handle.y(); break; } } @@ -551,10 +555,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { } EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index]; - key.pre_handle_x = qMin(0.0, new_pre_handle_x); - key.pre_handle_y = new_pre_handle_y; - key.post_handle_x = qMax(0.0, new_post_handle_x); - key.post_handle_y = new_post_handle_y; + key.pre_handle = QPointF(qMin(0.0, new_pre_handle_x), new_pre_handle_y); + key.post_handle = QPointF(qMax(0.0, new_post_handle_x), new_post_handle_y); moved_keys = true; update_ui(false); @@ -580,14 +582,14 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { KEYFRAME_SIZE+KEYFRAME_SIZE ); QRect pre_rect( - qRound(key_x + key.pre_handle_x*x_zoom - kBezierHandleSize), - qRound(key_y + key.pre_handle_y*y_zoom - kBezierHandleSize), + qRound(key_x + key.pre_handle.x()*x_zoom - kBezierHandleSize), + qRound(key_y + key.pre_handle.y()*y_zoom - kBezierHandleSize), kBezierHandleSize+kBezierHandleSize, kBezierHandleSize+kBezierHandleSize ); QRect post_rect( - qRound(key_x + key.post_handle_x*x_zoom - kBezierHandleSize), - qRound(key_y + key.post_handle_y*y_zoom - kBezierHandleSize), + qRound(key_x + key.post_handle.x()*x_zoom - kBezierHandleSize), + qRound(key_y + key.post_handle.y()*y_zoom - kBezierHandleSize), kBezierHandleSize+kBezierHandleSize, kBezierHandleSize+kBezierHandleSize ); @@ -653,20 +655,20 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) { // cubic bezier bezier_path.cubicTo( - QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom), - QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom), + QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom), + QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom), QPointF(key_x, key_y) ); } else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier // last keyframe is the bezier one bezier_path.quadTo( - QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom), + QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom), QPointF(key_x, key_y) ); } else { // this keyframe is the bezier one bezier_path.quadTo( - QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom), + QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom), QPointF(key_x, key_y) ); } @@ -708,7 +710,7 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) { case kBezierHandleNone: for (int i=0;iField(selected_keys_fields.at(i))->keyframes[selected_keys.at(i)]; - ca->append(new SetLong(&key.time, selected_keys_old_vals.at(i), key.time)); + ca->append(new SetDouble(&key.time, selected_keys_old_vals.at(i), key.time)); ca->append(new SetQVariant(&key.data, selected_keys_old_doubles.at(i), key.data)); } break; @@ -716,10 +718,8 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) { case kBezierHandlePost: { EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index]; - ca->append(new SetDouble(&key.pre_handle_x, old_pre_handle_x, key.pre_handle_x)); - ca->append(new SetDouble(&key.pre_handle_y, old_pre_handle_y, key.pre_handle_y)); - ca->append(new SetDouble(&key.post_handle_x, old_post_handle_x, key.post_handle_x)); - ca->append(new SetDouble(&key.post_handle_y, old_post_handle_y, key.post_handle_y)); + ca->append(new SetPointF(&key.pre_handle, QPointF(old_pre_handle_x, old_pre_handle_y), key.pre_handle)); + ca->append(new SetPointF(&key.post_handle, QPointF(old_post_handle_x, old_post_handle_y), key.post_handle)); } break; } @@ -834,7 +834,8 @@ void GraphView::set_row(NodeIO *r) { for (int i=0;iFieldCount();i++) { field_visibility[i] = row->Field(i)->IsEnabled(); } - visible_in = row->GetParentEffect()->parent_clip->timeline_in(); + // FIXME + //visible_in = row->ParentNode()->parent_clip->timeline_in(); set_view_to_all(); } else { update(); @@ -902,7 +903,8 @@ void GraphView::set_zoom(double xz, double yz) { int GraphView::get_screen_x(double d) { if (row != nullptr) { - d -= row->GetParentEffect()->parent_clip->clip_in(); + // FIXME + //d -= row->GetParentEffect()->parent_clip->clip_in(); } return qRound((d*x_zoom) - x_scroll); } @@ -914,7 +916,8 @@ int GraphView::get_screen_y(double d) { long GraphView::get_value_x(int i) { long frame = qRound((i + x_scroll)/x_zoom); if (row != nullptr) { - frame += row->GetParentEffect()->parent_clip->clip_in(); + // FIXME + //frame += row->GetParentEffect()->parent_clip->clip_in(); } return frame; } diff --git a/ui/graphview.h b/ui/graphview.h index 51f49a059..d88991134 100644 --- a/ui/graphview.h +++ b/ui/graphview.h @@ -77,7 +77,7 @@ private: QVector selected_keys; QVector selected_keys_fields; - QVector selected_keys_old_vals; + QVector selected_keys_old_vals; QVector selected_keys_old_doubles; double old_pre_handle_x; @@ -116,7 +116,7 @@ private slots: void reset_view(); void set_view_to_selection(); void set_view_to_all(); - void set_view_to_rect(int x1, double y1, int x2, double y2); + void set_view_to_rect(double x1, double y1, double x2, double y2); }; #endif // GRAPHVIEW_H diff --git a/ui/keyframedrawing.cpp b/ui/keyframedrawing.cpp index 006751782..9f0d3d069 100644 --- a/ui/keyframedrawing.cpp +++ b/ui/keyframedrawing.cpp @@ -55,7 +55,10 @@ void draw_keyframe(QPainter &p, int type, int x, int y, bool darker, int r, int // adjusts keyframe's internal time (in clip time) to timeline time long adjust_row_keyframe(NodeIO* row, long time, long visible_in) { + return 0; + /* FIXME return time - row->GetParentEffect()->parent_clip->clip_in() + (row->GetParentEffect()->parent_clip->timeline_in() - visible_in); + */ } diff --git a/ui/keyframeview.cpp b/ui/keyframeview.cpp index 01395eb8f..594f34cbc 100644 --- a/ui/keyframeview.cpp +++ b/ui/keyframeview.cpp @@ -123,8 +123,8 @@ void KeyframeView::paintEvent(QPaintEvent*) { OldEffectNode* e = container->GetEffect(); if (container->IsExpanded()) { - for (int j=0;jrow_count();j++) { - NodeIO* row = e->row(j); + for (int j=0;jParameterCount();j++) { + NodeIO* row = e->Parameter(j); int keyframe_y = container->GetRowY(j, this); @@ -261,6 +261,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) { for (int k=0;kFieldCount();k++) { EffectField* f = row->Field(k); for (int j=0;jkeyframes.size();j++) { + /* FIXME long eval_keyframe_time = f->keyframes.at(j).time-row->GetParentEffect()->parent_clip->clip_in()+(row->GetParentEffect()->parent_clip->timeline_in()-visible_in); if (eval_keyframe_time >= frame_min && eval_keyframe_time <= frame_max) { long eval_frame_diff = qAbs(eval_keyframe_time - drag_frame_start); @@ -271,6 +272,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) { frame_diff = eval_frame_diff; } } + */ } } break; @@ -381,6 +383,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) { olive::timeline::snapped = false; if (olive::timeline::snapping) { for (int i=0;iGetParentRow()->GetParentEffect()->parent_clip; long key_time = old_key_vals.at(i) + frame_diff - c->clip_in() + c->timeline_in(); @@ -389,6 +392,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) { frame_diff += (key_eval - key_time); break; } + */ } } @@ -428,7 +432,7 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent*) { if (dragging) { ComboAction* ca = new ComboAction(); for (int i=0;iappend(new SetLong( + ca->append(new SetDouble( &selected_fields.at(i)->keyframes[selected_keyframes.at(i)].time, old_key_vals.at(i), selected_fields.at(i)->keyframes.at(selected_keyframes.at(i)).time diff --git a/ui/nodeedgeui.cpp b/ui/nodeedgeui.cpp index a275af92f..4ea6c3e28 100644 --- a/ui/nodeedgeui.cpp +++ b/ui/nodeedgeui.cpp @@ -26,7 +26,7 @@ void NodeEdgeUI::adjust() if (node != nullptr) { // Check if this node has the output row - int row_index = node->GetNode()->IndexOfRow(edge_->output()); + int row_index = node->GetNode()->IndexOfParameter(edge_->output()); if (row_index > -1) { output_node_ = node; @@ -34,7 +34,7 @@ void NodeEdgeUI::adjust() } // Check if this node has the input row - row_index = node->GetNode()->IndexOfRow(edge_->input()); + row_index = node->GetNode()->IndexOfParameter(edge_->input()); if (row_index > -1) { input_node_ = node; diff --git a/ui/nodeui.cpp b/ui/nodeui.cpp index 208cc4428..45c51f836 100644 --- a/ui/nodeui.cpp +++ b/ui/nodeui.cpp @@ -32,14 +32,14 @@ void NodeUI::AddToScene(QGraphicsScene *scene) scene->addItem(this); } -void NodeUI::SetNode(OldEffectNode *n) +void NodeUI::SetNode(Node *n) { node_ = n; QRectF rectangle; rectangle.setTopLeft(pos()); - rectangle.setSize(QSizeF(200, GetRowY(node_->row_count()))); + rectangle.setSize(QSizeF(200, GetRowY(node_->ParameterCount()))); QRectF inner_rect = rectangle; inner_rect.setX(inner_rect.x() + kNodePlugSize/2); @@ -51,7 +51,7 @@ void NodeUI::SetNode(OldEffectNode *n) setRect(rectangle); } -OldEffectNode *NodeUI::GetNode() +Node *NodeUI::GetNode() { return node_; } @@ -90,12 +90,12 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW node_->name()); // Draw node row names - for (int i=0;irow_count();i++) { + for (int i=0;iParameterCount();i++) { int text_x; - if (node_->row(i)->IsNodeOutput()) { + if (node_->Parameter(i)->IsNodeOutput()) { // right alignment - text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->row(i)->name()) - kTextPadding; + text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->Parameter(i)->name()) - kTextPadding; } else { // left alignment text_x = left_text_x; @@ -103,7 +103,7 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW painter->drawText(text_x, GetRowY(i) + qApp->fontMetrics().ascent(), - node_->row(i)->name()); + node_->Parameter(i)->name()); } // Draw title splitter line @@ -128,8 +128,8 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event) if (clicked_socket_ > -1) { // See if this socket already has an edge connected - QVector edges = node_->row(clicked_socket_)->edges(); - if (!edges.isEmpty() && edges.last()->input()->GetParentEffect() == node_) { + QVector edges = node_->Parameter(clicked_socket_)->edges(); + if (!edges.isEmpty() && edges.last()->input()->ParentNode() == node_) { NodeEdge* e = edges.last().get(); @@ -137,9 +137,9 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event) NodeIO* other_row = e->output(); - OldEffectNode* other_node = other_row->GetParentEffect(); + Node* other_node = other_row->ParentNode(); - int other_row_index = other_node->IndexOfRow(other_row); + int other_row_index = other_node->IndexOfParameter(other_row); NodeUI* other_node_ui = FindUIFromNode(other_node); @@ -158,7 +158,7 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event) // Start a new edge here drag_line_start_ = pos() + sockets.at(clicked_socket_).center(); - drag_source_ = node_->row(clicked_socket_); + drag_source_ = node_->Parameter(clicked_socket_); } @@ -269,11 +269,11 @@ QVector NodeUI::GetNodeSocketRects() QVector rects; if (node_ != nullptr) { - OldEffectNode* e = node_; + Node* e = node_; - for (int i=0;irow_count();i++) { + for (int i=0;iParameterCount();i++) { - NodeIO* row = e->row(i); + NodeIO* row = e->Parameter(i); if (row->IsNodeInput() || row->IsNodeOutput()) { qreal x = (row->IsNodeOutput()) ? rect().right() - kNodePlugSize : rect().x(); @@ -292,13 +292,13 @@ QVector NodeUI::GetNodeSocketRects() NodeIO *NodeUI::GetRowFromIndex(int i) { - if (node_ != nullptr && i < node_->row_count()) { - return node_->row(i); + if (node_ != nullptr && i < node_->ParameterCount()) { + return node_->Parameter(i); } return nullptr; } -NodeUI *NodeUI::FindUIFromNode(OldEffectNode* n) +NodeUI *NodeUI::FindUIFromNode(Node* n) { QList all_items = scene()->items(); diff --git a/ui/nodeui.h b/ui/nodeui.h index 0ab291ca3..39645c329 100644 --- a/ui/nodeui.h +++ b/ui/nodeui.h @@ -7,7 +7,7 @@ class EffectUI; class NodeIO; class NodeEdge; -class OldEffectNode; +class Node; class NodeUI : public QGraphicsRectItem { public: @@ -15,8 +15,8 @@ public: void AddToScene(QGraphicsScene* scene); //void Resize(const QSize& s); - void SetNode(OldEffectNode* n); - OldEffectNode* GetNode(); + void SetNode(Node* n); + Node* GetNode(); QVector GetNodeSocketRects(); @@ -29,10 +29,10 @@ protected: private: NodeIO *GetRowFromIndex(int i); - NodeUI* FindUIFromNode(OldEffectNode* n); + NodeUI* FindUIFromNode(Node *n); int GetRowY(int index); - OldEffectNode* node_; + Node* node_; QGraphicsPathItem* drag_line_; QPointF drag_line_start_; diff --git a/undo/undo.cpp b/undo/undo.cpp index 34fb4cd27..7e194071a 100644 --- a/undo/undo.cpp +++ b/undo/undo.cpp @@ -1207,3 +1207,20 @@ void KeyframeDataChange::doRedo() done_ = true; } } + +SetPointF::SetPointF(QPointF *pointer, const QPointF &old_val, const QPointF &new_val) : + pointer_(pointer), + old_val_(old_val), + new_val_(new_val) +{ +} + +void SetPointF::doUndo() +{ + *pointer_ = old_val_; +} + +void SetPointF::doRedo() +{ + *pointer_ = new_val_; +} diff --git a/undo/undo.h b/undo/undo.h index 123441064..ebfa8b53c 100644 --- a/undo/undo.h +++ b/undo/undo.h @@ -489,6 +489,17 @@ private: QString newval; }; +class SetPointF : public OliveAction { +public: + SetPointF(QPointF* pointer, const QPointF& old_val, const QPointF& new_val); + virtual void doUndo() override; + virtual void doRedo() override; +private: + QPointF* pointer_; + QPointF old_val_; + QPointF new_val_; +}; + class CloseAllClipsCommand : public OliveAction { public: virtual void doUndo() override;