Add has_subtitles method to SubtitleContent; tidy up timeline display a bit.
[dcpomatic.git] / src / wx / timeline.cc
index 4b56168a1d0636be5d56642d212b8050e19b61ce..fc3aefdaac21b2f6252225ae557872d70d12e7cf 100644 (file)
@@ -22,6 +22,7 @@
 #include <boost/weak_ptr.hpp>
 #include "lib/film.h"
 #include "lib/playlist.h"
+#include "lib/image_content.h"
 #include "film_editor.h"
 #include "timeline.h"
 #include "wx_util.h"
@@ -127,6 +128,10 @@ public:
                _track = t;
        }
 
+       void unset_track () {
+               _track = boost::optional<int> ();
+       }
+
        optional<int> track () const {
                return _track;
        }
@@ -169,7 +174,7 @@ private:
                gc->StrokePath (path);
                gc->FillPath (path);
 
-               wxString name = wxString::Format (wxT ("%s [%s]"), std_to_wx (cont->path_summary()).data(), type().data());
+               wxString name = wxString::Format (wxT ("%s [%s]"), std_to_wx (cont->summary()).data(), type().data());
                wxDouble name_width;
                wxDouble name_height;
                wxDouble name_descent;
@@ -237,10 +242,10 @@ private:
 
        wxString type () const
        {
-               if (dynamic_pointer_cast<FFmpegContent> (content ())) {
-                       return _("video");
-               } else {
+               if (dynamic_pointer_cast<ImageContent> (content ()) && content()->number_of_paths() == 1) {
                        return _("still");
+               } else {
+                       return _("video");
                }
        }
 
@@ -386,7 +391,8 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
 
        SetMinSize (wxSize (640, tracks() * track_height() + 96));
 
-       _playlist_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this));
+       _playlist_changed_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this));
+       _playlist_content_changed_connection = film->playlist()->ContentChanged.connect (bind (&Timeline::playlist_content_changed, this, _2));
 }
 
 void
@@ -430,7 +436,9 @@ Timeline::playlist_changed ()
                if (dynamic_pointer_cast<AudioContent> (*i)) {
                        _views.push_back (shared_ptr<View> (new AudioContentView (*this, *i)));
                }
-               if (dynamic_pointer_cast<SubtitleContent> (*i)) {
+
+               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (*i);
+               if (sc && sc->has_subtitles ()) {
                        _views.push_back (shared_ptr<View> (new SubtitleContentView (*this, *i)));
                }
        }
@@ -440,9 +448,28 @@ Timeline::playlist_changed ()
        Refresh ();
 }
 
+void
+Timeline::playlist_content_changed (int property)
+{
+       ensure_ui_thread ();
+
+       if (property == ContentProperty::POSITION) {
+               assign_tracks ();
+               setup_pixels_per_second ();
+               Refresh ();
+       }
+}
+
 void
 Timeline::assign_tracks ()
 {
+       for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
+               shared_ptr<ContentView> c = dynamic_pointer_cast<ContentView> (*i);
+               if (c) {
+                       c->unset_track ();
+               }
+       }
+
        for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
                shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*i);
                if (!cv) {
@@ -680,7 +707,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
        if (new_position < DCPTime ()) {
                new_position = DCPTime ();
        }
-       
+
        _down_view->content()->set_position (new_position);
        
        shared_ptr<Film> film = _film.lock ();