Allow Insert Time option to move tempos and time sig changes, as per #1951.
authorCarl Hetherington <carl@carlh.net>
Mon, 8 Jun 2009 23:24:14 +0000 (23:24 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 8 Jun 2009 23:24:14 +0000 (23:24 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5132 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc
libs/ardour/ardour/tempo.h
libs/ardour/tempo.cc

index 2a28d0fe1b2d09b8e3be7184c31ac89eb4b27f11..2528f2054b6ea6838452927db042da420b762ab1 100644 (file)
@@ -1172,7 +1172,7 @@ class Editor : public PublicEditor
        void quantize_region ();
 
        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, nframes64_t, Editing::InsertTimeOption, bool, bool, bool);
 
        void tab_to_transient (bool forward);
 
index 4244567304a33fb6c18a0dc8abaa2b4d7407467a..5dac7820fb91496974410ea244fc017d5277a636 100644 (file)
@@ -6218,6 +6218,8 @@ Editor::do_insert_time ()
        d.get_vbox()->pack_start (move_glued);
        CheckButton move_markers (_("Move markers"));
        d.get_vbox()->pack_start (move_markers);
+       CheckButton move_tempos (_("Move tempo and meter changes"));
+       d.get_vbox()->pack_start (move_tempos);
        
        d.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
        d.add_button (_("Insert time"), Gtk::RESPONSE_OK);
@@ -6249,12 +6251,12 @@ Editor::do_insert_time ()
                break;
        }
 
-       insert_time (pos, distance, opt, move_glued.get_active(), move_markers.get_active());
+       insert_time (pos, distance, opt, move_glued.get_active(), move_markers.get_active(), move_tempos.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;
 
@@ -6317,6 +6319,10 @@ Editor::insert_time (nframes64_t pos, nframes64_t frames, InsertTimeOption opt,
                }
        }
 
+       if (tempo_too) {
+               session->tempo_map().insert_time (pos, frames);
+       }
+
        if (commit) {
                commit_reversible_command ();
        }
index d88c5366d22a63a7570b924eebc873edea2649e5..fcda463fe151d4b82ad95ac290d7ecb8d61acbff 100644 (file)
@@ -246,6 +246,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, nframes_t);
+
        int n_tempos () const;
        int n_meters () const;
 
index 00c187a5bd5171e4862b43b88423c5c4af1d032a..30560167523b55e7ac9f098a8f91b36de384a812 100644 (file)
@@ -1536,3 +1536,17 @@ TempoMap::n_meters() const
 
        return cnt;
 }
+
+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));
+}