removed tracklist layer

This commit is contained in:
itsmattkc
2019-05-08 19:32:31 +10:00
parent 9a13776b2c
commit 5f0debb7ec
15 changed files with 234 additions and 370 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ void OliveGlobal::PasteInternal(Sequence *s, bool insert)
ClipPtr c = std::static_pointer_cast<Clip>(olive::clipboard.Get(i));
// create copy of clip and offset by playhead
ClipPtr cc = c->copy(s->GetTrackList(c->track()->type())->TrackAt(c->track()->Index()));
ClipPtr cc = c->copy(s->GetTrackList(c->track()->type()).at(c->track()->Index()));
// convert frame rates
cc->set_timeline_in(rescale_frame_number(cc->timeline_in(), c->cached_frame_rate(), s->frame_rate));
-2
View File
@@ -177,7 +177,6 @@ SOURCES += \
rendering/pixelformats.cpp \
timeline/timelinefunctions.cpp \
timeline/track.cpp \
timeline/tracklist.cpp \
project/savethread.cpp \
project/projectfunctions.cpp \
ui/timelinearea.cpp \
@@ -344,7 +343,6 @@ HEADERS += \
timeline/ghost.h \
timeline/timelinefunctions.h \
timeline/track.h \
timeline/tracklist.h \
project/savethread.h \
project/projectfunctions.h \
ui/timelinearea.h \
+7 -6
View File
@@ -223,8 +223,8 @@ void Timeline::SetSequence(SequencePtr sequence)
sequence_ = sequence;
update_sequence();
video_area->SetTrackList(sequence_.get(), olive::kTypeVideo);
audio_area->SetTrackList(sequence_.get(), olive::kTypeAudio);
video_area->SetTrackType(sequence_.get(), olive::kTypeVideo);
audio_area->SetTrackType(sequence_.get(), olive::kTypeAudio);
repaint_timeline();
emit SequenceChanged(sequence_);
@@ -343,7 +343,7 @@ void Timeline::nest() {
ca->append(new DeleteClipAction(c));
// copy to new
Track* track = s->GetTrackList(c->type())->TrackAt(c->track()->Index());
Track* track = s->GetTrackList(c->type()).at(c->track()->Index());
ClipPtr copy = selected_clips.at(i)->copy(track);
copy->set_timeline_in(copy->timeline_in() - earliest_point);
copy->set_timeline_out(copy->timeline_out() - earliest_point);
@@ -782,9 +782,10 @@ QVector<Track *> Timeline::GetTracksInRectangle(int global_top, int global_botto
int rect_bottom = qMax(relative_tl.y(), relative_br.y());
// determine which clips are in this rectangular selection
TrackList* track_list = area->track_list();
for (int j=0;j<track_list->TrackCount();j++) {
Track* track = track_list->TrackAt(j);
QVector<Track*> area_tracks = sequence_->GetTrackList(area->track_type());
for (int j=0;j<area_tracks.size();j++) {
Track* track = area_tracks.at(j);
int track_top = area->view()->getScreenPointFromTrack(track);
int track_bottom = track_top + track->height();
+6 -5
View File
@@ -752,7 +752,9 @@ void Viewer::set_media(Media* m) {
new_sequence->frame_rate = video_stream.video_frame_rate * footage->speed;
}
ClipPtr c = std::make_shared<Clip>(new_sequence->GetTrackList(olive::kTypeVideo)->First());
Track* first_track = new_sequence->GetTrackList(olive::kTypeVideo).first();
ClipPtr c = std::make_shared<Clip>(first_track);
c->set_media(media, video_stream.file_index);
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate));
@@ -760,11 +762,10 @@ void Viewer::set_media(Media* m) {
// FIXME: Move this magic number to Config
c->set_timeline_out(150);
}
Track* track = new_sequence->GetTrackList(olive::kTypeVideo)->First();
c->set_track(track);
c->set_track(first_track);
c->set_clip_in(0);
c->refresh();
track->AddClip(c);
first_track->AddClip(c);
} else {
new_sequence->width = olive::config.default_sequence_width;
new_sequence->height = olive::config.default_sequence_height;
@@ -774,7 +775,7 @@ void Viewer::set_media(Media* m) {
const FootageStream& audio_stream = footage->audio_tracks.at(0);
new_sequence->audio_frequency = audio_stream.audio_frequency;
Track* track = new_sequence->GetTrackList(olive::kTypeAudio)->First();
Track* track = new_sequence->GetTrackList(olive::kTypeAudio).first();
ClipPtr c = std::make_shared<Clip>(track);
c->set_media(media, audio_stream.file_index);
c->set_timeline_in(0);
+143 -132
View File
@@ -35,12 +35,6 @@ Sequence::Sequence() :
workarea_out(0),
wrapper_sequence(false)
{
// Set up tracks
track_lists_.resize(olive::kTypeCount);
for (int i=0;i<track_lists_.size();i++) {
track_lists_[i] = new TrackList(this, static_cast<olive::TrackType>(i));
}
}
SequencePtr Sequence::copy() {
@@ -52,10 +46,12 @@ SequencePtr Sequence::copy() {
s->audio_frequency = audio_frequency;
s->audio_layout = audio_layout;
/* FIXME
// deep copy all of the sequence's clips
for (int i=0;i<track_lists_.size();i++) {
s->track_lists_[i] = track_lists_.at(i)->copy(s.get());
}
*/
// copy all of the sequence's markers
s->markers = markers;
@@ -89,9 +85,11 @@ void Sequence::Save(QXmlStreamWriter &stream)
QVector<TransitionPtr> transition_save_cache;
QVector<int> transition_clip_save_cache;
/* FIXME
for (int j=0;j<track_lists_.size();j++) {
track_lists_.at(j)->Save(stream);
}
*/
for (int j=0;j<markers.size();j++) {
markers.at(j).Save(stream);
@@ -103,14 +101,8 @@ void Sequence::Save(QXmlStreamWriter &stream)
long Sequence::GetEndFrame() {
long end_frame = 0;
for (int j=0;j<track_lists_.size();j++) {
TrackList* track_list = track_lists_.at(j);
for (int i=0;i<track_list->TrackCount();i++) {
end_frame = qMax(track_list->TrackAt(i)->GetEndFrame(), end_frame);
}
for (int i=0;i<tracks_.size();i++) {
end_frame = qMax(tracks_.at(i)->GetEndFrame(), end_frame);
}
return end_frame;
@@ -120,22 +112,26 @@ QVector<Clip *> Sequence::GetAllClips()
{
QVector<Clip*> all_clips;
for (int j=0;j<track_lists_.size();j++) {
for (int j=0;j<tracks_.size();j++) {
TrackList* track_list = track_lists_.at(j);
for (int i=0;i<track_list->TrackCount();i++) {
all_clips.append(track_list->TrackAt(i)->GetAllClips());
}
all_clips.append(tracks_.at(j)->GetAllClips());
}
return all_clips;
}
TrackList *Sequence::GetTrackList(olive::TrackType type)
QVector<Track *> Sequence::GetTrackList(olive::TrackType type)
{
return track_lists_.at(type);
QVector<Track*> tracks;
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i)->type() == type) {
tracks.append(tracks_.at(i));
}
}
return tracks;
}
void Sequence::Close()
@@ -166,14 +162,10 @@ QVector<Clip *> Sequence::SelectedClips(bool containing)
{
QVector<Clip*> selected_clips;
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
for (int j=0;j<tl->TrackCount();j++) {
Track* t = tl->TrackAt(j);
selected_clips.append(t->GetSelectedClips(containing));
}
selected_clips.append(t->GetSelectedClips(containing));
}
return selected_clips;
@@ -340,14 +332,8 @@ void Sequence::EditToPoint(bool in, bool ripple)
if (in_point >= 0) {
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tl->TrackCount();j++) {
areas.append(Selection(in_point, in_point+1, tl->TrackAt(j)));
}
for (int j=0;j<tracks_.size();j++) {
areas.append(Selection(in_point, in_point+1, tracks_.at(j)));
}
// trim and move clips around the in point
@@ -382,14 +368,8 @@ void Sequence::EditToPoint(bool in, bool ripple)
} else {
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tl->TrackCount();j++) {
areas.append(Selection(area_in, area_out, tl->TrackAt(j)));
}
for (int j=0;j<tracks_.size();j++) {
areas.append(Selection(area_in, area_out, tracks_.at(j)));
}
// trim and move clips around the in point
@@ -474,14 +454,8 @@ void Sequence::DeleteInToOut(bool ripple)
QVector<Selection> areas_to_delete;
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tl->TrackCount();j++) {
areas_to_delete.append(Selection(workarea_in, workarea_out, tl->TrackAt(j)));
}
for (int j=0;j<tracks_.size();j++) {
areas_to_delete.append(Selection(workarea_in, workarea_out, tracks_.at(j)));
}
ComboAction* ca = new ComboAction();
@@ -534,14 +508,10 @@ void Sequence::Ripple(ComboAction *ca, long point, long length, const QVector<Cl
void Sequence::ChangeTrackHeightsRelatively(int diff)
{
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
for (int j=0;j<tl->TrackCount();j++) {
Track* t = tl->TrackAt(j);
t->set_height(t->height() + diff);
}
t->set_height(t->height() + diff);
}
}
@@ -611,35 +581,30 @@ 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) {
TrackList* track_list;
Track* track;
foreach (track_list, track_lists_) {
foreach (track, tracks_) {
QVector<Track*> tracks = track_list->tracks();
foreach (track, tracks) {
QVector<Selection> track_selections = track->Selections();
QVector<long> split_positions;
QVector<Selection> track_selections = track->Selections();
QVector<long> split_positions;
for (int j=0;j<track_selections.size();j++) {
const Selection& s = track_selections.at(j);
for (int j=0;j<track_selections.size();j++) {
const Selection& s = track_selections.at(j);
if (!split_positions.contains(s.in())) {
split_positions.append(s.in());
}
if (!split_positions.contains(s.out())) {
split_positions.append(s.out());
}
if (!split_positions.contains(s.in())) {
split_positions.append(s.in());
}
for (int i=0;i<track->ClipCount();i++) {
Clip* c = track->GetClip(i).get();
if (!split_positions.contains(s.out())) {
split_positions.append(s.out());
}
}
if (SplitClipAtPositions(ca, c, split_positions, false)) {
split_occurred = true;
}
for (int i=0;i<track->ClipCount();i++) {
Clip* c = track->GetClip(i).get();
if (SplitClipAtPositions(ca, c, split_positions, false)) {
split_occurred = true;
}
}
}
@@ -857,44 +822,40 @@ void Sequence::RippleDeleteEmptySpace(ComboAction* ca, Track* track, long point)
void Sequence::RippleDeleteArea(ComboAction* ca, long ripple_point, long ripple_length) {
for (int i=0;i<track_lists_.size();i++) {
TrackList* tl = track_lists_.at(i);
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
for (int j=0;j<tl->TrackCount();j++) {
Track* t = tl->TrackAt(j);
// We've already tested `track`, so we don't need to test it again
long first_in_point_after_point = LONG_MAX;
long out_point_just_before_first_in_point = LONG_MIN;
// We've already tested `track`, so we don't need to test it again
long first_in_point_after_point = LONG_MAX;
long out_point_just_before_first_in_point = LONG_MIN;
QVector<Clip*> track_clips = t->GetAllClips();
QVector<Clip*> track_clips = t->GetAllClips();
// Find the in point of the clip directly after the point
for (int k=0;k<track_clips.size();k++) {
Clip* c = track_clips.at(k);
// Find the in point of the clip directly after the point
if (c->timeline_in() >= ripple_point) {
first_in_point_after_point = qMin(first_in_point_after_point, c->timeline_in());
}
}
// Ensure we found a valid in point before proceeding
if (first_in_point_after_point != LONG_MAX) {
// Find the out point of the clip directly before the clip found above
for (int k=0;k<track_clips.size();k++) {
Clip* c = track_clips.at(k);
if (c->timeline_in() >= ripple_point) {
first_in_point_after_point = qMin(first_in_point_after_point, c->timeline_in());
if (c->timeline_out() <= first_in_point_after_point) {
out_point_just_before_first_in_point = qMax(out_point_just_before_first_in_point, c->timeline_out());
}
}
// Ensure we found a valid in point before proceeding
if (first_in_point_after_point != LONG_MAX) {
long ripple_test = first_in_point_after_point - out_point_just_before_first_in_point + ripple_length;
// Find the out point of the clip directly before the clip found above
for (int k=0;k<track_clips.size();k++) {
Clip* c = track_clips.at(k);
if (c->timeline_out() <= first_in_point_after_point) {
out_point_just_before_first_in_point = qMax(out_point_just_before_first_in_point, c->timeline_out());
}
}
long ripple_test = first_in_point_after_point - out_point_just_before_first_in_point + ripple_length;
if (ripple_test < 0) {
ripple_length -= ripple_test;
}
if (ripple_test < 0) {
ripple_length -= ripple_test;
}
}
}
@@ -949,34 +910,22 @@ OldEffectNode *Sequence::GetSelectedGizmo()
void Sequence::SelectAll()
{
for (int j=0;j<track_lists_.size();j++) {
TrackList* tl = track_lists_.at(j);
for (int i=0;i<tl->TrackCount();i++) {
tl->TrackAt(i)->SelectAll();
}
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->SelectAll();
}
}
void Sequence::SelectAtPlayhead()
{
for (int j=0;j<track_lists_.size();j++) {
TrackList* tl = track_lists_.at(j);
for (int i=0;i<tl->TrackCount();i++) {
tl->TrackAt(i)->SelectAtPoint(playhead);
}
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->SelectAtPoint(playhead);
}
}
void Sequence::ClearSelections()
{
for (int j=0;j<track_lists_.size();j++) {
TrackList* tl = track_lists_.at(j);
for (int i=0;i<tl->TrackCount();i++) {
tl->TrackAt(i)->ClearSelections();
}
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->ClearSelections();
}
}
@@ -1057,12 +1006,8 @@ QVector<Selection> Sequence::Selections()
{
QVector<Selection> selections;
for (int j=0;j<track_lists_.size();j++) {
TrackList* tl = track_lists_.at(j);
for (int i=0;i<tl->TrackCount();i++) {
selections.append(tl->TrackAt(i)->Selections());
}
for (int i=0;i<tracks_.size();i++) {
selections.append(tracks_.at(i)->Selections());
}
return selections;
@@ -1086,6 +1031,72 @@ void Sequence::TidySelections()
SetSelections(selections);
}
Track *Sequence::PreviousTrack(Track *t)
{
Track* previous_track = nullptr;
// Loop through tracks
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i) == t) {
// If this is the track, we'll know the previous track by now
break;
} else if (tracks_.at(i)->type() == t->type()) {
// Otherwise, we'll keep "track" of it
previous_track = t;
}
}
return previous_track;
}
Track *Sequence::NextTrack(Track *t)
{
// FIXME: The old code created extra tracks if it couldn't find one here
Track* next_track = nullptr;
// Loop through tracks
for (int i=tracks_.size()-1;i>=0;i--) {
if (tracks_.at(i) == t) {
// If this is the track, we'll know the previous track by now
break;
} else if (tracks_.at(i)->type() == t->type()) {
// Otherwise, we'll keep "track" of it
next_track = t;
}
}
return next_track;
}
Track *Sequence::SiblingTrack(Track *t, int diff)
{
// FIXME: The old code created extra tracks if it couldn't find one here
if (diff == 0) {
return t;
}
QVector<Track*> tracks = GetTrackList(t->type());
return tracks.at(qMax(0, IndexOfTrack(t) + diff));
}
int Sequence::IndexOfTrack(Track *t)
{
QVector<Track*> tracks = GetTrackList(t->type());
for (int i=0;i<tracks.size();i++) {
if (tracks.at(i) == t) {
return i;
}
}
return -1;
}
ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long frame)
{
return SplitClip(ca, transitions, pre, frame, frame);
+7 -3
View File
@@ -27,7 +27,6 @@
#include "clip.h"
#include "marker.h"
#include "selection.h"
#include "tracklist.h"
#include "ghost.h"
class Sequence : public QObject {
@@ -47,7 +46,7 @@ public:
long GetEndFrame();
QVector<Clip*> GetAllClips();
TrackList* GetTrackList(olive::TrackType type);
QVector<Track*> GetTrackList(olive::TrackType type);
/**
* @brief Close all open clips in a Sequence
@@ -110,6 +109,11 @@ public:
void SetSelections(const QVector<Selection>& selections);
void TidySelections();
Track* PreviousTrack(Track* t);
Track* NextTrack(Track* t);
Track* SiblingTrack(Track* t, int diff);
int IndexOfTrack(Track* t);
long playhead;
bool using_workarea;
@@ -124,7 +128,7 @@ public:
signals:
void Changed();
private:
QVector<TrackList*> track_lists_;
QVector<Track*> tracks_;
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame);
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame, long post_in);
+4 -4
View File
@@ -119,7 +119,7 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
|| import_data.type() == olive::timeline::kImportBoth) {
for (int j=0;j<m->audio_tracks.size();j++) {
if (m->audio_tracks.at(j).enabled) {
g.track = seq->GetTrackList(olive::kTypeAudio)->TrackAt(j);
g.track = seq->GetTrackList(olive::kTypeAudio).at(j);
g.media_stream = m->audio_tracks.at(j).file_index;
ghosts.append(g);
}
@@ -130,7 +130,7 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
|| import_data.type() == olive::timeline::kImportBoth) {
for (int j=0;j<m->video_tracks.size();j++) {
if (m->video_tracks.at(j).enabled) {
g.track = seq->GetTrackList(olive::kTypeVideo)->TrackAt(j);
g.track = seq->GetTrackList(olive::kTypeVideo).at(j);
g.media_stream = m->video_tracks.at(j).file_index;
ghosts.append(g);
}
@@ -146,13 +146,13 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
if (import_data.type() == olive::timeline::kImportVideoOnly
|| import_data.type() == olive::timeline::kImportBoth) {
g.track = seq->GetTrackList(olive::kTypeVideo)->First();
g.track = seq->GetTrackList(olive::kTypeVideo).first();
ghosts.append(g);
}
if (import_data.type() == olive::timeline::kImportAudioOnly
|| import_data.type() == olive::timeline::kImportBoth) {
g.track = seq->GetTrackList(olive::kTypeAudio)->First();
g.track = seq->GetTrackList(olive::kTypeAudio).first();
ghosts.append(g);
}
+8 -23
View File
@@ -1,7 +1,6 @@
#include "track.h"
#include "timeline/clip.h"
#include "timeline/tracklist.h"
#include "timeline/sequence.h"
#include "global/math.h"
@@ -9,7 +8,7 @@ int olive::timeline::kTrackDefaultHeight = 40;
int olive::timeline::kTrackMinHeight = 30;
int olive::timeline::kTrackHeightIncrement = 10;
Track::Track(TrackList* parent, olive::TrackType type) :
Track::Track(Sequence* parent, olive::TrackType type) :
parent_(parent),
type_(type),
muted_(false),
@@ -19,7 +18,7 @@ Track::Track(TrackList* parent, olive::TrackType type) :
{
}
Track *Track::copy(TrackList *parent)
Track *Track::copy(Sequence *parent)
{
Track* t = new Track(parent, type_);
@@ -35,11 +34,6 @@ Track *Track::copy(TrackList *parent)
}
Sequence *Track::sequence()
{
return parent_->GetParent();
}
TrackList *Track::track_list()
{
return parent_;
}
@@ -210,27 +204,17 @@ bool Track::ContainsClip(Clip *c)
Track *Track::Previous()
{
int index = Index();
if (index == 0) {
return nullptr;
}
return parent_->TrackAt(index - 1);
return parent_->PreviousTrack(this);
}
Track *Track::Next()
{
return parent_->TrackAt(Index() + 1);
return parent_->NextTrack(this);
}
Track *Track::Sibling(int diff)
{
if (diff == 0) {
return this;
}
return track_list()->TrackAt(qMax(0, Index() + diff));
return parent_->SiblingTrack(this, diff);
}
int Track::Index()
@@ -394,8 +378,9 @@ bool Track::IsEffectivelyMuted()
// Check if any tracks are soloed
bool a_track_is_soloed = false;
for (int i=0;i<track_list()->TrackCount();i++) {
if (track_list()->TrackAt(i)->IsSoloed()) {
QVector<Track*> siblings = parent_->GetTrackList(type_);
for (int i=0;i<siblings.size();i++) {
if (siblings.at(i)->IsSoloed()) {
a_track_is_soloed = true;
break;
}
+4 -5
View File
@@ -35,17 +35,16 @@ namespace olive {
}
}
class TrackList;
class Sequence;
class Track : public QObject
{
Q_OBJECT
public:
Track(TrackList* parent, olive::TrackType type);
Track* copy(TrackList* parent);
Track(Sequence* parent, olive::TrackType type);
Track* copy(Sequence* parent);
Sequence* sequence();
TrackList* track_list();
void Save(QXmlStreamWriter& stream);
@@ -108,7 +107,7 @@ signals:
private:
void ResizeClipArray(int new_size);
TrackList* parent_;
Sequence* parent_;
olive::TrackType type_;
int height_;
QVector<ClipPtr> clips_;
-107
View File
@@ -1,107 +0,0 @@
#include "tracklist.h"
#include "timeline/sequence.h"
TrackList::TrackList(Sequence *parent, olive::TrackType type) :
QObject(parent),
type_(type)
{
// Ensure we have at least one track
AddTrack();
}
void TrackList::Save(QXmlStreamWriter &stream)
{
stream.writeStartElement("Tracks");
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->Save(stream);
}
stream.writeEndElement(); // Tracks
}
TrackList* TrackList::copy(Sequence *parent)
{
TrackList* t = new TrackList(parent, type_);
t->ResizeTrackArray(tracks_.size());
for (int i=0;i<tracks_.size();i++) {
t->tracks_[i] = tracks_.at(i)->copy(t);
}
return t;
}
void TrackList::AddTrack()
{
Track* track = new Track(this, type_);
tracks_.append(track);
emit TrackCountChanged();
}
void TrackList::RemoveTrack(int i)
{
if (tracks_.size() == 1) {
return;
}
tracks_.removeAt(i);
emit TrackCountChanged();
}
Track *TrackList::First()
{
return tracks_.first();
}
Track *TrackList::Last()
{
return tracks_.last();
}
int TrackList::TrackCount()
{
return tracks_.size();
}
int TrackList::IndexOfTrack(Track *track)
{
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i) == track) {
return i;
}
}
return -1;
}
Track *TrackList::TrackAt(int i)
{
while (i >= tracks_.size()) {
AddTrack();
}
return tracks_.at(i);
}
QVector<Track*> TrackList::tracks()
{
return tracks_;
}
olive::TrackType TrackList::type()
{
return type_;
}
Sequence *TrackList::GetParent()
{
return static_cast<Sequence*>(parent());
}
void TrackList::ResizeTrackArray(int i)
{
tracks_.resize(i);
}
-38
View File
@@ -1,38 +0,0 @@
#ifndef TRACKLIST_H
#define TRACKLIST_H
#include "track.h"
class TrackList : public QObject
{
Q_OBJECT
public:
TrackList(Sequence* parent, olive::TrackType type);
TrackList* copy(Sequence* parent);
void Save(QXmlStreamWriter& stream);
void AddTrack();
void RemoveTrack(int i);
Track* First();
Track* Last();
int TrackCount();
int IndexOfTrack(Track* track);
Track* TrackAt(int i);
QVector<Track*> tracks();
olive::TrackType type();
Sequence* GetParent();
signals:
void TrackCountChanged();
private:
void ResizeTrackArray(int i);
olive::TrackType type_;
QVector<Track*> tracks_;
};
#endif // TRACKLIST_H
+8 -6
View File
@@ -49,8 +49,9 @@ TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignm
connect(view_, SIGNAL(requestScrollChange(int)), scrollbar_, SLOT(setValue(int)));
}
void TimelineArea::SetTrackList(Sequence *sequence, olive::TrackType track_list)
void TimelineArea::SetTrackType(Sequence *sequence, olive::TrackType track_type)
{
/* FIXME
if (track_list_ != nullptr) {
disconnect(track_list_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
}
@@ -61,7 +62,7 @@ void TimelineArea::SetTrackList(Sequence *sequence, olive::TrackType track_list)
} else {
track_list_ = sequence->GetTrackList(track_list);
track_list_ = sequence->GetTrackList(track_type);
connect(track_list_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
}
@@ -69,7 +70,7 @@ void TimelineArea::SetTrackList(Sequence *sequence, olive::TrackType track_list)
RefreshLabels();
view_->SetTrackList(track_list_);
*/
}
void TimelineArea::SetAlignment(olive::timeline::Alignment alignment)
@@ -80,9 +81,9 @@ void TimelineArea::SetAlignment(olive::timeline::Alignment alignment)
RefreshLabels();
}
TrackList *TimelineArea::track_list()
olive::TrackType TimelineArea::track_type()
{
return track_list_;
return type_;
}
TimelineView *TimelineArea::view()
@@ -162,6 +163,7 @@ void TimelineArea::RefreshLabels()
} else {
/* FIXME
labels_.resize(track_list_->TrackCount());
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
@@ -179,7 +181,7 @@ void TimelineArea::RefreshLabels()
break;
}
}
*/
}
}
+4 -4
View File
@@ -3,7 +3,6 @@
#include "timeline/sequence.h"
#include "timeline/track.h"
#include "timeline/tracklist.h"
#include "timeline/timelinefunctions.h"
#include "ui/timelineview.h"
#include "ui/timelinelabel.h"
@@ -14,10 +13,10 @@ class TimelineArea : public QWidget
public:
TimelineArea(Timeline *timeline, olive::timeline::Alignment alignment = olive::timeline::kAlignmentTop);
void SetTrackList(Sequence* sequence, olive::TrackType track_list);
void SetTrackType(Sequence* sequence, olive::TrackType track_type);
void SetAlignment(olive::timeline::Alignment alignment);
TrackList* track_list();
olive::TrackType track_type();
TimelineView* view();
virtual void wheelEvent(QWheelEvent *event) override;
@@ -27,7 +26,8 @@ protected:
virtual void resizeEvent(QResizeEvent *event) override;
private:
Timeline* timeline_;
TrackList* track_list_;
Sequence* track_list_;
olive::TrackType type_;
TimelineView* view_;
QVector<TimelineLabelPtr> labels_;
olive::timeline::Alignment alignment_;
+39 -32
View File
@@ -69,7 +69,8 @@
TimelineView::TimelineView(Timeline *parent) :
timeline_(parent),
self_created_sequence(nullptr),
track_list_(nullptr),
sequence_(nullptr),
type_(olive::kTypeCount),
scroll(0),
alignment_(olive::timeline::kAlignmentTop),
track_resizing(false)
@@ -92,9 +93,10 @@ void TimelineView::SetAlignment(olive::timeline::Alignment alignment)
alignment_ = alignment;
}
void TimelineView::SetTrackList(TrackList *tl)
void TimelineView::SetTrackType(Sequence* s, olive::TrackType type)
{
track_list_ = tl;
sequence_ = s;
type_ = type;
update();
}
@@ -323,7 +325,7 @@ void TimelineView::dragEnterEvent(QDragEnterEvent *event) {
} else {
entry_point = ParentTimeline()->getTimelineFrameFromScreenPoint(event->pos().x());
ParentTimeline()->drag_frame_start = entry_point + getFrameFromScreenPoint(ParentTimeline()->zoom, 50);
ParentTimeline()->drag_track_start = track_list_->First();
ParentTimeline()->drag_track_start = sequence_->GetTrackList(type_).first();
}
ParentTimeline()->ghosts = olive::timeline::CreateGhostsFromMedia(seq, entry_point, media_list);
@@ -625,15 +627,15 @@ void TimelineView::mousePressEvent(QMouseEvent *event) {
}
// if the track the user clicked is correct for the type of object we're adding
if (track_list_->type() == create_type) {
if (type_ == create_type) {
Ghost g;
g.in = g.old_in = g.out = g.old_out = ParentTimeline()->drag_frame_start;
g.track = ParentTimeline()->drag_track_start;
if (g.track == nullptr) {
g.track = track_list_->Last();
ParentTimeline()->drag_track_start = track_list_->Last();
QVector<Track*> track_list = sequence_->GetTrackList(type_);
g.track = track_list.last();
ParentTimeline()->drag_track_start = track_list.last();
g.track_movement = getTrackIndexFromScreenPoint(event->pos().y()) - g.track->Index();
}
@@ -981,8 +983,9 @@ int TimelineView::GetTotalAreaHeight()
// start by adding a track height worth of padding
int panel_height = olive::timeline::kTrackDefaultHeight;
for (int i=0;i<track_list_->TrackCount();i++) {
panel_height += track_list_->TrackAt(i)->height();
QVector<Track*> track_list = sequence_->GetTrackList(type_);
for (int i=0;i<track_list.size();i++) {
panel_height += track_list.at(i)->height();
}
return panel_height;
@@ -1836,7 +1839,7 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
// Prevent any clips from going below the "zeroeth" track
if (ParentTimeline()->importing || g.track->type() == track_list_->type()) {
if (ParentTimeline()->importing || g.track->type() == type_) {
int track_validator = g.track->Index() + track_diff;
if (track_validator < 0) {
@@ -1929,7 +1932,7 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
g.track_movement = getTrackIndexFromScreenPoint(mouse_pos.y());
} else if (g.track->type() == track_list_->type() && g.transition == nullptr) {
} else if (g.track->type() == type_ && g.transition == nullptr) {
g.track_movement = track_diff;
@@ -2649,6 +2652,8 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) {
}
} else {
QVector<Track*> track_list = sequence_->GetTrackList(type_);
// we didn't find a trim target, so we must be doing something else
// (e.g. dragging a clip or resizing the track heights)
@@ -2660,8 +2665,8 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) {
// cursor range for resizing a track
int test_range = 10; // FIXME magic number
for (int i=0;i<track_list_->TrackCount();i++) {
Track* track = track_list_->TrackAt(i);
for (int i=0;i<track_list.size();i++) {
Track* track = track_list.at(i);
int effective_track_index = i;
@@ -2747,7 +2752,7 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) {
// cursor is hovering over a clip
// check if the clip and transition are both the same sign (meaning video/audio are the same)
if (track_list_->type() == olive::node_library[ParentTimeline()->transition_tool_meta]->subtype()) {
if (type_ == olive::node_library[ParentTimeline()->transition_tool_meta]->subtype()) {
// the range within which the transition tool will assume the user wants to make a shared transition
// between two clips rather than just one transition on one clip
@@ -2838,15 +2843,16 @@ void TimelineView::draw_transition(QPainter& p, Clip* c, const QRect& clip_rect,
void TimelineView::paintEvent(QPaintEvent*) {
// Draw clips
if (track_list_ != nullptr) {
if (sequence_ != nullptr) {
QPainter p(this);
// get widget width and height
emit setScrollMaximum(GetTotalAreaHeight());
for (int i=0;i<track_list_->TrackCount();i++) {
QVector<Track*> track_list = sequence_->GetTrackList(type_);
for (int i=0;i<track_list.size();i++) {
Track* track = track_list_->TrackAt(i);
Track* track = track_list.at(i);
int track_top = getScreenPointFromTrack(track);
int track_bottom = track_top + track->height();
@@ -3205,7 +3211,7 @@ void TimelineView::paintEvent(QPaintEvent*) {
for (int i=0;i<ParentTimeline()->ghosts.size();i++) {
const Ghost& g = ParentTimeline()->ghosts.at(i);
first_ghost = qMin(first_ghost, g.in);
if (g.track->type() == track_list_->type()) {
if (g.track->type() == type_) {
int ghost_x = ParentTimeline()->getTimelineScreenPointFromFrame(g.in);
int ghost_y = getScreenPointFromTrackIndex(g.track->Index() + g.track_movement);
@@ -3277,8 +3283,10 @@ Track *TimelineView::getTrackFromScreenPoint(int y) {
int index = getTrackIndexFromScreenPoint(y);
if (index < track_list_->TrackCount()) {
return track_list_->TrackAt(index);
QVector<Track*> track_list = sequence_->GetTrackList(type_);
if (index < track_list.size()) {
return track_list.at(index);
}
return nullptr;
@@ -3286,7 +3294,7 @@ Track *TimelineView::getTrackFromScreenPoint(int y) {
}
int TimelineView::getScreenPointFromTrack(Track *track) {
return getScreenPointFromTrackIndex(track_list_->IndexOfTrack(track));
return getScreenPointFromTrackIndex(track->Index());
}
int TimelineView::getTrackIndexFromScreenPoint(int y)
@@ -3312,8 +3320,9 @@ int TimelineView::getTrackIndexFromScreenPoint(int y)
int new_heights = heights;
if (i < track_list_->TrackCount()) {
new_heights += track_list_->TrackAt(i)->height();
QVector<Track*> track_list = sequence_->GetTrackList(type_);
if (i < track_list.size()) {
new_heights += track_list.at(i)->height();
} else {
new_heights += olive::timeline::kTrackDefaultHeight;
}
@@ -3342,7 +3351,8 @@ int TimelineView::getScreenPointFromTrackIndex(int track)
}
if (alignment_ == olive::timeline::kAlignmentBottom) {
return qMax(height(), GetTotalAreaHeight()) - point - scroll - track_list_->First()->height() - 1;
QVector<Track*> track_list = sequence_->GetTrackList(type_);
return qMax(height(), GetTotalAreaHeight()) - point - scroll - track_list.first()->height() - 1;
}
return point - scroll;
@@ -3350,8 +3360,9 @@ int TimelineView::getScreenPointFromTrackIndex(int track)
int TimelineView::getTrackHeightFromTrackIndex(int track)
{
if (track < track_list_->TrackCount()) {
return track_list_->TrackAt(track)->height();
QVector<Track*> track_list = sequence_->GetTrackList(type_);
if (track < track_list.size()) {
return track_list.at(track)->height();
} else {
return olive::timeline::kTrackDefaultHeight;
}
@@ -3364,11 +3375,7 @@ Timeline *TimelineView::ParentTimeline()
Sequence *TimelineView::sequence()
{
if (track_list_ == nullptr) {
return nullptr;
}
return track_list_->GetParent();
return sequence_;
}
void TimelineView::setScroll(int s) {
+3 -2
View File
@@ -44,7 +44,7 @@ public:
explicit TimelineView(Timeline *parent);
void SetAlignment(olive::timeline::Alignment alignment);
void SetTrackList(TrackList* tl);
void SetTrackType(Sequence* s, olive::TrackType type);
Track* getTrackFromScreenPoint(int y);
int getScreenPointFromTrack(Track* track);
@@ -91,7 +91,8 @@ private:
Timeline* timeline_;
olive::timeline::Alignment alignment_;
TrackList* track_list_;
Sequence* sequence_;
olive::TrackType type_;
bool track_resizing;
Track* track_target;