Make Active apply to the selection.
authorCarl Hetherington <carl@carlh.net>
Mon, 7 Mar 2011 13:04:46 +0000 (13:04 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 7 Mar 2011 13:04:46 +0000 (13:04 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9089 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_time_axis.cc
gtk2_ardour/midi_time_axis.cc
gtk2_ardour/midi_time_axis.h
gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h
gtk2_ardour/track_selection.h

index 79751145bf5f9f7034e72f2ac3309eb399dc6ae7..2480c87967f9b90743f4febe704b847465d7bf70 100644 (file)
@@ -409,7 +409,6 @@ AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
 void
 AudioTimeAxisView::route_active_changed ()
 {
-       RouteTimeAxisView::route_active_changed ();
        update_control_names ();
 }
 
index 0348e632f81f977fe64eac88e9c41ef1b7e8383e..a1e8ef1f0437743776ba0055d3890c54621b3090 100644 (file)
@@ -820,31 +820,39 @@ MidiTimeAxisView::update_range()
 }
 
 void
-MidiTimeAxisView::show_all_automation ()
+MidiTimeAxisView::show_all_automation (bool apply_to_selection)
 {
-       if (midi_track()) {
-               const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
-
-               for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
-                       create_automation_child(*i, true);
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_midi_time_axis (boost::bind (&MidiTimeAxisView::show_all_automation, _1, false));
+       } else {
+               if (midi_track()) {
+                       const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
+                       
+                       for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
+                               create_automation_child(*i, true);
+                       }
                }
+               
+               RouteTimeAxisView::show_all_automation ();
        }
-
-       RouteTimeAxisView::show_all_automation ();
 }
 
 void
-MidiTimeAxisView::show_existing_automation ()
+MidiTimeAxisView::show_existing_automation (bool apply_to_selection)
 {
-       if (midi_track()) {
-               const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
-
-               for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
-                       create_automation_child(*i, true);
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_midi_time_axis (boost::bind (&MidiTimeAxisView::show_existing_automation, _1, false));
+       } else {
+               if (midi_track()) {
+                       const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
+                       
+                       for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
+                               create_automation_child(*i, true);
+                       }
                }
+               
+               RouteTimeAxisView::show_existing_automation ();
        }
