ardour
main_clock.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #include "ardour_ui.h"
21 #include "main_clock.h"
22 #include "public_editor.h"
23 
24 #include "i18n.h"
25 
26 #include "ardour/tempo.h"
27 
28 using namespace Gtk;
29 
31  const std::string& clock_name,
32  const std::string& widget_name,
33  bool primary
34  )
35  : AudioClock (clock_name, false, widget_name, true, true, false, true)
36  , _primary (primary)
37 {
38 
39 }
40 
41 void
43 {
44  using namespace Menu_Helpers;
45 
47 
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());
52  if (_primary) {
53  if (ARDOUR_UI::config()->get_primary_clock_delta_edit_cursor ()) {
54  ARDOUR_UI::config()->set_primary_clock_delta_edit_cursor (false);
55  c->set_active (true);
56  }
57  } else {
58  if (ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ()) {
59  ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (false);
60  c->set_active (true);
61  }
62  }
63 
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)));
69 }
70 
73 {
74  if (get_is_duration ()) {
75  // delta to edit cursor
77  } else {
78  return current_time ();
79  }
80 }
81 
82 void
84 {
85  if (_primary) {
86  ARDOUR_UI::config()->set_primary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_primary_clock_delta_edit_cursor ());
87  } else {
88  ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ());
89  }
90 }
91 
92 void
94 {
97 }
98 
99 void
101 {
104 }
105 
106 void
108 {
110 }
111 
112 void
114 {
116 }
117 
118 bool
120 {
121  if (ev->button == 1) {
122  if (mode() == BBT) {
123  if (is_lower_layout_click(ev->y)) {
124  if (is_right_layout_click(ev->x)) {
125  // meter on the right
127  } else {
128  // tempo on the left
130  }
131  return true;
132  }
133  }
134  }
135 
137 }
138 
framepos_t absolute_time() const
Definition: main_clock.cc:72
framepos_t current_time(framepos_t position=0) const
void insert_new_tempo()
Definition: main_clock.cc:107
Definition: ardour_ui.h:130
TempoMap & tempo_map()
Definition: session.h:596
bool on_button_press_event(GdkEventButton *ev)
Definition: main_clock.cc:119
MainClock(const std::string &clock_name, const std::string &widget_name, bool primary)
Definition: main_clock.cc:30
bool is_right_layout_click(int x) const
Definition: audio_clock.h:111
virtual void build_ops_menu()
const TempoSection & tempo_section_at(framepos_t) const
Definition: tempo.cc:1589
#define _(Text)
Definition: i18n.h:11
virtual void mouse_add_new_meter_event(framepos_t where)=0
virtual void edit_meter_section(ARDOUR::MeterSection *)=0
void insert_new_meter()
Definition: main_clock.cc:113
void edit_current_meter()
Definition: main_clock.cc:100
Mode mode() const
Definition: audio_clock.h:56
void build_ops_menu()
Definition: main_clock.cc:42
bool is_lower_layout_click(int y) const
Definition: audio_clock.h:108
virtual void mouse_add_new_tempo_event(framepos_t where)=0
static PublicEditor & instance()
static UIConfiguration * config()
Definition: ardour_ui.h:188
virtual framepos_t get_preferred_edit_position(Editing::EditIgnoreOption=Editing::EDIT_IGNORE_NONE, bool from_context_menu=false, bool from_outside_canvas=false)=0
Gtk::Menu * ops_menu
Definition: audio_clock.h:104
void edit_current_tempo()
Definition: main_clock.cc:93
const MeterSection & meter_section_at(framepos_t) const
Definition: tempo.cc:1624
virtual void edit_tempo_section(ARDOUR::TempoSection *)=0
bool get_is_duration() const
Definition: audio_clock.h:101
int64_t framepos_t
void display_delta_to_edit_cursor()
Definition: main_clock.cc:83
bool _primary
Definition: main_clock.h:41
bool on_button_press_event(GdkEventButton *ev)
virtual ARDOUR::Session * session() const =0