change automation track selection model slightly so that auto tracks are highlighted...
authorBen Loftis <ben@glw.com>
Mon, 26 Apr 2010 21:47:58 +0000 (21:47 +0000)
committerBen Loftis <ben@glw.com>
Mon, 26 Apr 2010 21:47:58 +0000 (21:47 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6997 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_mixer.cc
gtk2_ardour/editor_selection.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h

index 6d2a882091909a0e32986b2cfc9e71995589cfd6..d6fa49a132ac87e7633133b578f415008b357f5c 100644 (file)
@@ -30,6 +30,7 @@
 #include "ardour_ui.h"
 #include "selection.h"
 #include "audio_time_axis.h"
+#include "automation_time_axis.h"
 #include "actions.h"
 
 #include "i18n.h"
@@ -162,13 +163,11 @@ Editor::create_editor_mixer ()
 void
 Editor::set_selected_mixer_strip (TimeAxisView& view)
 {
-       AudioTimeAxisView* at;
        bool show = false;
        bool created;
 
-       if (!session || (at = dynamic_cast<AudioTimeAxisView*>(&view)) == 0) {
+       if (!session)
                return;
-       }
 
        Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
        if (act) {
@@ -186,9 +185,21 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
                created = false;
        }
 
-       /* might be nothing to do */
+       //if this is an automation track then we should show the parent
+       boost::shared_ptr<ARDOUR::Route> route;
+       AutomationTimeAxisView *auto_tav;
+       if ( (auto_tav  = dynamic_cast<AutomationTimeAxisView*>(&view)) == 0 ) {
+               AudioTimeAxisView* at = dynamic_cast<AudioTimeAxisView*>(&view);
+               if (at != NULL)
+                       route = at->route();
+       } else {
+               AudioTimeAxisView *parent = dynamic_cast<AudioTimeAxisView*>( view.get_parent() );
+               if (parent != NULL) {
+                       route = parent->route();
+               }
+       }
        
-       if (current_mixer_strip->route() == at->route()) {
+       if (current_mixer_strip->route() == route) {
                return;
        }
        
@@ -196,7 +207,7 @@ Editor::set_selected_mixer_strip (TimeAxisView& view)
                show = true;
        }
 
-       current_mixer_strip->set_route (at->route());
+       current_mixer_strip->set_route (route);
 
        if (created) {
                current_mixer_strip->set_width (editor_mixer_strip_width, (void*) this);
@@ -315,18 +326,6 @@ Editor::current_mixer_strip_removed ()
 void
 Editor::current_mixer_strip_hidden ()
 {
-       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-               
-               AudioTimeAxisView* tmp;
-               
-               if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) {
-                       if (tmp->route() == current_mixer_strip->route()) {
-                               (*i)->set_selected (false);
-                               break;
-                       }
-               }
-       }
-
        Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
        if (act) {
                Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
index baaca9985084b2f29e09b07a24a1a61747422f87..40f98b11e9bd6124ef5f6c7c4e0a26f55d57d516 100644 (file)
@@ -829,11 +829,7 @@ Editor::track_selection_changed ()
        }
 
        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-               if (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()) {
-                       (*i)->set_selected (true);
-               } else {
-                       (*i)->set_selected (false);
-               }
+                       (*i)->set_selected ( *selection );
        }
 
        ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty());
index c0b6a697adfe97382fc5e6f9a035b2229f39b1fc..14a30bab47ffb9d3cebf279d693e9feb299a7b01 100644 (file)
@@ -588,20 +588,32 @@ TimeAxisView::popup_size_menu (guint32 when)
 }
 
 void
-TimeAxisView::set_selected (bool yn)
+TimeAxisView::set_selected (Selection &selection)
 {
-       if (yn == _selected) {
+       //give children a chance to be selected
+       for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
+               (*i)->set_selected (selection);
+       }
+
+       //determine if I am in the selection
+       bool selected = false;
+       if (find (selection.tracks.begin(), selection.tracks.end(), this) != selection.tracks.end()) {
+               selected = true;
+       }
+
+       //bail out here if my state is unchanged
+       if (selected == _selected) {
                return;
        }
        
-       Selectable::set_selected (yn);
+       Selectable::set_selected (selected);
 
        if (_selected) {
                controls_ebox.set_name (controls_base_selected_name);
                controls_frame.set_name (controls_base_selected_name);
                controls_vbox.set_name (controls_base_selected_name);
-               /* propagate any existing selection, if the mode is right */
 
+               /* propagate any existing selection, if the mode is right */
                if (editor.current_mouse_mode() == Editing::MouseRange && !editor.get_selection().time.empty()) {
                        show_selection (editor.get_selection().time);
                }
@@ -611,15 +623,6 @@ TimeAxisView::set_selected (bool yn)
                controls_frame.set_name (controls_base_unselected_name);
                controls_vbox.set_name (controls_base_unselected_name);
                hide_selection ();
-
-               /* children will be set for the yn=true case. but when deselecting
-                  the editor only has a list of top-level trackviews, so we
-                  have to do this here.
-               */
-
-               for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
-                       (*i)->set_selected (false);
-               }
        }
 
        resizer.queue_draw ();
@@ -693,10 +696,6 @@ TimeAxisView::show_selection (TimeSelection& ts)
        double y2;
        SelectionRect *rect;
 
-       for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
-               (*i)->show_selection (ts);
-       }
-
        if (canvas_item_visible (selection_group)) {
                while (!used_selection_rects.empty()) {
                        free_selection_rects.push_front (used_selection_rects.front());
index b624bda73a94b619f2636bd27238ed158c5e97b5..86721a55e28335057f52da3faf4dea470445dba7 100644 (file)
@@ -155,7 +155,7 @@ class TimeAxisView : public virtual AxisView, public Stateful
        virtual void hide ();
        bool hidden() const { return _hidden; }
 
-       virtual void set_selected (bool);
+       virtual void set_selected (Selection&);
 
        /**
         * potential handler for entered events
@@ -225,6 +225,7 @@ class TimeAxisView : public virtual AxisView, public Stateful
        /* state/serialization management */
 
        void set_parent (TimeAxisView& p);
+       TimeAxisView *get_parent () {return parent;}
        bool has_state () const;
 
        /* call this on the parent */