1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#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)
: VideoView (viewer)
{
_panel = new wxPanel (parent);
#ifndef __WXOSX__
_panel->SetDoubleBuffered (true);
#endif
_panel->SetBackgroundStyle (wxBG_STYLE_PAINT);
_panel->SetBackgroundColour (*wxBLACK);
_panel->Bind (wxEVT_PAINT, boost::bind (&SimpleVideoView::paint, this));
_panel->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized)));
}
void
SimpleVideoView::paint ()
{
_viewer->state_timer().set("paint-panel");
wxPaintDC dc (_panel);
#ifdef DCPOMATIC_VARIANT_SWAROOP
if (viewer->background_image()) {
dc.Clear ();
maybe_draw_background_image (dc);
return;
}
#endif
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, _image->data()[0], true);
wxBitmap frame_bitmap (frame);
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());
DCPTime to = from + DCPTime::from_seconds(Config::instance()->player_watermark_duration() / 1000.0);
if (from <= _video_position && _video_position <= to) {
if (!_in_watermark) {
_in_watermark = true;
_watermark_x = rand() % _panel_size.width;
_watermark_y = rand() % _panel_size.height;
}
dc.SetTextForeground(*wxWHITE);
string wm = Config::instance()->player_watermark_theatre();
boost::posix_time::ptime t = boost::posix_time::second_clock::local_time();
wm += "\n" + boost::posix_time::to_iso_extended_string(t);
dc.DrawText(std_to_wx(wm), _watermark_x, _watermark_y);
} else {
_in_watermark = false;
}
#endif
}
if (out_size.width < panel_size.GetWidth()) {
/* XXX: these colours are right for GNOME; may need adjusting for other OS */
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.GetWidth() - out_size.width, panel_size.GetHeight());
}
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.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 (_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.GetHeight() - out_size.height) / 2, inter_size.width, inter_size.height);
}
_viewer->state_timer().unset();
}
void
SimpleVideoView::update ()
{
_panel->Refresh ();
_panel->Update ();
}
|