Add tempo and meter editing functions to main clock context menu
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Tue, 3 Feb 2015 19:25:10 +0000 (19:25 +0000)
committerColin Fletcher <colin.m.fletcher@googlemail.com>
Thu, 12 Feb 2015 18:06:16 +0000 (18:06 +0000)
Add 'Edit Tempo/Meter' and 'Insert Tempo/Meter Change' to the main clock's
context menu.

gtk2_ardour/editor.h
gtk2_ardour/main_clock.cc
gtk2_ardour/main_clock.h
gtk2_ardour/public_editor.h

index bd5f3816fb9838181141bfe91572355d36011605..fd308bed125429f331554da05827af07c3456c1b 100644 (file)
@@ -524,6 +524,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
        RegionSelection get_regions_from_selection_and_mouse (framepos_t);
        
+       void mouse_add_new_tempo_event (framepos_t where);
+       void mouse_add_new_meter_event (framepos_t where);
+       void edit_tempo_section (ARDOUR::TempoSection*);
+       void edit_meter_section (ARDOUR::MeterSection*);
+
   protected:
        void map_transport_state ();
        void map_position_change (framepos_t);
index 80dece04aae20813cb97ce6ce5708060b67f2e9d..b8bc733ea6e55234ec061065164cadeaabd6764d 100644 (file)
 
 #include "ardour_ui.h"
 #include "main_clock.h"
+#include "public_editor.h"
 
 #include "i18n.h"
 
+#include "ardour/tempo.h"
+
 using namespace Gtk;
 
 MainClock::MainClock (
@@ -62,6 +65,12 @@ MainClock::build_ops_menu ()
                        c->set_active (true);
                }
        }
+
+       ops_items.push_back (SeparatorElem());
+       ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo)));
+       ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter)));
+       ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo)));
+       ops_items.push_back (MenuElem (_("Insert Meter Change"), sigc::mem_fun(*this, &MainClock::insert_new_meter)));
 }
 
 void
@@ -73,3 +82,31 @@ MainClock::display_delta_to_edit_cursor ()
                ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ());
        }
 }
+
+void
+MainClock::edit_current_tempo ()
+{
+       ARDOUR::TempoSection ts = PublicEditor::instance().session()->tempo_map().tempo_section_at(current_time());
+       PublicEditor::instance().edit_tempo_section (&ts);
+}
+
+void
+MainClock::edit_current_meter ()
+{
+       ARDOUR::Meter m = PublicEditor::instance().session()->tempo_map().meter_at(current_time());
+       ARDOUR::MeterSection ms(current_time(), m.divisions_per_bar(), m.note_divisor());
+       PublicEditor::instance().edit_meter_section (&ms);
+}
+
+void
+MainClock::insert_new_tempo ()
+{
+       PublicEditor::instance().mouse_add_new_tempo_event (current_time ());
+}
+
+void
+MainClock::insert_new_meter ()
+{
+       PublicEditor::instance().mouse_add_new_meter_event (current_time ());
+}
+
index 959a3f94407bf4601cefabbb6ed1720c05e8e9a0..f5f9096b396ff9e765f648436a958e316824e57b 100644 (file)
 
 #include "audio_clock.h"
 
-/** A simple subclass of AudioClock that adds the `display delta to edit cursor' option to its context menu */
+/** A simple subclass of AudioClock that adds a few things to its context menu:
+ * `display delta to edit cursor' and edit/change tempo/meter
+ */
 class MainClock : public AudioClock
 {
 public:
-       MainClock (const std::string &, bool, const std::string &, bool, bool, bool primary, bool duration = false, bool with_info = false);
+       MainClock (const std::string& clock_name, bool is_transient, const std::string& widget_name,
+                  bool editable, bool follows_playhead, bool primary, bool duration = false, bool with_info = false);
 
 private:
        
+       // Editor *_editor;
+
        void build_ops_menu ();
        void display_delta_to_edit_cursor ();
+       void edit_current_tempo ();
+       void edit_current_meter ();
+       void insert_new_tempo ();
+       void insert_new_meter ();
        bool _primary;
 };
index e580ac0ec332d49fe53629ddab01d724411bc639..3b18cd41e148e7c5b11390a85762a4e34d25e43c 100644 (file)
@@ -419,6 +419,11 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
        virtual void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const = 0;
        virtual void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const = 0;
 
+       virtual void mouse_add_new_tempo_event (framepos_t where) = 0;
+       virtual void mouse_add_new_meter_event (framepos_t where) = 0;
+       virtual void edit_tempo_section (ARDOUR::TempoSection*) = 0;
+       virtual void edit_meter_section (ARDOUR::MeterSection*) = 0;
+
        /// Singleton instance, set up by Editor::Editor()
 
        static PublicEditor* _instance;