Make left-click on tempo/meter in main clock edit current tempo/meter
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Sun, 15 Feb 2015 18:26:15 +0000 (18:26 +0000)
committerColin Fletcher <colin.m.fletcher@googlemail.com>
Mon, 9 Mar 2015 19:17:52 +0000 (19:17 +0000)
gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h
gtk2_ardour/main_clock.cc
gtk2_ardour/main_clock.h

index ae170b8548f3cabcbed7d5be08a402873aec460c..7ad1a89dc0400bba33d055fe4942085940773f42 100644 (file)
@@ -333,7 +333,7 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
 
                if (mode_based_info_ratio != 1.0) {
 
-                       double left_rect_width = round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5);
+                       double left_rect_width = get_left_rect_width();
 
                        if (_need_bg) {
                                if (corner_radius) {
index f00b6db8ec35d1927d1cc87aa2a9d7004e2a28cb..4602ce8efc9935c3d4f3cecb740bec42de9c66f4 100644 (file)
@@ -101,6 +101,17 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        virtual void build_ops_menu ();
        Gtk::Menu  *ops_menu;
 
+       bool on_button_press_event (GdkEventButton *ev);
+       bool on_button_release_event(GdkEventButton *ev);
+       bool is_lower_layout_click(int y) const {
+               return y > upper_height + separator_height;
+       }
+       bool is_right_layout_click(int x) const {
+               return x > x_leading_padding + get_left_rect_width() + separator_height;
+       }
+       double get_left_rect_width() const {
+              return round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5);
+       }
   private:
        Mode             _mode;
        std::string      _name;
@@ -186,8 +197,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        bool on_key_press_event (GdkEventKey *);
        bool on_key_release_event (GdkEventKey *);
        bool on_scroll_event (GdkEventScroll *ev);
-       bool on_button_press_event (GdkEventButton *ev);
-       bool on_button_release_event(GdkEventButton *ev);
        void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
        void on_size_request (Gtk::Requisition* req);
        bool on_motion_notify_event (GdkEventMotion *ev);
index bbb3d5af4e0ed18f3924505cd301f1341c8e32e7..f90599de1374e6675a636e0188305e2ccefc4850 100644 (file)
@@ -116,3 +116,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);
+}
+
index 767216be083e5825613ec0d9b949405766db5841..696b7e21e6acc99d9e685d17c33b743bb6ef9275 100644 (file)
@@ -39,4 +39,6 @@ private:
        void insert_new_meter ();
        framepos_t absolute_time () const;
        bool _primary;
+
+       bool on_button_press_event (GdkEventButton *ev);
 };