summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-05-14 23:06:53 +0100
committerCarl Hetherington <cth@carlh.net>2019-05-14 23:06:53 +0100
commitca20cd4711c6b56ac238cf2313d2d4d1db92fe1a (patch)
treee8ca98c003a15b93857af883f8d487d7d72f60f9 /src
parentfaa42e385ec2e36e75347ba5da1e4e0f69b6d6f3 (diff)
Add tooltip for input groups (#1557).
Diffstat (limited to 'src')
-rw-r--r--src/wx/audio_mapping_view.cc64
-rw-r--r--src/wx/audio_mapping_view.h1
2 files changed, 48 insertions, 17 deletions
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<string>
+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<string>();
+ }
+
+ 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<string>();
+}
+
void
AudioMappingView::left_down (wxMouseEvent& ev)
{
@@ -512,28 +530,40 @@ void
AudioMappingView::motion (wxMouseEvent& ev)
{
optional<pair<int, int> > 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<string> 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<std::pair<int, int> > mouse_event_to_channels (wxMouseEvent& ev) const;
+ boost::optional<std::string> mouse_event_to_input_group_name (wxMouseEvent& ev) const;
void setup ();
void off ();