From 478dd72fb0773c119d86848b00b8970304349144 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 11 Aug 2025 11:25:43 -0600 Subject: [PATCH] moved scoped tempo map from GUI to libtemporal (gui) --- gtk2_ardour/debug.cc | 1 - gtk2_ardour/debug.h | 1 - gtk2_ardour/editing_context.cc | 1 - gtk2_ardour/editing_context.h | 52 ++-------------------------------- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/gtk2_ardour/debug.cc b/gtk2_ardour/debug.cc index 517aa4f199..5c9895ba9a 100644 --- a/gtk2_ardour/debug.cc +++ b/gtk2_ardour/debug.cc @@ -32,4 +32,3 @@ PBD::DebugBits PBD::DEBUG::GUITiming = PBD::new_debug_bit ("guitiming"); PBD::DebugBits PBD::DEBUG::EngineControl = PBD::new_debug_bit ("enginecontrol"); PBD::DebugBits PBD::DEBUG::GuiStartup = PBD::new_debug_bit ("guistartup"); PBD::DebugBits PBD::DEBUG::TrackDrag = PBD::new_debug_bit ("trackdrag"); -PBD::DebugBits PBD::DEBUG::ScopedTempoMap = PBD::new_debug_bit ("scopedtempomap"); diff --git a/gtk2_ardour/debug.h b/gtk2_ardour/debug.h index b767965998..127b9dce3b 100644 --- a/gtk2_ardour/debug.h +++ b/gtk2_ardour/debug.h @@ -33,7 +33,6 @@ namespace PBD { extern DebugBits EngineControl; extern DebugBits GuiStartup; extern DebugBits TrackDrag; - extern DebugBits ScopedTempoMap; } } diff --git a/gtk2_ardour/editing_context.cc b/gtk2_ardour/editing_context.cc index ad74cdd5ef..0e5d735dca 100644 --- a/gtk2_ardour/editing_context.cc +++ b/gtk2_ardour/editing_context.cc @@ -153,7 +153,6 @@ EditingContext::EditingContext (std::string const & name) , time_line_group (nullptr) , temporary_zoom_focus_change (false) , _dragging_playhead (false) - , local_tempo_map_depth (0) { using namespace Gtk::Menu_Helpers; diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index cb98f8dd5f..558c504238 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -35,6 +35,7 @@ #include "pbd/signals.h" #include "temporal/timeline.h" +#include "temporal/scope.h" #include "ardour/midi_operator.h" #include "ardour/session_handle.h" @@ -47,7 +48,6 @@ #include "widgets/ardour_spacer.h" #include "axis_provider.h" -#include "debug.h" #include "editing.h" #include "editor_items.h" #include "selection.h" @@ -76,13 +76,14 @@ class Selection; class SelectionMemento; class SelectableOwner; -class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, public virtual sigc::trackable +class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, public Temporal::ScopedTempoMapOwner, public virtual sigc::trackable { public: EditingContext (std::string const &); ~EditingContext (); std::string editor_name() const { return _name; } + std::string scope_name() const { return _name; } void set_session (ARDOUR::Session*); @@ -652,37 +653,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, QuantizeDialog* quantize_dialog; - friend struct TempoMapScope; - - void start_local_tempo_map (std::shared_ptr map) { - _local_tempo_map = map; - local_tempo_map_in (); - DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: starting local tempo scope\n", editor_name())); - } - - void end_local_tempo_map () { - DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: ending local tempo scope\n", editor_name())); - local_tempo_map_depth = 1; - local_tempo_map_out (); - } - - void local_tempo_map_in () const { - if (local_tempo_map_depth++ == 0 ) { - DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo %2\n", editor_name(), local_tempo_map_depth)); - if (_local_tempo_map) { - Temporal::TempoMap::set (_local_tempo_map); - _local_tempo_map.reset (); - } - } - } - - void local_tempo_map_out () const { - DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: out to local tempo %2\n", editor_name(), local_tempo_map_depth)); - if (local_tempo_map_depth && --local_tempo_map_depth == 0) { - DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: done with local tempo, depth now %2\n", editor_name(), local_tempo_map_depth)); - Temporal::TempoMap::fetch (); /* get current global map into thread-local pointer */ - } - } virtual bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0; virtual bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0; @@ -848,21 +818,5 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider, bool temporary_zoom_focus_change; bool _dragging_playhead; - mutable std::shared_ptr _local_tempo_map; - mutable std::shared_ptr _pre_local_tempo_map; - mutable uint64_t local_tempo_map_depth; - - struct TempoMapScope { - TempoMapScope (EditingContext const & context) - : ec (context) - { - ec.local_tempo_map_in (); - } - ~TempoMapScope () { - ec.local_tempo_map_out (); - } - EditingContext const & ec; - }; }; -#define EC_LOCAL_TEMPO_SCOPE TempoMapScope __tms (*this);