Add new interface for setting reel breaks (#2678).
[dcpomatic.git] / src / wx / dcp_timeline_reel_marker_view.cc
1 /*
2     Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #include "dcp_timeline_reel_marker_view.h"
23 LIBDCP_DISABLE_WARNINGS
24 #include <wx/graphics.h>
25 LIBDCP_ENABLE_WARNINGS
26
27
28 using namespace std;
29 using namespace dcpomatic;
30
31
32 DCPTimelineReelMarkerView::DCPTimelineReelMarkerView(DCPTimeline& timeline, int y_pos)
33         : DCPTimelineView(timeline)
34         , _y_pos(y_pos)
35 {
36
37 }
38
39
40 int
41 DCPTimelineReelMarkerView::x_pos() const
42 {
43         /* Nudge it over slightly so that the full line width is drawn on the left hand side */
44         return time_x(_time) + 2;
45 }
46
47
48 void
49 DCPTimelineReelMarkerView::do_paint(wxGraphicsContext* gc)
50 {
51         wxColour const outline = _active ? wxColour(0, 0, 0) : wxColour(128, 128, 128);
52         wxColour const fill = _active ? wxColour(255, 0, 0) : wxColour(192, 192, 192);
53         gc->SetPen(*wxThePenList->FindOrCreatePen(outline, 2, wxPENSTYLE_SOLID));
54         gc->SetBrush(*wxTheBrushList->FindOrCreateBrush(fill, wxBRUSHSTYLE_SOLID));
55
56         gc->DrawRectangle(x_pos(), _y_pos, HEAD_SIZE, HEAD_SIZE);
57
58         auto path = gc->CreatePath();
59         path.MoveToPoint(x_pos(), _y_pos + HEAD_SIZE + TAIL_LENGTH);
60         path.AddLineToPoint(x_pos(), _y_pos);
61         gc->StrokePath(path);
62         gc->FillPath(path);
63 }
64
65
66 dcpomatic::Rect<int>
67 DCPTimelineReelMarkerView::bbox() const
68 {
69         return { x_pos(), _y_pos, HEAD_SIZE, HEAD_SIZE + TAIL_LENGTH };
70 }
71