From 7f641936b00ec87b6eea2ef0a5daa1b1710cf9f4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 9 Sep 2021 20:29:44 +0200 Subject: [PATCH] Extract colours to VideoView. --- src/wx/simple_video_view.cc | 19 +++++++------------ src/wx/video_view.cc | 14 ++++++++++++++ src/wx/video_view.h | 11 +++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 55b05dfaa..f5499ad9d 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -74,24 +74,19 @@ SimpleVideoView::paint () dc.DrawBitmap (frame_bitmap, 0, max(0, (panel_size.GetHeight() - out_size.height) / 2)); } - auto pad_colour = wxColour(240, 240, 240); - if (_viewer->pad_black()) { - pad_colour = wxColour(0, 0, 0); - } else if (gui_is_dark()) { - pad_colour = wxColour(50, 50, 50); - } + auto pad = pad_colour(); if (out_size.width < panel_size.GetWidth()) { - wxPen p (pad_colour); - wxBrush b (pad_colour); + wxPen p (pad); + wxBrush b (pad); dc.SetPen (p); dc.SetBrush (b); dc.DrawRectangle (out_size.width, 0, panel_size.GetWidth() - out_size.width, panel_size.GetHeight()); } if (out_size.height < panel_size.GetHeight()) { - wxPen p (pad_colour); - wxBrush b (pad_colour); + wxPen p (pad); + wxBrush b (pad); dc.SetPen (p); dc.SetBrush (b); int const gap = (panel_size.GetHeight() - out_size.height) / 2; @@ -100,7 +95,7 @@ SimpleVideoView::paint () } if (_viewer->outline_content()) { - wxPen p (wxColour (255, 0, 0), 2); + wxPen p (outline_content_colour(), 2); dc.SetPen (p); 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); @@ -108,7 +103,7 @@ SimpleVideoView::paint () auto subs = _viewer->outline_subtitles(); if (subs) { - wxPen p (wxColour(0, 255, 0), 2); + wxPen p (outline_subtitles_colour(), 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); diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index 387d4052f..4d80e2535 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -173,3 +173,17 @@ VideoView::add_dropped () emit (boost::bind(boost::ref(TooManyDropped))); } } + + +wxColour +VideoView::pad_colour () const +{ + if (_viewer->pad_black()) { + return wxColour(0, 0, 0); + } else if (gui_is_dark()) { + return wxColour(50, 50, 50); + } else { + return wxColour(240, 240, 240); + } +} + diff --git a/src/wx/video_view.h b/src/wx/video_view.h index d7d60c21d..9517a3bf4 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -28,6 +28,7 @@ #include "lib/signaller.h" #include "lib/timer.h" #include "lib/types.h" +#include #include #include @@ -131,6 +132,16 @@ protected: boost::optional time_until_next_frame () const; dcpomatic::DCPTime one_video_frame () const; + wxColour pad_colour () const; + + wxColour outline_content_colour () const { + return wxColour(255, 0, 0); + } + + wxColour outline_subtitles_colour () const { + return wxColour(0, 255, 0); + } + int video_frame_rate () const { boost::mutex::scoped_lock lm (_mutex); return _video_frame_rate; -- 2.30.2