From 4db7aa6bdc3c98e7c46745550b622bd302c3b6fb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 15 Jan 2022 22:53:36 -0700 Subject: [PATCH] add Editor API to manage tempo map edits (at least, drags) --- gtk2_ardour/editor.h | 3 +++ gtk2_ardour/editor_tempodisplay.cc | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 8017a9d6cc..d7cec55753 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1847,6 +1847,9 @@ private: void reassociate_metric_markers (Temporal::TempoMap::SharedPtr const &); void reassociate_metric_marker (Temporal::TempoMap::SharedPtr const & tmap, Temporal::TempoMap::Metrics & metric, ArdourMarker& marker); + void begin_tempo_map_edit (); + void abort_tempo_map_edit (); + void commit_tempo_map_edit (); void tempo_map_changed (); void redisplay_grid (bool immediate_redraw); diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 2a01136245..5e4f4a6d9b 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -626,3 +626,28 @@ Editor::real_remove_meter_marker (Temporal::MeterPoint *section) return FALSE; } + +void +Editor::begin_tempo_map_edit () +{ + TempoMap::fetch_writable (); + TempoMap::SharedPtr tmap (TempoMap::use()); + reassociate_metric_markers (tmap); +} + +void +Editor::abort_tempo_map_edit () +{ + /* this drops the lock held while we have a writable copy in our per-thread pointer */ + TempoMap::abort_update (); + + TempoMap::SharedPtr tmap (TempoMap::fetch()); + reassociate_metric_markers (tmap); +} + +void +Editor::commit_tempo_map_edit () +{ + TempoMap::SharedPtr tmap (TempoMap::use()); + TempoMap::update (tmap); +}