Fix some malformed placeholders in the cs_CZ translation.
[dcpomatic.git] / src / wx / audio_mapping_view.cc
index ccd78bb90f9cce5c4cdb875ef1d14189085b0b1e..9be6c9bb9b0e36ef33450d6d450d24aeb7204071 100644 (file)
@@ -207,30 +207,6 @@ AudioMappingView::paint_column_lines (wxGraphicsContext* gc)
        gc->StrokePath (lines);
 }
 
-static
-void clip (wxDC& dc, wxGraphicsContext* gc, int x, int y, int w, int h)
-{
-       dc.SetClippingRegion (x, y, w, h);
-       gc->Clip (x, y, w, h);
-}
-
-static
-void translate (wxDC& dc, wxGraphicsContext* gc, int x, int y)
-{
-       gc->PushState ();
-       gc->Translate (-x, -y);
-       dc.SetLogicalOrigin (x, y);
-}
-
-static
-void restore (wxDC& dc, wxGraphicsContext* gc)
-{
-       dc.SetLogicalOrigin (0, 0);
-       gc->PopState ();
-       dc.DestroyClippingRegion ();
-       gc->ResetClip ();
-}
-
 void
 AudioMappingView::paint_row_labels (wxDC& dc, wxGraphicsContext* gc)
 {
@@ -263,14 +239,29 @@ AudioMappingView::paint_row_labels (wxDC& dc, wxGraphicsContext* gc)
                if (label_width > height) {
                        label_width = height - 8;
                }
-               clip (dc, gc, GRID_SPACING, y + 4, GRID_SPACING, height - 4);
-               dc.DrawRotatedText (
-                       std_to_wx(i.name),
-                       GRID_SPACING + (GRID_SPACING - label_height) / 2,
-                       y + (height + label_width) / 2,
-                       90
-                       );
-               restore (dc, gc);
+
+               {
+                       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;
@@ -332,6 +323,30 @@ AudioMappingView::paint_indicators (wxDC& dc)
        }
 }
 
+static
+void clip (wxDC& dc, wxGraphicsContext* gc, int x, int y, int w, int h)
+{
+       dc.SetClippingRegion (x, y, w, h);
+       gc->Clip (x, y, w, h);
+}
+
+static
+void translate (wxDC& dc, wxGraphicsContext* gc, int x, int y)
+{
+       gc->PushState ();
+       gc->Translate (-x, -y);
+       dc.SetLogicalOrigin (x, y);
+}
+
+static
+void restore (wxDC& dc, wxGraphicsContext* gc)
+{
+       dc.SetLogicalOrigin (0, 0);
+       gc->PopState ();
+       dc.DestroyClippingRegion ();
+       gc->ResetClip ();
+}
+
 void
 AudioMappingView::paint ()
 {
@@ -526,6 +541,37 @@ AudioMappingView::set_output_channels (vector<string> 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<wxString> 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 +582,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
                                        );
                        }