y zoom.
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Jul 2018 22:17:37 +0000 (23:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Jul 2018 22:17:37 +0000 (23:17 +0100)
src/wx/timeline.cc
src/wx/timeline.h

index 30a5ef1724e9be5d23171de0a92f43ac405f847b..2c14b651eb1ee5b4774769aa7e996434cfb077f5 100644 (file)
@@ -71,6 +71,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film)
        , _tool (SELECT)
        , _x_scroll_rate (16)
        , _y_scroll_rate (16)
+       , _track_height (48)
 {
 #ifndef __WXOSX__
        _labels_panel->SetDoubleBuffered (true);
@@ -513,11 +514,17 @@ Timeline::left_up_zoom (wxMouseEvent& ev)
        wxPoint top_left(min(_down_point.x, _zoom_point->x), min(_down_point.y, _zoom_point->y));
        wxPoint bottom_right(max(_down_point.x, _zoom_point->x), max(_down_point.y, _zoom_point->y));
 
-       DCPTime time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second);
-       DCPTime time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second);
+       DCPTime const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second);
+       DCPTime const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second);
        _pixels_per_second = GetSize().GetWidth() / (time_right.seconds() - time_left.seconds());
+
+       double const tracks_top = double(top_left.y) / _track_height;
+       double const tracks_bottom = double(bottom_right.y) / _track_height;
+       _track_height = GetSize().GetHeight() / (tracks_bottom - tracks_top);
+       cout << tracks_top << " " << tracks_bottom << "\n";
+
        setup_scrollbars ();
-       _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, wxDefaultCoord);
+       _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, tracks_top * _track_height / _y_scroll_rate);
 
        _zoom_point = optional<wxPoint> ();
        Refresh ();
@@ -567,6 +574,7 @@ Timeline::right_down (wxMouseEvent& ev)
        case ZOOM:
                /* Zoom out */
                _pixels_per_second = *_pixels_per_second / 2;
+               _track_height = max (8, _track_height / 2);
                setup_scrollbars ();
                break;
        }
index 3175d028c758cb9263c1c0aed105d88b4d096344..6df44372b0664ad918b7968a9f931e6631b52532 100644 (file)
@@ -49,7 +49,7 @@ public:
        }
 
        int track_height () const {
-               return 48;
+               return _track_height;
        }
 
        boost::optional<double> pixels_per_second () const {
@@ -127,6 +127,7 @@ private:
        Tool _tool;
        int _x_scroll_rate;
        int _y_scroll_rate;
+       int _track_height;
 
        boost::signals2::scoped_connection _film_changed_connection;
        boost::signals2::scoped_connection _film_content_changed_connection;