Remove unused RGBPlusAlphaImage; merge Image/SimpleImage.
[dcpomatic.git] / src / wx / film_viewer.cc
index 6469d0962bce8c4560d2858276178eb21a20652a..2cc63aea4da7d0e5185c010b9485fd893cadfc8c 100644 (file)
@@ -67,9 +67,7 @@ FilmViewer::FilmViewer (shared_ptr<Film> 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<Film> 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,9 @@ 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);
+       
+       _player->seek (_player->video_position() - t * 1.5, true);
        fetch_next_frame ();
 }
 
@@ -174,7 +174,7 @@ FilmViewer::paint_panel (wxPaintEvent &)
                return;
        }
 
-       shared_ptr<SimpleImage> packed_frame (new SimpleImage (_frame, false));
+       shared_ptr<Image> 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 +202,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 +212,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 +275,7 @@ FilmViewer::process_video (shared_ptr<const Image> 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<double>(t) / TIME_HZ;
        int const h = (w / 3600);
        w -= h * 3600;
@@ -299,7 +300,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 +337,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 ();
 }