Remove assumption that GDC serials always start with 'A' (apparently there are other...
[dcpomatic.git] / src / wx / timeline.cc
index d8e0e692e6f9fed0e283b253ec9f83641171d7c5..9af8c3b85cb15ae4e0b11ae1fffc326d968bfcd1 100644 (file)
@@ -117,7 +117,7 @@ Timeline::Timeline(wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film, Fi
        _main_canvas->Bind   (wxEVT_SCROLLWIN_PAGEDOWN,   boost::bind (&Timeline::scrolled,     this, _1));
        _main_canvas->Bind   (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&Timeline::scrolled,     this, _1));
 
-       film_change (ChangeType::DONE, Film::Property::CONTENT);
+       film_change(ChangeType::DONE, FilmProperty::CONTENT);
 
        SetMinSize (wxSize (640, 4 * pixels_per_track() + 96));
 
@@ -175,6 +175,7 @@ void
 Timeline::paint_main ()
 {
        wxPaintDC dc (_main_canvas);
+       dc.Clear();
 
        auto film = _film.lock();
        if (film->content().empty()) {
@@ -237,16 +238,16 @@ Timeline::paint_main ()
 
 
 void
-Timeline::film_change (ChangeType type, Film::Property p)
+Timeline::film_change(ChangeType type, FilmProperty p)
 {
        if (type != ChangeType::DONE) {
                return;
        }
 
-       if (p == Film::Property::CONTENT || p == Film::Property::REEL_TYPE || p == Film::Property::REEL_LENGTH) {
+       if (p == FilmProperty::CONTENT || p == FilmProperty::REEL_TYPE || p == FilmProperty::REEL_LENGTH) {
                ensure_ui_thread ();
                recreate_views ();
-       } else if (p == Film::Property::CONTENT_ORDER) {
+       } else if (p == FilmProperty::CONTENT_ORDER) {
                Refresh ();
        }
 }
@@ -320,6 +321,7 @@ place (shared_ptr<const Film> film, TimelineViewList& views, int& tracks)
                }
 
                auto cv = dynamic_pointer_cast<TimelineContentView> (i);
+               DCPOMATIC_ASSERT(cv);
 
                int t = base;
 
@@ -702,6 +704,7 @@ Timeline::mouse_moved_zoom (wxMouseEvent& ev)
        }
 
        _zoom_point = ev.GetPosition ();
+       setup_scrollbars();
        Refresh ();
 }
 
@@ -949,8 +952,8 @@ Timeline::zoom_all ()
 {
        auto film = _film.lock ();
        DCPOMATIC_ASSERT (film);
-       set_pixels_per_second ((_main_canvas->GetSize().GetWidth() - 32) / film->length().seconds());
-       set_pixels_per_track ((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / _tracks);
+       set_pixels_per_second((_main_canvas->GetSize().GetWidth() - 32) / std::max(1.0, film->length().seconds()));
+       set_pixels_per_track((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / std::max(1, _tracks));
        setup_scrollbars ();
        _main_canvas->Scroll (0, 0);
        _labels_canvas->Scroll (0, 0);
@@ -969,9 +972,11 @@ Timeline::keypress(wxKeyEvent const& event)
                switch (event.GetRawKeyCode()) {
                case '+':
                        set_pixels_per_second(_pixels_per_second.get_value_or(1) * 2);
+                       setup_scrollbars();
                        break;
                case '-':
                        set_pixels_per_second(_pixels_per_second.get_value_or(1) / 2);
+                       setup_scrollbars();
                        break;
                }
        }