13
0

Arranger: implement bi-directional selection

This commit is contained in:
Ben Loftis 2023-09-03 14:17:53 -05:00 committed by Robin Gareus
parent 5ceb66c902
commit 4217a68852
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 35 additions and 3 deletions

View File

@ -86,7 +86,7 @@ EditorSections::EditorSections ()
ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &EditorSections::clock_format_changed)); ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &EditorSections::clock_format_changed));
_selection_change = PublicEditor::instance ().get_selection ().TimeChanged.connect (sigc::mem_fun (*this, &EditorSections::clear_selection)); _selection_change = PublicEditor::instance ().get_selection ().TimeChanged.connect (sigc::mem_fun (*this, &EditorSections::update_time_selection));
} }
void void
@ -116,6 +116,7 @@ EditorSections::redisplay ()
} }
_view.set_model (Glib::RefPtr<ListStore> ()); _view.set_model (Glib::RefPtr<ListStore> ());
_model->clear (); _model->clear ();
_location_row_map.clear ();
if (_session == 0) { if (_session == 0) {
return; return;
@ -135,6 +136,8 @@ EditorSections::redisplay ()
newrow[_columns.location] = l; newrow[_columns.location] = l;
newrow[_columns.start] = start; newrow[_columns.start] = start;
newrow[_columns.end] = end; newrow[_columns.end] = end;
_location_row_map.insert (pair<ARDOUR::Location*, Gtk::TreeModel::iterator> (l, newrow));
} }
} while (l); } while (l);
@ -189,9 +192,29 @@ EditorSections::scroll_row_timeout ()
} }
void void
EditorSections::clear_selection () EditorSections::update_time_selection ()
{ {
_view.get_selection ()->unselect_all (); _view.get_selection ()->unselect_all ();
Selection& selection (PublicEditor::instance ().get_selection ());
if (selection.time.empty ()) {
return;
}
Locations* loc = _session->locations ();
Location* l = NULL;
do {
timepos_t start, end;
l = loc->next_section (l, start, end);
if (l) {
if (start == selection.time.start_time () && end == selection.time.end_time ()) {
LocationRowMap::iterator map_it = _location_row_map.find (l);
TreeModel::iterator j = map_it->second;
_view.get_selection ()->select (*j);
}
}
} while (l);
} }
void void
@ -208,6 +231,7 @@ EditorSections::selection_changed ()
_selection_change.block (); _selection_change.block ();
Selection& s (PublicEditor::instance ().get_selection ()); Selection& s (PublicEditor::instance ().get_selection ());
s.clear ();
s.set (start, end); s.set (start, end);
_selection_change.unblock (); _selection_change.unblock ();
} }
@ -390,6 +414,9 @@ EditorSections::delete_selected_section ()
_session->cut_copy_section (start, end, timepos_t (0), DeleteSection); _session->cut_copy_section (start, end, timepos_t (0), DeleteSection);
} }
redisplay (); redisplay ();
PublicEditor::instance ().get_selection ().clear ();
return true; return true;
} }

View File

@ -19,6 +19,8 @@
#ifndef _gtk_ardour_editor_sections_h_ #ifndef _gtk_ardour_editor_sections_h_
#define _gtk_ardour_editor_sections_h_ #define _gtk_ardour_editor_sections_h_
#include <boost/unordered_map.hpp>
#include "ardour/location.h" #include "ardour/location.h"
#include "ardour/session_handle.h" #include "ardour/session_handle.h"
@ -44,7 +46,7 @@ private:
bool delete_selected_section (); bool delete_selected_section ();
bool rename_selected_section (); bool rename_selected_section ();
void clear_selection (); void update_time_selection ();
void selection_changed (); void selection_changed ();
void clock_format_changed (); void clock_format_changed ();
bool scroll_row_timeout (); bool scroll_row_timeout ();
@ -101,11 +103,14 @@ private:
Gtk::TreeModelColumn<Temporal::timepos_t> end; Gtk::TreeModelColumn<Temporal::timepos_t> end;
}; };
typedef boost::unordered_map<ARDOUR::Location*, Gtk::TreeModel::iterator> LocationRowMap;
Columns _columns; Columns _columns;
Glib::RefPtr<Gtk::ListStore> _model; Glib::RefPtr<Gtk::ListStore> _model;
Gtk::TreeView _view; Gtk::TreeView _view;
Gtk::ScrolledWindow _scroller; Gtk::ScrolledWindow _scroller;
LocationRowMap _location_row_map;
bool _no_redisplay; bool _no_redisplay;
sigc::connection _scroll_timeout; sigc::connection _scroll_timeout;
sigc::connection _selection_change; sigc::connection _selection_change;