Plot video and subtitle on one track and audio on the rest in the timeline.
[dcpomatic.git] / src / wx / timeline_content_view.cc
index 858214c33945cf83fe09e6b18a1ffa86e080f1cd..b520b5ceb2bd40e292709c0ffe254232d016a6ec 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -22,7 +22,9 @@
 #include "wx_util.h"
 #include "lib/content.h"
 #include <wx/graphics.h>
+#include <boost/foreach.hpp>
 
+using std::list;
 using boost::shared_ptr;
 
 TimelineContentView::TimelineContentView (Timeline& tl, shared_ptr<Content> c)
@@ -30,7 +32,7 @@ TimelineContentView::TimelineContentView (Timeline& tl, shared_ptr<Content> c)
        , _content (c)
        , _selected (false)
 {
-       _content_connection = c->Changed.connect (bind (&TimelineContentView::content_changed, this, _2, _3));
+       _content_connection = c->Changed.connect (bind (&TimelineContentView::content_changed, this, _2));
 }
 
 dcpomatic::Rect<int>
@@ -45,10 +47,10 @@ TimelineContentView::bbox () const
        }
 
        return dcpomatic::Rect<int> (
-               time_x (content->position ()) - 8,
-               y_pos (_track.get()) - 8,
-               content->length_after_trim().seconds() * _timeline.pixels_per_second().get_value_or(0) + 16,
-               _timeline.track_height() + 16
+               time_x (content->position ()),
+               y_pos (_track.get()),
+               content->length_after_trim().seconds() * _timeline.pixels_per_second().get_value_or(0),
+               _timeline.track_height()
                );
 }
 
@@ -90,7 +92,7 @@ TimelineContentView::track () const
 }
 
 void
-TimelineContentView::do_paint (wxGraphicsContext* gc)
+TimelineContentView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> > overlaps)
 {
        DCPOMATIC_ASSERT (_track);
 
@@ -112,15 +114,32 @@ TimelineContentView::do_paint (wxGraphicsContext* gc)
                gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (background_colour(), wxBRUSHSTYLE_SOLID));
        }
 
+       /* Outline */
        wxGraphicsPath path = gc->CreatePath ();
-       path.MoveToPoint    (time_x (position),       y_pos (_track.get()) + 4);
-       path.AddLineToPoint (time_x (position + len), y_pos (_track.get()) + 4);
-       path.AddLineToPoint (time_x (position + len), y_pos (_track.get() + 1) - 4);
-       path.AddLineToPoint (time_x (position),       y_pos (_track.get() + 1) - 4);
-       path.AddLineToPoint (time_x (position),       y_pos (_track.get()) + 4);
+       path.MoveToPoint    (time_x (position) + 1,           y_pos (_track.get()) + 4);
+       path.AddLineToPoint (time_x (position + len) - 1,     y_pos (_track.get()) + 4);
+       path.AddLineToPoint (time_x (position + len) - 1,     y_pos (_track.get() + 1) - 4);
+       path.AddLineToPoint (time_x (position) + 1,           y_pos (_track.get() + 1) - 4);
+       path.AddLineToPoint (time_x (position) + 1,           y_pos (_track.get()) + 4);
        gc->StrokePath (path);
        gc->FillPath (path);
 
+       /* Reel split points */
+       gc->SetPen (*wxThePenList->FindOrCreatePen (foreground_colour(), 1, wxPENSTYLE_DOT));
+       BOOST_FOREACH (DCPTime i, cont->reel_split_points ()) {
+               path = gc->CreatePath ();
+               path.MoveToPoint (time_x (i), y_pos (_track.get()) + 4);
+               path.AddLineToPoint (time_x (i), y_pos (_track.get() + 1) - 4);
+               gc->StrokePath (path);
+       }
+
+       /* Overlaps */
+       gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (foreground_colour(), wxBRUSHSTYLE_CROSSDIAG_HATCH));
+       for (list<dcpomatic::Rect<int> >::const_iterator i = overlaps.begin(); i != overlaps.end(); ++i) {
+               gc->DrawRectangle (i->x, i->y + 4, i->width, i->height - 8);
+       }
+
+       /* Label text */
        wxString name = std_to_wx (cont->summary());
        wxDouble name_width;
        wxDouble name_height;
@@ -140,16 +159,11 @@ TimelineContentView::y_pos (int t) const
 }
 
 void
-TimelineContentView::content_changed (int p, bool frequent)
+TimelineContentView::content_changed (int p)
 {
        ensure_ui_thread ();
 
        if (p == ContentProperty::POSITION || p == ContentProperty::LENGTH) {
                force_redraw ();
        }
-
-       if (!frequent) {
-               _timeline.setup_pixels_per_second ();
-               _timeline.Refresh ();
-       }
 }