Fix rebase onto master.
[dcpomatic.git] / src / wx / timeline.cc
index a7b41eb983d7516b3e12898e53bd47a9b0464167..8ce811c28c3f668ea913008e16ce4c09fd631a21 100644 (file)
@@ -33,6 +33,7 @@
 #include "lib/timer.h"
 #include "lib/audio_content.h"
 #include "lib/subtitle_content.h"
+#include "lib/video_content.h"
 #include <wx/graphics.h>
 #include <boost/weak_ptr.hpp>
 #include <boost/foreach.hpp>
@@ -77,7 +78,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film)
 
        SetMinSize (wxSize (640, tracks() * track_height() + 96));
 
-       _tracks_position = Position<int> (_labels_view->bbox().width, 8);
+       _tracks_position = Position<int> (_labels_view->bbox().width, 32);
 
        _film_changed_connection = film->Changed.connect (bind (&Timeline::film_changed, this, _1));
        _film_content_changed_connection = film->ContentChanged.connect (bind (&Timeline::film_content_changed, this, _2, _3));
@@ -93,6 +94,7 @@ Timeline::paint ()
                return;
        }
 
+       gc->SetAntialiasMode (wxANTIALIAS_DEFAULT);
 
        BOOST_FOREACH (shared_ptr<TimelineView> i, _views) {
 
@@ -102,7 +104,8 @@ Timeline::paint ()
                list<dcpomatic::Rect<int> > overlaps;
                BOOST_FOREACH (shared_ptr<TimelineView> j, _views) {
                        shared_ptr<TimelineContentView> jc = dynamic_pointer_cast<TimelineContentView> (j);
-                       if (!ic || !jc || i == j || ic->track() != jc->track() || !ic->active() || !jc->active()) {
+                       /* No overlap with non-content views, views no different tracks, audio views or non-active views */
+                       if (!ic || !jc || i == j || ic->track() != jc->track() || ic->track().get_value_or(2) >= 2 || !ic->active() || !jc->active()) {
                                continue;
                        }
 
@@ -143,18 +146,16 @@ Timeline::recreate_views ()
        _views.push_back (_labels_view);
 
        BOOST_FOREACH (shared_ptr<Content> i, film->content ()) {
-               if (dynamic_pointer_cast<VideoContent> (i)) {
+               if (i->video) {
                        _views.push_back (shared_ptr<TimelineView> (new TimelineVideoContentView (*this, i)));
                }
 
-               shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
-               if (ac && !ac->audio_mapping().mapped_output_channels().empty ()) {
+               if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) {
                        _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i)));
                }
 
-               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (i);
-               if (sc && sc->has_subtitles ()) {
-                       _views.push_back (shared_ptr<TimelineView> (new TimelineSubtitleContentView (*this, sc)));
+               if (i->subtitle) {
+                       _views.push_back (shared_ptr<TimelineView> (new TimelineSubtitleContentView (*this, i)));
                }
        }
 
@@ -168,7 +169,7 @@ Timeline::film_content_changed (int property, bool frequent)
 {
        ensure_ui_thread ();
 
-       if (property == AudioContentProperty::AUDIO_STREAMS) {
+       if (property == AudioContentProperty::STREAMS) {
                recreate_views ();
        } else if (!frequent) {
                setup_pixels_per_second ();
@@ -193,19 +194,19 @@ Timeline::assign_tracks ()
                }
 
                if (dynamic_pointer_cast<TimelineVideoContentView> (*i)) {
-                       /* Video on track 0 */
-                       cv->set_track (0);
-                       _tracks = max (_tracks, 1);
+                       /* Video on tracks 0 and 1 (left and right eye) */
+                       cv->set_track (cv->content()->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT ? 1 : 0);
+                       _tracks = max (_tracks, 2);
                        continue;
                } else if (dynamic_pointer_cast<TimelineSubtitleContentView> (*i)) {
-                       /* Subtitles on track 1 */
-                       cv->set_track (1);
-                       _tracks = max (_tracks, 2);
+                       /* Subtitles on track 2 */
+                       cv->set_track (2);
+                       _tracks = max (_tracks, 3);
                        continue;
                }
 
-               /* Audio on tracks 2 and up */
-               int t = 2;
+               /* Audio on tracks 3 and up */
+               int t = 3;
 
                shared_ptr<Content> content = cv->content();
                DCPTimePeriod content_period (content->position(), content->end());
@@ -243,7 +244,7 @@ Timeline::assign_tracks ()
        }
 
        _time_axis_view->set_y (tracks() * track_height() + 64);
-       _reels_view->set_y (tracks() * track_height() + 32);
+       _reels_view->set_y (8);
 }
 
 int