2 Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 /** @file src/wx/audio_mapping_view.h
23 * @brief AudioMappingView class.
28 #include "lib/audio_mapping.h"
29 #include "lib/types.h"
30 #include "lib/warnings.h"
31 DCPOMATIC_DISABLE_WARNINGS
33 DCPOMATIC_ENABLE_WARNINGS
34 #include <boost/signals2.hpp>
37 /** @class AudioMappingView
38 * @brief This class displays the mapping of one set of audio channels to another,
39 * with gain values on each node of the map.
41 * The AudioMapping passed to set() describes the actual channel mapping,
42 * and the names passed to set_input_channels() and set_output_channels() are
43 * used to label the rows and columns.
45 * The display's row count is equal to the AudioMapping's input channel count,
46 * and the column count is equal to the number of name passed to
47 * set_output_channels(). Any other output channels in the AudioMapping are
48 * hidden from view. Thus input channels are never hidden but output channels
51 class AudioMappingView : public wxPanel
54 AudioMappingView (wxWindow *, wxString left_label, wxString from, wxString top_label, wxString to);
56 void set (AudioMapping);
57 void set_input_channels (std::vector<NamedChannel> const& channels);
58 void set_output_channels (std::vector<NamedChannel> const& channels);
62 Group (int f, int t, std::string n)
68 /** First channel index (from 0) */
70 /** Last channel index (from 0) */
72 /** Name of this group */
76 void set_input_groups (std::vector<Group> const & groups);
78 boost::signals2::signal<void (AudioMapping)> Changed;
81 void map_values_changed ();
83 void paint_static (wxDC& dc);
84 void paint_column_labels (wxDC& dc);
85 void paint_column_lines (wxDC& dc);
86 void paint_row_labels (wxDC& dc);
87 void paint_row_lines (wxDC& dc);
88 void paint_indicators (wxDC& dc);
89 void size (wxSizeEvent &);
91 void left_down (wxMouseEvent &);
92 void right_down (wxMouseEvent &);
93 void motion (wxMouseEvent &);
94 void mouse_wheel (wxMouseEvent &);
95 boost::optional<std::pair<NamedChannel, NamedChannel>> mouse_event_to_channels (wxMouseEvent& ev) const;
96 boost::optional<std::string> mouse_event_to_input_group_name (wxMouseEvent& ev) const;
98 wxString input_channel_name_with_group (NamedChannel const& n) const;
100 void set_gain_from_menu (double linear);
105 wxMenu* _menu = nullptr;
106 wxPanel* _body = nullptr;
107 wxScrollBar* _vertical_scroll = nullptr;
108 wxScrollBar* _horizontal_scroll = nullptr;
112 wxString _left_label;
117 std::vector<NamedChannel> _input_channels;
118 std::vector<NamedChannel> _output_channels;
119 std::vector<Group> _input_groups;
120 std::vector<int> _column_widths;
121 int _column_widths_total = 0;
123 boost::optional<std::pair<NamedChannel, NamedChannel>> _last_tooltip_channels;