Allow multiple video tracks to be visible in the timeline.
authorCarl Hetherington <cth@carlh.net>
Sun, 14 Feb 2021 23:43:12 +0000 (00:43 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Feb 2021 02:16:16 +0000 (03:16 +0100)
src/wx/timeline.cc
src/wx/timeline_labels_view.cc
src/wx/timeline_labels_view.h

index 3187792bea4ea30545341917ea72a063f43f4a55..359de9bf9f1b93d65e64e2045487ad120f6d6071 100644 (file)
@@ -370,8 +370,9 @@ void
 Timeline::assign_tracks ()
 {
        /* Tracks are:
-          Video (mono or left-eye)
-          Video (right-eye)
+          Video 1
+          Video 2
+          Video N
           Text 1
           Text 2
           Text N
@@ -393,29 +394,7 @@ Timeline::assign_tracks ()
                }
        }
 
-       /* Video */
-
-       bool have_3d = false;
-       for (auto i: _views) {
-               auto cv = dynamic_pointer_cast<TimelineVideoContentView>(i);
-               if (!cv) {
-                       continue;
-               }
-
-               /* Video on tracks 0 and maybe 1 (left and right eye) */
-               if (cv->content()->video->frame_type() == VideoFrameType::THREE_D_RIGHT) {
-                       cv->set_track (1);
-                       _tracks = max (_tracks, 2);
-                       have_3d = true;
-               } else {
-                       cv->set_track (0);
-               }
-       }
-
-       _tracks = max (_tracks, 1);
-
-       /* Texts */
-
+       int const video_tracks = place<TimelineVideoContentView> (film, _views, _tracks);
        int const text_tracks = place<TimelineTextContentView> (film, _views, _tracks);
 
        /* Atmos */
@@ -441,7 +420,7 @@ Timeline::assign_tracks ()
        sort(views.begin(), views.end(), AudioMappingComparator());
        int const audio_tracks = place<TimelineAudioContentView> (film, views, _tracks);
 
-       _labels_view->set_3d (have_3d);
+       _labels_view->set_video_tracks (video_tracks);
        _labels_view->set_audio_tracks (audio_tracks);
        _labels_view->set_text_tracks (text_tracks);
        _labels_view->set_atmos (have_atmos);
index d3aa02afcc68b20b981a3029499721f5d40de0c6..b0bd8acbb48eeaedf1ea619e8b2b866498831910 100644 (file)
@@ -30,10 +30,6 @@ using std::max;
 
 TimelineLabelsView::TimelineLabelsView (Timeline& tl)
        : TimelineView (tl)
-       , _threed (true)
-       , _audio_tracks (0)
-       , _text_tracks (0)
-       , _atmos (true)
 {
        wxString labels[] = {
                _("Video"),
@@ -42,11 +38,9 @@ TimelineLabelsView::TimelineLabelsView (Timeline& tl)
                _("Atmos")
        };
 
-       _width = 0;
-
         wxClientDC dc (&_timeline);
        for (int i = 0; i < 3; ++i) {
-               wxSize size = dc.GetTextExtent (labels[i]);
+               auto size = dc.GetTextExtent (labels[i]);
                _width = max (_width, size.GetWidth());
        }
 
@@ -66,32 +60,34 @@ TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> >
        gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour (0, 0, 0)));
 
        int fy = 0;
-       int ty = _threed ? 2 * h : h;
-       gc->DrawText (_("Video"), 0, (ty + fy) / 2 - 8);
-       fy = ty;
+       if (_video_tracks) {
+               int ty = fy + _video_tracks * h;
+               gc->DrawText (_("Video"), 0, (ty + fy) / 2 - 8);
+               fy = ty;
+       }
 
        if (_text_tracks) {
-               ty = fy + _text_tracks * h;
+               int ty = fy + _text_tracks * h;
                gc->DrawText (_("Subtitles/captions"), 0, (ty + fy) / 2 - 8);
                fy = ty;
        }
 
        if (_atmos) {
-               ty = fy + h;
+               int ty = fy + h;
                gc->DrawText (_("Atmos"), 0, (ty + fy) / 2 - 8);
                fy = ty;
        }
 
        if (_audio_tracks) {
-               ty = _timeline.tracks() * h;
+               int ty = _timeline.tracks() * h;
                gc->DrawText (_("Audio"), 0, (ty + fy) / 2 - 8);
        }
 }
 
 void
-TimelineLabelsView::set_3d (bool s)
+TimelineLabelsView::set_video_tracks (int n)
 {
-       _threed = s;
+       _video_tracks = n;
 }
 
 void
index f26c9762b879abed4f73e1347b513489c183336f..88094f2c4068cd64cc4110eb165dc80d24a582ac 100644 (file)
@@ -29,7 +29,7 @@ public:
 
        dcpomatic::Rect<int> bbox () const;
 
-       void set_3d (bool s);
+       void set_video_tracks (int n);
        void set_audio_tracks (int n);
        void set_text_tracks (int n);
        void set_atmos (bool s);
@@ -37,9 +37,9 @@ public:
 private:
        void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int> > overlaps);
 
-       int _width;
-       bool _threed;
-       int _audio_tracks;
-       int _text_tracks;
-       bool _atmos;
+       int _width = 0;
+       int _video_tracks = 0;
+       int _audio_tracks = 0;
+       int _text_tracks = 0;
+       bool _atmos = true;
 };