Merge master.
[dcpomatic.git] / src / wx / film_viewer.cc
index 4d8685dd0cb232d3f95575c20f149500efd2119c..f8373d3fdc1f31655d9bea599396c24c4c880a1c 100644 (file)
@@ -58,7 +58,6 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        , _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
        , _display_frame_x (0)
        , _got_frame (false)
-       , _clear_required (false)
 {
        _panel->SetDoubleBuffered (true);
 #if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9
@@ -84,18 +83,6 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        _play_button->Connect (wxID_ANY, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler (FilmViewer::play_clicked), 0, this);
        _timer.Connect (wxID_ANY, wxEVT_TIMER, wxTimerEventHandler (FilmViewer::timer), 0, this);
 
-       if (f) {
-               /* We need a player before we set_film() so that the first frame will be displayed */
-               _player = f->player ();
-               _player->disable_audio ();
-               _player->disable_video_sync ();
-               /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them
-                  on and off without needing obtain a new Player.
-               */
-               
-               _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
-       }
-
        set_film (f);
 
        JobManager::instance()->ActiveJobsChanged.connect (
@@ -142,13 +129,22 @@ FilmViewer::set_film (shared_ptr<Film> f)
        if (_film == f) {
                return;
        }
-       
+
        _film = f;
 
        if (!_film) {
                return;
        }
 
+       _player = f->player ();
+       _player->disable_audio ();
+       _player->disable_video_sync ();
+       /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them
+          on and off without needing obtain a new Player.
+       */
+       
+       _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
+       
        _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));
 
        film_changed (Film::CONTENT);
@@ -196,11 +192,6 @@ FilmViewer::paint_panel (wxPaintEvent &)
 {
        wxPaintDC dc (_panel);
 
-       if (_clear_required) {
-               dc.Clear ();
-               _clear_required = false;
-       }
-
        if (!_display_frame || !_film || !_out_size.width || !_out_size.height) {
                dc.Clear ();
                return;
@@ -222,6 +213,22 @@ FilmViewer::paint_panel (wxPaintEvent &)
                wxBitmap sub_bitmap (sub);
                dc.DrawBitmap (sub_bitmap, _display_sub_position.x, _display_sub_position.y);
        }
+
+       if (_film_size.width < _panel_size.width) {
+               wxPen p (GetBackgroundColour ());
+               wxBrush b (GetBackgroundColour ());
+               dc.SetPen (p);
+               dc.SetBrush (b);
+               dc.DrawRectangle (_film_size.width, 0, _panel_size.width - _film_size.width, _panel_size.height);
+       }
+
+       if (_film_size.height < _panel_size.height) {
+               wxPen p (GetBackgroundColour ());
+               wxBrush b (GetBackgroundColour ());
+               dc.SetPen (p);
+               dc.SetBrush (b);
+               dc.DrawRectangle (0, _film_size.height, _panel_size.width, _panel_size.height - _film_size.height);
+       }               
 }
 
 
@@ -270,11 +277,6 @@ FilmViewer::raw_to_display ()
                return;
        }
 
-       libdcp::Size old_size;
-       if (_display_frame) {
-               old_size = _display_frame->size();
-       }
-
        shared_ptr<Image> input = _raw_frame;
 
        pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
@@ -285,10 +287,6 @@ FilmViewer::raw_to_display ()
        /* Get a compacted image as we have to feed it to wxWidgets */
        _display_frame = input->scale_and_convert_to_rgb (_film_size, 0, _film->scaler(), false);
 
-       if (old_size != _display_frame->size()) {
-               _clear_required = true;
-       }
-
        if (_raw_sub) {
 
                /* Our output is already cropped by the decoder, so we need to account for that