Fix up SimpleVideoView.
authorCarl Hetherington <cth@carlh.net>
Thu, 9 May 2019 00:17:46 +0000 (01:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 May 2019 22:43:55 +0000 (23:43 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/simple_video_view.cc
src/wx/simple_video_view.h
src/wx/wscript

index 1f718fa581c8a348b977b6587983a411d50a4115..5b2c5ff95abc78f21a9cbf47314bb9cef4f3eed5 100644 (file)
@@ -28,6 +28,7 @@
 #include "wx_util.h"
 #include "closed_captions_dialog.h"
 #include "gl_video_view.h"
+#include "simple_video_view.h"
 #include "lib/film.h"
 #include "lib/ratio.h"
 #include "lib/util.h"
@@ -79,7 +80,8 @@ rtaudio_callback (void* out, void *, unsigned int frames, double, RtAudioStreamS
 
 FilmViewer::FilmViewer (wxWindow* p)
        /* XXX: make this configurable */
-       : _video_view (new GLVideoView(p))
+//     : _video_view (new GLVideoView(p))
+       : _video_view (new SimpleVideoView(this, p))
        , _coalesce_player_changes (false)
        , _audio (DCPOMATIC_RTAUDIO_API)
        , _audio_channels (0)
index 93ca26da35fc32460ca7e95de4d75200879c1490..76917f8078122d3bfe46b4dc9255e86c7d3a15f1 100644 (file)
@@ -105,6 +105,23 @@ public:
                return _gets;
        }
 
+       /* Some accessors that VideoView classes need */
+       dcp::Size out_size () const {
+               return _out_size;
+       }
+       dcp::Size inter_size () const {
+               return _inter_size;
+       }
+       Position<int> inter_position () const {
+               return _inter_position;
+       }
+       bool outline_content () const {
+               return _outline_content;
+       }
+       bool pad_black () const {
+               return _pad_black;
+       }
+
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
        boost::signals2::signal<void ()> PositionChanged;
        boost::signals2::signal<void (dcpomatic::DCPTime)> Started;
index 3cc14625ea1876f6566d077180e3ab602a756f3b..6435e0226b0bb9f0e41c77f11a5fddf957b655a2 100644 (file)
 
 */
 
-SimpleVideoView::SimpleVideoView (wxWindow* parent)
+#include "simple_video_view.h"
+#include "film_viewer.h"
+#include "lib/image.h"
+#include <dcp/util.h>
+#include <wx/wx.h>
+#include <boost/bind.hpp>
+
+using std::max;
+
+SimpleVideoView::SimpleVideoView (FilmViewer* viewer, wxWindow* parent)
+       : _viewer (viewer)
 {
        _panel = new wxPanel (parent);
 
@@ -38,23 +48,26 @@ SimpleVideoView::paint ()
        wxPaintDC dc (_panel);
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
-       if (_background_image) {
+       if (viewer->background_image()) {
                dc.Clear ();
                maybe_draw_background_image (dc);
-               _state_timer.unset ();
                return;
        }
 #endif
 
-       if (!_out_size.width || !_out_size.height || !_film || !_frame || _out_size != _frame->size()) {
+       dcp::Size const out_size = _viewer->out_size ();
+       wxSize const panel_size = _panel->GetSize ();
+
+       if (!out_size.width || !out_size.height || !_image || out_size != _image->size()) {
                dc.Clear ();
        } else {
 
-               wxImage frame (_out_size.width, _out_size.height, _frame->data()[0], true);
+               wxImage frame (out_size.width, out_size.height, _image->data()[0], true);
                wxBitmap frame_bitmap (frame);
-               dc.DrawBitmap (frame_bitmap, 0, max(0, (_panel_size.height - _out_size.height) / 2));
+               dc.DrawBitmap (frame_bitmap, 0, max(0, (panel_size.GetHeight() - out_size.height) / 2));
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
+               XXX
                DCPTime const period = DCPTime::from_seconds(Config::instance()->player_watermark_period() * 60);
                int64_t n = _video_position.get() / period.get();
                DCPTime from(n * period.get());
@@ -76,29 +89,31 @@ SimpleVideoView::paint ()
 #endif
        }
 
-       if (_out_size.width < _panel_size.width) {
+       if (out_size.width < panel_size.GetWidth()) {
                /* XXX: these colours are right for GNOME; may need adjusting for other OS */
-               wxPen   p (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
-               wxBrush b (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
+               wxPen   p (_viewer->pad_black() ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
+               wxBrush b (_viewer->pad_black() ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
                dc.SetPen (p);
                dc.SetBrush (b);
-               dc.DrawRectangle (_out_size.width, 0, _panel_size.width - _out_size.width, _panel_size.height);
+               dc.DrawRectangle (out_size.width, 0, panel_size.GetWidth() - out_size.width, panel_size.GetHeight());
        }
 
-       if (_out_size.height < _panel_size.height) {
-               wxPen   p (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
-               wxBrush b (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
+       if (out_size.height < panel_size.GetHeight()) {
+               wxPen   p (_viewer->pad_black() ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
+               wxBrush b (_viewer->pad_black() ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
                dc.SetPen (p);
                dc.SetBrush (b);
-               int const gap = (_panel_size.height - _out_size.height) / 2;
-               dc.DrawRectangle (0, 0, _panel_size.width, gap);
-               dc.DrawRectangle (0, gap + _out_size.height + 1, _panel_size.width, gap + 1);
+               int const gap = (panel_size.GetHeight() - out_size.height) / 2;
+               dc.DrawRectangle (0, 0, panel_size.GetWidth(), gap);
+               dc.DrawRectangle (0, gap + out_size.height + 1, panel_size.GetWidth(), gap + 1);
        }
 
-       if (_outline_content) {
+       if (_viewer->outline_content()) {
+               Position<int> inter_position = _viewer->inter_position ();
+               dcp::Size inter_size = _viewer->inter_size ();
                wxPen p (wxColour (255, 0, 0), 2);
                dc.SetPen (p);
                dc.SetBrush (*wxTRANSPARENT_BRUSH);
-               dc.DrawRectangle (_inter_position.x, _inter_position.y + (_panel_size.height - _out_size.height) / 2, _inter_size.width, _inter_size.height);
+               dc.DrawRectangle (inter_position.x, inter_position.y + (panel_size.GetHeight() - out_size.height) / 2, inter_size.width, inter_size.height);
        }
 }
index 2eb62ab5f57dc1730e74a6f73c5a7a7143d122ff..8b3ec9f0bda91233857c978b25116c99baf46d20 100644 (file)
 
 */
 
+#include "video_view.h"
+#include <wx/wx.h>
+
+class FilmViewer;
+
 class SimpleVideoView : public VideoView
 {
 public:
-       SimpleVideoView (wxWindow* parent);
+       SimpleVideoView (FilmViewer* viewer, wxWindow* parent);
 
-       void set_image (boost::shared_ptr<const Image> image);
+       void set_image (boost::shared_ptr<const Image> image) {
+               _image = image;
+       }
 
        wxWindow* get () const {
                return _panel;
        }
 
 private:
+       void paint ();
+
+       FilmViewer* _viewer;
        wxPanel* _panel;
+       boost::shared_ptr<const Image> _image;
 };
index 9847187c615b124aa619508c5e7c020c5ef96be6..88987f1bf5db6346b2994d4c2b844a2e87e6bfc0 100644 (file)
@@ -116,6 +116,7 @@ sources = """
           send_i18n_dialog.cc
           server_dialog.cc
           servers_list_dialog.cc
+          simple_video_view.cc
           standard_controls.cc
           static_text.cc
           subtitle_appearance_dialog.cc