Make activate/deactivate all only operate on visible
[ardour.git] / gtk2_ardour / editor.cc
index d45d89a96e6106db35ce1c9c694b99dc4f34d90a..80f7feed72d34509cb9cb5b15e58d14d8eb37efa 100644 (file)
@@ -58,7 +58,6 @@
 #include "gtkmm2ext/choice.h"
 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
 
-#include "ardour/audio_diskstream.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioplaylist.h"
 #include "ardour/audioregion.h"
 #include "marker.h"
 #include "midi_time_axis.h"
 #include "mixer_strip.h"
+#include "mixer_ui.h"
 #include "mouse_cursors.h"
 #include "playlist_selector.h"
 #include "public_editor.h"
@@ -267,10 +267,8 @@ Editor::Editor ()
        , toolbar_selection_clock_table (2,3)
 
        , automation_mode_button (_("mode"))
-       , global_automation_button (_("automation"))
 
        , _toolbar_viewport (*manage (new Gtk::Adjustment (0, 0, 1e10)), *manage (new Gtk::Adjustment (0, 0, 1e10)))
-       , midi_panic_button (_("Panic"))
 
 #ifdef WITH_CMT
        , image_socket_listener(0)
@@ -285,6 +283,7 @@ Editor::Editor ()
        , _last_cut_copy_source_track (0)
 
        , _region_selection_change_updates_region_list (true)
+       , _following_mixer_selection (false)
 {
        constructed = false;
 
@@ -704,6 +703,7 @@ Editor::Editor ()
        ControlProtocol::ZoomIn.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, false), gui_context());
        ControlProtocol::ZoomOut.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, true), gui_context());
        ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), ui_bind (&Editor::control_scroll, this, _1), gui_context());
+       ControlProtocol::SelectByRID.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1), gui_context());
        BasicUI::AccessAction.connect (*this, invalidator (*this), ui_bind (&Editor::access_action, this, _1, _2), gui_context());
 
        /* problematic: has to return a value and thus cannot be x-thread */
@@ -871,6 +871,7 @@ Editor::show_window ()
 
                if (current_mixer_strip) {
                        current_mixer_strip->hide_things ();
+                       current_mixer_strip->parameter_changed ("mixer-strip-visibility");
                }
        }
 
@@ -911,6 +912,32 @@ Editor::zoom_adjustment_changed ()
        temporal_zoom (fpu);
 }
 
+void
+Editor::control_select (uint32_t rid) 
+{
+       /* handles the (static) signal from the ControlProtocol class that
+        * requests setting the selected track to a given RID
+        */
+        
+       if (!_session) {
+               return;
+       }
+
+       boost::shared_ptr<Route> r = _session->route_by_remote_id (rid);
+
+       if (!r) {
+               return;
+       }
+
+       TimeAxisView* tav = axis_view_from_route (r);
+
+       if (tav) {
+               selection->set (tav);
+       } else {
+               selection->clear_tracks ();
+       }
+}
+
 void
 Editor::control_scroll (float fraction)
 {
@@ -1111,6 +1138,44 @@ Editor::set_session (Session *t)
 
        compute_fixed_ruler_scale ();
 
+       /* Make sure we have auto loop and auto punch ranges */
+
+       Location* loc = _session->locations()->auto_loop_location();
+       if (loc == 0) {
+               loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
+
+               if (loc->start() == loc->end()) {
+                       loc->set_end (loc->start() + 1);
+               }
+
+               _session->locations()->add (loc, false);
+               _session->set_auto_loop_location (loc);
+       } else {
+               // force name
+               loc->set_name (_("Loop"));
+       }
+
+       loc = _session->locations()->auto_punch_location();
+
+       if (loc == 0) {
+               loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
+
+               if (loc->start() == loc->end()) {
+                       loc->set_end (loc->start() + 1);
+               }
+
+               _session->locations()->add (loc, false);
+               _session->set_auto_punch_location (loc);
+       } else {
+               // force name
+               loc->set_name (_("Punch"));
+       }
+
+       refresh_location_display ();
+
+       /* This must happen after refresh_location_display(), as (amongst other things) we restore
+          the selected Marker; this needs the LocationMarker list to be available.
+       */
        XMLNode* node = ARDOUR_UI::instance()->editor_settings();
        set_state (*node, Stateful::loading_state_version);
 
@@ -1156,43 +1221,10 @@ Editor::set_session (Session *t)
 
        playhead_cursor->canvas_item.show ();
 
-       Location* loc = _session->locations()->auto_loop_location();
-       if (loc == 0) {
-               loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
-
-               if (loc->start() == loc->end()) {
-                       loc->set_end (loc->start() + 1);
-               }
-
-               _session->locations()->add (loc, false);
-               _session->set_auto_loop_location (loc);
-       } else {
-               // force name
-               loc->set_name (_("Loop"));
-       }
-
-       loc = _session->locations()->auto_punch_location();
-
-       if (loc == 0) {
-               loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
-
-               if (loc->start() == loc->end()) {
-                       loc->set_end (loc->start() + 1);
-               }
-
-               _session->locations()->add (loc, false);
-               _session->set_auto_punch_location (loc);
-       } else {
-               // force name
-               loc->set_name (_("Punch"));
-       }
-
        boost::function<void (string)> pc (boost::bind (&Editor::parameter_changed, this, _1));
        Config->map_parameters (pc);
        _session->config.map_parameters (pc);
 
-       refresh_location_display ();
-
        restore_ruler_visibility ();
        //tempo_map_changed (PropertyChange (0));
        _session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
@@ -1218,7 +1250,7 @@ Editor::set_session (Session *t)
        }
 
        /* register for undo history */
