refinements to infrastructure for an EditingContext's locally scoped tempo map
This commit is contained in:
@@ -1629,11 +1629,17 @@ EditingContext::snap_relative_time_to_relative_time (timepos_t const & origin, t
|
||||
return origin.distance (snapped);
|
||||
}
|
||||
|
||||
std::shared_ptr<Temporal::TempoMap const>
|
||||
EditingContext::start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>)
|
||||
void
|
||||
EditingContext::start_local_tempo_map (std::shared_ptr<TempoMap> map)
|
||||
{
|
||||
/* default is a no-op */
|
||||
return Temporal::TempoMap::use ();
|
||||
_local_tempo_map = map;
|
||||
}
|
||||
|
||||
void
|
||||
EditingContext::end_local_tempo_map ()
|
||||
{
|
||||
_local_tempo_map.reset ();
|
||||
Temporal::TempoMap::fetch ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -87,18 +87,17 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
|
||||
|
||||
Temporal::TimeDomain time_domain () const;
|
||||
|
||||
|
||||
struct TempoMapScope {
|
||||
TempoMapScope (EditingContext& context, std::shared_ptr<Temporal::TempoMap> map)
|
||||
: ec (context)
|
||||
{
|
||||
old_map = ec.start_local_tempo_map (map);
|
||||
ec.start_local_tempo_map (map);
|
||||
ec.ensure_local_tempo_scope ();
|
||||
}
|
||||
~TempoMapScope () {
|
||||
ec.end_local_tempo_map (old_map);
|
||||
ec.end_local_tempo_map ();
|
||||
}
|
||||
EditingContext& ec;
|
||||
std::shared_ptr<Temporal::TempoMap const> old_map;
|
||||
};
|
||||
|
||||
DragManager* drags () const {
|
||||
@@ -666,8 +665,9 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
|
||||
QuantizeDialog* quantize_dialog;
|
||||
|
||||
friend struct TempoMapScope;
|
||||
virtual std::shared_ptr<Temporal::TempoMap const> start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>);
|
||||
virtual void end_local_tempo_map (std::shared_ptr<Temporal::TempoMap const>) { /* no-op by default */ }
|
||||
void set_local_tempo_map (std::shared_ptr<Temporal::TempoMap>);
|
||||
void start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>);
|
||||
void end_local_tempo_map ();
|
||||
|
||||
virtual bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
|
||||
virtual bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
|
||||
@@ -832,4 +832,15 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider,
|
||||
|
||||
bool temporary_zoom_focus_change;
|
||||
bool _dragging_playhead;
|
||||
|
||||
std::shared_ptr<Temporal::TempoMap> _local_tempo_map;
|
||||
void ensure_local_tempo_scope () {
|
||||
if (_local_tempo_map) {
|
||||
Temporal::TempoMap::set (_local_tempo_map);
|
||||
_local_tempo_map.reset ();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define EC_LOCAL_TEMPO_SCOPE ensure_local_tempo_scope ()
|
||||
#define EC_GIVEN_LOCAL_TEMPO_SCOPE(ec) ec.ensure_local_tempo_scope ()
|
||||
|
||||
Reference in New Issue
Block a user