X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_mapping_view.cc;h=32f4233804f9a4b1a48652070407b0380777e36f;hb=d1e9749ca290673639a49d693a8fe5c6557cc2de;hp=959975a0096912fd0a72149bfcd55214cadb7483;hpb=aef19d980eedbb65e88060fe90ce41c89a04a7cc;p=dcpomatic.git diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 959975a00..32f423380 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -46,6 +46,9 @@ using std::pair; using std::make_pair; using boost::shared_ptr; using boost::optional; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif using dcp::locale_convert; #define INDICATOR_SIZE 20 @@ -234,14 +237,34 @@ AudioMappingView::paint_row_labels (wxDC& dc, wxGraphicsContext* gc) int y = TOP_HEIGHT; BOOST_FOREACH (Group i, _input_groups) { - dc.GetTextExtent (std_to_wx(i.name), &label_width, &label_height); int const height = (i.to - i.from + 1) * GRID_SPACING; - dc.DrawRotatedText ( - std_to_wx(i.name), - GRID_SPACING + (GRID_SPACING - label_height) / 2, - y + (height + label_width) / 2, - 90 - ); + dc.GetTextExtent (std_to_wx(i.name), &label_width, &label_height); + if (label_width > height) { + label_width = height - 8; + } + + { + int yp = y; + if ((yp - 2 * GRID_SPACING) < dc.GetLogicalOrigin().y) { + yp += dc.GetLogicalOrigin().y; + } + + wxCoord old_x, old_y, old_width, old_height; + dc.GetClippingBox (&old_x, &old_y, &old_width, &old_height); + dc.DestroyClippingRegion (); + dc.SetClippingRegion (GRID_SPACING, yp + 4, GRID_SPACING, height - 8); + + dc.DrawRotatedText ( + std_to_wx(i.name), + GRID_SPACING + (GRID_SPACING - label_height) / 2, + y + (height + label_width) / 2, + 90 + ); + + dc.DestroyClippingRegion (); + dc.SetClippingRegion (old_x, old_y, old_width, old_height); + } + lines.MoveToPoint (GRID_SPACING, y); lines.AddLineToPoint (GRID_SPACING * 2, y); y += height; @@ -390,6 +413,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) { @@ -469,11 +510,9 @@ AudioMappingView::minus6dB () void AudioMappingView::edit () { - int const d = _menu_output - 1; - - AudioGainDialog* dialog = new AudioGainDialog (this, _menu_input, _menu_output - 1, _map.get(_menu_input, d)); + AudioGainDialog* dialog = new AudioGainDialog (this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output)); if (dialog->ShowModal() == wxID_OK) { - _map.set (_menu_input, d, dialog->value ()); + _map.set (_menu_input, _menu_output, dialog->value ()); map_values_changed (); } @@ -507,28 +546,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 (); }