X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fwx%2Ffilm_viewer.cc;h=ab53a9d154c48f21a2ae03db46890aed986f71e5;hb=bc5253cec3293a3cde39f5b9fea491a6be720640;hp=6469d0962bce8c4560d2858276178eb21a20652a;hpb=df52b97f307605aad15ab5f01c8fdcf93afc9d15;p=dcpomatic.git diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 6469d0962..ab53a9d15 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -67,9 +67,7 @@ FilmViewer::FilmViewer (shared_ptr f, wxWindow* p) _panel->SetDoubleBuffered (true); #endif -#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 _panel->SetBackgroundStyle (wxBG_STYLE_PAINT); -#endif _v_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_v_sizer); @@ -131,6 +129,7 @@ FilmViewer::set_film (shared_ptr f) _player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _2, _3)); _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this)); + calculate_sizes (); fetch_current_frame_again (); } @@ -141,8 +140,13 @@ FilmViewer::fetch_current_frame_again () return; } - /* This will cause a Player::Changed to be emitted */ - _player->seek (_player->video_position() - _film->video_frames_to_time (1)); + Time const t = _film->video_frames_to_time (1); + + /* This 2.5 is, in theory: 1 to get back to the same frame, 1 more + because we are about to call fetch_next_frame(), and 0.5 for luck. + */ + + _player->seek (_player->video_position() - t * 2.5, true); fetch_next_frame (); } @@ -174,7 +178,7 @@ FilmViewer::paint_panel (wxPaintEvent &) return; } - shared_ptr packed_frame (new SimpleImage (_frame, false)); + shared_ptr packed_frame (new Image (_frame, false)); wxImage frame (_out_size.width, _out_size.height, packed_frame->data()[0], true); wxBitmap frame_bitmap (frame); @@ -202,7 +206,7 @@ void FilmViewer::slider_moved (wxScrollEvent &) { if (_film && _player) { - _player->seek (_slider->GetValue() * _film->length() / 4096); + _player->seek (_slider->GetValue() * _film->length() / 4096, false); fetch_next_frame (); } } @@ -212,6 +216,7 @@ FilmViewer::panel_sized (wxSizeEvent& ev) { _panel_size.width = ev.GetSize().GetWidth(); _panel_size.height = ev.GetSize().GetHeight(); + calculate_sizes (); fetch_current_frame_again (); } @@ -274,7 +279,7 @@ FilmViewer::process_video (shared_ptr image, bool, Time t) double const fps = _film->dcp_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 (t * fps / TIME_HZ)) + 1)); - + double w = static_cast(t) / TIME_HZ; int const h = (w / 3600); w -= h * 3600; @@ -299,7 +304,7 @@ FilmViewer::fetch_next_frame () try { _got_frame = false; - while (!_got_frame && !_player->pass ()); + while (!_got_frame && !_player->pass ()) {} } catch (DecodeError& e) { _play_button->SetValue (false); check_play_state (); @@ -336,8 +341,10 @@ FilmViewer::back_clicked (wxCommandEvent &) if (!_player) { return; } + + Time const t = _film->video_frames_to_time (1); - _player->seek_back (); + _player->seek (_player->video_position() - t * 2.5, true); fetch_next_frame (); }