[Summary] Added menu item "Delete selected tracks". Refactoring of the RouteUI::remove_this_route(). Bug fix in top bar (set menu items "Move this track up/down" not selectable in case of Master was selected).

[Reviewed] GZharun
This commit is contained in:
nikolay 2014-08-13 11:21:11 +03:00
parent 7a410d5a45
commit 6270ee768f
8 changed files with 67 additions and 45 deletions

View file

@ -3565,6 +3565,13 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
session_add_audio_track (input_chan.n_audio(), output_chan.n_audio(), ARDOUR::Normal, NULL, _add_tracks_dialog->count(), "");
}
void
ARDOUR_UI::delete_selected_tracks()
{
TrackSelection& track_selection = ARDOUR_UI::instance()->the_editor().get_selection().tracks;
track_selection.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false));
}
void
ARDOUR_UI::add_audio_track_instantly ()
{

View file

@ -237,6 +237,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void synchronize_sync_source_and_video_pullup ();
void add_route (Gtk::Window* float_window);
void delete_selected_tracks();
void add_routes_part_two ();
void add_routes_thread ();

View file

@ -134,6 +134,9 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::write_sensitive_actions.push_back (act);
act = ActionManager::register_action (main_actions, X_("DeleteSelectedTracks"), _("Delete selected tracks"), sigc::mem_fun(*this, &ARDOUR_UI::delete_selected_tracks));
ActionManager::track_selection_sensitive_actions.push_back (act);
act = ActionManager::register_action (main_actions, X_("OpenVideo"), _("Open Video"),
sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_video), (Gtk::Window*) 0));
ActionManager::session_sensitive_actions.push_back (act);

View file

@ -1696,6 +1696,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void time_selection_changed ();
void update_time_selection_display ();
void track_selection_changed ();
bool non_master_track_selected ();
void output_connection_mode_changed ();
void region_selection_changed ();
sigc::connection editor_regions_selection_changed_connection;

View file

@ -939,6 +939,30 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView*
return true;
}
/*
Return true if selection is empty even MasterTrack is selected
Otherwise return false
*/
bool
Editor::non_master_track_selected ()
{
if( selection->tracks.empty() )
return false;
if( selection->tracks.size() >=2 )
return true;
TimeAxisView* tv = selection->tracks.front();
RouteTimeAxisView* rtv = dynamic_cast <RouteTimeAxisView*> (tv);
if (rtv) {
AudioTrack* atr = dynamic_cast <AudioTrack*> (rtv->route().get() );
if (atr && _session && atr->is_master_track() )
return false;
else
return true;
}
}
void
Editor::track_selection_changed ()
{
@ -1026,7 +1050,7 @@ Editor::track_selection_changed ()
}
}
ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty());
ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, non_master_track_selected());
/* notify control protocols */

View file

