Extract colours to VideoView.
authorCarl Hetherington <cth@carlh.net>
Thu, 9 Sep 2021 18:29:44 +0000 (20:29 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 21 Sep 2021 07:46:56 +0000 (09:46 +0200)
src/wx/simple_video_view.cc
src/wx/video_view.cc
src/wx/video_view.h

index 55b05dfaaf9c641e910c105ac0cfb08cffbfb805..f5499ad9d4f6b93aa27113f7ed8d19992acd1abe 100644 (file)
@@ -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);
index 387d4052fd87b1f02298b8c6ba8dbac083b43dc8..4d80e2535248ceaccc35621bfa6c59435c3768b8 100644 (file)
@@ -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);
+       }
+}
+
index d7d60c21da14b4e933af418a8ea79ad223fdc574..9517a3bf479a2f31b8d9c7fdfbff955fa29e9509 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/signaller.h"
 #include "lib/timer.h"
 #include "lib/types.h"
+#include <wx/wx.h>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
 
@@ -131,6 +132,16 @@ protected:
        boost::optional<int> 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;