add right-click 'Ramp to Next' tempo marker menu item.

This commit is contained in:
nick_m 2017-02-27 03:03:55 +11:00 committed by Robin Gareus
parent f8a6f8918d
commit 663d0e1743
2 changed files with 36 additions and 0 deletions

View File

@ -1688,6 +1688,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void rename_marker (ArdourMarker *marker);
void toggle_marker_lock_style ();
void toggle_tempo_type ();
void ramp_to_next_tempo ();
void toggle_marker_menu_lock ();
void toggle_marker_menu_glue ();
void marker_menu_hide ();

View File

@ -995,6 +995,10 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
}
if (_session->tempo_map().next_tempo_section (&loc->tempo())) {
items.push_back (MenuElem (_("Ramp to Next"), sigc::mem_fun(*this, &Editor::ramp_to_next_tempo)));
}
if (loc->tempo().position_lock_style() == AudioTime && can_remove) {
items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
} else if (can_remove) {
@ -1455,6 +1459,37 @@ Editor::toggle_tempo_type ()
}
}
void
Editor::ramp_to_next_tempo ()
{
TempoMarker* tm;
MeterMarker* mm;
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
if (tm) {
TempoMap& tmap (_session->tempo_map());
TempoSection* tsp = &tm->tempo();
TempoSection* next_ts = tmap.next_tempo_section (&tm->tempo());
if (next_ts) {
const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), next_ts->end_note_types_per_minute());
const double pulse = tsp->pulse();
const framepos_t frame = tsp->frame();
const PositionLockStyle pls = tsp->position_lock_style();
begin_reversible_command (_("ramp to next tempo"));
XMLNode &before = _session->tempo_map().get_state();
tmap.replace_tempo (*tsp, tempo, pulse, frame, pls);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
}
//const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type());
}
}
void
Editor::toggle_marker_menu_lock ()
{