diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 6fd6043475..c3ec5321df 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -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; diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 7a633d7a8e..cb836c76f5 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -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: diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 3e8d4b0d05..a5f30355f2 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -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 (); +}