Prevent viewer updates on timeline drag (#175).
authorCarl Hetherington <cth@carlh.net>
Tue, 16 Jul 2013 10:49:08 +0000 (11:49 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 Jul 2013 10:49:08 +0000 (11:49 +0100)
src/lib/content.cc
src/lib/content.h
src/lib/player.cc
src/lib/player.h
src/lib/playlist.cc
src/lib/playlist.h
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/timeline.cc
src/wx/timeline.h

index 6a33e9f7e27ce8961ce6439d648138cf891af7ce..49c579fb618dac4a3672b3568263f8b1b91b6232 100644 (file)
@@ -24,6 +24,7 @@
 #include "util.h"
 
 using std::string;
+using std::set;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
@@ -33,6 +34,7 @@ int const ContentProperty::LENGTH = 401;
 Content::Content (shared_ptr<const Film> f, Time s)
        : _film (f)
        , _start (s)
+       , _change_signals_frequent (false)
 {
 
 }
@@ -41,12 +43,14 @@ Content::Content (shared_ptr<const Film> f, boost::filesystem::path p)
        : _film (f)
        , _file (p)
        , _start (0)
+       , _change_signals_frequent (false)
 {
 
 }
 
 Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
        : _film (f)
+       , _change_signals_frequent (false)
 {
        _file = node->string_child ("File");
        _digest = node->string_child ("Digest");
@@ -59,6 +63,7 @@ Content::Content (Content const & o)
        , _file (o._file)
        , _digest (o._digest)
        , _start (o._start)
+       , _change_signals_frequent (o._change_signals_frequent)
 {
 
 }
@@ -83,7 +88,7 @@ Content::examine (shared_ptr<Job>)
 void
 Content::signal_changed (int p)
 {
-       Changed (shared_from_this (), p);
+       Changed (shared_from_this (), p, _change_signals_frequent);
 }
 
 void
index a190a393fbe1ad52fadbc9a4bae6b7e0bb618db9..cd8914cba095b88aff3597d6def5cb167a280a1b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DCPOMATIC_CONTENT_H
 #define DCPOMATIC_CONTENT_H
 
+#include <set>
 #include <boost/filesystem.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread/mutex.hpp>
@@ -79,7 +80,11 @@ public:
                return start() + length();
        }
 
-       boost::signals2::signal<void (boost::weak_ptr<Content>, int)> Changed;
+       void set_change_signals_frequent (bool f) {
+               _change_signals_frequent = f;
+       }
+
+       boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed;
 
 protected:
        void signal_changed (int);
@@ -91,6 +96,7 @@ private:
        boost::filesystem::path _file;
        std::string _digest;
        Time _start;
+       bool _change_signals_frequent;
 };
 
 #endif
index 6ee8c50298d2a2a9a4a1b77e8604b6fdfa8af49c..50f401fb75fac7d3164ef3c80b10a654554575ea 100644 (file)
@@ -97,7 +97,7 @@ Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> p)
        , _audio_buffers (f->dcp_audio_channels(), 0)
 {
        _playlist->Changed.connect (bind (&Player::playlist_changed, this));
-       _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2));
+       _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
        _film->Changed.connect (bind (&Player::film_changed, this, _1));
        set_video_container_size (_film->container()->size (_film->full_frame ()));
 }
@@ -461,7 +461,7 @@ Player::setup_pieces ()
 }
 
 void
-Player::content_changed (weak_ptr<Content> w, int p)
+Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
 {
        shared_ptr<Content> c = w.lock ();
        if (!c) {
@@ -469,16 +469,16 @@ Player::content_changed (weak_ptr<Content> w, int p)
        }
 
        if (
-               p == ContentProperty::START || p == ContentProperty::LENGTH ||
-               p == VideoContentProperty::VIDEO_CROP || p == VideoContentProperty::VIDEO_RATIO
+               property == ContentProperty::START || property == ContentProperty::LENGTH ||
+               property == VideoContentProperty::VIDEO_CROP || property == VideoContentProperty::VIDEO_RATIO
                ) {
                
                _have_valid_pieces = false;
-               Changed ();
+               Changed (frequent);
 
-       } else if (p == SubtitleContentProperty::SUBTITLE_OFFSET || p == SubtitleContentProperty::SUBTITLE_SCALE) {
+       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) {
                update_subtitle ();
-               Changed ();
+               Changed (frequent);
        }
 }
 
@@ -486,7 +486,7 @@ void
 Player::playlist_changed ()
 {
        _have_valid_pieces = false;
-       Changed ();
+       Changed (false);
 }
 
 void
@@ -541,7 +541,7 @@ Player::film_changed (Film::Property p)
        */
 
        if (p == Film::SCALER || p == Film::WITH_SUBTITLES || p == Film::CONTAINER) {
-               Changed ();
+               Changed (false);
        }
 }
 
index 92a35804397609c2263708e5566fc82b4488a944..2d8eca9b3264909d5e2b452f7b89e0fe7e4f8f94 100644 (file)
@@ -71,8 +71,10 @@ public:
        /** Emitted when something has changed such that if we went back and emitted
         *  the last frame again it would look different.  This is not emitted after
         *  a seek.
+        *
+        *  The parameter is true if these signals are currently likely to be frequent.
         */
