Keep Location List ordered by start-time

Now that Location signal(s) are only emitted when the
drag ended, the list can be kept in sync.

This also adds a further optimization to only update the
list once, even when multiple locations have been changed.
This commit is contained in:
Robin Gareus 2023-12-08 22:03:22 +01:00
parent 067a124fd1
commit 67f6363dcd
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 18 additions and 1 deletions

View File

@ -352,7 +352,6 @@ LocationEditRow::set_location (Location *loc)
/* connect to per-location signals, since this row only cares about this location */
location->NameChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::name_changed, this), gui_context());
location->StartChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::start_changed, this), gui_context());
location->EndChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::end_changed, this), gui_context());
location->Changed.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::location_changed, this), gui_context());
location->FlagsChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::flags_changed, this), gui_context());
@ -890,6 +889,20 @@ LocationUI::location_remove_requested (ARDOUR::Location *loc)
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &LocationUI::do_location_remove), loc));
}
void
LocationUI::queue_refresh_location_list ()
{
if (!_redisplay_connection.connected ()) {
_redisplay_connection = Glib::signal_idle().connect (sigc::mem_fun (*this, &LocationUI::idle_refresh_location_list), Glib::PRIORITY_HIGH_IDLE+10);
}
}
bool
LocationUI::idle_refresh_location_list ()
{
refresh_location_list ();
return false;
}
void
LocationUI::location_redraw_ranges ()
@ -1097,6 +1110,7 @@ LocationUI::set_session(ARDOUR::Session* s)
_session->locations()->added.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::location_added, this, _1), gui_context());
_session->locations()->removed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::location_removed, this, _1), gui_context());
_session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
Location::start_changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::queue_refresh_location_list, this), gui_context());
_clock_group->set_clock_mode (clock_mode_from_session_instant_xml ());
} else {

View File

@ -202,6 +202,9 @@ private:
void location_remove_requested (ARDOUR::Location *);
void location_redraw_ranges ();
void queue_refresh_location_list ();
bool idle_refresh_location_list ();
sigc::connection _redisplay_connection;
gint do_location_remove (ARDOUR::Location *);