diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-19 15:22:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-19 15:22:26 +0100 |
| commit | 56506a1993f402fe889a650faa3de2e265632498 (patch) | |
| tree | ea8b0f404dbfaf3def2592e6192280ab37338049 /src/lib | |
| parent | 3857b8b178d94873a6ffc6f51cdb4c241fd54f90 (diff) | |
Add remove option; resize timeline after drags.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 25 | ||||
| -rw-r--r-- | src/lib/playlist.h | 5 | ||||
| -rw-r--r-- | src/lib/types.h | 1 |
6 files changed, 28 insertions, 11 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 172fd20ab..d5a5abae4 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -728,7 +728,7 @@ Film::playlist () const return _playlist; } -Playlist::ContentList +ContentList Film::content () const { return _playlist->content (); diff --git a/src/lib/film.h b/src/lib/film.h index 497320c5e..51db8ce00 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -106,7 +106,7 @@ public: /* Proxies for some Playlist methods */ - Playlist::ContentList content () const; + ContentList content () const; Time length () const; bool has_subtitles () const; diff --git a/src/lib/player.cc b/src/lib/player.cc index ec20892ef..d3d5d0f6b 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -401,10 +401,10 @@ Player::setup_pieces () _pieces.clear (); - Playlist::ContentList content = _playlist->content (); + ContentList content = _playlist->content (); sort (content.begin(), content.end(), ContentSorter ()); - for (Playlist::ContentList::iterator i = content.begin(); i != content.end(); ++i) { + for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { shared_ptr<Piece> piece (new Piece (*i)); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e4494acb0..c9d05b049 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -158,6 +158,23 @@ Playlist::remove (shared_ptr<Content> c) } } +void +Playlist::remove (ContentList c) +{ + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { + ContentList::iterator j = _content.begin (); + while (j != _content.end() && *j != *i) { + ++j; + } + + if (j != _content.end ()) { + _content.erase (j); + } + } + + Changed (); +} + bool Playlist::has_subtitles () const { @@ -285,17 +302,17 @@ ContentSorter::operator() (shared_ptr<Content> a, shared_ptr<Content> b) } /** @return content in an undefined order */ -Playlist::ContentList +ContentList Playlist::content () const { return _content; } void -Playlist::repeat (list<shared_ptr<Content> > c, int n) +Playlist::repeat (ContentList c, int n) { pair<Time, Time> range (TIME_MAX, 0); - for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) { + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { range.first = min (range.first, (*i)->start ()); range.second = max (range.second, (*i)->start ()); range.first = min (range.first, (*i)->end ()); @@ -304,7 +321,7 @@ Playlist::repeat (list<shared_ptr<Content> > c, int n) Time pos = range.second; for (int i = 0; i < n; ++i) { - for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) { + for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { shared_ptr<Content> copy = (*i)->clone (); copy->set_start (pos + copy->start() - range.first); _content.push_back (copy); diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 1d69c34ba..e39e9f51f 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -60,11 +60,10 @@ public: void add (boost::shared_ptr<Content>); void remove (boost::shared_ptr<Content>); + void remove (ContentList); bool has_subtitles () const; - typedef std::vector<boost::shared_ptr<Content> > ContentList; - ContentList content () const; std::string video_identifier () const; @@ -77,7 +76,7 @@ public: void set_sequence_video (bool); void maybe_sequence_video (); - void repeat (std::list<boost::shared_ptr<Content> >, int); + void repeat (ContentList, int); mutable boost::signals2::signal<void ()> Changed; /** Third parameter is true if signals are currently being emitted frequently */ diff --git a/src/lib/types.h b/src/lib/types.h index aeaa82ec6..458a2ecf3 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -32,6 +32,7 @@ typedef int64_t Time; #define TIME_HZ ((Time) 96000) typedef int64_t OutputAudioFrame; typedef int OutputVideoFrame; +typedef std::vector<boost::shared_ptr<Content> > ContentList; /** @struct Crop * @brief A description of the crop of an image or video. |
