(Source List) Source list, Region List: Resolve various action+behaviors between...
authorBen Loftis <ben@harrisonconsoles.com>
Mon, 22 Oct 2018 21:46:44 +0000 (16:46 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Thu, 1 Aug 2019 17:11:31 +0000 (12:11 -0500)
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.

gtk2_ardour/ardour.menus.in
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_regions.cc
gtk2_ardour/editor_regions.h
gtk2_ardour/editor_sources.cc
gtk2_ardour/editor_sources.h
gtk2_ardour/public_editor.h

index c083d58427b80fcfa3744f2b0ecda1205d35c960..b3a5be159e32a90c8e7d737dc68568e98a456f89 100644 (file)
@@ -49,7 +49,8 @@
       <menu name='Cleanup' action='Cleanup'>
         <menuitem action='bring-into-session'/>
         <menuitem action='CleanupPeakFiles'/>
-        <menuitem action='CleanupUnused'/>
+        <menuitem action='CleanupUnusedSources'/>
+        <menuitem action='CleanupUnusedRegions'/>
         <menuitem action='FlushWastebasket'/>
       </menu>
 #ifdef __APPLE__
index 1acaa41f3de3371cde47a852d0460774982b6802..d44da988f6655e5a90bb1ba261846b5e429cd344 100644 (file)
@@ -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);
 
index 911f46213e38a16a207c44e89798390742b5e896..2e2bba3c89e3a51a476546767871f06a811e19f0 100644 (file)
@@ -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 ()
 {
index 753e718fa9f920b9bf33bcb9e21eb0faff6ba552..64de32c240e7a8473ea51d144c0a5da050c3b977 100644 (file)
@@ -388,6 +388,8 @@ public:
 
        void select_topmost_track ();
 
+       void cleanup_regions ();
+
        void prepare_for_cleanup ();
        void finish_cleanup ();
 
index f984ee7c2689ae09320a72af949296102da0ea42..8036175d8037020e4b0745a5df42ec98b39db496 100644 (file)
@@ -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 */
 
index eaa83bc3390f231cb298ef57d9a1ff3614aa6458..d03d06c0852dbe50444ac921abd70a762b526937 100644 (file)
@@ -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<CellRendererToggle*> (_display.get_column_cell_renderer (3));
+       /* checkbox cells */
+       int check_start_col = 4;
+
+       CellRendererToggle* locked_cell = dynamic_cast<CellRendererToggle*> (_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<CellRendererToggle*> (_display.get_column_cell_renderer (4));
+       CellRendererToggle* glued_cell = dynamic_cast<CellRendererToggle*> (_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<CellRendererToggle*> (_display.get_column_cell_renderer (5));
+       CellRendererToggle* muted_cell = dynamic_cast<CellRendererToggle*> (_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<CellRendererToggle*> (_display.get_column_cell_renderer (6));
+       CellRendererToggle* opaque_cell = dynamic_cast<CellRendererToggle*> (_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> region, TreeModel:
 void
 EditorRegions::populate_row_end (boost::shared_ptr<Region> 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> region, TreeMode
 void
 EditorRegions::populate_row_sync (boost::shared_ptr<Region> 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> region, TreeModel::R
 void
 EditorRegions::populate_row_fade_in (boost::shared_ptr<Region> region, TreeModel::Row const &row, boost::shared_ptr<AudioRegion> 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> region, TreeModel
 void
 EditorRegions::populate_row_fade_out (boost::shared_ptr<Region> region, TreeModel::Row const &row, boost::shared_ptr<AudioRegion> 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> region, TreeModel:
 void
 EditorRegions::show_context_menu (int button, int time)
 {
-       if (_menu == 0) {
-               _menu = dynamic_cast<Menu*> (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<Menu*> (ActionManager::get_widget (X_("/PopupRegionMenu")));
+       menu->popup (button, time);
 }
 
 bool
index 3f9c756448a44ba5db72318db487575de0cd9fd1..c6a71641f3fc5ba5d775d7875699297344ba4f7f 100644 (file)
@@ -78,8 +78,8 @@ private:
                        add (name);
                        add (tags);
                        add (start);
-                       add (end);
                        add (length);
+                       add (end);
                        add (sync);
                        add (fadein);
                        add (fadeout);
index 3ba9468c49c4fb017dabd02239d88cf30705762c..567640874f26c0a5b3d4203afbdd87672a9e3228 100644 (file)
@@ -163,7 +163,7 @@ EditorSources::EditorSources (Editor* e)
        nat_col->set_alignment (ALIGN_RIGHT);
        renderer = dynamic_cast<CellRendererText*>(_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<ARDOUR::Source> 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<string> 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<ARDOUR::Source> source = (*iter)[_columns.source];
+                                       if (source) {
+
+                                               set<boost::shared_ptr<Region> > regions;
+                                               RegionFactory::get_regions_using_source ( source, regions );
+
+                                               for (set<boost::shared_ptr<Region> >::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;
 }
 
index 8eef1bc442d5ea607f1a0e11a32e4a9989eb88ed..7e8b05f2034fb109123b3abf2ab4d3104f25dc19 100644 (file)
@@ -44,6 +44,8 @@ public:
        }
 
        void clear ();
+       
+       void remove_selected_sources ();
 
        void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
 
index 63ee45a9ac0f230a2c6724c9b5ce6425400b0386..1b3fe45efc6a6e22db5863066fc5b7800e51578e 100644 (file)
@@ -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;