summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2015-02-03 19:25:10 +0000
committerColin Fletcher <colin.m.fletcher@googlemail.com>2015-02-12 18:06:16 +0000
commit7de6128169f5e7834c6670b2d43e944aae2dd193 (patch)
treedd0c45761bea0636bd20a9401621eca1a4c55c83
parentee6ecf903425f8e3821e20b43c337cb9558c74f5 (diff)
Add tempo and meter editing functions to main clock context menu
Add 'Edit Tempo/Meter' and 'Insert Tempo/Meter Change' to the main clock's context menu.
-rw-r--r--gtk2_ardour/editor.h5
-rw-r--r--gtk2_ardour/main_clock.cc37
-rw-r--r--gtk2_ardour/main_clock.h13
-rw-r--r--gtk2_ardour/public_editor.h5
4 files changed, 58 insertions, 2 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index bd5f3816fb..fd308bed12 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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);
diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc
index 80dece04aa..b8bc733ea6 100644
--- a/gtk2_ardour/main_clock.cc
+++ b/gtk2_ardour/main_clock.cc
@@ -19,9 +19,12 @@
#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 ());
+}
+
diff --git a/gtk2_ardour/main_clock.h b/gtk2_ardour/main_clock.h
index 959a3f9440..f5f9096b39 100644
--- a/gtk2_ardour/main_clock.h
+++ b/gtk2_ardour/main_clock.h
@@ -19,15 +19,24 @@
#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;
};
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index e580ac0ec3..3b18cd41e1 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -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;