rework AudioUnit variable input port count.
[ardour.git] / gtk2_ardour / main_clock.cc
index 8bb685da4b807d1f0cdcb1fdba6ef71f732147e4..c7cb4102a87041b46007fc48943d1860ddee5713 100644 (file)
@@ -29,15 +29,10 @@ 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)
 {
 
@@ -78,7 +73,7 @@ MainClock::absolute_time () const
 {
        if (get_is_duration ()) {
                // delta to edit cursor
-               return current_time () + PublicEditor::instance().get_preferred_edit_position (true);
+               return current_time () + PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD);
        } else {
                return current_time ();
        }
@@ -97,6 +92,7 @@ MainClock::display_delta_to_edit_cursor ()
 void
 MainClock::edit_current_tempo ()
 {
+       if (!PublicEditor::instance().session()) return;
        ARDOUR::TempoSection ts = PublicEditor::instance().session()->tempo_map().tempo_section_at (absolute_time());
        PublicEditor::instance().edit_tempo_section (&ts);
 }
@@ -104,8 +100,8 @@ MainClock::edit_current_tempo ()
 void
 MainClock::edit_current_meter ()
 {
-       ARDOUR::Meter m = PublicEditor::instance().session()->tempo_map().meter_at (absolute_time());
-       ARDOUR::MeterSection ms (absolute_time(), m.divisions_per_bar(), m.note_divisor());
+       if (!PublicEditor::instance().session()) return;
+       ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time());
        PublicEditor::instance().edit_meter_section (&ms);
 }
 
@@ -121,3 +117,24 @@ 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);
+}
+