summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-11-05 23:51:20 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-08 21:56:47 +0100
commit694a9f48880efd428c8137e975de3581ad0a75a9 (patch)
tree577296e45dbfd2e0c93e2d55ab82d4909a9a6ae5
parent15e82df97cc99b94a7028313dff4eba213ecd84d (diff)
Remove PositionChanged in favour of consumers having their own GUI-thread timers.
-rw-r--r--src/wx/controls.cc9
-rw-r--r--src/wx/controls.h4
-rw-r--r--src/wx/film_viewer.cc2
-rw-r--r--src/wx/film_viewer.h1
-rw-r--r--src/wx/simple_video_view.cc1
-rw-r--r--src/wx/swaroop_controls.cc11
-rw-r--r--src/wx/swaroop_controls.h4
-rw-r--r--src/wx/timeline.cc8
-rw-r--r--src/wx/timeline.h4
9 files changed, 25 insertions, 19 deletions
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index b173b43ff..71af4e8cf 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -67,6 +67,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
, _forward_button (new Button (this, wxT(">")))
, _frame_number (new StaticText (this, wxT("")))
, _timecode (new StaticText (this, wxT("")))
+ , _timer (this)
{
_v_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (_v_sizer);
@@ -137,10 +138,12 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
_jump_to_selected->SetValue (Config::instance()->jump_to_selected ());
}
- _viewer->PositionChanged.connect (boost::bind(&Controls::position_changed, this));
_viewer->Started.connect (boost::bind(&Controls::started, this));
_viewer->Stopped.connect (boost::bind(&Controls::stopped, this));
+ Bind (wxEVT_TIMER, boost::bind(&Controls::update_position, this));
+ _timer.Start (80, wxTIMER_CONTINUOUS);
+
set_film (_viewer->film());
setup_sensitivity ();
@@ -172,7 +175,7 @@ Controls::stopped ()
}
void
-Controls::position_changed ()
+Controls::update_position ()
{
if (!_slider_being_moved) {
update_position_label ();
diff --git a/src/wx/controls.h b/src/wx/controls.h
index dfa11e6d7..014464456 100644
--- a/src/wx/controls.h
+++ b/src/wx/controls.h
@@ -87,7 +87,7 @@ private:
void image_changed (boost::weak_ptr<PlayerVideo>);
void outline_content_changed ();
void eye_changed ();
- void position_changed ();
+ void update_position ();
void film_change (ChangeType, Film::Property);
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
@@ -105,6 +105,8 @@ private:
ClosedCaptionsDialog* _closed_captions_dialog;
+ wxTimer _timer;
+
boost::signals2::scoped_connection _film_change_connection;
boost::signals2::scoped_connection _config_changed_connection;
};
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index dc6ed10c4..5c73f292c 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -256,7 +256,6 @@ FilmViewer::video_view_sized ()
if (!quick_refresh()) {
slow_refresh ();
}
- PositionChanged ();
}
void
@@ -380,7 +379,6 @@ FilmViewer::player_change (ChangeType type, int property, bool frequent)
if (!refreshed) {
slow_refresh ();
}
- PositionChanged ();
}
void
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index a59468c36..6b6aa78f5 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -141,7 +141,6 @@ public:
int time_until_next_frame () const;
boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
- boost::signals2::signal<void ()> PositionChanged;
boost::signals2::signal<void (dcpomatic::DCPTime)> Started;
boost::signals2::signal<void (dcpomatic::DCPTime)> Stopped;
/** While playing back we reached the end of the film (emitted from GUI thread) */
diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc
index 1e97adb30..619a35cce 100644
--- a/src/wx/simple_video_view.cc
+++ b/src/wx/simple_video_view.cc
@@ -193,7 +193,6 @@ SimpleVideoView::get (bool lazy)
}
display_player_video ();
- _viewer->PositionChanged ();
return true;
}
diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc
index 5ce6c45fc..add9bf3e0 100644
--- a/src/wx/swaroop_controls.cc
+++ b/src/wx/swaroop_controls.cc
@@ -54,6 +54,7 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
, _previous_button (new Button(this, "Previous"))
, _current_disable_timeline (false)
, _current_disable_next (false)
+ , _timer (this)
{
_button_sizer->Add (_previous_button, 0, wxEXPAND);
_button_sizer->Add (_play_button, 0, wxEXPAND);
@@ -112,10 +113,13 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
_spl_view->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
_spl_view->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
_viewer->Finished.connect (boost::bind(&SwaroopControls::viewer_finished, this));
- _viewer->PositionChanged.connect (boost::bind(&SwaroopControls::viewer_position_changed, this));
_refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::update_playlist_directory, this));
_refresh_content_view->Bind (wxEVT_BUTTON, boost::bind(&ContentView::update, _content_view));
+ /* Write position every two minutes if we're playing */
+ Bind (wxEVT_TIMER, boost::bind(&SwaroopControls::write_position, this));
+ _timer.Start (2 * 60 * 1000, wxTIMER_CONTINUOUS);
+
_content_view->update ();
update_playlist_directory ();
@@ -153,10 +157,9 @@ SwaroopControls::check_restart ()
}
void
-SwaroopControls::viewer_position_changed ()
+SwaroopControls::write_position ()
{
- /* Write position every two minutes if we're playing */
- if (!_selected_playlist || !_viewer->playing() || _viewer->position().get() % (2 * 60 * DCPTime::HZ)) {
+ if (!_selected_playlist || !_viewer->playing()) {
return;
}
diff --git a/src/wx/swaroop_controls.h b/src/wx/swaroop_controls.h
index 11dbcfc10..a8bb41dea 100644
--- a/src/wx/swaroop_controls.h
+++ b/src/wx/swaroop_controls.h
@@ -54,7 +54,7 @@ private:
void setup_sensitivity ();
void config_changed (int);
void viewer_finished ();
- void viewer_position_changed ();
+ void write_position ();
void reset_film ();
void update_current_content ();
bool can_do_previous ();
@@ -84,4 +84,6 @@ private:
std::vector<SPL> _playlists;
boost::optional<int> _selected_playlist;
int _selected_playlist_position;
+
+ wxTimer _timer;
};
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index daeeb0a51..9f71847f5 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -82,6 +82,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film, w
, _y_scroll_rate (16)
, _pixels_per_track (48)
, _first_resize (true)
+ , _timer (this)
{
#ifndef __WXOSX__
_labels_canvas->SetDoubleBuffered (true);
@@ -116,16 +117,15 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film, w
_film_changed_connection = film->Change.connect (bind (&Timeline::film_change, this, _1, _2));
_film_content_change_connection = film->ContentChange.connect (bind (&Timeline::film_content_change, this, _1, _3, _4));
- shared_ptr<FilmViewer> vp = viewer.lock ();
- DCPOMATIC_ASSERT (vp);
- _viewer_position_change_connection = vp->PositionChanged.connect (bind(&Timeline::position_change, this));
+ Bind (wxEVT_TIMER, boost::bind(&Timeline::update_playhead, this));
+ _timer.Start (200, wxTIMER_CONTINUOUS);
setup_scrollbars ();
_labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
}
void
-Timeline::position_change ()
+Timeline::update_playhead ()
{
Refresh ();
}
diff --git a/src/wx/timeline.h b/src/wx/timeline.h
index ef887dab8..44a897371 100644
--- a/src/wx/timeline.h
+++ b/src/wx/timeline.h
@@ -104,7 +104,7 @@ private:
void set_pixels_per_second (double pps);
void set_pixels_per_track (int h);
void zoom_all ();
- void position_change ();
+ void update_playhead ();
boost::shared_ptr<TimelineView> event_to_view (wxMouseEvent &);
TimelineContentViewList selected_views () const;
@@ -137,11 +137,11 @@ private:
int _y_scroll_rate;
int _pixels_per_track;
bool _first_resize;
+ wxTimer _timer;
static double const _minimum_pixels_per_second;
static int const _minimum_pixels_per_track;
boost::signals2::scoped_connection _film_changed_connection;
boost::signals2::scoped_connection _film_content_change_connection;
- boost::signals2::scoped_connection _viewer_position_change_connection;
};