2 Copyright (C) 2012 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "ardour_ui.h"
21 #include "main_clock.h"
22 #include "public_editor.h"
26 #include "ardour/tempo.h"
30 MainClock::MainClock (
31 const std::string& clock_name,
32 const std::string& widget_name,
35 : AudioClock (clock_name, false, widget_name, true, true, false, true)
42 MainClock::build_ops_menu ()
44 using namespace Menu_Helpers;
46 AudioClock::build_ops_menu ();
48 MenuList& ops_items = ops_menu->items();
49 ops_items.push_back (SeparatorElem ());
50 ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor)));
51 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem *> (&ops_items.back());
53 if (ARDOUR_UI::config()->get_primary_clock_delta_edit_cursor ()) {
54 ARDOUR_UI::config()->set_primary_clock_delta_edit_cursor (false);
58 if (ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ()) {
59 ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (false);
64 ops_items.push_back (SeparatorElem());
65 ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo)));
66 ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter)));
67 ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo)));
68 ops_items.push_back (MenuElem (_("Insert Meter Change"), sigc::mem_fun(*this, &MainClock::insert_new_meter)));
72 MainClock::absolute_time () const
74 if (get_is_duration ()) {
75 // delta to edit cursor
76 return current_time () + PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD);
78 return current_time ();
83 MainClock::display_delta_to_edit_cursor ()
86 ARDOUR_UI::config()->set_primary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_primary_clock_delta_edit_cursor ());
88 ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ());
93 MainClock::edit_current_tempo ()
95 if (!PublicEditor::instance().session()) return;
96 ARDOUR::TempoSection ts = PublicEditor::instance().session()->tempo_map().tempo_section_at (absolute_time());
97 PublicEditor::instance().edit_tempo_section (&ts);
101 MainClock::edit_current_meter ()
103 if (!PublicEditor::instance().session()) return;
104 ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time());
105 PublicEditor::instance().edit_meter_section (&ms);
109 MainClock::insert_new_tempo ()
111 PublicEditor::instance().mouse_add_new_tempo_event (absolute_time ());
115 MainClock::insert_new_meter ()
117 PublicEditor::instance().mouse_add_new_meter_event (absolute_time ());
121 MainClock::on_button_press_event (GdkEventButton *ev)
123 if (ev->button == 1) {
125 if (is_lower_layout_click(ev->y)) {
126 if (is_right_layout_click(ev->x)) {
127 // meter on the right
128 edit_current_meter();
131 edit_current_tempo();
138 return AudioClock::on_button_press_event (ev);