Use round() when moving the slider - try to make it the same as trim so that there...
[dcpomatic.git] / src / wx / film_viewer.cc
index ade45d766879ab4030f5dfcdc80fc9ea6b462535..2c0712e92bfb282a16fc34921b5f5c004d7103cf 100644 (file)
@@ -373,7 +373,7 @@ FilmViewer::paint_panel ()
 {
        wxPaintDC dc (_panel);
 
-       if (!_frame || !_film || !_out_size.width || !_out_size.height) {
+       if (!_frame || !_film || !_out_size.width || !_out_size.height || _out_size != _frame->size()) {
                dc.Clear ();
                return;
        }
@@ -421,6 +421,7 @@ FilmViewer::slider_moved (bool page)
        }
 
        DCPTime t (_slider->GetValue() * _film->length().get() / 4096);
+       t = t.round (_film->video_frame_rate());
        /* Ensure that we hit the end of the film at the end of the slider */
        if (t >= _film->length ()) {
                t = _film->length() - one_video_frame();
@@ -505,6 +506,10 @@ FilmViewer::check_play_state ()
 void
 FilmViewer::start ()
 {
+       if (!_film) {
+               return;
+       }
+
        if (_audio.isStreamOpen()) {
                _audio.setStreamTime (_video_position.seconds());
                _audio.startStream ();
@@ -576,7 +581,7 @@ FilmViewer::active_jobs_changed (optional<string> j)
 }
 
 DCPTime
-FilmViewer::nudge_amount (wxMouseEvent& ev)
+FilmViewer::nudge_amount (wxKeyboardState& ev)
 {
        DCPTime amount = one_video_frame ();
 
@@ -615,17 +620,35 @@ FilmViewer::rewind_clicked (wxMouseEvent& ev)
 }
 
 void
-FilmViewer::back_clicked (wxMouseEvent& ev)
+FilmViewer::back_frame ()
+{
+       if (!_film) {
+               return;
+       }
+
+       go_to (_video_position - one_video_frame());
+}
+
+void
+FilmViewer::forward_frame ()
+{
+       if (!_film) {
+               return;
+       }
+
+       go_to (_video_position + one_video_frame());
+}
+
+void
+FilmViewer::back_clicked (wxKeyboardState& ev)
 {
        go_to (_video_position - nudge_amount (ev));
-       ev.Skip ();
 }
 
 void
-FilmViewer::forward_clicked (wxMouseEvent& ev)
+FilmViewer::forward_clicked (wxKeyboardState& ev)
 {
        go_to (_video_position + nudge_amount (ev));
-       ev.Skip ();
 }
 
 void
@@ -796,7 +819,7 @@ FilmViewer::config_changed (Config::Property p)
                _audio.closeStream ();
        }
 
-       if (Config::instance()->sound()) {
+       if (Config::instance()->sound() && _audio.getDeviceCount() > 0) {
                unsigned int st = 0;
                if (Config::instance()->sound_output()) {
                        while (st < _audio.getDeviceCount()) {