-
-       RouteTimeAxisView::show_existing_automation ();
 }
 
 /** Create an automation track for the given parameter (pitch bend, channel pressure).
index 94926e28a24d740eb77e6fadc3e0bd18e8829d86..88dcb9d9171d4f6c69d5776f53c4e7ccb717294b 100644 (file)
@@ -74,8 +74,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
         
        boost::shared_ptr<ARDOUR::MidiRegion> add_region (ARDOUR::framepos_t, ARDOUR::framecnt_t, bool);
 
-       void show_all_automation ();
-       void show_existing_automation ();
+       void show_all_automation (bool apply_to_selection = false);
+       void show_existing_automation (bool apply_to_selection = false);
        void create_automation_child (const Evoral::Parameter& param, bool show);
 
        ARDOUR::NoteMode  note_mode() const { return _note_mode; }
index 919ec86adaa6ceb9c343728288648c870427e41e..ba79bd2419789ffe0351bfbff78faabd6bbc7803 100644 (file)
@@ -1321,13 +1321,13 @@ MixerStrip::show_route_color ()
 {
        name_button.modify_bg (STATE_NORMAL, color());
        top_event_box.modify_bg (STATE_NORMAL, color());
-       route_active_changed ();
+       reset_strip_style ();
 }
 
 void
 MixerStrip::show_passthru_color ()
 {
-       route_active_changed ();
+       reset_strip_style ();
 }
 
 void
@@ -1345,9 +1345,10 @@ MixerStrip::build_route_ops_menu ()
        items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
        rename_menu_item = &items.back();
        items.push_back (SeparatorElem());
-       items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
-       route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
-       route_active_menu_item->set_active (_route->active());
+       items.push_back (CheckMenuElem (_("Active")));
+       CheckMenuItem* i = dynamic_cast<CheckMenuItem *> (&items.back());
+       i->set_active (_route->active());
+       i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
 
        items.push_back (SeparatorElem());
 
@@ -1387,9 +1388,8 @@ MixerStrip::name_button_button_press (GdkEventButton* ev)
 void
 MixerStrip::list_route_operations ()
 {
-       if (route_ops_menu == 0) {
-               build_route_ops_menu ();
-       }
+       delete route_ops_menu;
+       build_route_ops_menu ();
 }
 
 void
@@ -1496,13 +1496,6 @@ MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
        }
 }
 
-void
-MixerStrip::route_active_changed ()
-{
-       RouteUI::route_active_changed ();
-       reset_strip_style ();
-}
-
 void
 MixerStrip::reset_strip_style ()
 {
index 5debbdb3a18932a25d027946996721d2688062c1..ef35bf237d9e49d4c2076d95bcd1151037e74372 100644 (file)
@@ -260,8 +260,6 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
        void show_route_color ();
        void show_passthru_color ();
 
-       void route_active_changed ();
-
        void name_changed ();
        void update_speed_display ();
        void map_frozen ();
index 7197f30bcd79f35310473c5589e058b73d1e1200..cb9f23ff32eaa5b062f33395a3c1ab8aac3a26ef 100644 (file)
@@ -621,9 +621,32 @@ RouteTimeAxisView::build_display_menu ()
                items.push_back (SeparatorElem());
        }
 
-       items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
-       route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
-       route_active_menu_item->set_active (_route->active());
+       int active = 0;
+       int inactive = 0;
+       TrackSelection const & s = _editor.get_selection().tracks;
+       for (TrackSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
+               RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
+               if (!r) {
+                       continue;
+               }
+
+               if (r->route()->active()) {
+                       ++active;
+               } else {
+                       ++inactive;
+               }
+       }
+
+       items.push_back (CheckMenuElem (_("Active")));
+       CheckMenuItem* i = dynamic_cast<CheckMenuItem *> (&items.back());
+       bool click_sets_active = true;
+       if (active > 0 && inactive == 0) {
+               i->set_active (true);
+               click_sets_active = false;
+       } else if (active > 0 && inactive > 0) {
+               i->set_inconsistent (true);
+       }
+       i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), click_sets_active, true));
 
        items.push_back (SeparatorElem());
        items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
index 4600f04f1465d4f533331d2d817e55448f660b15..3df8e74d493aafce76e213778b8024990637d675 100644 (file)
@@ -109,7 +109,6 @@ RouteUI::init ()
         solo_safe_led = 0;
        _solo_release = 0;
        _mute_release = 0;
-       route_active_menu_item = 0;
        denormal_menu_item = 0;
         step_edit_item = 0;
        multiple_mute_change = false;
@@ -179,7 +178,6 @@ RouteUI::reset ()
                xml_node = 0;
        }
 
-       route_active_menu_item = 0;
        denormal_menu_item = 0;
 }
 
@@ -1467,26 +1465,15 @@ RouteUI::property_changed (const PropertyChange& what_changed)
 }
 
 void
-RouteUI::toggle_route_active ()
+RouteUI::set_route_active (bool a, bool apply_to_selection)
 {
-       bool yn;
-
-       if (route_active_menu_item) {
-               if (route_active_menu_item->get_active() != (yn = _route->active())) {
-                       _route->set_active (!yn, this);
-               }
-       }
-}
-
-void
-RouteUI::route_active_changed ()
-{
-       if (route_active_menu_item) {
-               Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&CheckMenuItem::set_active, route_active_menu_item, _route->active()));
+       if (apply_to_selection) {
+               ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteTimeAxisView::set_route_active, _1, a, false));
+       } else {
+               _route->set_active (a, this);
        }
 }
 
-
 void
 RouteUI::toggle_denormal_protection ()
 {
index 4a33c8f16dcdb0c0e246840a158de50a3e0fc800..41721abc774e7690f771900b18f8e7a8a3868dcc 100644 (file)
@@ -175,9 +175,8 @@ class RouteUI : public virtual AxisView
        virtual void property_changed (const PBD::PropertyChange&);
        void route_removed ();
 
-       Gtk::CheckMenuItem *route_active_menu_item;
-       void toggle_route_active ();
-       virtual void route_active_changed ();
+       virtual void route_active_changed () {}
+       void set_route_active (bool, bool);
 
         Gtk::Menu* record_menu;
         void build_record_menu ();
index e61e62958f6a2dadec2f791b17e4a71a3b344114..5f85bcfd5866e73323abe38df7b104aeb3edfa9e 100644 (file)
@@ -23,6 +23,7 @@
 #include "track_view_list.h"
 #include "route_ui.h"
 #include "audio_time_axis.h"
+#include "midi_time_axis.h"
 
 class PublicEditor;
 
@@ -47,7 +48,9 @@ public:
        void foreach_route_ui (Function f) {
                for (iterator i = begin(); i != end(); ++i) {
                        RouteUI* t = dynamic_cast<RouteUI*> (*i);
-                       f (t);
+                       if (t) {
+                               f (t);
+                       }
                }
        }
 
@@ -55,7 +58,9 @@ public:
        void foreach_route_time_axis (Function f) {
                for (iterator i = begin(); i != end(); ++i) {
                        RouteTimeAxisView* t = dynamic_cast<RouteTimeAxisView*> (*i);
-                       f (t);
+                       if (t) {
+                               f (t);
+                       }
                }
        }
 
@@ -63,7 +68,19 @@ public:
        void foreach_audio_time_axis (Function f) {
                for (iterator i = begin(); i != end(); ++i) {
                        AudioTimeAxisView* t = dynamic_cast<AudioTimeAxisView*> (*i);
-                       f (t);
+                       if (t) {
+                               f (t);
+                       }
+               }
+       }
+
+       template <typename Function>
+       void foreach_midi_time_axis (Function f) {
+               for (iterator i = begin(); i != end(); ++i) {
+                       MidiTimeAxisView* t = dynamic_cast<MidiTimeAxisView*> (*i);
+                       if (t) {
+                               f (t);
+                       }
                }
        }