From: Ben Loftis Date: Mon, 22 Oct 2018 21:46:44 +0000 (-0500) Subject: (Source List) Source list, Region List: Resolve various action+behaviors between... X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=71c2ed81603e6ed3231316df57161f4077c0a2c1;p=ardour.git (Source List) Source list, Region List: Resolve various action+behaviors between the 2 lists. Duplicate the remove_unsued_region action in the Session->Cleanup menu, for discoverability. Region list should use the same Region actions as the canvas... OK, now resolve the change in use-cases of Region List and Source List. tentative. Rough-in remove_selected_sources (Delete in Sources list). Column tweaks. --- diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index c083d58427..b3a5be159e 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -49,7 +49,8 @@ - + + #ifdef __APPLE__ diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 1acaa41f3d..d44da988f6 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -238,7 +238,11 @@ ARDOUR_UI::install_actions () act = ActionManager::register_action (main_actions, X_("Export"), _("Export")); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_action (main_actions, X_("CleanupUnused"), _("Clean-up Unused Sources..."), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup)); + act = global_actions.register_action (main_actions, X_("CleanupUnusedSources"), _("Clean-up Unused Sources..."), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup)); + ActionManager::session_sensitive_actions.push_back (act); + ActionManager::write_sensitive_actions.push_back (act); + + act = global_actions.register_action (main_actions, X_("CleanupUnusedRegions"), _("Clean-up Unused Regions..."), sigc::mem_fun (*editor, &PublicEditor::cleanup_regions)); ActionManager::session_sensitive_actions.push_back (act); ActionManager::write_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 911f46213e..2e2bba3c89 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1948,7 +1948,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Separate"), mem_fun(*this, &Editor::separate_region_from_selection))); - edit_items.push_back (MenuElem (_("Convert to Region in Region List"), sigc::mem_fun(*this, &Editor::new_region_from_selection))); +// edit_items.push_back (MenuElem (_("Convert to Region in Region List"), sigc::mem_fun(*this, &Editor::new_region_from_selection))); edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection))); @@ -1968,8 +1968,8 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (SeparatorElem()); edit_items.push_back (MenuElem (_("Consolidate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), true, false))); 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 (_("Bounce Range to Source List"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, false))); + edit_items.push_back (MenuElem (_("Bounce Range to Source 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))); if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) { edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true))); @@ -4277,6 +4277,13 @@ Editor::audio_region_selection_covers (samplepos_t where) return false; } +void +Editor::cleanup_regions () +{ + _regions->remove_unused_regions(); +} + + void Editor::prepare_for_cleanup () { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 753e718fa9..64de32c240 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -388,6 +388,8 @@ public: void select_topmost_track (); + void cleanup_regions (); + void prepare_for_cleanup (); void finish_cleanup (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index f984ee7c26..8036175d80 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -680,7 +680,7 @@ Editor::register_actions () /* the next two are duplicate items with different names for use in two different contexts */ - act = reg_sens (editor_actions, X_("addExternalAudioToRegionList"), _("Import to Region List..."), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion)); + act = reg_sens (editor_actions, X_("addExternalAudioToRegionList"), _("Import to Source List..."), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion)); ActionManager::write_sensitive_actions.push_back (act); act = ActionManager::register_action (editor_actions, X_("importFromSession"), _("Import from Session"), sigc::mem_fun(*this, &Editor::session_import_dialog)); @@ -1559,7 +1559,7 @@ Editor::register_region_actions () /* PART 2: actions that are not related to the selection, but for which the edit point type and location is important */ - register_region_action (_region_actions, RegionActionTarget (ListSelection), "insert-region-from-region-list", _("Insert Region from Region List"), sigc::bind (sigc::mem_fun (*this, &Editor::insert_region_list_selection), 1)); +// register_region_action (_region_actions, RegionActionTarget (ListSelection), "insert-region-from-region-list", _("Insert Region from Region List"), sigc::bind (sigc::mem_fun (*this, &Editor::insert_region_list_selection), 1)); /* PART 3: actions that operate on the selection and also require the edit point location */ diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index eaa83bc339..d03d06c085 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -75,6 +75,8 @@ struct ColumnInfo { const char* tooltip; }; +//#define SHOW_REGION_EXTRAS + EditorRegions::EditorRegions (Editor* e) : EditorComponent (e) , old_focus (0) @@ -148,15 +150,18 @@ EditorRegions::EditorRegions (Editor* e) _display.append_column (*col_name); _display.append_column (*col_tags); _display.append_column (*col_start); + _display.append_column (*col_length); _display.append_column (*col_locked); _display.append_column (*col_glued); _display.append_column (*col_muted); _display.append_column (*col_opaque); + +#ifdef SHOW_REGION_EXTRAS _display.append_column (*col_end); - _display.append_column (*col_length); - _display.append_column (*col_sync); + _display.append_column (*col_sync); _display.append_column (*col_fadein); _display.append_column (*col_fadeout); +#endif TreeViewColumn* col; Gtk::Label* l; @@ -165,15 +170,17 @@ EditorRegions::EditorRegions (Editor* e) { 0, 0, ALIGN_LEFT, _("Region"), _("Region name, with number of channels in []'s") }, { 1, 1, ALIGN_LEFT, _("Tags"), _("Tags") }, { 2, 15, ALIGN_RIGHT, _("Start"), _("Position of start of region") }, - { 3, -1, ALIGN_CENTER, S_("Lock|L"), _("Region position locked?") }, - { 4, -1, ALIGN_CENTER, S_("Gain|G"), _("Region position glued to Bars|Beats time?") }, - { 5, -1, ALIGN_CENTER, S_("Mute|M"), _("Region muted?") }, - { 6, -1, ALIGN_CENTER, S_("Opaque|O"), _("Region opaque (blocks regions below it from being heard)?") }, - { 7, -1, ALIGN_RIGHT, _("End"), _("Position of end of region") }, - { 8, -1, ALIGN_RIGHT, _("Length"), _("Length of the region") }, + { 3, -1, ALIGN_RIGHT, _("Length"), _("Length of the region") }, + { 4, -1, ALIGN_CENTER, S_("Lock|L"), _("Region position locked?") }, + { 5, -1, ALIGN_CENTER, S_("Gain|G"), _("Region position glued to Bars|Beats time?") }, + { 6, -1, ALIGN_CENTER, S_("Mute|M"), _("Region muted?") }, + { 7, -1, ALIGN_CENTER, S_("Opaque|O"), _("Region opaque (blocks regions below it from being heard)?") }, +#ifdef SHOW_REGION_EXTRAS + { 8, -1, ALIGN_RIGHT, _("End"), _("Position of end of region") }, { 9, -1, ALIGN_RIGHT, _("Sync"), _("Position of region sync point, relative to start of the region") }, { 10,-1, ALIGN_RIGHT, _("Fade In"), _("Length of region fade-in (units: secondary clock), () if disabled") }, { 11,-1, ALIGN_RIGHT, _("Fade Out"), _("Length of region fade-out (units: secondary clock), () if disabled") }, +#endif { -1,-1, ALIGN_CENTER, 0, 0 } }; @@ -232,19 +239,22 @@ EditorRegions::EditorRegions (Editor* e) region_tags_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRegions::tag_edit)); region_tags_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRegions::tag_editing_started)); - CellRendererToggle* locked_cell = dynamic_cast (_display.get_column_cell_renderer (3)); + /* checkbox cells */ + int check_start_col = 4; + + CellRendererToggle* locked_cell = dynamic_cast (_display.get_column_cell_renderer (check_start_col++)); locked_cell->property_activatable() = true; locked_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::locked_changed)); - CellRendererToggle* glued_cell = dynamic_cast (_display.get_column_cell_renderer (4)); + CellRendererToggle* glued_cell = dynamic_cast (_display.get_column_cell_renderer (check_start_col++)); glued_cell->property_activatable() = true; glued_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::glued_changed)); - CellRendererToggle* muted_cell = dynamic_cast (_display.get_column_cell_renderer (5)); + CellRendererToggle* muted_cell = dynamic_cast (_display.get_column_cell_renderer (check_start_col++)); muted_cell->property_activatable() = true; muted_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::muted_changed)); - CellRendererToggle* opaque_cell = dynamic_cast (_display.get_column_cell_renderer (6)); + CellRendererToggle* opaque_cell = dynamic_cast (_display.get_column_cell_renderer (check_start_col)); opaque_cell->property_activatable() = true; opaque_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::opaque_changed)); @@ -751,6 +761,10 @@ EditorRegions::populate_row_length (boost::shared_ptr region, TreeModel: void EditorRegions::populate_row_end (boost::shared_ptr region, TreeModel::Row const &row) { +#ifndef SHOW_REGION_EXTRAS + return; +#endif + if (region->last_sample() >= region->first_sample()) { char buf[16]; format_position (region->last_sample(), buf, sizeof (buf)); @@ -773,6 +787,9 @@ EditorRegions::populate_row_position (boost::shared_ptr region, TreeMode void EditorRegions::populate_row_sync (boost::shared_ptr region, TreeModel::Row const &row) { +#ifndef SHOW_REGION_EXTRAS + return; +#endif if (region->sync_position() == region->position()) { row[_columns.sync] = _("Start"); } else if (region->sync_position() == (region->last_sample())) { @@ -787,6 +804,9 @@ EditorRegions::populate_row_sync (boost::shared_ptr region, TreeModel::R void EditorRegions::populate_row_fade_in (boost::shared_ptr region, TreeModel::Row const &row, boost::shared_ptr audioregion) { +#ifndef SHOW_REGION_EXTRAS + return; +#endif if (!audioregion) { row[_columns.fadein] = ""; } else { @@ -799,6 +819,9 @@ EditorRegions::populate_row_fade_in (boost::shared_ptr region, TreeModel void EditorRegions::populate_row_fade_out (boost::shared_ptr region, TreeModel::Row const &row, boost::shared_ptr audioregion) { +#ifndef SHOW_REGION_EXTRAS + return; +#endif if (!audioregion) { row[_columns.fadeout] = ""; } else { @@ -861,17 +884,9 @@ EditorRegions::populate_row_source (boost::shared_ptr region, TreeModel: void EditorRegions::show_context_menu (int button, int time) { - if (_menu == 0) { - _menu = dynamic_cast (ActionManager::get_widget ("/RegionListMenu")); - } - - if (_display.get_selection()->count_selected_rows() > 0) { - ActionManager::set_sensitive (ActionManager::region_list_selection_sensitive_actions, true); - } else { - ActionManager::set_sensitive (ActionManager::region_list_selection_sensitive_actions, false); - } - - _menu->popup (button, time); + using namespace Gtk::Menu_Helpers; + Gtk::Menu* menu = dynamic_cast (ActionManager::get_widget (X_("/PopupRegionMenu"))); + menu->popup (button, time); } bool diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h index 3f9c756448..c6a71641f3 100644 --- a/gtk2_ardour/editor_regions.h +++ b/gtk2_ardour/editor_regions.h @@ -78,8 +78,8 @@ private: add (name); add (tags); add (start); - add (end); add (length); + add (end); add (sync); add (fadein); add (fadeout); diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index 3ba9468c49..567640874f 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -163,7 +163,7 @@ EditorSources::EditorSources (Editor* e) nat_col->set_alignment (ALIGN_RIGHT); renderer = dynamic_cast(_display.get_column_cell_renderer (2)); if (renderer) { - renderer->property_xalign() = ( ALIGN_RIGHT ); + renderer->property_xalign() = ( 1.0 ); } //the PATH field should expand when the pane is opened wider @@ -420,7 +420,6 @@ EditorSources::source_changed (boost::shared_ptr source) void EditorSources::selection_changed () { -// _editor->_region_selection_change_updates_region_list = false; if (_display.get_selection()->count_selected_rows() > 0) { @@ -453,7 +452,6 @@ EditorSources::selection_changed () _editor->get_selection().clear_regions (); } -// _editor->_region_selection_change_updates_region_list = true; } void @@ -542,9 +540,71 @@ EditorSources::show_context_menu (int button, int time) } +void +EditorSources::remove_selected_sources () +{ + vector choices; + string prompt; + + prompt = _("Do you really want to destroy the selected source files?" + "\nAll regions using the files will be deleted."); + + choices.push_back (_("No, do nothing.")); + choices.push_back (_("Only destroy the regions, not the sources. (may be undone)")); + choices.push_back (_("Yes, destroy them. (cannot be undone!")); + + Choice prompter (_("Destroy selected Sources"), prompt, choices); + + int opt = prompter.run (); + + if ( opt >= 1) { + if (_display.get_selection()->count_selected_rows() > 0) { + + TreeIter iter; + TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows (); + + _editor->get_selection().clear_regions (); + + for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) { + + if ((iter = _model->get_iter (*i))) { + + boost::shared_ptr source = (*iter)[_columns.source]; + if (source) { + + set > regions; + RegionFactory::get_regions_using_source ( source, regions ); + + for (set >::iterator region = regions.begin(); region != regions.end(); region++ ) { + _change_connection.block (true); + _editor->set_selected_regionview_from_region_list (*region, Selection::Add); + _change_connection.block (false); + + } + } + } + + } + } + _editor->remove_selected_regions(); + + if ( opt == 2 ) { //TODO: actually delete some sources? + } + } + +} + + bool EditorSources::key_press (GdkEventKey* ev) { + switch (ev->keyval) { + case GDK_Delete: + case GDK_BackSpace: + /* remove_selected_sources(); */ + return true; //for now, just "eat" this, so Delete doesn't get propogated into the canvas, based on Source selections + } + return false; } diff --git a/gtk2_ardour/editor_sources.h b/gtk2_ardour/editor_sources.h index 8eef1bc442..7e8b05f203 100644 --- a/gtk2_ardour/editor_sources.h +++ b/gtk2_ardour/editor_sources.h @@ -44,6 +44,8 @@ public: } void clear (); + + void remove_selected_sources (); void selection_mapover (sigc::slot >); diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 63ee45a9ac..1b3fe45efc 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -316,6 +316,7 @@ public: virtual bool scroll_down_one_track (bool skip_child_views = false) = 0; virtual bool scroll_up_one_track (bool skip_child_views = false) = 0; virtual void select_topmost_track () = 0; + virtual void cleanup_regions () = 0; virtual void prepare_for_cleanup () = 0; virtual void finish_cleanup () = 0; virtual void reset_x_origin (samplepos_t sample) = 0;