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