-       _session->register_with_memento_command_factory(_id, this);
+       _session->register_with_memento_command_factory(id(), this);
 
        ActionManager::ui_manager->signal_pre_activate().connect (sigc::mem_fun (*this, &Editor::action_pre_activated));
 
@@ -1857,7 +1889,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
        edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), true, true)));
        edit_items.push_back (MenuElem (_("Bounce Range to Region List"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, false)));
        edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, true)));
-       edit_items.push_back (MenuElem (_("Export Range"), sigc::mem_fun(*this, &Editor::export_selection)));
+       edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection)));
 }
 
 
@@ -2134,9 +2166,7 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        int x, y;
        Gdk::Geometry g;
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       }
+       set_id (node);
 
        g.base_width = default_width;
        g.base_height = default_height;
@@ -2348,7 +2378,7 @@ Editor::get_state ()
        XMLNode* node = new XMLNode ("Editor");
        char buf[32];
 
-       _id.print (buf, sizeof (buf));
+       id().print (buf, sizeof (buf));
        node->add_property ("id", buf);
 
        if (is_realized()) {
@@ -2730,6 +2760,7 @@ Editor::setup_toolbar ()
        /* table containing mode buttons */
 
        HBox* mouse_mode_button_box = manage (new HBox ());
+       mouse_mode_button_box->set_spacing (2);
 
        if (Profile->get_sae()) {
                mouse_mode_button_box->pack_start (mouse_move_button);
@@ -2779,48 +2810,30 @@ Editor::setup_toolbar ()
        _mouse_mode_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
                                                          &_mouse_mode_tearoff->tearoff_window(), 1));
 
-       mouse_move_button.set_mode (false);
-       mouse_select_button.set_mode (false);
-       mouse_gain_button.set_mode (false);
-       mouse_zoom_button.set_mode (false);
-       mouse_timefx_button.set_mode (false);
-       mouse_audition_button.set_mode (false);
-       join_object_range_button.set_mode (false);
-
-       mouse_move_button.set_name ("MouseModeButton");
-       mouse_select_button.set_name ("MouseModeButton");
-       mouse_gain_button.set_name ("MouseModeButton");
-       mouse_zoom_button.set_name ("MouseModeButton");
-       mouse_timefx_button.set_name ("MouseModeButton");
-       mouse_audition_button.set_name ("MouseModeButton");
-       internal_edit_button.set_name ("MouseModeButton");
-       join_object_range_button.set_name ("MouseModeButton");
-
-       mouse_move_button.unset_flags (CAN_FOCUS);
-       mouse_select_button.unset_flags (CAN_FOCUS);
-       mouse_gain_button.unset_flags (CAN_FOCUS);
-       mouse_zoom_button.unset_flags (CAN_FOCUS);
-       mouse_timefx_button.unset_flags (CAN_FOCUS);
-       mouse_audition_button.unset_flags (CAN_FOCUS);
-       internal_edit_button.unset_flags (CAN_FOCUS);
-       join_object_range_button.unset_flags (CAN_FOCUS);
-
        /* Zoom */
 
-       _zoom_box.set_spacing (1);
-       _zoom_box.set_border_width (0);
+       _zoom_box.set_spacing (2);
+       _zoom_box.set_border_width (2);
+
+       RefPtr<Action> act;
 
-       zoom_in_button.set_name ("EditorTimeButton");
-       zoom_in_button.set_image (*(manage (new Image (::get_icon ("zoom_in")))));
-       zoom_in_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), false));
+       zoom_in_button.set_name ("zoom button");
+       zoom_in_button.set_image (::get_icon ("zoom_in"));
+       zoom_in_button.set_tweaks (ArdourButton::ShowClick);
+       act = ActionManager::get_action (X_("Editor"), X_("temporal-zoom-in"));
+       zoom_in_button.set_related_action (act);
 
-       zoom_out_button.set_name ("EditorTimeButton");
-       zoom_out_button.set_image (*(manage (new Image (::get_icon ("zoom_out")))));
-       zoom_out_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), true));
+       zoom_out_button.set_name ("zoom button");
+       zoom_out_button.set_image (::get_icon ("zoom_out"));
+       zoom_out_button.set_tweaks (ArdourButton::ShowClick);
+       act = ActionManager::get_action (X_("Editor"), X_("temporal-zoom-out"));
+       zoom_out_button.set_related_action (act);
 
