Improve scrolling performance for sessions containing hundreds of regions over many...
authorNick Mainsbridge <beatroute@iprimus.com.au>
Sat, 4 Oct 2008 08:23:29 +0000 (08:23 +0000)
committerNick Mainsbridge <beatroute@iprimus.com.au>
Sat, 4 Oct 2008 08:23:29 +0000 (08:23 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3853 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_time_axis.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_route_list.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h

index 12a0f8a86ad5411bcdefa7739e948e9daba07eed..f67dd960343475a6a792d027d4853694e9574ac5 100644 (file)
@@ -367,11 +367,11 @@ AutomationTimeAxisView::set_height (uint32_t h)
                        clear_button.hide();
                        hide_button.hide();
                }
-       } else  if (h >= hNormal){
-                       auto_button.show();
-                       height_button.show();
-                       clear_button.show();
-                       hide_button.show_all();
+       } else if (h >= hNormal){
+               auto_button.show();
+               height_button.show();
+               clear_button.show();
+               hide_button.show_all();
        }
 
        if (changed) {
index 4afce621cfb8fb756ab7fa92c975d6511a4a9217..019ffcadc12f252712e98b2158775b85f1c259d9 100644 (file)
@@ -838,6 +838,7 @@ class Editor : public PublicEditor
 
        gdouble get_trackview_group_vertical_offset () const { return vertical_adjustment.get_value () - canvas_timebars_vsize;}
        ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
+       double last_trackview_group_vertical_offset;
        void tie_vertical_scrolling ();
        void scroll_canvas_horizontally ();
        void scroll_canvas_vertically ();
index 53f114c962919e4b830ce93267316d9bb39b13d8..870f195baea1e3a96c623d74fb09a14f18411344 100644 (file)
@@ -333,6 +333,8 @@ Editor::track_canvas_size_allocated ()
 
        update_fixed_rulers();
 
+       last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
+
        Resized (); /* EMIT_SIGNAL */
 
        return false;
@@ -350,6 +352,7 @@ Editor::controls_layout_size_request (Requisition* req)
                TimeAxisView *tv = (*i)[route_display_columns.tv];
                if (tv != 0) {
                        pos += tv->effective_height;
+                       tv->clip_to_viewport ();
                }
        }
 
@@ -511,29 +514,17 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
 void
 Editor::maybe_autoscroll (GdkEventMotion* event)
 {
+
        nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
        nframes64_t frame = drag_info.current_pointer_frame;
        bool startit = false;
-       double vertical_pos = vertical_adjustment.get_value();
-       double upper = vertical_adjustment.get_upper();
-
-       /* 
-          adjust the event.y to take account of the bounds 
-          of the _trackview_group 
-       */
-
-       double vsx1, vsx2, vsy1, vsy2;
-       _trackview_group->get_bounds (vsx1, vsy1, vsx2, vsy2);
 
        autoscroll_y = 0;
        autoscroll_x = 0;
-
-       if ((event->y - vsy1) < vertical_pos) {
+       if (event->y < canvas_timebars_vsize) {
                autoscroll_y = -1;
                startit = true;
-       }
-
-       if ((event->y - vsy1) > (vertical_pos + canvas_height - canvas_timebars_vsize) && vertical_pos <= upper) {
+       } else if (event->y > canvas_height) {
                autoscroll_y = 1;
                startit = true;
        }
@@ -622,44 +613,21 @@ Editor::autoscroll_canvas ()
        double target_pixel;
 
        if (autoscroll_x_distance != 0) {
+               if (autoscroll_x > 0) {
+                       autoscroll_x_distance = (unit_to_frame (drag_info.current_pointer_x) - (leftmost_frame + current_page_frames())) / 3;
+               } else if (autoscroll_x < 0) {
+                       autoscroll_x_distance = (leftmost_frame - unit_to_frame (drag_info.current_pointer_x)) / 3;
 
-               if (autoscroll_cnt == 50) { /* 0.5 seconds */
-                       
-                       /* after about a while, speed up a bit by changing the timeout interval */
-                       
-                       autoscroll_x_distance = (nframes64_t) floor (current_page_frames()/30.0f);
-                       
-               } else if (autoscroll_cnt == 150) { /* 1.0 seconds */
-                       
-                       autoscroll_x_distance = (nframes64_t) floor (current_page_frames()/20.0f);
-                       
-               } else if (autoscroll_cnt == 300) { /* 1.5 seconds */
-                       
-                       /* after about another while, speed up by increasing the shift per callback */
-                       
-                       autoscroll_x_distance =  (nframes64_t) floor (current_page_frames()/10.0f);
-                       
-               } 
+               }
        }
 
        if (autoscroll_y_distance != 0) {
+               if (autoscroll_y > 0) {
+                       autoscroll_y_distance = (drag_info.current_pointer_y - (get_trackview_group_vertical_offset() + canvas_height)) / 3;
+               } else if (autoscroll_y < 0) {
 
-               if (autoscroll_cnt == 50) { /* 0.5 seconds */
-                       
-                       /* after about a while, speed up a bit by changing the timeout interval */
-                       
-                       autoscroll_y_distance = 10;
-                       
-               } else if (autoscroll_cnt == 150) { /* 1.0 seconds */
-                       
-                       autoscroll_y_distance = 20;
-                       
-               } else if (autoscroll_cnt == 300) { /* 1.5 seconds */
-                       
-                       /* after about another while, speed up by increasing the shift per callback */
-                       
-                       autoscroll_y_distance =  40;
-               } 
+                       autoscroll_y_distance = (vertical_adjustment.get_value () - drag_info.current_pointer_y) / 3;
+               }
        }
 
        if (autoscroll_x < 0) {
@@ -716,8 +684,6 @@ Editor::autoscroll_canvas ()
                new_pixel = vertical_pos;
        }
 
-
-
        if ((new_frame == 0 || new_frame == limit) && (new_pixel == 0 || new_pixel == DBL_MAX)) {
                /* we are done */
                return false;
@@ -843,13 +809,16 @@ Editor::scroll_canvas_vertically ()
 {
        /* vertical scrolling only */
 
-       double x1, x2, y1, y2, y_delta;
+       double y_delta;
 
-       _trackview_group->get_bounds(x1, y1, x2, y2);
-       y_delta = y1 + get_trackview_group_vertical_offset ();
+       y_delta = last_trackview_group_vertical_offset - get_trackview_group_vertical_offset ();
 
-       _trackview_group->move (0, -y_delta);
+       _trackview_group->move (0, y_delta);
 
+       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+               (*i)->clip_to_viewport ();
+       }
+       last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
        /* required to keep the controls_layout in lock step with the canvas group */
        track_canvas->update_now ();
 }
@@ -938,10 +907,12 @@ Editor::color_handler()
        location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
 
        refresh_location_display ();
+/*
        redisplay_tempo (true);
 
        if (session)
                session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
+*/
 }
 
 void
index 78a7754e5a972088779090747e2731c6a4a34789..659876407d5e2e1f9e1668405d24d6afac000d6b 100644 (file)
@@ -301,6 +301,7 @@ Editor::redisplay_route_list ()
                if (visible) {
                        tv->set_marked_for_display (true);
                        position += tv->show_at (position, n, &edit_controls_vbox);
+                       tv->clip_to_viewport ();
                } else {
                        tv->hide ();
                }
index 0ca20e4670271e52e83cc51efa826cc49a325e15..88d585ddc29000cfdf0f273a8945f04bf4b3a918 100644 (file)
@@ -222,29 +222,15 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent)
        order = nth;
 
        if (y_position != y) {
-               /* the coordinates used here are in the system of the
-                  item's parent ...
-               */
-               Group* pg;
-               double ix1, iy1, ix2, iy2;
-               canvas_display->get_bounds (ix1, iy1, ix2, iy2);
-               iy1 += editor.get_trackview_group_vertical_offset ();
-               pg = canvas_display->property_parent();
-               pg->i2w (ix1, iy1);
-               
-               if (iy1 < 0) {
-                       iy1 = 0;
-               }
-               
-               canvas_display->move (0.0, y - iy1);
+               canvas_display->property_y () = y;
+               /* silly canvas */
+               canvas_display->move (0.0, 0.0);
                y_position = y;
-
        }
 
        canvas_display->raise_to_top ();
 
        if (_marked_for_display) {
-               canvas_display->show();
                controls_frame.show ();
                controls_ebox.show ();
        }
@@ -266,6 +252,19 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent)
        return effective_height;
 }
 
+void
+TimeAxisView::clip_to_viewport ()
+{
+       if (_marked_for_display) {
+               if (y_position  +  effective_height < editor.get_trackview_group_vertical_offset () || y_position > editor.get_trackview_group_vertical_offset () + canvas_display->get_canvas()->get_height()) {
+                       canvas_display->hide ();
+                       return;
+               }
+               canvas_display->show ();
+       }
+       return;
+}
+
 bool
 TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
 {
@@ -380,8 +379,8 @@ TimeAxisView::set_height(uint32_t h)
        if (h == height) {
                return;
        }
-       controls_frame.property_height_request () = h;
        height = h;
+       controls_frame.property_height_request () = h;
 
        if (canvas_item_visible (selection_group)) {
                /* resize the selection rect */
index 2f014c7a166ecb25d959e5a4c4f771077577f3ad..059312c16b5868ec15906c22ef3d8d211a68d90a 100644 (file)
@@ -143,6 +143,8 @@ class TimeAxisView : public virtual AxisView, public Stateful
         */
        virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
 
+       void clip_to_viewport ();
+
        bool touched (double top, double bot);
 
        /**