2.8 fixes.
[dcpomatic.git] / src / wx / timeline.cc
index 828756362c6391d14e4c9145ceb60fc9f5769858..2539038881ff903cd5dbb97f161e34a07bf630ca 100644 (file)
@@ -27,6 +27,7 @@ using std::list;
 using std::cout;
 using std::max;
 using boost::shared_ptr;
+using boost::bind;
 
 int const Timeline::_track_height = 64;
 
@@ -41,8 +42,11 @@ Timeline::Timeline (wxWindow* parent, shared_ptr<Playlist> pl)
        if (pl->audio_from() == Playlist::AUDIO_FFMPEG) {
                SetMinSize (wxSize (640, _track_height * 2 + 96));
        } else {
-               SetMinSize (wxSize (640, _track_height * (max (1UL, pl->audio().size()) + 1) + 96));
+               SetMinSize (wxSize (640, _track_height * (max (size_t (1), pl->audio().size()) + 1) + 96));
        }
+
+       pl->Changed.connect (bind (&Timeline::playlist_changed, this));
+       pl->ContentChanged.connect (bind (&Timeline::playlist_changed, this));
 }
 
 template <class T>
@@ -63,7 +67,7 @@ plot_content_list (
                gc->StrokePath (path);
                gc->FillPath (path);
 
-               wxString name = wxString::Format ("%s [%s]", std_to_wx ((*i)->file().filename().string()), type);
+               wxString name = wxString::Format (wxT ("%s [%s]"), std_to_wx ((*i)->file().filename().string()).data(), type.data());
                wxDouble name_width;
                wxDouble name_height;
                wxDouble name_descent;
@@ -115,15 +119,15 @@ Timeline::paint (wxPaintEvent &)
        gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 4, wxPENSTYLE_SOLID));
        gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (149, 121, 232, 255), wxBRUSHSTYLE_SOLID));
 #else                  
-       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 4, SOLID));
-       gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (149, 121, 232, 255), SOLID));
+       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 4, wxSOLID));
+       gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (149, 121, 232, 255), wxSOLID));
 #endif
        y = plot_content_list (pl->video (), gc, x_offset, y, pixels_per_second, _track_height, _("video"), true);
        
 #if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9
        gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (242, 92, 120, 255), wxBRUSHSTYLE_SOLID));
 #else                  
-       gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (242, 92, 120, 255), SOLID));
+       gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (242, 92, 120, 255), wxSOLID));
 #endif
        y = plot_content_list (pl->audio (), gc, x_offset, y, pixels_per_second, _track_height, _("audio"), pl->audio_from() == Playlist::AUDIO_FFMPEG);
 
@@ -132,7 +136,7 @@ Timeline::paint (wxPaintEvent &)
 #if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9
         gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxPENSTYLE_SOLID));
 #else              
-       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, SOLID));
+       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxSOLID));
 #endif             
                    
        int mark_interval = rint (128 / pixels_per_second);
@@ -172,7 +176,7 @@ Timeline::paint (wxPaintEvent &)
                tc -= m * 60;
                int const s = tc;
 
-               wxString str = wxString::Format ("%02d:%02d:%02d", h, m, s);
+               wxString str = wxString::Format (wxT ("%02d:%02d:%02d"), h, m, s);
                wxDouble str_width;
                wxDouble str_height;
                wxDouble str_descent;
@@ -189,3 +193,8 @@ Timeline::paint (wxPaintEvent &)
        delete gc;
 }
 
+void
+Timeline::playlist_changed ()
+{
+       Refresh ();
+}