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 "main_clock.h"
21 #include "public_editor.h"
23 #include "ui_config.h"
27 #include "ardour/tempo.h"
31 MainClock::MainClock (
32 const std::string& clock_name,
33 const std::string& widget_name,
36 : AudioClock (clock_name, false, widget_name, true, true, false, true)
43 MainClock::build_ops_menu ()
45 using namespace Menu_Helpers;
47 AudioClock::build_ops_menu ();
49 MenuList& ops_items = ops_menu->items();
50 ops_items.push_back (SeparatorElem ());
51 ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor)));
52 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem *> (&ops_items.back());
54 if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor ()) {
55 UIConfiguration::instance().set_primary_clock_delta_edit_cursor (false);
59 if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ()) {
60 UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (false);
65 ops_items.push_back (SeparatorElem());
66 ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo)));
67 ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter)));
68 ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo)));
69 ops_items.push_back (MenuElem (_("Insert Meter Change"), sigc::mem_fun(*this, &MainClock::insert_new_meter)));
73 MainClock::absolute_time () const
75 if (get_is_duration ()) {
76 // delta to edit cursor
77 return current_time () + PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD);
79 return current_time ();
84 MainClock::display_delta_to_edit_cursor ()
87 UIConfiguration::instance().set_primary_clock_delta_edit_cursor (!UIConfiguration::instance().get_primary_clock_delta_edit_cursor ());
89 UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (!UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ());
94 MainClock::edit_current_tempo ()
96 if (!PublicEditor::instance().session()) return;
97 ARDOUR::TempoSection ts = PublicEditor::instance().session()->tempo_map().tempo_section_at (absolute_time());
98 PublicEditor::instance().edit_tempo_section (&ts);
102 MainClock::edit_current_meter ()
104 if (!PublicEditor::instance().session()) return;
105 ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time());
106 PublicEditor::instance().edit_meter_section (&ms);
110 MainClock::insert_new_tempo ()
112 PublicEditor::instance().mouse_add_new_tempo_event (absolute_time ());
116 MainClock::insert_new_meter ()
118 PublicEditor::instance().mouse_add_new_meter_event (absolute_time ());
122 MainClock::on_button_press_event (GdkEventButton *ev)
124 if (ev->button == 1) {
126 if (is_lower_layout_click(ev->y)) {
127 if (is_right_layout_click(ev->x)) {
128 // meter on the right
129 edit_current_meter();
132 edit_current_tempo();
139 return AudioClock::on_button_press_event (ev);