Preserve region list selection state even if a region is selected which is not shown...
authorCarl Hetherington <carl@carlh.net>
Sat, 18 Sep 2010 23:31:39 +0000 (23:31 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 18 Sep 2010 23:31:39 +0000 (23:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7802 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_regions.cc
gtk2_ardour/editor_selection.cc

index a044f2ad91c9c8bfb70798e8b6c2f2f325cd4462..9c431fdd2c1d148f944882e1282d68402fecd236 100644 (file)
@@ -304,6 +304,8 @@ Editor::Editor ()
        , _pending_locate_request (false)
        , _pending_initial_locate (false)
        , _last_cut_copy_source_track (0)
+
+       , _block_region_list_update_if_empty (false)
 {
        constructed = false;
 
index 390b94664b431ffc4f0c135bb13c1ea2fb93d8f8..e47946499df1ab97d30a2e06f471e612a2af31cf 100644 (file)
@@ -2047,6 +2047,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        */
        TimeAxisView* _last_cut_copy_source_track;
 
+       /** true if the update of the region list's selection from the current Selection
+           should be blocked if the Selection is empty.  See EditorRegions::selection_changed.
+       */
+       bool _block_region_list_update_if_empty;
+
        friend class Drag;
        friend class RegionDrag;
        friend class RegionMoveDrag;
index 9fc2a7066367378b992400a980f04eb7370f3374..7034a76af11ada3a2362c53535794a35474c3eaf 100644 (file)
@@ -377,6 +377,13 @@ EditorRegions::selection_changed ()
                return;
        }
 
+       /* We may have selected a region which is not displayed in the Editor.  If this happens, the
+          result will be no selected regions in the editor's Selection.  Without the following line,
+          this `no-selection' will be mapped back to our list, meaning that the selection will
+          appear not to take.
+       */
+       _editor->_block_region_list_update_if_empty = true;
+
        if (_display.get_selection()->count_selected_rows() > 0) {
 
                TreeIter iter;
@@ -409,6 +416,8 @@ EditorRegions::selection_changed ()
        } else {
                _editor->get_selection().clear_regions ();
        }
+
+       _editor->_block_region_list_update_if_empty = false;
 }
 
 void
index d17d230cf87ce7e9a0aa761213bf2455a272f855..5c0a3003220260cccc956cd705d9ff13c1965379 100644 (file)
@@ -957,7 +957,9 @@ Editor::region_selection_changed ()
        _regions->block_change_connection (true);
        editor_regions_selection_changed_connection.block(true);
 
-       _regions->unselect_all ();
+       if (!_block_region_list_update_if_empty || !selection->regions.empty()) {
+               _regions->unselect_all ();
+       }
 
        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                (*i)->set_selected_regionviews (selection->regions);