Updated zh_CN translation from Danbo Song.
[dcpomatic.git] / src / wx / timeline.cc
index 604a00f39cd60ed482719c789af534c11bc2aadc..2b8fba6fd50468766c09a36e3c05646df1d0a5a5 100644 (file)
@@ -151,6 +151,11 @@ Timeline::paint_labels ()
 {
        wxPaintDC dc (_labels_canvas);
 
+       auto film = _film.lock();
+       if (film->content().empty()) {
+               return;
+       }
+
        auto gc = wxGraphicsContext::Create (dc);
        if (!gc) {
                return;
@@ -170,6 +175,12 @@ void
 Timeline::paint_main ()
 {
        wxPaintDC dc (_main_canvas);
+
+       auto film = _film.lock();
+       if (film->content().empty()) {
+               return;
+       }
+
        _main_canvas->DoPrepareDC (dc);
 
        auto gc = wxGraphicsContext::Create (dc);
@@ -319,7 +330,7 @@ place (shared_ptr<const Film> film, TimelineViewList& views, int& tracks)
                int t = base;
 
                auto content = cv->content();
-               DCPTimePeriod const content_period (content->position(), content->end(film));
+               DCPTimePeriod const content_period = content->period(film);
 
                while (true) {
                        auto j = views.begin();
@@ -333,7 +344,8 @@ place (shared_ptr<const Film> film, TimelineViewList& views, int& tracks)
                                auto test_content = test->content();
                                if (
                                        test->track() && test->track().get() == t &&
-                                       content_period.overlap(DCPTimePeriod(test_content->position(), test_content->end(film)))) {
+                                       content_period.overlap(test_content->period(film))
+                                  ) {
                                        /* we have an overlap on track `t' */
                                        ++t;
                                        break;
@@ -950,3 +962,14 @@ Timeline::zoom_all ()
        _labels_canvas->Scroll (0, 0);
        Refresh ();
 }
+
+
+void
+Timeline::keypress(wxKeyEvent const& event)
+{
+       if (event.GetKeyCode() == WXK_DELETE) {
+               auto film = _film.lock();
+               film->remove_content(selected_content());
+       }
+}
+