Allow Insert Time option to move tempos and time sig changes, as per #1951 (thanks...
authorBen Loftis <ben@glw.com>
Wed, 10 Jun 2009 12:51:37 +0000 (12:51 +0000)
committerBen Loftis <ben@glw.com>
Wed, 10 Jun 2009 12:51:37 +0000 (12:51 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5150 d708f5d6-7413-0410-9779-e7cbd77b26cf

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

index 9d661c8125c97ae81011ffbb8343dacbd4fa44ec..f3ed303fc2aa640e98c375312286191c13159275 100644 (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);
 
index 40e1b22aededc21881eed10188c31ee1a0c29405..3c19d69a301b96ace59f8566b822bbe7c8f49b91 100644 (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 ();
index c4915072c57ba7349b6e00fcb10adcc57404b932..23f18eda57d4b1232874b9333fca570ddff513b0 100644 (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;
 
index ab7b7c096eeb619a0f7bc5fbf117c0b035a72e03..4b9ac61e4913380a6b67e87834a5145be2651b21 100644 (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)
 {