Add FilmViewer::time_until_next_frame.
[dcpomatic.git] / src / wx / timeline_labels_view.cc
1 /*
2     Copyright (C) 2016-2018 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         , _audio_tracks (0)
35         , _text_tracks (0)
36         , _atmos (true)
37 {
38         wxString labels[] = {
39                 _("Video"),
40                 _("Audio"),
41                 _("Subtitles/captions"),
42                 _("Atmos")
43         };
44
45         _width = 0;
46
47         wxClientDC dc (&_timeline);
48         for (int i = 0; i < 3; ++i) {
49                 wxSize size = dc.GetTextExtent (labels[i]);
50                 _width = max (_width, size.GetWidth());
51         }
52
53         _width += 24;
54 }
55
56 dcpomatic::Rect<int>
57 TimelineLabelsView::bbox () const
58 {
59         return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.pixels_per_track());
60 }
61
62 void
63 TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> >)
64 {
65         int const h = _timeline.pixels_per_track ();
66         gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour (0, 0, 0)));
67
68         int fy = 0;
69         int ty = _threed ? 2 * h : h;
70         gc->DrawText (_("Video"), 0, (ty + fy) / 2 - 8);
71         fy = ty;
72
73         if (_text_tracks) {
74                 ty = fy + _text_tracks * h;
75                 gc->DrawText (_("Subtitles/captions"), 0, (ty + fy) / 2 - 8);
76                 fy = ty;
77         }
78
79         if (_atmos) {
80                 ty = fy + h;
81                 gc->DrawText (_("Atmos"), 0, (ty + fy) / 2 - 8);
82                 fy = ty;
83         }
84
85         if (_audio_tracks) {
86                 ty = _timeline.tracks() * h;
87                 gc->DrawText (_("Audio"), 0, (ty + fy) / 2 - 8);
88         }
89 }
90
91 void
92 TimelineLabelsView::set_3d (bool s)
93 {
94         _threed = s;
95 }
96
97 void
98 TimelineLabelsView::set_audio_tracks (int n)
99 {
100         _audio_tracks = n;
101 }
102
103 void
104 TimelineLabelsView::set_text_tracks (int n)
105 {
106         _text_tracks = n;
107 }
108
109 void
110 TimelineLabelsView::set_atmos (bool s)
111 {
112         _atmos = s;
113 }