No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / wx / timeline_labels_view.cc
1 /*
2     Copyright (C) 2016 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 "timeline_labels_view.h"
23 #include "timeline.h"
24 #include <wx/wx.h>
25 #include <wx/graphics.h>
26
27 using std::list;
28 using std::min;
29 using std::max;
30
31 TimelineLabelsView::TimelineLabelsView (Timeline& tl)
32         : TimelineView (tl)
33         , _threed (true)
34         , _subtitle (true)
35         , _atmos (true)
36 {
37         wxString labels[] = {
38                 _("Video"),
39                 _("Audio"),
40                 _("Subtitles"),
41                 _("Atmos")
42         };
43
44         _width = 0;
45
46         wxClientDC dc (&_timeline);
47         for (int i = 0; i < 3; ++i) {
48                 wxSize size = dc.GetTextExtent (labels[i]);
49                 _width = max (_width, size.GetWidth());
50         }
51
52         _width += 16;
53 }
54
55 dcpomatic::Rect<int>
56 TimelineLabelsView::bbox () const
57 {
58         return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.track_height());
59 }
60
61 void
62 TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> >)
63 {
64         int const h = _timeline.track_height ();
65         gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour (0, 0, 0)));
66
67         int fy = 0;
68         int ty = _threed ? 2 * h : h;
69         gc->DrawText (_("Video"),     0, _timeline.tracks_position().y + (ty + fy) / 2 - 8);
70         fy = ty;
71
72         if (_subtitle) {
73                 ty = fy + h;
74                 gc->DrawText (_("Subtitles"), 0, _timeline.tracks_position().y + (ty + fy) / 2 - 8);
75                 fy = ty;
76         }
77
78         if (_atmos) {
79                 ty = fy + h;
80                 gc->DrawText (_("Atmos"), 0, _timeline.tracks_position().y + (ty + fy) / 2 - 8);
81                 fy = ty;
82         }
83
84         ty = _timeline.tracks() * h;
85         gc->DrawText (_("Audio"), 0, _timeline.tracks_position().y + (ty + fy) / 2 - 8);
86 }
87
88 void
89 TimelineLabelsView::set_3d (bool s)
90 {
91         _threed = s;
92 }
93
94 void
95 TimelineLabelsView::set_subtitle (bool s)
96 {
97         _subtitle = s;
98 }
99
100 void
101 TimelineLabelsView::set_atmos (bool s)
102 {
103         _atmos = s;
104 }