e1c96fdebe962d35784f5940c63aa03a52ed9a33
[dcpomatic.git] / src / wx / audio_mapping_view.cc
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.cc
22  *  @brief AudioMappingView class and helpers.
23  */
24
25 #include "audio_mapping_view.h"
26 #include "wx_util.h"
27 #include "audio_gain_dialog.h"
28 #include "lib/audio_mapping.h"
29 #include "lib/util.h"
30 #include "lib/warnings.h"
31 #include <dcp/locale_convert.h>
32 #include <dcp/types.h>
33 DCPOMATIC_DISABLE_WARNINGS
34 #include <wx/wx.h>
35 #include <wx/renderer.h>
36 #include <wx/grid.h>
37 #include <wx/graphics.h>
38 DCPOMATIC_ENABLE_WARNINGS
39 #include <boost/foreach.hpp>
40 #include <iostream>
41
42 using std::cout;
43 using std::list;
44 using std::string;
45 using std::min;
46 using std::max;
47 using std::vector;
48 using std::pair;
49 using std::make_pair;
50 using boost::shared_ptr;
51 using boost::optional;
52 using dcp::locale_convert;
53
54 #define INDICATOR_SIZE 20
55 #define GRID_SPACING 32
56 #define LEFT_WIDTH (GRID_SPACING * 3)
57 #define TOP_HEIGHT (GRID_SPACING * 2)
58
59 enum {
60         ID_off = 1,
61         ID_minus6dB = 2,
62         ID_0dB = 3,
63         ID_plus3dB = 4,
64         ID_edit = 5
65 };
66
67 AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxString from, wxString top_label, wxString to)
68         : wxPanel (parent, wxID_ANY)
69         , _menu_input (0)
70         , _menu_output (1)
71         , _left_label (left_label)
72         , _from (from)
73         , _top_label (top_label)
74         , _to (to)
75 {
76         _menu = new wxMenu;
77         _menu->Append (ID_off, _("Off"));
78         _menu->Append (ID_minus6dB, _("-6dB"));
79         _menu->Append (ID_0dB, _("0dB (unchanged)"));
80         _menu->Append (ID_plus3dB, _("+3dB"));
81         _menu->Append (ID_edit, _("Edit..."));
82
83         _body = new wxPanel (this, wxID_ANY);
84         _vertical_scroll = new wxScrollBar (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
85         _horizontal_scroll = new wxScrollBar (this, wxID_ANY);
86
87 #ifndef __WXOSX__
88         SetDoubleBuffered (true);
89 #endif
90
91         Bind (wxEVT_SIZE, boost::bind(&AudioMappingView::size, this, _1));
92         Bind (wxEVT_MENU, boost::bind(&AudioMappingView::set_gain_from_menu, this, 0), ID_off);
93         Bind (wxEVT_MENU, boost::bind(&AudioMappingView::set_gain_from_menu, this, db_to_linear(-6)), ID_minus6dB);
94         Bind (wxEVT_MENU, boost::bind(&AudioMappingView::set_gain_from_menu, this, 1), ID_0dB);
95         Bind (wxEVT_MENU, boost::bind(&AudioMappingView::set_gain_from_menu, this, db_to_linear(3)), ID_plus3dB);
96         Bind (wxEVT_MENU, boost::bind(&AudioMappingView::edit, this), ID_edit);
97         Bind (wxEVT_MOUSEWHEEL, boost::bind(&AudioMappingView::mouse_wheel, this, _1));
98         _body->Bind (wxEVT_PAINT, boost::bind(&AudioMappingView::paint, this));
99         _body->Bind (wxEVT_LEFT_DOWN, boost::bind(&AudioMappingView::left_down, this, _1));
100         _body->Bind (wxEVT_RIGHT_DOWN, boost::bind(&AudioMappingView::right_down, this, _1));
101         _body->Bind (wxEVT_MOTION, boost::bind(&AudioMappingView::motion, this, _1));
102         _vertical_scroll->Bind (wxEVT_SCROLL_TOP, boost::bind(&AudioMappingView::scroll, this));
103         _vertical_scroll->Bind (wxEVT_SCROLL_BOTTOM, boost::bind(&AudioMappingView::scroll, this));
104         _vertical_scroll->Bind (wxEVT_SCROLL_LINEUP, boost::bind(&AudioMappingView::scroll, this));
105         _vertical_scroll->Bind (wxEVT_SCROLL_LINEDOWN, boost::bind(&AudioMappingView::scroll, this));
106         _vertical_scroll->Bind (wxEVT_SCROLL_PAGEUP, boost::bind(&AudioMappingView::scroll, this));
107         _vertical_scroll->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind(&AudioMappingView::scroll, this));
108         _vertical_scroll->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind(&AudioMappingView::scroll, this));
109         _vertical_scroll->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind(&AudioMappingView::scroll, this));
110         _horizontal_scroll->Bind (wxEVT_SCROLL_TOP, boost::bind(&AudioMappingView::scroll, this));
111         _horizontal_scroll->Bind (wxEVT_SCROLL_BOTTOM, boost::bind(&AudioMappingView::scroll, this));
112         _horizontal_scroll->Bind (wxEVT_SCROLL_LINEUP, boost::bind(&AudioMappingView::scroll, this));
113         _horizontal_scroll->Bind (wxEVT_SCROLL_LINEDOWN, boost::bind(&AudioMappingView::scroll, this));
114         _horizontal_scroll->Bind (wxEVT_SCROLL_PAGEUP, boost::bind(&AudioMappingView::scroll, this));
115         _horizontal_scroll->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind(&AudioMappingView::scroll, this));
116         _horizontal_scroll->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind(&AudioMappingView::scroll, this));
117         _horizontal_scroll->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind(&AudioMappingView::scroll, this));
118 }
119
120 void
121 AudioMappingView::size (wxSizeEvent& ev)
122 {
123         setup ();
124         ev.Skip ();
125 }
126
127 void
128 AudioMappingView::setup ()
129 {
130         wxSize const s = GetSize();
131         int const w = _vertical_scroll->GetSize().GetWidth();
132         int const h = _horizontal_scroll->GetSize().GetHeight();
133
134         _vertical_scroll->SetPosition (wxPoint(s.GetWidth() - w, 0));
135         _vertical_scroll->SetSize (wxSize(w, max(0, s.GetHeight() - h)));
136
137         _body->SetSize (wxSize(max(0, s.GetWidth() - w), max(0, s.GetHeight() - h)));
138
139         _horizontal_scroll->SetPosition (wxPoint(0, s.GetHeight() - h));
140         _horizontal_scroll->SetSize (wxSize(max(0, s.GetWidth() - w), h));
141
142         _vertical_scroll->SetScrollbar (
143                 _vertical_scroll->GetThumbPosition(),
144                 s.GetHeight() - h - 8,
145                 GRID_SPACING * (2 + _input_channels.size()),
146                 GRID_SPACING,
147                 true
148                 );
149
150         _horizontal_scroll->SetScrollbar (
151                 _horizontal_scroll->GetThumbPosition(),
152                 s.GetWidth() - w - 8,
153                 GRID_SPACING * (3 + _output_channels.size()),
154                 GRID_SPACING,
155                 true);
156 }
157
158 void
159 AudioMappingView::scroll ()
160 {
161         Refresh ();
162 }
163
164 void
165 AudioMappingView::paint_static (wxDC& dc)
166 {
167         dc.SetFont (wxSWISS_FONT->Bold());
168         wxCoord label_width;
169         wxCoord label_height;
170
171         dc.GetTextExtent (_top_label, &label_width, &label_height);
172         dc.DrawText (_top_label, LEFT_WIDTH + (_output_channels.size() * GRID_SPACING - label_width) / 2, (GRID_SPACING - label_height) / 2);
173
174         dc.GetTextExtent (_left_label, &label_width, &label_height);
175         dc.DrawRotatedText (
176                 _left_label,
177                 (GRID_SPACING - label_height) / 2,
178                 TOP_HEIGHT + (_input_channels.size() * GRID_SPACING + label_width) / 2,
179                 90
180                 );
181
182         dc.SetFont (*wxSWISS_FONT);
183 }
184
185 void
186 AudioMappingView::paint_column_labels (wxDC& dc)
187 {
188         wxCoord label_width;
189         wxCoord label_height;
190         int N = 0;
191         BOOST_FOREACH (string i, _output_channels) {
192                 dc.GetTextExtent (std_to_wx(i), &label_width, &label_height);
193                 dc.DrawText (std_to_wx(i), LEFT_WIDTH + GRID_SPACING * N + (GRID_SPACING - label_width) / 2, GRID_SPACING + (GRID_SPACING - label_height) / 2);
194                 ++N;
195         }
196
197         dc.DrawLine(wxPoint(LEFT_WIDTH, GRID_SPACING), wxPoint(LEFT_WIDTH + _output_channels.size() * GRID_SPACING, GRID_SPACING));
198         dc.DrawLine(wxPoint(LEFT_WIDTH, GRID_SPACING * 2), wxPoint(LEFT_WIDTH + _output_channels.size() * GRID_SPACING, GRID_SPACING * 2));
199 }
200
201 void
202 AudioMappingView::paint_column_lines (wxDC& dc)
203 {
204         for (size_t i = 0; i < _output_channels.size(); ++i) {
205                 dc.DrawLine (
206                         wxPoint(LEFT_WIDTH + GRID_SPACING * i, GRID_SPACING),
207                         wxPoint(LEFT_WIDTH + GRID_SPACING * i, TOP_HEIGHT + _input_channels.size() * GRID_SPACING)
208                         );
209         }
210
211         dc.DrawLine (
212                 wxPoint(LEFT_WIDTH + GRID_SPACING * _output_channels.size(), GRID_SPACING),
213                 wxPoint(LEFT_WIDTH + GRID_SPACING * _output_channels.size(), TOP_HEIGHT + _input_channels.size() * GRID_SPACING)
214                 );
215 }
216
217 void
218 AudioMappingView::paint_row_labels (wxDC& dc)
219 {
220         wxCoord label_width;
221         wxCoord label_height;
222
223         /* Row channel labels */
224
225         int N = 0;
226         BOOST_FOREACH (string i, _input_channels) {
227                 dc.GetTextExtent (std_to_wx(i), &label_width, &label_height);
228                 dc.DrawText (std_to_wx(i), GRID_SPACING * 2 + (GRID_SPACING - label_width) / 2, TOP_HEIGHT + GRID_SPACING * N + (GRID_SPACING - label_height) / 2);
229                 ++N;
230         }
231
232         /* Vertical lines on the left */
233
234         for (int i = 1; i < 3; ++i) {
235                 dc.DrawLine (
236                         wxPoint(GRID_SPACING * i, TOP_HEIGHT),
237                         wxPoint(GRID_SPACING * i, TOP_HEIGHT + _input_channels.size() * GRID_SPACING)
238                         );
239         }
240
241         /* Group labels and lines */
242
243         int y = TOP_HEIGHT;
244         BOOST_FOREACH (Group i, _input_groups) {
245                 int const height = (i.to - i.from + 1) * GRID_SPACING;
246                 dc.GetTextExtent (std_to_wx(i.name), &label_width, &label_height);
247                 if (label_width > height) {
248                         label_width = height - 8;
249                 }
250
251                 {
252                         int yp = y;
253                         if ((yp - 2 * GRID_SPACING) < dc.GetLogicalOrigin().y) {
254                                 yp += dc.GetLogicalOrigin().y;
255                         }
256
257                         dc.DrawRotatedText (
258                                 std_to_wx(i.name),
259                                 GRID_SPACING + (GRID_SPACING - label_height) / 2,
260                                 y + (height + label_width) / 2,
261                                 90
262                                 );
263                 }
264
265                 dc.DrawLine (wxPoint(GRID_SPACING, y), wxPoint(GRID_SPACING * 2, y));
266                 y += height;
267         }
268
269         dc.DrawLine (wxPoint(GRID_SPACING, y), wxPoint(GRID_SPACING * 2, y));
270         }
271
272 void
273 AudioMappingView::paint_row_lines (wxDC& dc)
274 {
275         for (size_t i = 0; i < _input_channels.size(); ++i) {
276                 dc.DrawLine (
277                         wxPoint(GRID_SPACING * 2, TOP_HEIGHT + GRID_SPACING * i),
278                         wxPoint(LEFT_WIDTH + _output_channels.size() * GRID_SPACING, TOP_HEIGHT + GRID_SPACING * i)
279                         );
280         }
281         dc.DrawLine (
282                 wxPoint(GRID_SPACING * 2, TOP_HEIGHT + GRID_SPACING * _input_channels.size()),
283                 wxPoint(LEFT_WIDTH + _output_channels.size() * GRID_SPACING, TOP_HEIGHT + GRID_SPACING * _input_channels.size())
284                 );
285 }
286
287 void
288 AudioMappingView::paint_indicators (wxDC& dc)
289 {
290         /* _{input,output}_channels and _map may not always be in sync, be careful here */
291         size_t const output = min(_output_channels.size(), size_t(_map.output_channels()));
292         size_t const input = min(_input_channels.size(), size_t(_map.input_channels()));
293
294         for (size_t x = 0; x < output; ++x) {
295                 for (size_t y = 0; y < input; ++y) {
296                         dc.SetBrush (*wxWHITE_BRUSH);
297                         dc.DrawRectangle (
298                                 wxRect(
299                                         LEFT_WIDTH + x * GRID_SPACING + (GRID_SPACING - INDICATOR_SIZE) / 2,
300                                         TOP_HEIGHT + y * GRID_SPACING + (GRID_SPACING - INDICATOR_SIZE) / 2,
301                                         INDICATOR_SIZE, INDICATOR_SIZE
302                                         )
303                                 );
304
305                         float const value_dB = linear_to_db(_map.get(y, x));
306                         wxColour const colour = value_dB <= 0 ? wxColour(0, 255, 0) : wxColour(255, 150, 0);
307                         int const range = 18;
308                         int height = 0;
309                         if (value_dB > -range) {
310                                 height = min(INDICATOR_SIZE, static_cast<int>(INDICATOR_SIZE * (1 + value_dB / range)));
311                         }
312
313                         dc.SetBrush (*wxTheBrushList->FindOrCreateBrush(colour, wxBRUSHSTYLE_SOLID));
314                         dc.DrawRectangle (
315                                 wxRect(
316                                         LEFT_WIDTH + x * GRID_SPACING + (GRID_SPACING - INDICATOR_SIZE) / 2,
317                                         TOP_HEIGHT + y * GRID_SPACING + (GRID_SPACING - INDICATOR_SIZE) / 2 + INDICATOR_SIZE - height,
318                                         INDICATOR_SIZE, height
319                                         )
320                                 );
321                 }
322         }
323 }
324
325 static
326 void clip (wxDC& dc, int x, int y, int w, int h)
327 {
328         dc.SetClippingRegion (x, y, w, h);
329 }
330
331 static
332 void translate (wxDC& dc, int x, int y)
333 {
334         dc.SetLogicalOrigin (x, y);
335 }
336
337 static
338 void restore (wxDC& dc)
339 {
340         dc.SetLogicalOrigin (0, 0);
341         dc.DestroyClippingRegion ();
342 }
343
344 void
345 AudioMappingView::paint ()
346 {
347         wxPaintDC dc (_body);
348
349         int const hs = _horizontal_scroll->GetThumbPosition ();
350         int const vs = _vertical_scroll->GetThumbPosition ();
351
352         paint_static (dc);
353
354         clip (
355                 dc,
356                 LEFT_WIDTH,
357                 0,
358                 GRID_SPACING * _output_channels.size(),
359                 GRID_SPACING * (2 + _input_channels.size())
360              );
361         translate (dc, hs, 0);
362         paint_column_labels (dc);
363         restore (dc);
364
365         clip (
366                 dc,
367                 0,
368                 TOP_HEIGHT,
369                 GRID_SPACING * 3,
370                 min(int(GRID_SPACING * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
371              );
372         translate (dc, 0, vs);
373         paint_row_labels (dc);
374         restore (dc);
375
376         clip (
377                 dc,
378                 GRID_SPACING * 2,
379                 TOP_HEIGHT,
380                 GRID_SPACING * (1 + _output_channels.size()),
381                 min(int(GRID_SPACING * (2 + _input_channels.size())), GetSize().GetHeight() - TOP_HEIGHT)
382              );
383         translate (dc, hs, vs);
384         paint_row_lines (dc);
385         restore (dc);
386
387         clip (
388                 dc,
389                 LEFT_WIDTH,
390                 GRID_SPACING,
391                 GRID_SPACING * (1 + _output_channels.size()),
392                 min(int(GRID_SPACING * (1 + _input_channels.size())), GetSize().GetHeight() - GRID_SPACING)
393              );
394         translate (dc, hs, vs);
395         paint_column_lines (dc);
396         restore (dc);
397
398         clip (
399                 dc,
400                 LEFT_WIDTH,
401                 TOP_HEIGHT,
402                 GRID_SPACING * _output_channels.size(),
403                 min(int(GRID_SPACING * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
404              );
405         translate (dc, hs, vs);
406         paint_indicators (dc);
407         restore (dc);
408 }
409
410 optional<pair<int, int> >
411 AudioMappingView::mouse_event_to_channels (wxMouseEvent& ev) const
412 {
413         int const x = ev.GetX() + _horizontal_scroll->GetThumbPosition();
414         int const y = ev.GetY() + _vertical_scroll->GetThumbPosition();
415
416         if (x <= LEFT_WIDTH || y < TOP_HEIGHT) {
417                 return optional<pair<int, int> >();
418         }
419
420         int const input = (y - TOP_HEIGHT) / GRID_SPACING;
421         int const output = (x - LEFT_WIDTH) / GRID_SPACING;
422
423         if (input >= int(_input_channels.size()) || output >= int(_output_channels.size())) {
424                 return optional<pair<int, int> >();
425         }
426
427         return make_pair (input, output);
428 }
429
430 optional<string>
431 AudioMappingView::mouse_event_to_input_group_name (wxMouseEvent& ev) const
432 {
433         int const x = ev.GetX() + _horizontal_scroll->GetThumbPosition();
434         if (x < GRID_SPACING || x > (2 * GRID_SPACING)) {
435                 return optional<string>();
436         }
437
438         int y = (ev.GetY() + _vertical_scroll->GetThumbPosition() - (GRID_SPACING * 2)) / GRID_SPACING;
439         BOOST_FOREACH (Group i, _input_groups) {
440                 if (i.from <= y && y <= i.to) {
441                         return i.name;
442                 }
443         }
444
445         return optional<string>();
446 }
447
448 void
449 AudioMappingView::left_down (wxMouseEvent& ev)
450 {
451         optional<pair<int, int> > channels = mouse_event_to_channels (ev);
452         if (!channels) {
453                 return;
454         }
455
456         if (_map.get(channels->first, channels->second) > 0) {
457                 _map.set (channels->first, channels->second, 0);
458         } else {
459                 _map.set (channels->first, channels->second, 1);
460         }
461
462         map_values_changed ();
463 }
464
465 void
466 AudioMappingView::right_down (wxMouseEvent& ev)
467 {
468         optional<pair<int, int> > channels = mouse_event_to_channels (ev);
469         if (!channels) {
470                 return;
471         }
472
473         _menu_input = channels->first;
474         _menu_output = channels->second;
475         PopupMenu (_menu, ev.GetPosition());
476 }
477
478 void
479 AudioMappingView::mouse_wheel (wxMouseEvent& ev)
480 {
481         if (ev.ShiftDown()) {
482                 _horizontal_scroll->SetThumbPosition (
483                         _horizontal_scroll->GetThumbPosition() + (ev.GetWheelRotation() > 0 ? -GRID_SPACING : GRID_SPACING)
484                         );
485
486         } else {
487                 _vertical_scroll->SetThumbPosition (
488                         _vertical_scroll->GetThumbPosition() + (ev.GetWheelRotation() > 0 ? -GRID_SPACING : GRID_SPACING)
489                         );
490         }
491         Refresh ();
492 }
493
494 /** Called when any gain value has changed */
495 void
496 AudioMappingView::map_values_changed ()
497 {
498         Changed (_map);
499         _last_tooltip_channels = optional<pair<int, int> >();
500         Refresh ();
501 }
502
503 void
504 AudioMappingView::set_gain_from_menu (double linear)
505 {
506         _map.set (_menu_input, _menu_output, linear);
507         map_values_changed ();
508 }
509
510 void
511 AudioMappingView::edit ()
512 {
513         AudioGainDialog* dialog = new AudioGainDialog (this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
514         if (dialog->ShowModal() == wxID_OK) {
515                 _map.set (_menu_input, _menu_output, dialog->value ());
516                 map_values_changed ();
517         }
518
519         dialog->Destroy ();
520 }
521
522 void
523 AudioMappingView::set (AudioMapping map)
524 {
525         _map = map;
526         Refresh ();
527 }
528
529 void
530 AudioMappingView::set_input_channels (vector<string> const & names)
531 {
532         _input_channels = names;
533         setup ();
534         Refresh ();
535 }
536
537 void
538 AudioMappingView::set_output_channels (vector<string> const & names)
539 {
540         _output_channels = names;
541         setup ();
542         Refresh ();
543 }
544
545 wxString
546 AudioMappingView::safe_input_channel_name (int n) const
547 {
548         if (n >= int(_input_channels.size())) {
549                 return wxString::Format ("%d", n + 1);
550         }
551
552         optional<wxString> group;
553         BOOST_FOREACH (Group i, _input_groups) {
554                 if (i.from <= n && n <= i.to) {
555                         group = std_to_wx (i.name);
556                 }
557         }
558
559         if (group && !group->IsEmpty()) {
560                 return wxString::Format ("%s/%s", group->data(), std_to_wx(_input_channels[n]).data());
561         }
562
563         return std_to_wx(_input_channels[n]);
564 }
565
566 wxString
567 AudioMappingView::safe_output_channel_name (int n) const
568 {
569         if (n >= int(_output_channels.size())) {
570                 return wxString::Format ("%d", n + 1);
571         }
572
573         return std_to_wx(_output_channels[n]);
574 }
575
576 void
577 AudioMappingView::motion (wxMouseEvent& ev)
578 {
579         optional<pair<int, int> > channels = mouse_event_to_channels (ev);
580         if (channels) {
581                 if (channels != _last_tooltip_channels) {
582                         wxString s;
583                         float const gain = _map.get(channels->first, channels->second);
584                         if (gain == 0) {
585                                 s = wxString::Format (
586                                         _("No audio will be passed from %s channel '%s' to %s channel '%s'."),
587                                         _from,
588                                         safe_input_channel_name(channels->first),
589                                         _to,
590                                         safe_output_channel_name(channels->second)
591                                         );
592                         } else if (gain == 1) {
593                                 s = wxString::Format (
594                                         _("Audio will be passed from %s channel %s to %s channel %s unaltered."),
595                                         _from,
596                                         safe_input_channel_name(channels->first),
597                                         _to,
598                                         safe_output_channel_name(channels->second)
599                                         );
600                         } else {
601                                 float const dB = linear_to_db(gain);
602                                 s = wxString::Format (
603                                         _("Audio will be passed from %s channel %s to %s channel %s with gain %.1fdB."),
604                                         _from,
605                                         safe_input_channel_name(channels->first),
606                                         _to,
607                                         safe_output_channel_name(channels->second),
608                                         dB
609                                         );
610                         }
611
612                         SetToolTip (s + " " + _("Right click to change gain."));
613                 }
614         } else {
615                 optional<string> group = mouse_event_to_input_group_name (ev);
616                 if (group) {
617                         SetToolTip (std_to_wx(*group));
618                 } else {
619                         SetToolTip ("");
620                 }
621         }
622
623         _last_tooltip_channels = channels;
624         ev.Skip ();
625 }
626
627 void
628 AudioMappingView::set_input_groups (vector<Group> const & groups)
629 {
630         _input_groups = groups;
631 }