X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmain_clock.cc;h=f0cbd9bf289732d94804c4eb673c50dc42039319;hb=0038820f473664a9a4fb524537cd846a9e024661;hp=80dece04aae20813cb97ce6ce5708060b67f2e9d;hpb=64fa63212f7e79bab16147817211a33a3f7c8fba;p=ardour.git diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc index 80dece04aa..f0cbd9bf28 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 (Editing::EDIT_IGNORE_PHEAD); + } 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); +} +