Supporters update.
[dcpomatic.git] / src / wx / timeline_labels_view.cc
1 /*
2     Copyright (C) 2016-2021 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.h"
23 #include "timeline_labels_view.h"
24 #include "wx_util.h"
25 #include <dcp/warnings.h>
26 LIBDCP_DISABLE_WARNINGS
27 #include <wx/graphics.h>
28 #include <wx/wx.h>
29 LIBDCP_ENABLE_WARNINGS
30
31
32 using std::list;
33 using std::max;
34 using std::min;
35
36
37 TimelineLabelsView::TimelineLabelsView (Timeline& tl)
38         : TimelineView (tl)
39 {
40         wxString labels[] = {
41                 _("Video"),
42                 _("Audio"),
43                 _("Subtitles/captions"),
44                 _("Atmos")
45         };
46
47         wxClientDC dc (&_timeline);
48         for (int i = 0; i < 3; ++i) {
49                 auto size = dc.GetTextExtent (labels[i]);
50                 _width = max (_width, size.GetWidth());
51         }
52
53         _width += 24;
54 }
55
56
57 dcpomatic::Rect<int>
58 TimelineLabelsView::bbox () const
59 {
60         return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.pixels_per_track());
61 }
62
63
64 void
65 TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>>)
66 {
67         int const h = _timeline.pixels_per_track ();
68         wxColour const colour = gui_is_dark() ? *wxWHITE : *wxBLACK;
69         gc->SetFont(gc->CreateFont(wxNORMAL_FONT->Bold(), colour));
70
71         int fy = 0;
72         if (_video_tracks) {
73                 int ty = fy + _video_tracks * h;
74                 gc->DrawText (_("Video"), 0, (ty + fy) / 2 - 8);
75                 fy = ty;
76         }
77
78         if (_text_tracks) {
79                 int ty = fy + _text_tracks * h;
80                 gc->DrawText (_("Subtitles/captions"), 0, (ty + fy) / 2 - 8);
81                 fy = ty;
82         }
83
84         if (_atmos) {
85                 int ty = fy + h;
86                 gc->DrawText (_("Atmos"), 0, (ty + fy) / 2 - 8);
87                 fy = ty;
88         }
89
90         if (_audio_tracks) {
91                 int ty = _timeline.tracks() * h;
92                 gc->DrawText (_("Audio"), 0, (ty + fy) / 2 - 8);
93         }
94 }
95
96
97 void
98 TimelineLabelsView::set_video_tracks (int n)
99 {
100         _video_tracks = n;
101 }
102
103
104 void
105 TimelineLabelsView::set_audio_tracks (int n)
106 {
107         _audio_tracks = n;
108 }
109
110
111 void
112 TimelineLabelsView::set_text_tracks (int n)
113 {
114         _text_tracks = n;
115 }
116
117
118 void
119 TimelineLabelsView::set_atmos (bool s)
120 {
121         _atmos = s;
122 }