various: extended marker and timeline functionality

This commit is contained in:
itsmattkc
2022-05-01 21:17:22 -07:00
parent cdcd83c09a
commit 6a0b5856c9
23 changed files with 781 additions and 240 deletions
+16 -4
View File
@@ -208,10 +208,22 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
// Find connected viewer node
auto viewers = FindInputNodesConnectedToInput<ViewerOutput>(NodeInput(this, kBufferIn));
if (viewers.isEmpty()) {
connected_viewer_ = nullptr;
} else {
connected_viewer_ = viewers.first();
ViewerOutput *new_connected_viewer = viewers.isEmpty() ? nullptr : viewers.first();
if (new_connected_viewer != connected_viewer_) {
if (connected_viewer_) {
disconnect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerAdded, this, &ClipBlock::PreviewChanged);
disconnect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerRemoved, this, &ClipBlock::PreviewChanged);
disconnect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerModified, this, &ClipBlock::PreviewChanged);
}
connected_viewer_ = new_connected_viewer;
if (connected_viewer_) {
connect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerAdded, this, &ClipBlock::PreviewChanged);
connect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerRemoved, this, &ClipBlock::PreviewChanged);
connect(connected_viewer_->GetTimelinePoints()->markers(), &TimelineMarkerList::MarkerModified, this, &ClipBlock::PreviewChanged);
}
}
super::InvalidateCache(adj, from, element, options);
+6
View File
@@ -195,4 +195,10 @@ NodeKeyframe::BezierType NodeKeyframe::get_opposing_bezier_type(NodeKeyframe::Be
}
}
bool NodeKeyframe::has_sibling_at_time(const rational &t) const
{
NodeKeyframe *k = parent()->GetKeyframeAtTimeOnTrack(input(), t, track(), element());
return k && k != this;
}
}
+2
View File
@@ -167,6 +167,8 @@ public:
next_ = keyframe;
}
bool has_sibling_at_time(const rational &t) const;
signals:
/**
* @brief Signal emitted when this keyframe's time is changed
+2
View File
@@ -68,6 +68,8 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs, bool create_default_stream
}
SetFlags(kDontShowInParamView);
timeline_points_ = new TimelinePoints(this);
}
Node *ViewerOutput::copy() const
+2 -2
View File
@@ -137,7 +137,7 @@ public:
TimelinePoints* GetTimelinePoints()
{
return &timeline_points_;
return timeline_points_;
}
QVector<Track::Reference> GetEnabledStreamsAsReferences() const;
@@ -252,7 +252,7 @@ private:
AudioParams cached_audio_params_;
TimelinePoints timeline_points_;
TimelinePoints *timeline_points_;
bool video_cache_enabled_;
bool audio_cache_enabled_;
@@ -991,6 +991,7 @@ void ProjectSerializer220403::LoadMarkerList(QXmlStreamReader *reader, TimelineM
if (reader->name() == QStringLiteral("marker")) {
QString name;
rational in, out;
int color = Config::Current()[QStringLiteral("MarkerColor")].toInt();
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("name")) {
@@ -999,10 +1000,12 @@ void ProjectSerializer220403::LoadMarkerList(QXmlStreamReader *reader, TimelineM
in = rational::fromString(attr.value().toString());
} else if (attr.name() == QStringLiteral("out")) {
out = rational::fromString(attr.value().toString());
} else if (attr.name() == QStringLiteral("color")) {
color = attr.value().toInt();
}
}
new TimelineMarker(Config::Current()[QStringLiteral("MarkerColor")].toInt(), TimeRange(in, out), name, markers);
new TimelineMarker(color, TimeRange(in, out), name, markers);
}
reader->skipCurrentElement();
@@ -1011,13 +1014,16 @@ void ProjectSerializer220403::LoadMarkerList(QXmlStreamReader *reader, TimelineM
void ProjectSerializer220403::SaveMarkerList(QXmlStreamWriter *writer, TimelineMarkerList *markers) const
{
foreach (TimelineMarker* marker, markers->list()) {
for (auto it=markers->cbegin(); it!=markers->cend(); it++) {
TimelineMarker* marker = *it;
writer->writeStartElement(QStringLiteral("marker"));
writer->writeAttribute(QStringLiteral("name"), marker->name());
writer->writeAttribute(QStringLiteral("in"), marker->time().in().toString());
writer->writeAttribute(QStringLiteral("out"), marker->time().out().toString());
writer->writeAttribute(QStringLiteral("in"), marker->time_range().in().toString());
writer->writeAttribute(QStringLiteral("out"), marker->time_range().out().toString());
writer->writeAttribute(QStringLiteral("color"), QString::number(marker->color()));
writer->writeEndElement(); // marker
}