From 6743eacf57a1209270f4021684425865bb72b00f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 9 May 2019 01:17:46 +0100 Subject: [PATCH] Fix up SimpleVideoView. --- src/wx/film_viewer.cc | 4 ++- src/wx/film_viewer.h | 17 +++++++++++++ src/wx/simple_video_view.cc | 51 ++++++++++++++++++++++++------------- src/wx/simple_video_view.h | 15 +++++++++-- src/wx/wscript | 1 + 5 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 1f718fa58..5b2c5ff95 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -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) diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 93ca26da3..76917f807 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -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 inter_position () const { + return _inter_position; + } + bool outline_content () const { + return _outline_content; + } + bool pad_black () const { + return _pad_black; + } + boost::signals2::signal)> ImageChanged; boost::signals2::signal PositionChanged; boost::signals2::signal Started; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 3cc14625e..6435e0226 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -18,7 +18,17 @@ */ -SimpleVideoView::SimpleVideoView (wxWindow* parent) +#include "simple_video_view.h" +#include "film_viewer.h" +#include "lib/image.h" +#include +#include +#include + +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 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); } } diff --git a/src/wx/simple_video_view.h b/src/wx/simple_video_view.h index 2eb62ab5f..8b3ec9f0b 100644 --- a/src/wx/simple_video_view.h +++ b/src/wx/simple_video_view.h @@ -18,17 +18,28 @@ */ +#include "video_view.h" +#include + +class FilmViewer; + class SimpleVideoView : public VideoView { public: - SimpleVideoView (wxWindow* parent); + SimpleVideoView (FilmViewer* viewer, wxWindow* parent); - void set_image (boost::shared_ptr image); + void set_image (boost::shared_ptr image) { + _image = image; + } wxWindow* get () const { return _panel; } private: + void paint (); + + FilmViewer* _viewer; wxPanel* _panel; + boost::shared_ptr _image; }; diff --git a/src/wx/wscript b/src/wx/wscript index 9847187c6..88987f1bf 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -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 -- 2.30.2