diff --git a/dialogs/speeddialog.h b/dialogs/speeddialog.h index 54f903ba3..966232780 100644 --- a/dialogs/speeddialog.h +++ b/dialogs/speeddialog.h @@ -3,7 +3,7 @@ #include -struct Clip; +class Clip; class LabelSlider; class QCheckBox; diff --git a/io/loadthread.cpp b/io/loadthread.cpp index bc771d7b1..39df0c6c6 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -447,7 +447,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { m.name = attr.value().toString(); } } - c->markers.append(m); + c->get_markers().append(m); } } } diff --git a/io/loadthread.h b/io/loadthread.h index 3aba462ce..573f27d2b 100644 --- a/io/loadthread.h +++ b/io/loadthread.h @@ -10,7 +10,7 @@ class Media; struct Footage; -struct Clip; +class Clip; struct Sequence; class LoadDialog; struct TransitionData; diff --git a/panels/effectcontrols.h b/panels/effectcontrols.h index 034d9572e..042b664b2 100644 --- a/panels/effectcontrols.h +++ b/panels/effectcontrols.h @@ -5,7 +5,7 @@ #include #include -struct Clip; +class Clip; class QMenu; class Effect; class TimelineHeader; diff --git a/panels/project.cpp b/panels/project.cpp index cb7e804a4..c71b1ab5a 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -1062,8 +1062,8 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, } // save markers - for (int k=0;kmarkers.size();k++) { - save_marker(stream, c->markers.at(k)); + for (int k=0;kget_markers().size();k++) { + save_marker(stream, c->get_markers().at(k)); } stream.writeStartElement("linked"); // linked diff --git a/panels/project.h b/panels/project.h index 0653d7c48..4f2c37aef 100644 --- a/panels/project.h +++ b/panels/project.h @@ -10,7 +10,7 @@ struct Footage; struct Sequence; -struct Clip; +class Clip; class Timeline; class Viewer; class SourceTable; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 1e7b80225..f195bac02 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -1428,8 +1428,8 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo return true; } else { // try to snap to clip markers - for (int j=0;jmarkers.size();j++) { - if (snap_to_point(c->markers.at(j).frame + c->timeline_in - c->clip_in, l)) { + for (int j=0;jget_markers().size();j++) { + if (snap_to_point(c->get_markers().at(j).frame + c->timeline_in - c->clip_in, l)) { return true; } } @@ -1452,14 +1452,26 @@ void Timeline::set_marker() { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); if (c != nullptr - && is_clip_selected(c, true) - && sequence->playhead >= c->timeline_in - && sequence->playhead <= c->timeline_out) { - clips_selected.append(c); + && is_clip_selected(c, true)) { + + // only add markers if the playhead is inside the clip + if (sequence->playhead >= c->timeline_in + && sequence->playhead <= c->timeline_out) { + clips_selected.append(c); + } + + // we are definitely adding markers to clips though clip_mode = true; + } } + // if we've selected clips but none of the clips are within the playhead, + // nothing to do here + if (clip_mode && clips_selected.size() == 0) { + return; + } + QString marker_name; // if (config.set_name_with_marker) is false (set above), ask for a marker name diff --git a/panels/timeline.h b/panels/timeline.h index 94cf94657..3dbf51eb2 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -31,7 +31,7 @@ class AudioMonitor; class QScrollBar; struct EffectMeta; struct Sequence; -struct Clip; +class Clip; struct Footage; struct FootageStream; diff --git a/playback/cacher.h b/playback/cacher.h index e06939c72..8b1043da1 100644 --- a/playback/cacher.h +++ b/playback/cacher.h @@ -4,7 +4,7 @@ #include #include -struct Clip; +class Clip; class Cacher : public QThread { diff --git a/playback/playback.h b/playback/playback.h index 2758e9ead..591978419 100644 --- a/playback/playback.h +++ b/playback/playback.h @@ -4,7 +4,7 @@ #include #include -struct Clip; +class Clip; struct ClipCache; struct Sequence; struct AVFrame; diff --git a/project/clip.cpp b/project/clip.cpp index e76e162cd..5516f124d 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -147,7 +147,14 @@ void Clip::queue_remove_earliest() { } } av_frame_free(&queue[earliest_frame]); - queue.removeAt(earliest_frame); + queue.removeAt(earliest_frame); +} + +QVector &Clip::get_markers() { + if (media != nullptr && media->get_type() == MEDIA_TYPE_SEQUENCE) { + return media->to_sequence()->markers; + } + return markers; } Transition* Clip::get_opening_transition() { diff --git a/project/clip.h b/project/clip.h index 488045cd1..82d385437 100644 --- a/project/clip.h +++ b/project/clip.h @@ -33,8 +33,8 @@ struct AVFilterContext; struct AVDictionary; class QOpenGLTexture; -struct Clip -{ +class Clip { +public: Clip(Sequence* s); ~Clip(); Clip* copy(Sequence* s, bool duplicate_transitions = true); @@ -76,7 +76,7 @@ struct Clip bool autoscale; // markers - QVector markers; + QVector& get_markers(); // other variables (should be deep copied/duplicated in copy()) QList effects; @@ -136,6 +136,8 @@ struct Clip bool audio_reset; bool audio_just_reset; long audio_target_frame; +private: + QVector markers; }; #endif // CLIP_H diff --git a/project/effect.h b/project/effect.h index 6db358d8e..665cdcedf 100644 --- a/project/effect.h +++ b/project/effect.h @@ -17,7 +17,7 @@ class QGridLayout; class QPushButton; class QMouseEvent; -struct Clip; +class Clip; class QXmlStreamReader; class QXmlStreamWriter; class Effect; diff --git a/project/footage.h b/project/footage.h index 6e5219078..749c3bf86 100644 --- a/project/footage.h +++ b/project/footage.h @@ -16,7 +16,7 @@ enum VideoInterlacingMode { }; struct Sequence; -struct Clip; +class Clip; class PreviewGenerator; class MediaThrobber; diff --git a/project/sequence.h b/project/sequence.h index d3e02504f..e3afc6d36 100644 --- a/project/sequence.h +++ b/project/sequence.h @@ -6,7 +6,7 @@ #include "project/marker.h" #include "project/selection.h" -struct Clip; +class Clip; class Transition; class Media; diff --git a/project/undo.cpp b/project/undo.cpp index b4fb804a8..a1473e860 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -814,7 +814,7 @@ AddMarkerAction::AddMarkerAction(bool is_sequence, void* s, long t, QString n) : void AddMarkerAction::undo() { QVector& markers = is_sequence_internal ? static_cast(target)->markers : - static_cast(target)->markers; + static_cast(target)->get_markers(); if (index == -1) { markers.removeLast(); @@ -830,7 +830,7 @@ void AddMarkerAction::redo() { QVector& markers = is_sequence_internal ? static_cast(target)->markers : - static_cast(target)->markers; + static_cast(target)->get_markers(); for (int i=0;i #include -struct Clip; +class Clip; class Effect; class EffectRow; class EffectField; diff --git a/ui/renderfunctions.h b/ui/renderfunctions.h index 0830d6cb4..176ebd563 100644 --- a/ui/renderfunctions.h +++ b/ui/renderfunctions.h @@ -8,7 +8,7 @@ class Effect; class Viewer; class QOpenGLShaderProgram; struct Sequence; -struct Clip; +class Clip; struct ComposeSequenceParams { Viewer* viewer; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index a3e848631..a3d512125 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -1267,8 +1267,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { // if the ghost is attached to a clip, snap its markers too if (panel_timeline->trim_target == -1 && g.clip >= 0) { Clip* c = sequence->clips.at(g.clip); - for (int j=0;jmarkers.size();j++) { - long marker_real_time = c->markers.at(j).frame + c->timeline_in - c->clip_in; + for (int j=0;jget_markers().size();j++) { + long marker_real_time = c->get_markers().at(j).frame + c->timeline_in - c->clip_in; fm = marker_real_time + frame_diff; if (panel_timeline->snap_to_timeline(&fm, true, true, true)) { frame_diff = fm - marker_real_time; @@ -2430,8 +2430,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } // draw clip markers - for (int j=0;jmarkers.size();j++) { - const Marker& m = clip->markers.at(j); + for (int j=0;jget_markers().size();j++) { + const Marker& m = clip->get_markers().at(j); // convert marker time (in clip time) to sequence time long marker_time = m.frame + clip->timeline_in - clip->clip_in; @@ -2440,6 +2440,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { draw_marker(p, marker_x, clip_rect.bottom()-p.fontMetrics().height(), clip_rect.bottom(), false, false); } } + p.setBrush(Qt::NoBrush); // draw clip transitions draw_transition(p, clip, clip_rect, text_rect, TA_OPENING_TRANSITION); diff --git a/ui/timelinewidget.h b/ui/timelinewidget.h index 863e03cda..4c94a9087 100644 --- a/ui/timelinewidget.h +++ b/ui/timelinewidget.h @@ -12,7 +12,7 @@ #define TRACK_HEIGHT_INCREMENT 10 struct Sequence; -struct Clip; +class Clip; struct FootageStream; class Timeline; class TimelineAction; diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index ce09c790a..90327019f 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -11,7 +11,7 @@ #include class Viewer; -struct Clip; +class Clip; struct FootageStream; class QOpenGLFramebufferObject; class Effect;