summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-16 11:49:08 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-16 11:49:08 +0100
commitd5085584d82c021e924cec6ce00e682a8e63d800 (patch)
treecfd1094beca5be9fd788d2ca264567e51cc729d1
parent6f5d58eb442a7808e00c6431c6289e82cf333658 (diff)
Prevent viewer updates on timeline drag (#175).
-rw-r--r--src/lib/content.cc7
-rw-r--r--src/lib/content.h8
-rw-r--r--src/lib/player.cc18
-rw-r--r--src/lib/player.h6
-rw-r--r--src/lib/playlist.cc8
-rw-r--r--src/lib/playlist.h5
-rw-r--r--src/wx/film_viewer.cc8
-rw-r--r--src/wx/film_viewer.h2
-rw-r--r--src/wx/timeline.cc24
-rw-r--r--src/wx/timeline.h1
10 files changed, 64 insertions, 23 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 6a33e9f7e..49c579fb6 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -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
diff --git a/src/lib/content.h b/src/lib/content.h
index a190a393f..cd8914cba 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -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
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 6ee8c5029..50f401fb7 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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);
}
}
diff --git a/src/lib/player.h b/src/lib/player.h
index 92a358043..2d8eca9b3 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -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 ();
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 1535ad61f..5aa913bc7 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -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)));
}
}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 805df4d70..0b928fe51 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -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;
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index cb5e6b4c2..cd331a25a 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -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 ();
}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 28fc4971d..5c8320295 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -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;
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 4e0737b41..7f3c1996b 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -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) {
diff --git a/src/wx/timeline.h b/src/wx/timeline.h
index 3e984bfe1..0470ed7b9 100644
--- a/src/wx/timeline.h
+++ b/src/wx/timeline.h
@@ -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;