Add FilmViewer::time_until_next_frame.
[dcpomatic.git] / src / wx / audio_mapping_view.h
1 /*
2     Copyright (C) 2013-2019 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 /** @file  src/wx/audio_mapping_view.h
22  *  @brief AudioMappingView class.
23  *
24  */
25
26 #include <boost/signals2.hpp>
27 #include <wx/wx.h>
28 #include "lib/audio_mapping.h"
29
30 /** @class AudioMappingView
31  *  @brief This class displays the mapping of one set of audio channels to another,
32  *  with gain values on each node of the map.
33  *
34  *  The AudioMapping passed to set() describes the actual channel mapping,
35  *  and the names passed to set_input_channels() and set_output_channels() are
36  *  used to label the rows and columns.
37  *
38  *  The display's row count is equal to the AudioMapping's input channel count,
39  *  and the column count is equal to the number of name passed to
40  *  set_output_channels().  Any other output channels in the AudioMapping are
41  *  hidden from view.  Thus input channels are never hidden but output channels
42  *  might be.
43  */
44
45 class AudioMappingView : public wxPanel
46 {
47 public:
48         explicit AudioMappingView (wxWindow *, wxString left_label, wxString from, wxString top_label, wxString to);
49
50         void set (AudioMapping);
51         void set_input_channels (std::vector<std::string> const & names);
52         void set_output_channels (std::vector<std::string> const & names);
53
54         struct Group
55         {
56                 Group (int f, int t, std::string n)
57                         : from (f)
58                         , to (t)
59                         , name (n)
60                 {}
61
62                 /** First channel index (from 0) */
63                 int from;
64                 /** Last channel index (from 0) */
65                 int to;
66                 /** Name of this group */
67                 std::string name;
68         };
69
70         void set_input_groups (std::vector<Group> const & groups);
71
72         boost::signals2::signal<void (AudioMapping)> Changed;
73
74 private:
75         void map_values_changed ();
76         void setup_sizes ();
77         void paint ();
78         void paint_static (wxDC& dc, wxGraphicsContext* gc);
79         void paint_column_labels (wxDC& dc, wxGraphicsContext* gc);
80         void paint_column_lines (wxGraphicsContext* gc);
81         void paint_row_labels (wxDC& dc, wxGraphicsContext* gc);
82         void paint_row_lines (wxGraphicsContext* gc);
83         void paint_indicators (wxDC& dc);
84         void size (wxSizeEvent &);
85         void scroll ();
86         void left_down (wxMouseEvent &);
87         void right_down (wxMouseEvent &);
88         void motion (wxMouseEvent &);
89         void mouse_wheel (wxMouseEvent &);
90         boost::optional<std::pair<int, int> > mouse_event_to_channels (wxMouseEvent& ev) const;
91         boost::optional<std::string> mouse_event_to_input_group_name (wxMouseEvent& ev) const;
92         void setup ();
93         wxString safe_input_channel_name (int n) const;
94         wxString safe_output_channel_name (int n) const;
95
96         void off ();
97         void full ();
98         void minus6dB ();
99         void edit ();
100
101         AudioMapping _map;
102
103         wxMenu* _menu;
104         wxPanel* _body;
105         wxScrollBar* _vertical_scroll;
106         wxScrollBar* _horizontal_scroll;
107         int _menu_input;
108         int _menu_output;
109
110         wxString _left_label;
111         wxString _from;
112         wxString _top_label;
113         wxString _to;
114
115         std::vector<std::string> _input_channels;
116         std::vector<std::string> _output_channels;
117         std::vector<Group> _input_groups;
118
119         boost::optional<std::pair<int, int> > _last_tooltip_channels;
120 };