13
0

tempo display: further simplifications to handling map changes

When a tempo map change originates from a drag, we know the required redraws have
already been done. Use a new bool member, ignore_map_change, to tell the Editor
to ignore the map change signal. For all other map changes, do the full reset.
This commit is contained in:
Paul Davis 2022-06-28 10:16:31 -06:00
parent 32a3bf229e
commit bf87916fb1
4 changed files with 24 additions and 26 deletions

View File

@ -388,6 +388,7 @@ Editor::Editor ()
, lock_dialog (0) , lock_dialog (0)
/* , last_event_time { 0, 0 } */ /* this initialization style requires C++11 */ /* , last_event_time { 0, 0 } */ /* this initialization style requires C++11 */
, _dragging_playhead (false) , _dragging_playhead (false)
, ignore_map_change (false)
, _follow_playhead (true) , _follow_playhead (true)
, _stationary_playhead (false) , _stationary_playhead (false)
, _maximised (false) , _maximised (false)

View File

@ -1729,6 +1729,8 @@ private:
Temporal::TempoMap::WritableSharedPtr begin_tempo_map_edit (); Temporal::TempoMap::WritableSharedPtr begin_tempo_map_edit ();
void abort_tempo_map_edit (); void abort_tempo_map_edit ();
void commit_tempo_map_edit (Temporal::TempoMap::WritableSharedPtr&);
bool ignore_map_change;
enum MidTempoChanges { enum MidTempoChanges {
TempoChanged = 0x1, TempoChanged = 0x1,
@ -1875,7 +1877,6 @@ private:
void update_tempo_curves (double min_tempo, double max_tempo, samplecnt_t sr); void update_tempo_curves (double min_tempo, double max_tempo, samplecnt_t sr);
void tempo_map_changed (); void tempo_map_changed ();
void tempo_map_model_update ();
void redisplay_grid (bool immediate_redraw); void redisplay_grid (bool immediate_redraw);

View File

@ -3145,7 +3145,7 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
_editor->set_grid_to (_old_grid_type); _editor->set_grid_to (_old_grid_type);
_editor->set_snap_mode (_old_snap_mode); _editor->set_snap_mode (_old_snap_mode);
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
XMLNode &after = map->get_state(); XMLNode &after = map->get_state();
_editor->session()->add_command (new Temporal::TempoCommand (_("move time signature"), before_state, &after)); _editor->session()->add_command (new Temporal::TempoCommand (_("move time signature"), before_state, &after));
@ -3237,7 +3237,7 @@ TempoCurveDrag::finished (GdkEvent* event, bool movement_occurred)
/* push the current state of our writable map copy */ /* push the current state of our writable map copy */
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
XMLNode &after = map->get_state(); XMLNode &after = map->get_state();
_editor->session()->add_command (new Temporal::TempoCommand (_("change tempo"), _before_state, &after)); _editor->session()->add_command (new Temporal::TempoCommand (_("change tempo"), _before_state, &after));
@ -3346,7 +3346,7 @@ TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
/* push the current state of our writable map copy */ /* push the current state of our writable map copy */
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
XMLNode &after = map->get_state(); XMLNode &after = map->get_state();
_editor->session()->add_command (new Temporal::TempoCommand (_("move tempo"), _before_state, &after)); _editor->session()->add_command (new Temporal::TempoCommand (_("move tempo"), _before_state, &after));
@ -3518,7 +3518,7 @@ BBTRulerDrag::finished (GdkEvent* event, bool movement_occurred)
} }
} }
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
XMLNode &after = map->get_state(); XMLNode &after = map->get_state();
@ -3628,7 +3628,7 @@ TempoTwistDrag::finished (GdkEvent* event, bool movement_occurred)
_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_reversible_command ();
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
} }
void void
@ -3734,7 +3734,7 @@ TempoEndDrag::finished (GdkEvent* event, bool movement_occurred)
return; return;
} }
TempoMap::update (map); _editor->commit_tempo_map_edit (map);
XMLNode &after = map->get_state(); XMLNode &after = map->get_state();
_editor->session()->add_command (new Temporal::TempoCommand (_("move tempo end"), _before_state, &after)); _editor->session()->add_command (new Temporal::TempoCommand (_("move tempo end"), _before_state, &after));

View File

@ -36,6 +36,7 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/memento_command.h" #include "pbd/memento_command.h"
#include "pbd/unwind.h"
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/gtk_ui.h>
@ -327,6 +328,10 @@ Editor::update_tempo_curves (double min_tempo, double max_tempo, samplecnt_t sr)
void void
Editor::tempo_map_changed () Editor::tempo_map_changed ()
{ {
if (ignore_map_change) {
return;
}
TempoMap::SharedPtr current_map = TempoMap::fetch (); TempoMap::SharedPtr current_map = TempoMap::fetch ();
/* If the tempo map was changed by something other than the Editor, we /* If the tempo map was changed by something other than the Editor, we
@ -334,25 +339,9 @@ Editor::tempo_map_changed ()
* with the new map. * with the new map.
*/ */
if (!tempo_marks.empty()) { reset_metric_marks ();
/* a little awkward using shared_ptr<T>::get() but better than every update_tempo_based_rulers ();
* point in the map holding a shared_ptr ref to the map that owns it. maybe_draw_grid_lines ();
*/
if (&tempo_marks.front()->point().map() != current_map.get()) {
reassociate_metric_markers (current_map);
}
}
tempo_map_model_update ();
}
void
Editor::tempo_map_model_update ()
{
reset_metric_marks ();
update_tempo_based_rulers ();
maybe_draw_grid_lines ();
} }
void void
@ -730,6 +719,13 @@ Editor::abort_tempo_map_edit ()
reassociate_metric_markers (tmap); reassociate_metric_markers (tmap);
} }
void
Editor::commit_tempo_map_edit (TempoMap::WritableSharedPtr& new_map)
{
PBD::Unwinder<bool> uw (ignore_map_change, true);
TempoMap::update (new_map);
}
void void
Editor::mid_tempo_change (MidTempoChanges what_changed) Editor::mid_tempo_change (MidTempoChanges what_changed)
{ {