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