-       zoom_out_full_button.set_name ("EditorTimeButton");
-       zoom_out_full_button.set_image (*(manage (new Image (::get_icon ("zoom_full")))));
-       zoom_out_full_button.signal_clicked().connect (sigc::mem_fun(*this, &Editor::temporal_zoom_session));
+       zoom_out_full_button.set_name ("zoom button");
+       zoom_out_full_button.set_image (::get_icon ("zoom_full"));
+       zoom_out_full_button.set_tweaks (ArdourButton::ShowClick);
+       act = ActionManager::get_action (X_("Editor"), X_("zoom-to-session"));
+       zoom_out_full_button.set_related_action (act);
 
        zoom_focus_selector.set_name ("ZoomFocusSelector");
        set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
@@ -2836,7 +2849,7 @@ Editor::setup_toolbar ()
        tav_expand_button.set_name ("TrackHeightButton");
        tav_expand_button.set_size_request (-1, 20);
        tav_expand_button.add (*(manage (new Image (::get_icon ("tav_exp")))));
-       RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("expand-tracks"));
+       act = ActionManager::get_action (X_("Editor"), X_("expand-tracks"));
        act->connect_proxy (tav_expand_button);
 
        tav_shrink_button.set_name ("TrackHeightButton");
@@ -2881,7 +2894,7 @@ Editor::setup_toolbar ()
        /* Nudge */
 
        HBox *nudge_box = manage (new HBox);
-       nudge_box->set_spacing(1);
+       nudge_box->set_spacing (2);
        nudge_box->set_border_width (2);
 
        nudge_forward_button.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::nudge_forward_release), false);
@@ -2968,19 +2981,9 @@ Editor::setup_tooltips ()
        ARDOUR_UI::instance()->set_tip (snap_mode_selector, _("Snap/Grid Mode"));
        ARDOUR_UI::instance()->set_tip (edit_point_selector, _("Edit point"));
        ARDOUR_UI::instance()->set_tip (midi_sound_notes, _("Sound Notes"));
-       ARDOUR_UI::instance()->set_tip (midi_panic_button, _("Send note off and reset controller messages on all MIDI channels"));
        ARDOUR_UI::instance()->set_tip (edit_mode_selector, _("Edit Mode"));
 }
 
-void
-Editor::midi_panic ()
-{
-       cerr << "MIDI panic\n";
-
-       if (_session) {
-               _session->midi_panic();
-       }
-}
 
 void
 Editor::setup_midi_toolbar ()
@@ -2990,15 +2993,12 @@ Editor::setup_midi_toolbar ()
        /* Midi sound notes */
        midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
        midi_sound_notes.unset_flags (CAN_FOCUS);
+       midi_sound_notes.set_name (X_("MidiSoundNotesButton"));
 
        /* Panic */
 
-       act = ActionManager::get_action (X_("MIDI"), X_("panic"));
-       midi_panic_button.set_name("MidiPanicButton");
-       act->connect_proxy (midi_panic_button);
-
        panic_box.pack_start (midi_sound_notes , true, true);
-       panic_box.pack_start (midi_panic_button, true, true);
+       // panic_box.pack_start (midi_panic_button, true, true);
 }
 
 int
@@ -4699,13 +4699,13 @@ void
 Editor::first_idle ()
 {
        MessageDialog* dialog = 0;
-
+       
        if (track_views.size() > 1) {
-               dialog = new MessageDialog (*this,
-                                           string_compose (_("Please wait while %1 loads visual data"), PROGRAM_NAME),
-                                           true,
-                                           Gtk::MESSAGE_INFO,
-                                           Gtk::BUTTONS_NONE);
+               dialog = new MessageDialog (
+                       *this,
+                       string_compose (_("Please wait while %1 loads visual data."), PROGRAM_NAME),
+                       true
+                       );
                dialog->present ();
                ARDOUR_UI::instance()->flush_pending ();
        }
@@ -4718,7 +4718,6 @@ Editor::first_idle ()
        _routes->redisplay ();
 
        delete dialog;
-
        _have_idled = true;
 }
 
@@ -5008,7 +5007,7 @@ Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
 
 /** Find a RouteTimeAxisView by the ID of its route */
 RouteTimeAxisView*
-Editor::get_route_view_by_route_id (PBD::ID& id) const
+Editor::get_route_view_by_route_id (const PBD::ID& id) const
 {
        RouteTimeAxisView* v;
 
@@ -5502,3 +5501,4 @@ Editor::popup_control_point_context_menu (ArdourCanvas::Item* item, GdkEvent* ev
 
        _control_point_context_menu.popup (event->button.button, event->button.time);
 }
+