@ -269,6 +269,7 @@
43279460194F0062003C9FEA /* tracks_preferences.xml in Resources */ = {isa = PBXBuildFile; fileRef = 43279430194F0062003C9FEA /* tracks_preferences.xml */; };
4327947F194F009E003C9FEA /* tracks.menus.in in Resources */ = {isa = PBXBuildFile; fileRef = 43279475194F009E003C9FEA /* tracks.menus.in */; };
43B351ED194F04E00038C140 /* step_editing.bindings in Resources */ = {isa = PBXBuildFile; fileRef = 43B351C0194F04E00038C140 /* step_editing.bindings */; };
CE1A907A199A37AE00ECA62B /* add_tracks_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE1A9079199A37AE00ECA62B /* add_tracks_dialog.cc */; };
CE1C6DCE19879F04006BDB03 /* compact_meter_bridge.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE1C6DCC19879F04006BDB03 /* compact_meter_bridge.cc */; };
CE1C6DCF19879F04006BDB03 /* compact_meter_strip.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE1C6DCD19879F04006BDB03 /* compact_meter_strip.cc */; };
CE1C6DE01987A924006BDB03 /* master_bus_ui.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE1C6DDF1987A924006BDB03 /* master_bus_ui.cc */; };
@ -1093,6 +1094,8 @@
43B351EE194F12FB0038C140 /* waves_audiobackend.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = waves_audiobackend.xcodeproj; path = ../../libs/backends/wavesaudio/macosx/waves_audiobackend.xcodeproj; sourceTree = "<group>"; };
43B351F4194F130C0038C140 /* libardour.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libardour.xcodeproj; path = ../../libs/ardour/macosx/libardour.xcodeproj; sourceTree = "<group>"; };
43B351FA194F131D0038C140 /* pbd.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = pbd.xcodeproj; path = ../../libs/pbd/macosx/pbd.xcodeproj; sourceTree = "<group>"; };
CE1A9079199A37AE00ECA62B /* add_tracks_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = add_tracks_dialog.cc; path = ../add_tracks_dialog.cc; sourceTree = "<group>"; };
CE1A907E199A37BF00ECA62B /* add_tracks_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = add_tracks_dialog.h; path = ../add_tracks_dialog.h; sourceTree = "<group>"; };
CE1C6DCC19879F04006BDB03 /* compact_meter_bridge.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = compact_meter_bridge.cc; path = ../compact_meter_bridge.cc; sourceTree = "<group>"; };
CE1C6DCD19879F04006BDB03 /* compact_meter_strip.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = compact_meter_strip.cc; path = ../compact_meter_strip.cc; sourceTree = "<group>"; };
CE1C6DD319879F1B006BDB03 /* compact_meter_bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = compact_meter_bridge.h; path = ../compact_meter_bridge.h; sourceTree = "<group>"; };
@ -1154,6 +1157,7 @@
43279040194EFF38003C9FEA /* source */ = {
isa = PBXGroup;
children = (
CE1A9079199A37AE00ECA62B /* add_tracks_dialog.cc */,
CE1C6DDF1987A924006BDB03 /* master_bus_ui.cc */,
CE1C6DCC19879F04006BDB03 /* compact_meter_bridge.cc */,
CE1C6DCD19879F04006BDB03 /* compact_meter_strip.cc */,
@ -1779,6 +1783,7 @@
43279480194F00CB003C9FEA /* headers */ = {
isa = PBXGroup;
children = (
CE1A907E199A37BF00ECA62B /* add_tracks_dialog.h */,
CE1C6DDB1987A910006BDB03 /* master_bus_ui.h */,
CE1C6DD319879F1B006BDB03 /* compact_meter_bridge.h */,
CE1C6DD419879F1B006BDB03 /* compact_meter_strip.h */,
@ -2443,6 +2448,7 @@
CE1C6DCE19879F04006BDB03 /* compact_meter_bridge.cc in Sources */,
CE1C6DCF19879F04006BDB03 /* compact_meter_strip.cc in Sources */,
CE1C6DE01987A924006BDB03 /* master_bus_ui.cc in Sources */,
CE1A907A199A37AE00ECA62B /* add_tracks_dialog.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -1331,52 +1331,31 @@ RouteUI::set_color_from_route ()
void
RouteUI::remove_this_route (bool apply_to_selection)
{
if (apply_to_selection) {
ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false));
if (apply_to_selection) {
TrackSelection& track_selection = ARDOUR_UI::instance()->the_editor().get_selection().tracks;
for (list<TimeAxisView*>::iterator i = track_selection.begin(); i != track_selection.end(); ++i) {
RouteUI* t = dynamic_cast<RouteUI*> (*i);
if (t) {
if ( t->route()->is_master() || t->route()->is_monitor() )
continue;
AudioTrack* audio_track = dynamic_cast<AudioTrack*>( t->route().get() );
if( audio_track && audio_track->is_master_track() )
continue;
Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), t));
}
}
} 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 (_(
"Removing the master or monitor bus is such a bad idea\n\
that %1 is not going to allow it.\n\
\n\
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 ();
if ( route()->is_master() || route()->is_monitor() )
return;
}
vector<string> 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\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));
}
AudioTrack* audio_track = dynamic_cast<AudioTrack*>( route().get() );
if( audio_track && audio_track->is_master_track() )
return;
Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
}
}

View file

@ -96,6 +96,7 @@
<menu action='TrackMenu'>
<menuitem action='AddTrackBus'/>
<menuitem action='DeleteSelectedTracks'/>
<menuitem action="move-selected-tracks-up"/>
<menuitem action="move-selected-tracks-down"/>
</menu>