summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-01-15 00:14:51 +0000
committerCarl Hetherington <cth@carlh.net>2018-01-15 00:14:51 +0000
commitb93167217949c866135eeeefc1dae003a7fb88f7 (patch)
treeeedcf6d87e7a3d244cfd7f5a39a9c3ce9caaccaf /src
parenta203b32e34f7d8b2155d1d48f392112a5db8825d (diff)
Try to tidy up behaviour of seek during playback in the preview;
before play would continue during the drag which made it feel nasty. Now play stops during the drag (at least on Linux...)
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_viewer.cc27
-rw-r--r--src/wx/film_viewer.h5
2 files changed, 25 insertions, 7 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 5c218ae44..b160d7753 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -88,6 +88,8 @@ FilmViewer::FilmViewer (wxWindow* p, bool outline_content, bool jump_to_selected
, _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
, _coalesce_player_changes (false)
, _pending_player_change (false)
+ , _slider_being_moved (false)
+ , _was_running_before_slider (false)
, _audio (DCPOMATIC_RTAUDIO_API)
, _audio_channels (0)
, _audio_block_size (1024)
@@ -147,9 +149,9 @@ FilmViewer::FilmViewer (wxWindow* p, bool outline_content, bool jump_to_selected
_left_eye->Bind (wxEVT_RADIOBUTTON, boost::bind (&FilmViewer::refresh, this));
_right_eye->Bind (wxEVT_RADIOBUTTON, boost::bind (&FilmViewer::refresh, this));
_slider->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_CHANGED, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind (&FilmViewer::slider_released, this));
_play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind (&FilmViewer::play_clicked, this));
_timer.Bind (wxEVT_TIMER, boost::bind (&FilmViewer::timer, this));
_rewind_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&FilmViewer::rewind_clicked, this, _1));
@@ -400,13 +402,19 @@ FilmViewer::paint_panel ()
}
}
+/** @param page true if this was a PAGEUP/PAGEDOWN event for which we won't receive a THUMBRELEASE */
void
-FilmViewer::slider_moved (bool update_slider)
+FilmViewer::slider_moved (bool page)
{
if (!_film) {
return;
}
+ if (!page && !_slider_being_moved) {
+ /* This is the first event of a drag; stop playback for the duration of the drag */
+ _was_running_before_slider = stop ();
+ _slider_being_moved = true;
+ }
DCPTime t (_slider->GetValue() * _film->length().get() / 4096);
/* Ensure that we hit the end of the film at the end of the slider */
@@ -415,9 +423,16 @@ FilmViewer::slider_moved (bool update_slider)
}
seek (t, false);
update_position_label ();
- if (update_slider) {
- update_position_slider ();
+}
+
+void
+FilmViewer::slider_released ()
+{
+ if (_was_running_before_slider) {
+ /* Restart after a drag */
+ start ();
}
+ _slider_being_moved = false;
}
void
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 0c71ae1bd..1c4f3c693 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -72,7 +72,8 @@ public:
private:
void paint_panel ();
void panel_sized (wxSizeEvent &);
- void slider_moved (bool update_slider);
+ void slider_moved (bool page);
+ void slider_released ();
void play_clicked ();
void timer ();
void calculate_sizes ();
@@ -122,6 +123,8 @@ private:
wxTimer _timer;
bool _coalesce_player_changes;
bool _pending_player_change;
+ bool _slider_being_moved;
+ bool _was_running_before_slider;
boost::shared_ptr<const Image> _frame;
DCPTime _video_position;