API change for the start of making tempo mapping undoable (GUI)

This commit is contained in:
Paul Davis 2023-08-06 13:40:00 -06:00
parent e7c35cf601
commit b3a5e0b2b1
4 changed files with 10 additions and 6 deletions

View File

@ -1758,7 +1758,7 @@ private:
void mid_tempo_per_region_update (RegionView*);
bool ignore_map_change;
Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping ();
Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping (PBD::Command**);
void abort_tempo_mapping ();
void commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr&);

View File

@ -3012,7 +3012,8 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
return;
}
Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping ();
PBD::Command* swap_undo_command;
Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping (&swap_undo_command);
/* Decide between a mid-twist, which we do if the
* pointer is between two tempo markers, and an end-stretch,
@ -3103,6 +3104,7 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
if (at_end) {
begin_reversible_command (_("tempo mapping: end-stretch"));
_session->add_command (swap_undo_command);
std::cerr << "END STRETCH\n";
_drags->set (new MappingEndDrag (this, item, map, tempo, *focus, *before_state), event);
return;
@ -3111,11 +3113,13 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
if (before && focus && after) {
std::cerr << "TWIST\n";
begin_reversible_command (_("tempo mapping: mid-twist"));
_session->add_command (swap_undo_command);
_drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state, ramped), event);
} else if (ramped && focus && after) {
/* special case 4: user is manipulating a beat line after the INITIAL tempo marker, so there is no prior marker*/
std::cerr << "TWIST ON START\n";
begin_reversible_command (_("tempo mapping: mid-twist"));
_session->add_command (swap_undo_command);
before = focus; /* this is unused in MappingTwistDrag, when ramped is true, but let's not pass in garbage */
_drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state, ramped), event);
} else {

View File

@ -813,13 +813,13 @@ Editor::real_remove_meter_marker (Temporal::MeterPoint const * section)
Temporal::TempoMap::WritableSharedPtr
Editor::begin_tempo_mapping ()
Editor::begin_tempo_mapping (PBD::Command** cmd)
{
TempoMap::WritableSharedPtr wmap = TempoMap::write_copy ();
TempoMap::set (wmap);
TempoMap::set (wmap);
reassociate_metric_markers (wmap);
(void) Temporal::DomainSwapInformation::start (Temporal::BeatTime);
_session->globally_change_time_domain (Temporal::BeatTime, Temporal::AudioTime);
*cmd = _session->globally_change_time_domain (Temporal::BeatTime, Temporal::AudioTime);
return wmap;
}

View File

@ -528,7 +528,7 @@ public:
_commit_tempo_map_edit (map, with_update);
}
virtual Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping () = 0;
virtual Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping (PBD::Command**) = 0;
virtual void abort_tempo_mapping () = 0;
virtual void commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr& map) = 0;