From a19daa1abebf1a8e9e942387d2319a778187c0d3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 May 2019 23:22:00 +0100 Subject: [PATCH] Better tooltips over audio mapping view nodes. --- src/wx/audio_mapping_view.cc | 47 +++++++++++++++++++++++++++++++----- src/wx/audio_mapping_view.h | 2 ++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index ccd78bb90..5702d2ed6 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -526,6 +526,37 @@ AudioMappingView::set_output_channels (vector const & names) Refresh (); } +wxString +AudioMappingView::safe_input_channel_name (int n) const +{ + if (n >= int(_input_channels.size())) { + return wxString::Format ("%d", n + 1); + } + + optional group; + BOOST_FOREACH (Group i, _input_groups) { + if (i.from <= n && n <= i.to) { + group = std_to_wx (i.name); + } + } + + if (group) { + return wxString::Format ("%s/%s", group->data(), std_to_wx(_input_channels[n]).data()); + } + + return std_to_wx(_input_channels[n]); +} + +wxString +AudioMappingView::safe_output_channel_name (int n) const +{ + if (n >= int(_output_channels.size())) { + return wxString::Format ("%d", n + 1); + } + + return std_to_wx(_output_channels[n]); +} + void AudioMappingView::motion (wxMouseEvent& ev) { @@ -536,19 +567,23 @@ AudioMappingView::motion (wxMouseEvent& ev) 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 + _("No audio will be passed from content channel '%s' to DCP channel '%s'."), + safe_input_channel_name(channels->first), + safe_output_channel_name(channels->second) ); } 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 + _("Audio will be passed from content channel %s to DCP channel %s unaltered."), + safe_input_channel_name(channels->first), + safe_output_channel_name(channels->second) ); } 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 + _("Audio will be passed from content channel %s to DCP channel %s with gain %.1fdB."), + safe_input_channel_name(channels->first), + safe_output_channel_name(channels->second), + dB ); } diff --git a/src/wx/audio_mapping_view.h b/src/wx/audio_mapping_view.h index a96757b5c..fd8a16d5c 100644 --- a/src/wx/audio_mapping_view.h +++ b/src/wx/audio_mapping_view.h @@ -90,6 +90,8 @@ private: boost::optional > mouse_event_to_channels (wxMouseEvent& ev) const; boost::optional mouse_event_to_input_group_name (wxMouseEvent& ev) const; void setup (); + wxString safe_input_channel_name (int n) const; + wxString safe_output_channel_name (int n) const; void off (); void full (); -- 2.30.2