Fix hidden reels view and time axis not moving under zoom.
authorCarl Hetherington <cth@carlh.net>
Tue, 3 Jul 2018 22:31:11 +0000 (23:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 3 Jul 2018 22:31:11 +0000 (23:31 +0100)
src/wx/timeline.cc
src/wx/timeline.h
src/wx/timeline_content_view.cc
src/wx/timeline_time_axis_view.cc
src/wx/timeline_time_axis_view.h

index 667bf5f873a69081aebab94255093b00fe89077f..480f6d69045b1a9c85db18a206b83ebfd7e18916 100644 (file)
@@ -117,7 +117,7 @@ Timeline::paint_labels ()
 
        int vsx, vsy;
        _labels_canvas->GetViewStart (&vsx, &vsy);
-       gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate);
+       gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset());
 
        _labels_view->paint (gc, list<dcpomatic::Rect<int> >());
 
@@ -365,7 +365,7 @@ Timeline::assign_tracks ()
        _labels_view->set_subtitle_tracks (subtitle_tracks);
        _labels_view->set_atmos (have_atmos);
 
-       _time_axis_view->set_y (tracks() * track_height() + 64);
+       _time_axis_view->set_y (tracks());
        _reels_view->set_y (8);
 }
 
@@ -745,3 +745,9 @@ Timeline::set_selection (ContentList selection)
                }
        }
 }
+
+int
+Timeline::tracks_y_offset () const
+{
+       return _reels_view->bbox().height + 4;
+}
index 1b75f7ab2f6c62aeb8dab320abb8b6c396dfb204..503025f3ce3e6f0006a237505db422ae9d386a33 100644 (file)
@@ -77,6 +77,8 @@ public:
                _tool = t;
        }
 
+       int tracks_y_offset () const;
+
 private:
        void paint_labels ();
        void paint_main ();
index abb671b770695e217a1c234423317c8730173553..1d0c1668f0a2840f490097d90165f1ee8ffce44d 100644 (file)
@@ -156,7 +156,7 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>
 int
 TimelineContentView::y_pos (int t) const
 {
-       return t * _timeline.track_height();
+       return t * _timeline.track_height() + _timeline.tracks_y_offset();
 }
 
 void
index c8808a62f5c6b35a0553f825918410171231988f..1d7aefb738d4df0bcdf758bdfec9a2fa5343749a 100644 (file)
@@ -39,6 +39,7 @@ TimelineTimeAxisView::bbox () const
        return dcpomatic::Rect<int> (0, _y - 4, _timeline.width(), 24);
 }
 
+/** @param y y position in tracks (not pixels) */
 void
 TimelineTimeAxisView::set_y (int y)
 {
@@ -59,9 +60,11 @@ TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>
 
        double const mark_interval = calculate_mark_interval (rint (128 / pps));
 
+       int y = _y * _timeline.track_height() + 32;
+
        wxGraphicsPath path = gc->CreatePath ();
-       path.MoveToPoint (0, _y);
-       path.AddLineToPoint (_timeline.width(), _y);
+       path.MoveToPoint (0, y);
+       path.AddLineToPoint (_timeline.width(), y);
        gc->StrokePath (path);
 
        gc->SetFont (gc->CreateFont (*wxNORMAL_FONT));
@@ -70,8 +73,8 @@ TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>
        DCPTime t;
        while ((t.seconds() * pps) < _timeline.width()) {
                wxGraphicsPath path = gc->CreatePath ();
-               path.MoveToPoint (time_x (t), _y - 4);
-               path.AddLineToPoint (time_x (t), _y + 4);
+               path.MoveToPoint (time_x (t), y - 4);
+               path.AddLineToPoint (time_x (t), y + 4);
                gc->StrokePath (path);
 
                double tc = t.seconds ();
@@ -90,7 +93,7 @@ TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>
 
                int const tx = t.seconds() * pps;
                if ((tx + str_width) < _timeline.width()) {
-                       gc->DrawText (str, time_x (t), _y + 16);
+                       gc->DrawText (str, time_x (t), y + 16);
                }
 
                t += DCPTime::from_seconds (mark_interval);
index 5eecb8232a5e0eadd512a311abe568fb8f13b843..5477e61f13cfaf660f5c95af1ab480e0383a0d32 100644 (file)
@@ -31,6 +31,5 @@ public:
 private:
        void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int> > overlaps);
 
-       int _y;
+       int _y; ///< y position in tracks (not pixels)
 };
-