From eabe5b31f88fc2723980cb812e836c02b296b80f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 7 Mar 2011 13:05:45 +0000 Subject: [PATCH] Hide/Remove to apply to the track selection. git-svn-id: svn://localhost/ardour2/branches/3.0@9090 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 26 ++++++++---- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_ops.cc | 2 +- gtk2_ardour/mixer_strip.cc | 2 +- gtk2_ardour/public_editor.h | 2 +- gtk2_ardour/route_time_axis.cc | 6 +-- gtk2_ardour/route_ui.cc | 74 ++++++++++++++++++---------------- gtk2_ardour/route_ui.h | 2 +- 8 files changed, 66 insertions(+), 50 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 819309d8f4..36154b82d3 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -5026,16 +5026,28 @@ Editor::timeaxisview_deleted (TimeAxisView *tv) } void -Editor::hide_track_in_display (TimeAxisView* tv, bool /*temponly*/) +Editor::hide_track_in_display (TimeAxisView* tv, bool apply_to_selection) { - RouteTimeAxisView* rtv = dynamic_cast (tv); + if (apply_to_selection) { + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ) { - if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) { - // this will hide the mixer strip - set_selected_mixer_strip (*tv); + TrackSelection::iterator j = i; + ++j; + + hide_track_in_display (*i, false); + + i = j; + } + } else { + RouteTimeAxisView* rtv = dynamic_cast (tv); + + if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) { + // this will hide the mixer strip + set_selected_mixer_strip (*tv); + } + + _routes->hide_track_in_display (*tv); } - - _routes->hide_track_in_display (*tv); } bool diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 11592d2b45..428b1889e6 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -326,7 +326,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void show_editor_list (bool yn); void set_selected_mixer_strip (TimeAxisView&); void mixer_strip_width_changed (); - void hide_track_in_display (TimeAxisView* tv, bool temporary = false); + void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false); /* nudge is initiated by transport controls owned by ARDOUR_UI */ diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d79f1df47b..dac504bf26 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1545,7 +1545,7 @@ Editor::temporal_zoom_region (bool both_axes) for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { if (find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) { - hide_track_in_display (*i, true); + hide_track_in_display (*i); } } diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index ba79bd2419..5181878fb5 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1365,7 +1365,7 @@ MixerStrip::build_route_ops_menu () } items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route))); + items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), false))); } gboolean diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index df549d164e..703b65ba52 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -233,7 +233,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible { virtual void select_all_tracks () = 0; virtual void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove = false) = 0; virtual void set_selected_mixer_strip (TimeAxisView&) = 0; - virtual void hide_track_in_display (TimeAxisView* tv, bool temporary = false) = 0; + virtual void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false) = 0; virtual void set_stationary_playhead (bool yn) = 0; virtual void toggle_stationary_playhead () = 0; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index cb9f23ff32..cde6d552b4 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -649,12 +649,12 @@ RouteTimeAxisView::build_display_menu () 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))); + items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, true))); if (!Profile->get_sae()) { - items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route))); + items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true))); } else { items.push_front (SeparatorElem()); - items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route))); + items.push_front (MenuElem (_("Delete"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true))); } } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 3df8e74d49..9ad84290b5 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -1373,15 +1373,18 @@ RouteUI::set_color_from_route () } void -RouteUI::remove_this_route () +RouteUI::remove_this_route (bool apply_to_selection) { - if ((route()->is_master() || route()->is_monitor()) && - !Config->get_allow_special_bus_removal()) { - MessageDialog msg (_("That would be bad news ...."), - false, - Gtk::MESSAGE_INFO, + if (apply_to_selection) { + ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false)); + } else { + if ((route()->is_master() || route()->is_monitor()) && + !Config->get_allow_special_bus_removal()) { + MessageDialog msg (_("That would be bad news ...."), + false, + Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK); - msg.set_secondary_text (string_compose (_( + msg.set_secondary_text (string_compose (_( "Removing the master or monitor bus is such a bad idea\n\ that %1 is not going to allow it.\n\ \n\ @@ -1389,34 +1392,35 @@ If you really want to do this sort of thing\n\ edit your ardour.rc file to set the\n\ \"allow-special-bus-removal\" option to be \"yes\""), PROGRAM_NAME)); - msg.present (); - msg.run (); - return; - } - - vector choices; - string prompt; - - if (is_track()) { - prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); - } else { - prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); - } - - choices.push_back (_("No, do nothing.")); - choices.push_back (_("Yes, remove it.")); - - string title; - if (is_track()) { - title = _("Remove track"); - } else { - title = _("Remove bus"); - } - - Choice prompter (title, prompt, choices); - - if (prompter.run () == 1) { - Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this)); + msg.present (); + msg.run (); + return; + } + + vector choices; + string prompt; + + if (is_track()) { + prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); + } else { + prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); + } + + choices.push_back (_("No, do nothing.")); + choices.push_back (_("Yes, remove it.")); + + string title; + if (is_track()) { + title = _("Remove track"); + } else { + title = _("Remove bus"); + } + + Choice prompter (title, prompt, choices); + + if (prompter.run () == 1) { + Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this)); + } } } diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 41721abc77..2f515f8c6d 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -167,7 +167,7 @@ class RouteUI : public virtual AxisView int set_color_from_route (); - void remove_this_route (); + void remove_this_route (bool apply_to_selection = false); static gint idle_remove_this_route (RouteUI *); void route_rename();