2 Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 SimpleVideoView::SimpleVideoView (wxWindow* parent)
23 _panel = new wxPanel (parent);
26 _panel->SetDoubleBuffered (true);
29 _panel->SetBackgroundStyle (wxBG_STYLE_PAINT);
30 _panel->SetBackgroundColour (*wxBLACK);
32 _panel->Bind (wxEVT_PAINT, boost::bind (&SimpleVideoView::paint, this));
36 SimpleVideoView::paint ()
38 wxPaintDC dc (_panel);
40 #ifdef DCPOMATIC_VARIANT_SWAROOP
41 if (_background_image) {
43 maybe_draw_background_image (dc);
44 _state_timer.unset ();
49 if (!_out_size.width || !_out_size.height || !_film || !_frame || _out_size != _frame->size()) {
53 wxImage frame (_out_size.width, _out_size.height, _frame->data()[0], true);
54 wxBitmap frame_bitmap (frame);
55 dc.DrawBitmap (frame_bitmap, 0, max(0, (_panel_size.height - _out_size.height) / 2));
57 #ifdef DCPOMATIC_VARIANT_SWAROOP
58 DCPTime const period = DCPTime::from_seconds(Config::instance()->player_watermark_period() * 60);
59 int64_t n = _video_position.get() / period.get();
60 DCPTime from(n * period.get());
61 DCPTime to = from + DCPTime::from_seconds(Config::instance()->player_watermark_duration() / 1000.0);
62 if (from <= _video_position && _video_position <= to) {
65 _watermark_x = rand() % _panel_size.width;
66 _watermark_y = rand() % _panel_size.height;
68 dc.SetTextForeground(*wxWHITE);
69 string wm = Config::instance()->player_watermark_theatre();
70 boost::posix_time::ptime t = boost::posix_time::second_clock::local_time();
71 wm += "\n" + boost::posix_time::to_iso_extended_string(t);
72 dc.DrawText(std_to_wx(wm), _watermark_x, _watermark_y);
74 _in_watermark = false;
79 if (_out_size.width < _panel_size.width) {
80 /* XXX: these colours are right for GNOME; may need adjusting for other OS */
81 wxPen p (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
82 wxBrush b (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
85 dc.DrawRectangle (_out_size.width, 0, _panel_size.width - _out_size.width, _panel_size.height);
88 if (_out_size.height < _panel_size.height) {
89 wxPen p (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
90 wxBrush b (_pad_black ? wxColour(0, 0, 0) : wxColour(240, 240, 240));
93 int const gap = (_panel_size.height - _out_size.height) / 2;
94 dc.DrawRectangle (0, 0, _panel_size.width, gap);
95 dc.DrawRectangle (0, gap + _out_size.height + 1, _panel_size.width, gap + 1);
98 if (_outline_content) {
99 wxPen p (wxColour (255, 0, 0), 2);
101 dc.SetBrush (*wxTRANSPARENT_BRUSH);
102 dc.DrawRectangle (_inter_position.x, _inter_position.y + (_panel_size.height - _out_size.height) / 2, _inter_size.width, _inter_size.height);