-       boost::signals2::signal<void ()> Changed;
+       boost::signals2::signal<void (bool)> Changed;
 
 private:
        friend class PlayerWrapper;
@@ -82,7 +84,7 @@ private:
        void process_subtitle (boost::weak_ptr<Piece>, boost::shared_ptr<Image>, dcpomatic::Rect<double>, Time, Time);
        void setup_pieces ();
        void playlist_changed ();
-       void content_changed (boost::weak_ptr<Content>, int);
+       void content_changed (boost::weak_ptr<Content>, int, bool);
        void do_seek (Time, bool);
        void flush ();
        void emit_black ();
index 1535ad61f1809a8e47ba1a47a2b966593cfbfdc0..5aa913bc79c5fcecda3803b534f09c36a3b37020 100644 (file)
@@ -70,13 +70,13 @@ Playlist::~Playlist ()
 }
 
 void
-Playlist::content_changed (weak_ptr<Content> c, int p)
+Playlist::content_changed (weak_ptr<Content> content, int property, bool frequent)
 {
-       if (p == ContentProperty::LENGTH) {
+       if (property == ContentProperty::LENGTH) {
                maybe_sequence_video ();
        }
        
-       ContentChanged (c, p);
+       ContentChanged (content, property, frequent);
 }
 
 
@@ -285,7 +285,7 @@ Playlist::reconnect ()
        _content_connections.clear ();
                
        for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
-               _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2)));
+               _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3)));
        }
 }
 
index 805df4d70b3f30eddbc7cb21f1cd34ae50dc3a67..0b928fe51e46b27378a3aab87284a0221cae920f 100644 (file)
@@ -89,10 +89,11 @@ public:
        void maybe_sequence_video ();
 
        mutable boost::signals2::signal<void ()> Changed;
-       mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
+       /** Third parameter is true if signals are currently being emitted frequently */
+       mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged;
        
 private:
-       void content_changed (boost::weak_ptr<Content>, int);
+       void content_changed (boost::weak_ptr<Content>, int, bool);
        void reconnect ();
 
        ContentList _content;
index cb5e6b4c2003063fd20060c963982b417c23a47d..cd331a25a4c859ee08bc017c248b0eaa1b583062 100644 (file)
@@ -129,7 +129,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
        _player = f->player ();
        _player->disable_audio ();
        _player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _3));
-       _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this));
+       _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
 
        calculate_sizes ();
        fetch_current_frame_again ();
@@ -377,8 +377,12 @@ FilmViewer::forward_clicked (wxCommandEvent &)
 }
 
 void
-FilmViewer::player_changed ()
+FilmViewer::player_changed (bool frequent)
 {
+       if (frequent) {
+               return;
+       }
+       
        calculate_sizes ();
        fetch_current_frame_again ();
 }
index 28fc4971d287eefbdc4a496814f750954e91abd6..5c8320295c9d8b9c4e3e39019c2bb11501494d99 100644 (file)
@@ -66,7 +66,7 @@ private:
        void active_jobs_changed (bool);
        void back_clicked (wxCommandEvent &);
        void forward_clicked (wxCommandEvent &);
-       void player_changed ();
+       void player_changed (bool);
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<Player> _player;
index 4e0737b41d2e17da4ce0810428dc9ea6c7e8084e..7f3c1996b4f7e22e5d935c88bf64d69f4004bc0e 100644 (file)
@@ -493,12 +493,28 @@ Timeline::left_down (wxMouseEvent& ev)
        _left_down = true;
        _down_point = ev.GetPosition ();
        _first_move = false;
+
+       if (_down_view) {
+               shared_ptr<Content> c = _down_view->content().lock ();
+               if (c) {
+                       c->set_change_signals_frequent (true);
+               }
+       }
 }
 
 void
-Timeline::left_up (wxMouseEvent &)
+Timeline::left_up (wxMouseEvent& ev)
 {
        _left_down = false;
+
+       if (_down_view) {
+               shared_ptr<Content> c = _down_view->content().lock ();
+               if (c) {
+                       c->set_change_signals_frequent (false);
+               }
+       }
+
+       set_start_from_event (ev);
 }
 
 void
@@ -508,6 +524,12 @@ Timeline::mouse_moved (wxMouseEvent& ev)
                return;
        }
 
+       set_start_from_event (ev);
+}
+
+void
+Timeline::set_start_from_event (wxMouseEvent& ev)
+{
        wxPoint const p = ev.GetPosition();
 
        if (!_first_move) {
index 3e984bfe1dcab4512c21928bb40104c2e322ee83..0470ed7b99c2e64300d981452694f8105d14b556 100644 (file)
@@ -70,6 +70,7 @@ private:
        void setup_pixels_per_time_unit ();
        void resized (wxSizeEvent &);
        void assign_tracks ();
+       void set_start_from_event (wxMouseEvent &);
 
        FilmEditor* _film_editor;
        boost::weak_ptr<Film> _film;