Allow Insert Time option to move tempos and time sig changes, as per #1951 (thanks carlh)

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5150 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Ben Loftis 2009-06-10 12:51:37 +00:00
parent 9c8ecfd3bb
commit adb94a0d9e
4 changed files with 26 additions and 3 deletions

View file

@ -1098,7 +1098,7 @@ class Editor : public PublicEditor
void adjust_region_scale_amplitude (bool up);
void do_insert_time ();
void insert_time (nframes64_t pos, nframes64_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too);
void insert_time (nframes64_t pos, nframes64_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too, bool tempo_too);
void tab_to_transient (bool forward);

View file

@ -6000,6 +6000,7 @@ Editor::do_insert_time ()
Label intersect_option_label (_("Intersected regions should:"));
CheckButton glue_button (_("Move Glued Regions"));
CheckButton marker_button (_("Move Markers"));
CheckButton tempo_button (_("Move Tempo & Meters"));
AudioClock clock ("insertTimeClock", true, X_("InsertTimeClock"), true, true, true);
HBox clock_box;
@ -6014,6 +6015,7 @@ Editor::do_insert_time ()
option_box.pack_start (button_box, false, false);
option_box.pack_start (glue_button, false, false);
option_box.pack_start (marker_button, false, false);
option_box.pack_start (tempo_button, false, false);
button_box.pack_start (leave_button, false, false);
button_box.pack_start (move_button, false, false);
@ -6033,6 +6035,7 @@ Editor::do_insert_time ()
clock.show_all();
clock_box.show ();
marker_button.show ();
tempo_button.show ();
d.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
d.add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
@ -6060,12 +6063,12 @@ Editor::do_insert_time ()
opt = SplitIntersected;
}
insert_time (pos, distance, opt, glue_button.get_active(), marker_button.get_active());
insert_time (pos, distance, opt, glue_button.get_active(), marker_button.get_active(), tempo_button.get_active());
}
void
Editor::insert_time (nframes64_t pos, nframes64_t frames, InsertTimeOption opt,
bool ignore_music_glue, bool markers_too)
bool ignore_music_glue, bool markers_too, bool tempo_too)
{
bool commit = false;
@ -6127,6 +6130,9 @@ Editor::insert_time (nframes64_t pos, nframes64_t frames, InsertTimeOption opt,
session->add_command (new MementoCommand<Locations>(*session->locations(), &before, &after));
}
}
if (tempo_too)
session->tempo_map().insert_time (pos, frames);
if (commit) {
commit_reversible_command ();

View file

@ -281,6 +281,8 @@ class TempoMap : public PBD::StatefulDestructible
void change_existing_tempo_at (nframes_t, double bpm, double note_type);
void change_initial_tempo (double bpm, double note_type);
void insert_time( nframes_t where, nframes_t amount);
int n_tempos () const;
int n_meters () const;

View file

@ -528,6 +528,21 @@ TempoMap::change_initial_tempo (double beats_per_minute, double note_type)
}
}
void
TempoMap::insert_time (nframes_t where, nframes_t amount)
{
for (Metrics::iterator i = metrics->begin(); i != metrics->end(); ++i) {
if ((*i)->frame() >= where) {
(*i)->set_frame ((*i)->frame() + amount);
}
}
timestamp_metrics (false);
StateChanged (Change (0));
}
void
TempoMap::change_existing_tempo_at (nframes_t where, double beats_per_minute, double note_type)
{