Make Active apply to the selection.
[ardour.git] / gtk2_ardour / audio_time_axis.cc
index fd809a9b0d7cafd692e299e9c43fa4b7b0bf4844..2480c87967f9b90743f4febe704b847465d7bf70 100644 (file)
@@ -40,7 +40,9 @@
 #include "ardour/audioplaylist.h"
 #include "ardour/event_type_map.h"
 #include "ardour/location.h"
+#include "ardour/pannable.h"
 #include "ardour/panner.h"
+#include "ardour/panner_shell.h"
 #include "ardour/playlist.h"
 #include "ardour/processor.h"
 #include "ardour/profile.h"
@@ -107,8 +109,8 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session* sess, boost::sh
        }
 
        if (_route->panner()) {
-               _route->panner()->Changed.connect (*this, invalidator (*this), 
-                                                   boost::bind (&AudioTimeAxisView::ensure_pan_views, this, false), gui_context());
+               _route->panner_shell()->Changed.connect (*this, invalidator (*this), 
+                                                         boost::bind (&AudioTimeAxisView::ensure_pan_views, this, false), gui_context());
        }
 
        /* map current state of the route */
@@ -178,9 +180,10 @@ AudioTimeAxisView::append_extra_display_menu_items ()
        MenuList& items = display_menu->items();
 
        // crossfade stuff
-       if (!Profile->get_sae()) {
-               items.push_back (MenuElem (_("Hide All Crossfades"), sigc::mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
-               items.push_back (MenuElem (_("Show All Crossfades"), sigc::mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
+       if (!Profile->get_sae() && is_track ()) {
+               items.push_back (MenuElem (_("Hide All Crossfades"), sigc::bind (sigc::mem_fun(*this, &AudioTimeAxisView::hide_all_xfades), true)));
+               items.push_back (MenuElem (_("Show All Crossfades"), sigc::bind (sigc::mem_fun(*this, &AudioTimeAxisView::show_all_xfades), true)));
+               items.push_back (SeparatorElem ());
        }
 }
 
@@ -189,27 +192,19 @@ AudioTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool
 {
        if (param.type() == GainAutomation) {
 
-               boost::shared_ptr<AutomationControl> c = _route->gain_control();
-               if (!c) {
-                       error << "Route has no gain automation, unable to add automation track view." << endmsg;
-                       return;
-               }
-
-               gain_track.reset (new AutomationTimeAxisView (_session,
-                                                             _route, _route->amp(), c,
-                                                             _editor,
-                                                             *this,
-                                                             false,
-                                                             parent_canvas,
-                                                             _route->amp()->describe_parameter(param)));
-
-               add_automation_child(Evoral::Parameter(GainAutomation), gain_track, show);
+               create_gain_automation_child (param, show);
 
-       } else if (param.type() == PanAutomation) {
+       } else if (param.type() == PanWidthAutomation ||
+                   param.type() == PanElevationAutomation ||
+                   param.type() == PanAzimuthAutomation) {
 
                ensure_xml_node ();
                ensure_pan_views (show);
 
+       } else if (param.type() == PluginAutomation) {
+                
+               /* handled elsewhere */
+
        } else {
                error << "AudioTimeAxisView: unknown automation child " << EventTypeMap::instance().to_symbol(param) << endmsg;
        }
@@ -227,13 +222,11 @@ AudioTimeAxisView::ensure_pan_views (bool show)
                return;
        }
 
-       const set<Evoral::Parameter>& params = _route->panner()->what_can_be_automated();
+       set<Evoral::Parameter> params = _route->panner()->what_can_be_automated();
        set<Evoral::Parameter>::iterator p;
 
        for (p = params.begin(); p != params.end(); ++p) {
-               boost::shared_ptr<ARDOUR::AutomationControl> pan_control
-                       = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
-                               _route->panner()->control(*p));
+               boost::shared_ptr<ARDOUR::AutomationControl> pan_control = _route->pannable()->automation_control(*p);
 
                if (pan_control->parameter().type() == NullAutomation) {
                        error << "Pan control has NULL automation type!" << endmsg;
@@ -248,7 +241,10 @@ AudioTimeAxisView::ensure_pan_views (bool show)
 
                        boost::shared_ptr<AutomationTimeAxisView> t (
                                new AutomationTimeAxisView (_session,
-                                                           _route, _route->panner(), pan_control,
+                                                           _route, 
+                                                            _route->pannable(), 
+                                                            pan_control,
+                                                           pan_control->parameter (),
                                                            _editor,
                                                            *this,
                                                            false,
@@ -315,57 +311,76 @@ AudioTimeAxisView::update_pan_track_visibility ()
 }
 
 void
-AudioTimeAxisView::show_all_automation ()
+AudioTimeAxisView::show_all_automation (bool apply_to_selection)
 {
-       no_redraw = true;
-
-       RouteTimeAxisView::show_all_automation ();
-
-       no_redraw = false;
-
-       _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::show_all_automation, _1, false));
+       } else {
+               
+               no_redraw = true;
+               
+               RouteTimeAxisView::show_all_automation ();
+
+               no_redraw = false;
+               
+               _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       }
 }
 
 void
-AudioTimeAxisView::show_existing_automation ()
+AudioTimeAxisView::show_existing_automation (bool apply_to_selection)
 {
-       no_redraw = true;
-
-       RouteTimeAxisView::show_existing_automation ();
-
-       no_redraw = false;
-
-       _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::show_existing_automation, _1, false));
+       } else {
+               no_redraw = true;
+               
+               RouteTimeAxisView::show_existing_automation ();
+               
+               no_redraw = false;
+               
+               _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       }
 }
 
 void
