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.
27 #include "lib/audio_mapping.h"
28 #include "lib/named_channel.h"
29 #include <dcp/warnings.h>
30 LIBDCP_DISABLE_WARNINGS
32 LIBDCP_ENABLE_WARNINGS
33 #include <boost/signals2.hpp>
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.
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.
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
50 class AudioMappingView : public wxPanel
53 AudioMappingView (wxWindow *, wxString left_label, wxString from, wxString top_label, wxString to);
55 void set (AudioMapping);
56 void set_input_channels (std::vector<NamedChannel> const& channels);
57 void set_output_channels (std::vector<NamedChannel> const& channels);
61 Group (int f, int t, std::string n)
67 /** First channel index (from 0) */
69 /** Last channel index (from 0) */
71 /** Name of this group */
75 void set_input_groups (std::vector<Group> const & groups);
77 boost::signals2::signal<void (AudioMapping)> Changed;
80 void map_values_changed ();
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 left_down (wxMouseEvent &);
90 void right_down (wxMouseEvent &);
91 void motion (wxMouseEvent &);
92 boost::optional<std::pair<NamedChannel, NamedChannel>> mouse_event_to_channels (wxMouseEvent& ev) const;
93 boost::optional<std::string> mouse_event_to_input_group_name (wxMouseEvent& ev) const;
95 wxString input_channel_name_with_group (NamedChannel const& n) const;
96 int left_width() const;
98 void set_gain_from_menu (double linear);
103 wxMenu* _menu = nullptr;
107 wxString _left_label;
112 std::vector<NamedChannel> _input_channels;
113 std::vector<NamedChannel> _output_channels;
114 std::vector<Group> _input_groups;
115 std::vector<int> _column_widths;
116 int _column_widths_total = 0;
118 boost::optional<std::pair<NamedChannel, NamedChannel>> _last_tooltip_channels;