Label audio content with mapping (part of #1279).
authorCarl Hetherington <cth@carlh.net>
Wed, 4 Jul 2018 22:42:21 +0000 (23:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 4 Jul 2018 22:42:21 +0000 (23:42 +0100)
ChangeLog
src/wx/timeline_audio_content_view.cc
src/wx/timeline_audio_content_view.h
src/wx/timeline_content_view.cc
src/wx/timeline_content_view.h

index 01692c8ef88b188f668a93bade07b08e8d5dfd7e..296300c4a7973cd2225ff330e9c6dc32c420a76b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2018-07-04  Carl Hetherington  <cth@carlh.net>
 
+       * Label audio content with its DCP channel mapping in the timeline (#1279).
+
        * Add scrolling and zoom to the timeline (#1279, #1320).
 
 2018-07-01  Carl Hetherington  <cth@carlh.net>
index e8d5265f7f50d970b02ba1ee3e09d0f3db536c79..fe098c48b061220f1c0d57dfd7e5d45cbd26b5b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 */
 
 #include "timeline_audio_content_view.h"
+#include "wx_util.h"
+#include "lib/audio_content.h"
+#include "lib/util.h"
 
+using std::list;
 using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
 
 /** @class TimelineAudioContentView
  *  @brief Timeline view for AudioContent.
@@ -43,3 +48,20 @@ TimelineAudioContentView::foreground_colour () const
 {
        return wxColour (0, 0, 0, 255);
 }
+
+wxString
+TimelineAudioContentView::label () const
+{
+       wxString s = TimelineContentView::label ();
+       shared_ptr<AudioContent> ac = content()->audio;
+       DCPOMATIC_ASSERT (ac);
+       list<int> mapped = ac->mapping().mapped_output_channels();
+       if (!mapped.empty ()) {
+               s += " → ";
+               BOOST_FOREACH (int i, mapped) {
+                       s += std_to_wx(short_audio_channel_name(i)) + ", ";
+               }
+               s = s.Left(s.Length() - 2);
+       }
+       return s;
+}
index 17665111f4ffbcd0b72c85c04d14a2b57f8e26e9..bede1dcdaf00e5938f63c852b142b12819f195bb 100644 (file)
@@ -34,4 +34,5 @@ private:
        }
        wxColour background_colour () const;
        wxColour foreground_colour () const;
+       wxString label () const;
 };
index 88b50076af501cb6d567ebaf02e644c6624ba611..bf22e0156d7d739f4ecc0f6d47f24685ac042f53 100644 (file)
@@ -141,15 +141,15 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>
        }
 
        /* Label text */
-       wxString name = std_to_wx (cont->summary());
-       wxDouble name_width;
-       wxDouble name_height;
-       wxDouble name_descent;
-       wxDouble name_leading;
+       wxString lab = label ();
+       wxDouble lab_width;
+       wxDouble lab_height;
+       wxDouble lab_descent;
+       wxDouble lab_leading;
        gc->SetFont (gc->CreateFont (*wxNORMAL_FONT, foreground_colour ()));
-       gc->GetTextExtent (name, &name_width, &name_height, &name_descent, &name_leading);
+       gc->GetTextExtent (lab, &lab_width, &lab_height, &lab_descent, &lab_leading);
        gc->Clip (wxRegion (time_x (position), y_pos (_track.get()), len.seconds() * _timeline.pixels_per_second().get_value_or(0), _timeline.pixels_per_track()));
-       gc->DrawText (name, time_x (position) + 12, y_pos (_track.get() + 1) - name_height - 4);
+       gc->DrawText (lab, time_x (position) + 12, y_pos (_track.get() + 1) - lab_height - 4);
        gc->ResetClip ();
 }
 
@@ -168,3 +168,9 @@ TimelineContentView::content_changed (int p)
                force_redraw ();
        }
 }
+
+wxString
+TimelineContentView::label () const
+{
+       return std_to_wx(content()->summary());
+}
index 7875900991b587f83c496739afec984c18e3983e..b5b000bdb9cc14ece8451c1506cd8ff6d0bfdabb 100644 (file)
@@ -47,6 +47,7 @@ public:
        virtual bool active () const = 0;
        virtual wxColour background_colour () const = 0;
        virtual wxColour foreground_colour () const = 0;
+       virtual wxString label () const;
 
 protected: