Remove 'pipex' from my pbd.vcproj as it's not needed for Ardour3
[ardour.git] / gtk2_ardour / editor_routes.cc
index e0b562b4942f48682221437cbdc0dce0b1e99aad..38706a652587e2afa76d6018e2457ce0cb0be1b5 100644 (file)
@@ -222,6 +222,7 @@ EditorRoutes::EditorRoutes (Editor* e)
        _display.set_headers_visible (true);
        _display.get_selection()->set_mode (SELECTION_SINGLE);
        _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
+       _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
        _display.set_reorderable (true);
        _display.set_name (X_("EditGroupList"));
        _display.set_rules_hint (true);
@@ -518,7 +519,7 @@ EditorRoutes::redisplay ()
                /* show or hide the TimeAxisView */
                if (visible) {
                        position += tv->show_at (position, n, &_editor->edit_controls_vbox);
-                       tv->clip_to_viewport ();
+                       // SHOWTRACKS
                } else {
                        tv->hide ();
                }
@@ -534,15 +535,14 @@ EditorRoutes::redisplay ()
 
         _editor->reset_controls_layout_height (position);
         _editor->reset_controls_layout_width ();
-       _editor->full_canvas_height = position + _editor->canvas_timebars_vsize;
-       _editor->vertical_adjustment.set_upper (_editor->full_canvas_height);
+       _editor->_full_canvas_height = position;
 
-       if ((_editor->vertical_adjustment.get_value() + _editor->_canvas_height) > _editor->vertical_adjustment.get_upper()) {
+       if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
                /*
                   We're increasing the size of the canvas while the bottom is visible.
                   We scroll down to keep in step with the controls layout.
                */
-               _editor->vertical_adjustment.set_value (_editor->full_canvas_height - _editor->_canvas_height);
+               _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
        }
 }
 
@@ -706,7 +706,6 @@ EditorRoutes::handle_gui_changes (string const & what, void*)
                /* Optional :make tracks change height while it happens, instead
                   of on first-idle
                */
-               //update_canvas_now ();
                redisplay ();
        }
 
@@ -1025,12 +1024,6 @@ EditorRoutes::hide_all_tracks (bool /*with_select*/)
        }
 
        resume_redisplay ();
-
-       /* XXX this seems like a hack and half, but its not clear where to put this
-          otherwise.
-       */
-
-       //reset_scrolling_region ();
 }
 
 void
@@ -1296,27 +1289,46 @@ EditorRoutes::button_press (GdkEventButton* ev)
        //Scroll editor canvas to selected track
        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
 
-               // Get the model row.
                Gtk::TreeModel::Row row = *_model->get_iter (path);
-
                TimeAxisView *tv = row[_columns.tv];
 
-               int y_pos = tv->y_position();
-
-               //Clamp the y pos so that we do not extend beyond the canvas full height.
-               if (_editor->full_canvas_height - y_pos < _editor->_canvas_height){
-                   y_pos = _editor->full_canvas_height - _editor->_canvas_height;
-               }
-
-               //Only scroll to if the track is visible
-               if(y_pos != -1){
-                   _editor->reset_y_origin (y_pos);
+               if (tv) {
+                       _editor->ensure_time_axis_view_is_visible (*tv, true);
                }
        }
 
        return false;
 }
 
+void
+EditorRoutes::selection_changed ()
+{
+       if (_display.get_selection()->count_selected_rows() > 0) {
+
+               TreeIter iter;
+               TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
+               TrackViewList selected;
+
+               _editor->get_selection().clear_regions ();
+
+               for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
+
+                       if ((iter = _model->get_iter (*i))) {
+
+                               TimeAxisView* tv = (*iter)[_columns.tv];
+                               selected.push_back (tv);
+                       }
+                       
+               }
+
+               _editor->get_selection().set (selected);
+               _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
+
+       } else {
+               _editor->get_selection().clear_tracks ();
+       }
+}
+
 bool
 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const &, TreeModel::Path const&, bool /*selected*/)
 {