summaryrefslogtreecommitdiff
path: root/gtk2_ardour/main_clock.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour/main_clock.cc')
-rw-r--r--gtk2_ardour/main_clock.cc77
1 files changed, 70 insertions, 7 deletions
diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc
index 80dece04aa..26d780ea8a 100644
--- a/gtk2_ardour/main_clock.cc
+++ b/gtk2_ardour/main_clock.cc
@@ -19,22 +19,20 @@
#include "ardour_ui.h"
#include "main_clock.h"
+#include "public_editor.h"
#include "i18n.h"
+#include "ardour/tempo.h"
+
using namespace Gtk;
MainClock::MainClock (
const std::string& clock_name,
- bool is_transient,
const std::string& widget_name,
- bool editable,
- bool follows_playhead,
- bool primary,
- bool duration,
- bool with_info
+ bool primary
)
- : AudioClock (clock_name, is_transient, widget_name, editable, follows_playhead, duration, with_info)
+ : AudioClock (clock_name, false, widget_name, true, true, false, true)
, _primary (primary)
{
@@ -62,6 +60,23 @@ 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)));
+}
+
+framepos_t
+MainClock::absolute_time () const
+{
+ if (get_is_duration ()) {
+ // delta to edit cursor
+ return current_time () + PublicEditor::instance().get_preferred_edit_position (true);
+ } else {
+ return current_time ();
+ }
}
void
@@ -73,3 +88,51 @@ 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 (absolute_time());
+ PublicEditor::instance().edit_tempo_section (&ts);
+}
+
+void
+MainClock::edit_current_meter ()
+{
+ ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time());
+ PublicEditor::instance().edit_meter_section (&ms);
+}
+
+void
+MainClock::insert_new_tempo ()
+{
+ PublicEditor::instance().mouse_add_new_tempo_event (absolute_time ());
+}
+
+void
+MainClock::insert_new_meter ()
+{
+ PublicEditor::instance().mouse_add_new_meter_event (absolute_time ());
+}
+
+bool
+MainClock::on_button_press_event (GdkEventButton *ev)
+{
+ if (ev->button == 1) {
+ if (mode() == BBT) {
+ if (is_lower_layout_click(ev->y)) {
+ if (is_right_layout_click(ev->x)) {
+ // meter on the right
+ edit_current_meter();
+ } else {
+ // tempo on the left
+ edit_current_tempo();
+ }
+ return true;
+ }
+ }
+ }
+
+ return AudioClock::on_button_press_event (ev);
+}
+