From: Carl Hetherington Date: Sun, 14 Jun 2015 18:04:30 +0000 (+0100) Subject: Fix messed up position slider caused by trim changes. X-Git-Tag: v2.1.3~1 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=cea83d339056dbd0213d1eb327accd96ea0c3b46;ds=sidebyside Fix messed up position slider caused by trim changes. --- diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index bdbfc6c03..26d81ee86 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -130,7 +130,8 @@ FilmViewer::set_film (shared_ptr f) _frame.reset (); - update_position (); + update_position_slider (); + update_position_label (); if (!_film) { return; @@ -212,7 +213,6 @@ FilmViewer::get (DCPTime p, bool accurate) _position = p; } - update_position (); refresh_panel (); _last_get_accurate = accurate; @@ -222,6 +222,8 @@ void FilmViewer::timer () { get (_position + DCPTime::from_frames (1, _film->video_frame_rate ()), true); + update_position_label (); + update_position_slider (); } void @@ -275,6 +277,7 @@ FilmViewer::slider_moved () t = _film->length() - DCPTime::from_frames (1, _film->video_frame_rate ()); } get (t, false); + update_position_label (); } void @@ -285,6 +288,8 @@ FilmViewer::panel_sized (wxSizeEvent& ev) calculate_sizes (); get (_position, _last_get_accurate); + update_position_label (); + update_position_slider (); } void @@ -337,15 +342,13 @@ FilmViewer::check_play_state () } void -FilmViewer::update_position () +FilmViewer::update_position_slider () { if (!_film) { _slider->SetValue (0); - _frame_number->SetLabel ("0"); - _timecode->SetLabel ("0:0:0.0"); return; } - + DCPTime const len = _film->length (); if (len.get ()) { @@ -354,7 +357,17 @@ FilmViewer::update_position () _slider->SetValue (new_slider_position); } } - +} + +void +FilmViewer::update_position_label () +{ + if (!_film) { + _frame_number->SetLabel ("0"); + _timecode->SetLabel ("0:0:0.0"); + return; + } + double const fps = _film->video_frame_rate (); /* Count frame number from 1 ... not sure if this is the best idea */ _frame_number->SetLabel (wxString::Format (wxT("%d"), int (rint (_position.seconds() * fps)) + 1)); @@ -390,12 +403,16 @@ FilmViewer::back_clicked () } get (p, true); + update_position_label (); + update_position_slider (); } void FilmViewer::forward_clicked () { get (_position + DCPTime::from_frames (1, _film->video_frame_rate ()), true); + update_position_label (); + update_position_slider (); } void @@ -407,6 +424,8 @@ FilmViewer::player_changed (bool frequent) calculate_sizes (); get (_position, _last_get_accurate); + update_position_label (); + update_position_slider (); } void diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 9e4a454ea..f6ab1a567 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -56,7 +56,8 @@ private: void back_clicked (); void forward_clicked (); void player_changed (bool); - void update_position (); + void update_position_label (); + void update_position_slider (); void get (DCPTime, bool); void refresh_panel (); void setup_sensitivity ();