From: Carl Hetherington Date: Tue, 14 May 2019 22:06:53 +0000 (+0100) Subject: Add tooltip for input groups (#1557). X-Git-Tag: v2.15.5~4 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=ca20cd4711c6b56ac238cf2313d2d4d1db92fe1a;p=dcpomatic.git Add tooltip for input groups (#1557). --- diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 9d776b63d..ccd78bb90 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -395,6 +395,24 @@ AudioMappingView::mouse_event_to_channels (wxMouseEvent& ev) const return make_pair (input, output); } +optional +AudioMappingView::mouse_event_to_input_group_name (wxMouseEvent& ev) const +{ + int const x = ev.GetX() + _horizontal_scroll->GetThumbPosition(); + if (x < GRID_SPACING || x > (2 * GRID_SPACING)) { + return optional(); + } + + int y = (ev.GetY() + _vertical_scroll->GetThumbPosition() - (GRID_SPACING * 2)) / GRID_SPACING; + BOOST_FOREACH (Group i, _input_groups) { + if (i.from <= y && y <= i.to) { + return i.name; + } + } + + return optional(); +} + void AudioMappingView::left_down (wxMouseEvent& ev) { @@ -512,28 +530,40 @@ void AudioMappingView::motion (wxMouseEvent& ev) { optional > channels = mouse_event_to_channels (ev); - if (!channels) { - SetToolTip (""); - _last_tooltip_channels = channels; - return; - } + if (channels) { + if (channels != _last_tooltip_channels) { + wxString s; + float const gain = _map.get(channels->first, channels->second); + if (gain == 0) { + s = wxString::Format ( + _("No audio will be passed from content channel %d to DCP channel %d."), + channels->first + 1, channels->second + 1 + ); + } else if (gain == 1) { + s = wxString::Format ( + _("Audio will be passed from content channel %d to DCP channel %d unaltered."), + channels->first + 1, channels->second + 1 + ); + } else { + float const dB = 20 * log10 (gain); + s = wxString::Format ( + _("Audio will be passed from content channel %d to DCP channel %d with gain %.1fdB."), + channels->first + 1, channels->second + 1, dB + ); + } - if (channels != _last_tooltip_channels) { - wxString s; - float const gain = _map.get(channels->first, channels->second); - if (gain == 0) { - s = wxString::Format (_("No audio will be passed from content channel %d to DCP channel %d."), channels->first + 1, channels->second + 1); - } else if (gain == 1) { - s = wxString::Format (_("Audio will be passed from content channel %d to DCP channel %d unaltered."), channels->first + 1, channels->second + 1); + SetToolTip (s + " " + _("Right click to change gain.")); + } + } else { + optional group = mouse_event_to_input_group_name (ev); + if (group) { + SetToolTip (std_to_wx(*group)); } else { - float const dB = 20 * log10 (gain); - s = wxString::Format (_("Audio will be passed from content channel %d to DCP channel %d with gain %.1fdB."), channels->first + 1, channels->second + 1, dB); + SetToolTip (""); } - - SetToolTip (s + " " + _("Right click to change gain.")); - _last_tooltip_channels = channels; } + _last_tooltip_channels = channels; ev.Skip (); } diff --git a/src/wx/audio_mapping_view.h b/src/wx/audio_mapping_view.h index 527510c77..a96757b5c 100644 --- a/src/wx/audio_mapping_view.h +++ b/src/wx/audio_mapping_view.h @@ -88,6 +88,7 @@ private: void motion (wxMouseEvent &); void mouse_wheel (wxMouseEvent &); boost::optional > mouse_event_to_channels (wxMouseEvent& ev) const; + boost::optional mouse_event_to_input_group_name (wxMouseEvent& ev) const; void setup (); void off ();