next iteration of changes to handle time domain bounces as undoable (GUI)

This commit is contained in:
Paul Davis
2023-08-14 23:38:44 -06:00
parent 076cb86912
commit 7c029f5f6a
6 changed files with 25 additions and 18 deletions

View File

@@ -468,6 +468,7 @@ Editor::Editor ()
, quantize_dialog (0) , quantize_dialog (0)
, _main_menu_disabler (0) , _main_menu_disabler (0)
, _tempo_edit_behavior (UIConfiguration::instance().get_tempo_edit_behavior()) , _tempo_edit_behavior (UIConfiguration::instance().get_tempo_edit_behavior())
, domain_bounce_info (nullptr)
{ {
/* we are a singleton */ /* we are a singleton */
@@ -3674,6 +3675,7 @@ Editor::begin_reversible_selection_op (string name)
void void
Editor::abort_reversible_selection_op () Editor::abort_reversible_selection_op ()
{ {
PBD::stacktrace (std::cerr, 20);
if (!_session) { if (!_session) {
return; return;
} }

View File

@@ -1761,7 +1761,7 @@ private:
void mid_tempo_per_region_update (RegionView*); void mid_tempo_per_region_update (RegionView*);
bool ignore_map_change; bool ignore_map_change;
Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping (PBD::Command**); Temporal::TempoMap::WritableSharedPtr begin_tempo_mapping (Temporal::DomainBounceInfo&);
void abort_tempo_mapping (); void abort_tempo_mapping ();
void commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr&); void commit_tempo_mapping (Temporal::TempoMap::WritableSharedPtr&);
@@ -2556,6 +2556,8 @@ private:
clear_tempo_markers_after (Temporal::timepos_t (0), false); clear_tempo_markers_after (Temporal::timepos_t (0), false);
} }
Temporal::DomainBounceInfo* domain_bounce_info;
friend class Drag; friend class Drag;
friend class RegionCutDrag; friend class RegionCutDrag;
friend class RegionDrag; friend class RegionDrag;

View File

@@ -3545,7 +3545,6 @@ MappingEndDrag::finished (GdkEvent* event, bool movement_occurred)
XMLNode& after = map->get_state (); XMLNode& after = map->get_state ();
_editor->session ()->add_command (new Temporal::TempoCommand (_("stretch tempo"), _before_state, &after)); _editor->session ()->add_command (new Temporal::TempoCommand (_("stretch tempo"), _before_state, &after));
_editor->commit_reversible_command ();
/* 2nd argument means "update tempo map display after the new map is /* 2nd argument means "update tempo map display after the new map is
* installed. We need to do this because the code above has not * installed. We need to do this because the code above has not
@@ -3554,6 +3553,8 @@ MappingEndDrag::finished (GdkEvent* event, bool movement_occurred)
*/ */
_editor->commit_tempo_mapping (map); _editor->commit_tempo_mapping (map);
_editor->commit_reversible_command ();
} }
void void
@@ -3656,8 +3657,8 @@ MappingTwistDrag::finished (GdkEvent* event, bool movement_occurred)
XMLNode& after = map->get_state (); XMLNode& after = map->get_state ();
_editor->session ()->add_command (new Temporal::TempoCommand (_("twist tempo"), _before_state, &after)); _editor->session ()->add_command (new Temporal::TempoCommand (_("twist tempo"), _before_state, &after));
_editor->commit_reversible_command ();
_editor->commit_tempo_mapping (map); _editor->commit_tempo_mapping (map);
_editor->commit_reversible_command ();
} }
void void

View File

@@ -3012,8 +3012,8 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
return; return;
} }
PBD::Command* swap_undo_command; domain_bounce_info = new Temporal::DomainBounceInfo (Temporal::BeatTime, Temporal::AudioTime);
Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping (&swap_undo_command); Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping (*domain_bounce_info);
/* Decide between a mid-twist, which we do if the /* Decide between a mid-twist, which we do if the
* pointer is between two tempo markers, and an end-stretch, * pointer is between two tempo markers, and an end-stretch,
@@ -3104,7 +3104,6 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
if (at_end) { if (at_end) {
begin_reversible_command (_("tempo mapping: end-stretch")); begin_reversible_command (_("tempo mapping: end-stretch"));
_session->add_command (swap_undo_command);
std::cerr << "END STRETCH\n"; std::cerr << "END STRETCH\n";
_drags->set (new MappingEndDrag (this, item, map, tempo, *focus, *before_state), event); _drags->set (new MappingEndDrag (this, item, map, tempo, *focus, *before_state), event);
return; return;
@@ -3113,13 +3112,11 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
if (before && focus && after) { if (before && focus && after) {
std::cerr << "TWIST\n"; std::cerr << "TWIST\n";
begin_reversible_command (_("tempo mapping: mid-twist")); 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); _drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state, ramped), event);
} else if (ramped && focus && after) { } 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*/ /* 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"; std::cerr << "TWIST ON START\n";
begin_reversible_command (_("tempo mapping: mid-twist")); 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 */ 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); _drags->set (new MappingTwistDrag (this, item, map, *before, *focus, *after, *before_state, ramped), event);
} else { } else {

View File

@@ -813,21 +813,20 @@ Editor::real_remove_meter_marker (Temporal::MeterPoint const * section)
Temporal::TempoMap::WritableSharedPtr Temporal::TempoMap::WritableSharedPtr
Editor::begin_tempo_mapping (PBD::Command** cmd) Editor::begin_tempo_mapping (Temporal::DomainBounceInfo& dbi)
{ {
TempoMap::WritableSharedPtr wmap = TempoMap::write_copy (); TempoMap::WritableSharedPtr wmap = TempoMap::write_copy ();
TempoMap::set (wmap); TempoMap::set (wmap);
reassociate_metric_markers (wmap); reassociate_metric_markers (wmap);
(void) Temporal::DomainSwapInformation::start (Temporal::BeatTime); _session->start_domain_bounce (dbi);
*cmd = _session->globally_change_time_domain (Temporal::BeatTime, Temporal::AudioTime);
return wmap; return wmap;
} }
void void
Editor::abort_tempo_mapping () Editor::abort_tempo_mapping ()
{ {
delete domain_swap; /* undo the domain swap */ delete domain_bounce_info;
domain_swap = 0; domain_bounce_info = nullptr;
TempoMap::abort_update (); TempoMap::abort_update ();
TempoMap::SharedPtr tmap (TempoMap::fetch()); TempoMap::SharedPtr tmap (TempoMap::fetch());
@@ -838,8 +837,14 @@ void
Editor::commit_tempo_mapping (TempoMap::WritableSharedPtr& new_map) Editor::commit_tempo_mapping (TempoMap::WritableSharedPtr& new_map)
{ {
TempoMap::update (new_map); TempoMap::update (new_map);
delete domain_swap; /* undo the domain swap */
domain_swap = 0; /* revert all positions */
_session->finish_domain_bounce (*domain_bounce_info);
delete domain_bounce_info;
domain_bounce_info = nullptr;
TempoMap::SharedPtr tmap (TempoMap::fetch()); TempoMap::SharedPtr tmap (TempoMap::fetch());
reassociate_metric_markers (tmap); reassociate_metric_markers (tmap);
} }

View File

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