API development for time domain flipping (GUI edition)

This commit is contained in:
Paul Davis 2023-02-23 23:01:09 -07:00
parent d513653912
commit d25a615e20
4 changed files with 43 additions and 3 deletions

View File

@ -1742,6 +1742,9 @@ private:
void mid_tempo_per_region_update (RegionView*);
bool ignore_map_change;
Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping ();
void abort_tempo_mapping ();
enum MidTempoChanges {
TempoChanged = 0x1,
MeterChanged = 0x2,
@ -1752,6 +1755,7 @@ private:
protected:
void _commit_tempo_map_edit (Temporal::TempoMap::WritableSharedPtr&, bool with_update = false);
void _commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr&);
private:
friend class DragManager;

View File

@ -3633,7 +3633,8 @@ TempoTwistDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
Drag::start_grab (event, cursor);
map = _editor->begin_tempo_map_edit ();
map = _editor->begin_tempo_mapping ();
/* Get the tempo point that starts this section */
_tempo = const_cast<TempoPoint*> (&map->tempo_at (raw_grab_time()));
@ -3714,13 +3715,13 @@ TempoTwistDrag::finished (GdkEvent* event, bool movement_occurred)
_editor->session()->add_command (new Temporal::TempoCommand (_("twist tempo"), _before_state, &after));
_editor->commit_reversible_command ();
_editor->commit_tempo_map_edit (map);
_editor->commit_tempo_mapping (map);
}
void
TempoTwistDrag::aborted (bool moved)
{
_editor->abort_tempo_map_edit ();
_editor->abort_tempo_mapping ();
}
TempoEndDrag::TempoEndDrag (Editor* e, ArdourCanvas::Item* i)

View File

@ -754,6 +754,34 @@ Editor::real_remove_meter_marker (Temporal::MeterPoint const * section)
return FALSE;
}
Temporal::TempoMap::WritableSharedPtr
Editor::begin_tempo_mapping ()
{
TempoMap::WritableSharedPtr wmap = TempoMap::fetch_writable ();
reassociate_metric_markers (wmap);
(void) Temporal::DomainSwapInformation::start (Temporal::BeatTime);
_session->globally_change_time_domain (Temporal::BeatTime, Temporal::AudioTime);
return wmap;
}
void
Editor::abort_tempo_mapping ()
{
delete domain_swap; /* undo the domain swap */
domain_swap = 0;
TempoMap::SharedPtr tmap (TempoMap::fetch());
reassociate_metric_markers (tmap);
}
void
Editor::_commit_tempo_mapping (TempoMap::WritableSharedPtr& new_map)
{
TempoMap::update (new_map);
abort_tempo_mapping ();
}
Temporal::TempoMap::WritableSharedPtr
Editor::begin_tempo_map_edit ()
{

View File

@ -520,6 +520,12 @@ public:
_commit_tempo_map_edit (map, with_update);
}
virtual Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping () = 0;
virtual void abort_tempo_mapping () = 0;
void commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr& map) {
_commit_tempo_mapping (map);
}
virtual void access_action (const std::string&, const std::string&) = 0;
virtual void set_toggleaction (const std::string&, const std::string&, bool) = 0;
@ -584,6 +590,7 @@ protected:
virtual void suspend_route_redisplay () = 0;
virtual void resume_route_redisplay () = 0;
virtual void _commit_tempo_map_edit (Temporal::TempoMap::WritableSharedPtr&, bool with_update) = 0;
virtual void _commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr&) = 0;
std::atomic<int> _suspend_route_redisplay_counter;
};