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/tempo.h"
23 #include "main_clock.h"
24 #include "ui_config.h"
25 #include "public_editor.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)
42 MainClock::set_session (ARDOUR::Session *s)
44 AudioClock::set_session (s);
45 _left_btn.set_related_action (ActionManager::get_action (X_("Editor"), X_("edit-current-tempo")));
46 _right_btn.set_related_action (ActionManager::get_action (X_("Editor"), X_("edit-current-meter")));
50 MainClock::build_ops_menu ()
52 using namespace Menu_Helpers;
54 AudioClock::build_ops_menu ();
56 MenuList& ops_items = ops_menu->items();
57 ops_items.push_back (SeparatorElem ());
58 ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor)));
59 Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem *> (&ops_items.back());
61 if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor ()) {
62 UIConfiguration::instance().set_primary_clock_delta_edit_cursor (false);
66 if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ()) {
67 UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (false);
72 ops_items.push_back (SeparatorElem());
73 ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo)));
74 ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter)));
75 ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo)));
76 ops_items.push_back (MenuElem (_("Insert Meter Change"), sigc::mem_fun(*this, &MainClock::insert_new_meter)));
80 MainClock::absolute_time () const
82 if (get_is_duration ()) {
83 // delta to edit cursor
84 return current_time () + PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD);
86 return current_time ();
91 MainClock::display_delta_to_edit_cursor ()
94 UIConfiguration::instance().set_primary_clock_delta_edit_cursor (!UIConfiguration::instance().get_primary_clock_delta_edit_cursor ());
96 UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (!UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ());
101 MainClock::edit_current_tempo ()
103 if (!PublicEditor::instance().session()) return;
104 ARDOUR::TempoSection* ts = const_cast<ARDOUR::TempoSection*>(&PublicEditor::instance().session()->tempo_map().tempo_section_at_frame (absolute_time()));
105 PublicEditor::instance().edit_tempo_section (ts);
109 MainClock::edit_current_meter ()
111 if (!PublicEditor::instance().session()) return;
112 ARDOUR::MeterSection* ms = const_cast<ARDOUR::MeterSection*>(&PublicEditor::instance().session()->tempo_map().meter_section_at_frame (absolute_time()));
113 PublicEditor::instance().edit_meter_section (ms);
117 MainClock::insert_new_tempo ()
119 PublicEditor::instance().mouse_add_new_tempo_event (absolute_time ());
123 MainClock::insert_new_meter ()
125 PublicEditor::instance().mouse_add_new_meter_event (absolute_time ());