-AudioTimeAxisView::hide_all_automation ()
+AudioTimeAxisView::hide_all_automation (bool apply_to_selection)
 {
-       no_redraw = true;
-
-       RouteTimeAxisView::hide_all_automation();
-
-       no_redraw = false;
-       _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::hide_all_automation, _1, false));
+       } else {
+               no_redraw = true;
+               
+               RouteTimeAxisView::hide_all_automation();
+               
+               no_redraw = false;
+               _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+       }
 }
 
 void
-AudioTimeAxisView::show_all_xfades ()
+AudioTimeAxisView::show_all_xfades (bool apply_to_selection)
 {
-       AudioStreamView* asv = audio_view();
-
-       if (asv) {
-               asv->show_all_xfades ();
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::show_all_xfades, _1, false));
+       } else {
+               AudioStreamView* asv = audio_view ();
+               if (asv) {
+                       asv->show_all_xfades ();
+               }
        }
 }
 
 void
-AudioTimeAxisView::hide_all_xfades ()
+AudioTimeAxisView::hide_all_xfades (bool apply_to_selection)
 {
-       AudioStreamView* asv = audio_view();
-
-       if (asv) {
-               asv->hide_all_xfades ();
+       if (apply_to_selection) {
+               _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::hide_all_xfades, _1, false));
+       } else {
+               AudioStreamView* asv = audio_view ();
+               if (asv) {
+                       asv->hide_all_xfades ();
+               }
        }
 }
 
@@ -394,7 +409,6 @@ AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
 void
 AudioTimeAxisView::route_active_changed ()
 {
-       RouteTimeAxisView::route_active_changed ();
        update_control_names ();
 }
 
@@ -434,25 +448,25 @@ AudioTimeAxisView::update_control_names ()
 }
 
 void
-AudioTimeAxisView::build_automation_action_menu ()
+AudioTimeAxisView::build_automation_action_menu (bool for_selection)
 {
        using namespace Menu_Helpers;
 
-       RouteTimeAxisView::build_automation_action_menu ();
+       RouteTimeAxisView::build_automation_action_menu (for_selection);
 
        MenuList& automation_items = automation_action_menu->items ();
 
        automation_items.push_back (CheckMenuElem (_("Fader"), sigc::mem_fun (*this, &AudioTimeAxisView::update_gain_track_visibility)));
        gain_automation_item = dynamic_cast<CheckMenuItem*> (&automation_items.back ());
-       gain_automation_item->set_active (gain_track->marked_for_display ());
+       gain_automation_item->set_active (gain_track->marked_for_display () && (!for_selection || _editor.get_selection().tracks.size() == 1));
 
        _main_automation_menu_map[Evoral::Parameter(GainAutomation)] = gain_automation_item;
 
        automation_items.push_back (CheckMenuElem (_("Pan"), sigc::mem_fun (*this, &AudioTimeAxisView::update_pan_track_visibility)));
        pan_automation_item = dynamic_cast<CheckMenuItem*> (&automation_items.back ());
-       pan_automation_item->set_active (pan_tracks.front()->marked_for_display ());
+       pan_automation_item->set_active (pan_tracks.front()->marked_for_display () && (!for_selection || _editor.get_selection().tracks.size() == 1));
 
-       set<Evoral::Parameter> const & params = _route->panner()->what_can_be_automated ();
+       set<Evoral::Parameter> const & params = _route->pannable()->what_can_be_automated ();
        for (set<Evoral::Parameter>::iterator p = params.begin(); p != params.end(); ++p) {
                _main_automation_menu_map[*p] = pan_automation_item;
        }
@@ -475,3 +489,19 @@ AudioTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> w
                RouteTimeAxisView::add_processor_to_subplugin_menu (wp);
        }
 }
+
+void
+AudioTimeAxisView::enter_internal_edit_mode ()
+{
+        if (audio_view()) {
+                audio_view()->enter_internal_edit_mode ();
+        }
+}
+
+void
+AudioTimeAxisView::leave_internal_edit_mode ()
+{
+        if (audio_view()) {
+                audio_view()->leave_internal_edit_mode ();
+        }
+}