Rename TYPE_DEBUG_PLAYER to TYPE_DEBUG_VIDEO_VIEW.
[dcpomatic.git] / src / wx / simple_video_view.cc
index 63dc102001b06344e64d78a2162b2cd7621f5f43..d68ea48ddf679c38c818e8394e00004882ca4620 100644 (file)
@@ -85,10 +85,10 @@ SimpleVideoView::paint ()
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
                DCPTime const period = DCPTime::from_seconds(Config::instance()->player_watermark_period() * 60);
-               int64_t n = _viewer->position().get() / period.get();
+               int64_t n = position().get() / period.get();
                DCPTime from(n * period.get());
                DCPTime to = from + DCPTime::from_seconds(Config::instance()->player_watermark_duration() / 1000.0);
-               if (from <= _viewer->position() && _viewer->position() <= to) {
+               if (from <= position() && position() <= to) {
                        if (!_in_watermark) {
                                _in_watermark = true;
                                _watermark_x = rand() % panel_size.GetWidth();
@@ -130,13 +130,22 @@ SimpleVideoView::paint ()
                dc.SetBrush (*wxTRANSPARENT_BRUSH);
                dc.DrawRectangle (_inter_position.x, _inter_position.y + (panel_size.GetHeight() - out_size.height) / 2, _inter_size.width, _inter_size.height);
        }
+
+       optional<dcpomatic::Rect<double> > subs = _viewer->outline_subtitles();
+       if (subs) {
+               wxPen p (wxColour(0, 255, 0), 2);
+               dc.SetPen (p);
+               dc.SetBrush (*wxTRANSPARENT_BRUSH);
+               dc.DrawRectangle (subs->x * out_size.width, subs->y * out_size.height, subs->width * out_size.width, subs->height * out_size.height);
+       }
+
         _state_timer.unset();
 }
 
 void
-SimpleVideoView::update ()
+SimpleVideoView::refresh_panel ()
 {
-       _state_timer.set ("update-view");
+       _state_timer.set ("refresh-panel");
        _panel->Refresh ();
        _panel->Update ();
        _state_timer.unset ();
@@ -150,16 +159,15 @@ SimpleVideoView::timer ()
        }
 
        display_next_frame (false);
-       DCPTime const next = _viewer->position() + _viewer->one_video_frame();
+       DCPTime const next = position() + _viewer->one_video_frame();
 
        if (next >= length()) {
-               _viewer->stop ();
-               _viewer->Finished ();
+               _viewer->finished ();
                return;
        }
 
-       LOG_DEBUG_PLAYER("%1 -> %2; delay %3", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0));
-       _timer.Start (time_until_next_frame(), wxTIMER_ONE_SHOT);
+       LOG_DEBUG_VIDEO_VIEW("%1 -> %2; delay %3", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0));
+       _timer.Start (max(1, time_until_next_frame().get_value_or(0)), wxTIMER_ONE_SHOT);
 
        if (_viewer->butler()) {
                _viewer->butler()->rethrow ();
@@ -193,7 +201,7 @@ SimpleVideoView::display_next_frame (bool non_blocking)
                }
        }
 
-       display_player_video ();
+       update ();
 
        try {
                _viewer->butler()->rethrow ();
@@ -205,11 +213,11 @@ SimpleVideoView::display_next_frame (bool non_blocking)
 }
 
 void
-SimpleVideoView::display_player_video ()
+SimpleVideoView::update ()
 {
        if (!player_video().first) {
                set_image (shared_ptr<Image>());
-               update ();
+               refresh_panel ();
                return;
        }
 
@@ -252,7 +260,5 @@ SimpleVideoView::display_player_video ()
        _inter_position = player_video().first->inter_position ();
        _inter_size = player_video().first->inter_size ();
 
-       update ();
-
-       _viewer->closed_captions_dialog()->update (_viewer->time());
+       refresh_panel ();
 }