Accessor for ClosedCaptionsDialog.
[dcpomatic.git] / src / wx / timeline_audio_content_view.cc
1 /*
2     Copyright (C) 2013-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 #include "timeline_audio_content_view.h"
22 #include "wx_util.h"
23 #include "lib/audio_content.h"
24 #include "lib/util.h"
25
26 using std::list;
27 using boost::shared_ptr;
28 using boost::dynamic_pointer_cast;
29
30 /** @class TimelineAudioContentView
31  *  @brief Timeline view for AudioContent.
32  */
33
34 TimelineAudioContentView::TimelineAudioContentView (Timeline& tl, shared_ptr<Content> c)
35         : TimelineContentView (tl, c)
36 {
37
38 }
39
40 wxColour
41 TimelineAudioContentView::background_colour () const
42 {
43         return wxColour (149, 121, 232, 255);
44 }
45
46 wxColour
47 TimelineAudioContentView::foreground_colour () const
48 {
49         return wxColour (0, 0, 0, 255);
50 }
51
52 wxString
53 TimelineAudioContentView::label () const
54 {
55         wxString s = TimelineContentView::label ();
56         shared_ptr<AudioContent> ac = content()->audio;
57         DCPOMATIC_ASSERT (ac);
58
59         if (ac->gain() > 0.01) {
60                 s += wxString::Format (" +%.1fdB", ac->gain());
61         } else if (ac->gain() < -0.01) {
62                 s += wxString::Format (" %.1fdB", ac->gain());
63         }
64
65         if (ac->delay() > 0) {
66                 s += wxString::Format (_(" delayed by %dms"), ac->delay());
67         } else if (ac->delay() < 0) {
68                 s += wxString::Format (_(" advanced by %dms"), -ac->delay());
69         }
70
71         list<int> mapped = ac->mapping().mapped_output_channels();
72         if (!mapped.empty ()) {
73                 s += " → ";
74                 BOOST_FOREACH (int i, mapped) {
75                         s += std_to_wx(short_audio_channel_name(i)) + ", ";
76                 }
77                 s = s.Left(s.Length() - 2);
78         }
79
80         return s;
81 }