diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-24 14:31:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-24 14:31:13 +0100 |
| commit | 5ece2775cee162d7523a5318663a6dd8f7e52651 (patch) | |
| tree | b1d376a0ad572f82bdc945f6308b0881cca37616 /src | |
| parent | ebd495da2fe5be8c07cf7fb52e8283bb7f4113c1 (diff) | |
More various tweaks.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/imagemagick_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 45 | ||||
| -rw-r--r-- | src/wx/timeline.cc | 107 |
3 files changed, 91 insertions, 63 deletions
diff --git a/src/lib/imagemagick_decoder.cc b/src/lib/imagemagick_decoder.cc index 81b3e4b9a..b2bbb4118 100644 --- a/src/lib/imagemagick_decoder.cc +++ b/src/lib/imagemagick_decoder.cc @@ -73,7 +73,7 @@ ImageMagickDecoder::video_frame_rate () const void ImageMagickDecoder::pass () { - if (_next_video >= _imagemagick_content->video_length ()) { + if (_next_video >= _imagemagick_content->length ()) { return; } diff --git a/src/lib/player.cc b/src/lib/player.cc index dc802e220..c03b4753c 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -102,7 +102,8 @@ Player::pass () shared_ptr<Piece> earliest; for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) { - if ((*i)->content->end() < _position) { +// cout << "check " << (*i)->decoder->next() << " cf " << (*i)->content->end() << "\n"; + if (((*i)->decoder->next() + (*i)->content->start()) >= (*i)->content->end()) { continue; } @@ -117,21 +118,24 @@ Player::pass () return true; } - earliest->decoder->pass (); - - /* Move position to earliest active next emission */ - - for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) { - if ((*i)->content->end() < _position) { - continue; - } - - Time const t = (*i)->content->start() + (*i)->decoder->next(); - - if (t < _position) { - _position = t; - } +#if 0 + cout << "PASS:\n"; + cout << "\tpass "; + if (dynamic_pointer_cast<FFmpegContent> (earliest->content)) { + cout << " FFmpeg.\n"; + } else if (dynamic_pointer_cast<ImageMagickContent> (earliest->content)) { + cout << " ImageMagickContent.\n"; + } else if (dynamic_pointer_cast<SndfileContent> (earliest->content)) { + cout << " SndfileContent.\n"; + } else if (dynamic_pointer_cast<BlackDecoder> (earliest->decoder)) { + cout << " Black.\n"; + } else if (dynamic_pointer_cast<SilenceDecoder> (earliest->decoder)) { + cout << " Silence.\n"; } +#endif + + earliest->decoder->pass (); + _position = earliest->content->start() + earliest->decoder->next (); return false; } @@ -207,8 +211,6 @@ Player::seek (Time t) (*i)->decoder->seek (t - (*i)->content->start()); } - _position = t; - /* XXX: don't seek audio because we don't need to... */ } @@ -236,6 +238,8 @@ struct ContentSorter void Player::setup_pieces () { +// cout << "----- Player SETUP PIECES.\n"; + list<shared_ptr<Piece> > old_pieces = _pieces; _pieces.clear (); @@ -257,6 +261,7 @@ Player::setup_pieces () fd->Audio.connect (bind (&Player::process_audio, this, *i, _1, _2)); decoder = fd; +// cout << "\tFFmpeg @ " << fc->start() << " -- " << fc->end() << "\n"; } shared_ptr<const ImageMagickContent> ic = dynamic_pointer_cast<const ImageMagickContent> (*i); @@ -277,6 +282,7 @@ Player::setup_pieces () } decoder = id; +// cout << "\tImageMagick @ " << ic->start() << " -- " << ic->end() << "\n"; } shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i); @@ -285,6 +291,7 @@ Player::setup_pieces () sd->Audio.connect (bind (&Player::process_audio, this, *i, _1, _2)); decoder = sd; +// cout << "\tSndfile @ " << sc->start() << " -- " << sc->end() << "\n"; } _pieces.push_back (shared_ptr<Piece> (new Piece (*i, decoder))); @@ -303,6 +310,7 @@ Player::setup_pieces () shared_ptr<BlackDecoder> bd (new BlackDecoder (_film, nc)); bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3, _4)); _pieces.push_back (shared_ptr<Piece> (new Piece (nc, bd))); +// cout << "\tblack @ " << video_pos << " -- " << (video_pos + diff) << "\n"; } video_pos = (*i)->content->end(); @@ -313,12 +321,11 @@ Player::setup_pieces () shared_ptr<SilenceDecoder> sd (new SilenceDecoder (_film, nc)); sd->Audio.connect (bind (&Player::process_audio, this, nc, _1, _2)); _pieces.push_back (shared_ptr<Piece> (new Piece (nc, sd))); +// cout << "\tsilence @ " << audio_pos << " -- " << (audio_pos + diff) << "\n"; } audio_pos = (*i)->content->end(); } } - - _position = 0; } void diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index de15635b6..96bd2ccd4 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -44,21 +44,32 @@ public: } - virtual void paint (wxGraphicsContext *) = 0; - virtual Rect bbox () const = 0; - + void paint (wxGraphicsContext* g) + { + _last_paint_bbox = bbox (); + do_paint (g); + } + void force_redraw () { + _timeline.force_redraw (_last_paint_bbox); _timeline.force_redraw (bbox ()); } + virtual Rect bbox () const = 0; + protected: + virtual void do_paint (wxGraphicsContext *) = 0; + int time_x (Time t) const { return _timeline.tracks_position().x + t * _timeline.pixels_per_time_unit(); } Timeline& _timeline; + +private: + Rect _last_paint_bbox; }; class ContentView : public View @@ -70,10 +81,44 @@ public: , _track (t) , _selected (false) { + c->Changed.connect (bind (&ContentView::content_changed, this, _2)); + } + + Rect bbox () const + { + shared_ptr<const Film> film = _timeline.film (); + shared_ptr<const Content> content = _content.lock (); + if (!film || !content) { + return Rect (); + } + + return Rect ( + time_x (content->start ()) - 8, + y_pos (_track) - 8, + content->length () * _timeline.pixels_per_time_unit() + 16, + _timeline.track_height() + 16 + ); + } + + void set_selected (bool s) { + _selected = s; + force_redraw (); + } + + bool selected () const { + return _selected; + } + weak_ptr<Content> content () const { + return _content; } - void paint (wxGraphicsContext* gc) + virtual wxString type () const = 0; + virtual wxColour colour () const = 0; + +private: + + void do_paint (wxGraphicsContext* gc) { shared_ptr<const Film> film = _timeline.film (); shared_ptr<const Content> content = _content.lock (); @@ -125,43 +170,16 @@ public: gc->ResetClip (); } - Rect bbox () const + int y_pos (int t) const { - shared_ptr<const Film> film = _timeline.film (); - shared_ptr<const Content> content = _content.lock (); - if (!film || !content) { - return Rect (); - } - - return Rect ( - time_x (content->start ()), - y_pos (_track), - content->length () * _timeline.pixels_per_time_unit(), - _timeline.track_height() - ); - } - - void set_selected (bool s) { - _selected = s; - force_redraw (); - } - - bool selected () const { - return _selected; - } - - weak_ptr<Content> content () const { - return _content; + return _timeline.tracks_position().y + t * _timeline.track_height(); } - virtual wxString type () const = 0; - virtual wxColour colour () const = 0; - -private: - - int y_pos (int t) const + void content_changed (int p) { - return _timeline.tracks_position().y + t * _timeline.track_height(); + if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) { + force_redraw (); + } } boost::weak_ptr<Content> _content; @@ -216,7 +234,7 @@ public: , _y (y) {} - void paint (wxGraphicsContext* gc) + void do_paint (wxGraphicsContext* gc) { #if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxPENSTYLE_SOLID)); @@ -309,7 +327,6 @@ Timeline::Timeline (wxWindow* parent, shared_ptr<const Film> film) playlist_changed (); film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this)); - film->playlist()->ContentChanged.connect (bind (&Timeline::playlist_changed, this)); } void @@ -386,13 +403,19 @@ Timeline::left_down (wxMouseEvent& ev) _down_view.reset (); - for (list<shared_ptr<View> >::iterator j = _views.begin(); j != _views.end(); ++j) { - shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*j); + if (i != _views.end ()) { + shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*i); if (cv) { _down_view = cv; shared_ptr<Content> c = cv->content().lock(); assert (c); _down_view_start = c->start (); + } + } + + for (list<shared_ptr<View> >::iterator j = _views.begin(); j != _views.end(); ++j) { + shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*j); + if (cv) { cv->set_selected (i == j); } } @@ -429,9 +452,7 @@ Timeline::mouse_moved (wxMouseEvent& ev) if (_down_view) { shared_ptr<Content> c = _down_view->content().lock(); if (c) { - _down_view->force_redraw (); c->set_start (_down_view_start + time_diff); - _down_view->force_redraw (); } } } |
