locate when clicking on start/end fields in time info box
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 7 Jun 2011 18:20:22 +0000 (18:20 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 7 Jun 2011 18:20:22 +0000 (18:20 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9683 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_clock.cc
gtk2_ardour/time_info_box.cc
gtk2_ardour/time_info_box.h

index 40ff8f3f14e132bc1701e8b0136697ef9b24f30e..bc9783cf860e633f43225bf56c3a5b2781b6c8a7 100644 (file)
@@ -889,21 +889,23 @@ AudioClock::button_press (GdkEventButton *ev, CairoCell* cell)
 {
        switch (ev->button) {
        case 1:
-               if (cell) {
-                       editing_field = (Field) cell->id ();
-                       display->start_editing (cell);
+               if (editable) {
+                       if (cell) {
+                               editing_field = (Field) cell->id ();
+                               display->start_editing (cell);
+                       }
+                       
+                       Keyboard::magic_widget_grab_focus ();
+                       
+                       /* make absolutely sure that the pointer is grabbed */
+                       gdk_pointer_grab(ev->window,false ,
+                                        GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
+                                        NULL,NULL,ev->time);
+                       dragging = true;
+                       drag_accum = 0;
+                       drag_start_y = ev->y;
+                       drag_y = ev->y;
                }
-
-               Keyboard::magic_widget_grab_focus ();
-
-               /* make absolutely sure that the pointer is grabbed */
-               gdk_pointer_grab(ev->window,false ,
-                                GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
-                                NULL,NULL,ev->time);
-               dragging = true;
-               drag_accum = 0;
-               drag_start_y = ev->y;
-               drag_y = ev->y;
                break;
                
        default:
@@ -917,21 +919,15 @@ AudioClock::button_press (GdkEventButton *ev, CairoCell* cell)
 bool
 AudioClock::button_release (GdkEventButton *ev, CairoCell* cell)
 {
-       if (dragging) {
-               gdk_pointer_ungrab (GDK_CURRENT_TIME);
-               dragging = false;
-               if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
-                       // we actually dragged so return without setting editing focus, or we shift clicked
-                       return true;
-               }
-       }
-
-       if (!editable) {
-               if (ops_menu == 0) {
-                       build_ops_menu ();
+       if (editable) {
+               if (dragging) {
+                       gdk_pointer_ungrab (GDK_CURRENT_TIME);
+                       dragging = false;
+                       if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
+                               // we actually dragged so return without setting editing focus, or we shift clicked
+                               return true;
+                       }
                }
-               ops_menu->popup (1, ev->time);
-               return true;
        }
 
        if (Keyboard::is_context_menu_event (ev)) {
@@ -942,7 +938,7 @@ AudioClock::button_release (GdkEventButton *ev, CairoCell* cell)
                return true;
        }
 
-       return true;
+       return false;
 }
 
 bool
index ebebade6c16b1eeeb85bbe0802a07048dc52c73e..ae3d3b65d4ced7414efc8a154f43467f2d145ce7 100644 (file)
@@ -125,6 +125,12 @@ TimeInfoBox::TimeInfoBox ()
        punch_start->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_start));
        punch_end->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_end));
 
+       selection_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_start), true);
+       selection_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_end), true);
+
+       punch_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_start), true);
+       punch_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_end), true);
+
        Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
 }
 
@@ -138,6 +144,21 @@ TimeInfoBox::~TimeInfoBox ()
         delete punch_end;
 }
 
+bool
+TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
+{
+       if (!_session) {
+               return false;
+       }
+
+       if (ev->button == 1) {
+               _session->request_locate (src->current_time ());
+               return true;
+       }
+
+       return false;
+}
+
 void
 TimeInfoBox::sync_selection_mode (AudioClock* src)
 {
index 734f9ebb95492492a922b74ba6a1ca7350ebc894..50561d1249a2dffe6d21ced4d8ef066cc73ac5b0 100644 (file)
@@ -72,6 +72,8 @@ class TimeInfoBox : public Gtk::Table, public ARDOUR::SessionHandlePtr
 
     void sync_selection_mode (AudioClock*);
     void sync_punch_mode (AudioClock*);
+
+    bool clock_button_release_event (GdkEventButton* ev, AudioClock* src);
 };