clean up mapping bar context menu, extend with clear tempos

This commit is contained in:
Paul Davis 2023-06-30 15:50:47 -06:00
parent 20e1b6b287
commit d688af76c0
3 changed files with 60 additions and 8 deletions

View File

@ -2543,6 +2543,12 @@ private:
return thing_with_time_domain ? thing_with_time_domain->time_domain() : Temporal::AudioTime;
}
void clear_tempo_markers_before (Temporal::timepos_t where, bool stop_at_music_times);
void clear_tempo_markers_after (Temporal::timepos_t where, bool stop_at_music_times);
void clear_tempo_markers () {
clear_tempo_markers_after (Temporal::timepos_t (0), false);
}
friend class Drag;
friend class RegionCutDrag;
friend class RegionDrag;

View File

@ -253,16 +253,19 @@ Editor::popup_ruler_menu (timepos_t const & where, ItemType t)
}
break;
case MappingBarItem:
#warning paul fix mapping bar context menu
ruler_items.push_back (MenuElem (_("New BBT Marker"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
ruler_items.push_back (MenuElem (_("New Tempo Marker"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
ruler_items.push_back (MenuElem (_("Clear")));
break;
case TempoBarItem:
case TempoCurveItem:
ruler_items.push_back (MenuElem (_("New Tempo"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
ruler_items.push_back (MenuElem (_("Add New Tempo"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
ruler_items.push_back (SeparatorElem ());
/* fallthrough */
case MappingBarItem:
ruler_items.push_back (MenuElem (_("Clear All Tempos"), sigc::mem_fun (*this, &Editor::clear_tempo_markers)));
ruler_items.push_back (SeparatorElem ());
ruler_items.push_back (MenuElem (_("Clear All Earlier Tempos"), sigc::bind (sigc::mem_fun (*this, &Editor::clear_tempo_markers_before), where, true)));
ruler_items.push_back (MenuElem (_("Clear All Later Tempos"), sigc::bind (sigc::mem_fun (*this, &Editor::clear_tempo_markers_after), where, true)));
ruler_items.push_back (SeparatorElem ());
ruler_items.push_back (MenuElem (_("Clear All Earlier Tempos (w/BBT markers)"), sigc::bind (sigc::mem_fun (*this, &Editor::clear_tempo_markers_before), where, false)));
ruler_items.push_back (MenuElem (_("Clear All Later Tempos (w/BBT markers)"), sigc::bind (sigc::mem_fun (*this, &Editor::clear_tempo_markers_after), where, false)));
break;
case MeterBarItem:

View File

@ -1019,3 +1019,46 @@ Editor::tempo_edit_behavior_toggled (TempoEditBehavior teb)
break;
}
}
void
Editor::clear_tempo_markers_before (timepos_t where, bool stop_at_music_times)
{
if (!_session) {
return;
}
TempoMap::WritableSharedPtr wmap = begin_tempo_map_edit ();
XMLNode* before_state = &wmap->get_state ();
if (!wmap->clear_tempos_before (where, stop_at_music_times)) {
abort_tempo_map_edit ();
return;
}
begin_reversible_command (_("clear earlier tempos"));
commit_tempo_map_edit (wmap, true);
XMLNode& after = wmap->get_state ();
_session->add_command (new Temporal::TempoCommand (_("clear earlier tempos"), before_state, &after));
commit_reversible_command ();
}
void
Editor::clear_tempo_markers_after (timepos_t where, bool stop_at_music_times)
{
if (!_session) {
return;
}
TempoMap::WritableSharedPtr wmap = begin_tempo_map_edit ();
XMLNode* before_state = &wmap->get_state ();
if (!wmap->clear_tempos_after (where, stop_at_music_times)) {
abort_tempo_map_edit ();
return;
}
begin_reversible_command (_("clear later tempos"));
commit_tempo_map_edit (wmap, true);
XMLNode& after = wmap->get_state ();
_session->add_command (new Temporal::TempoCommand (_("clear later tempos"), before_state, &after));
commit_reversible_command ();
}