diff --git a/libs/widgets/ardour_fader.cc b/libs/widgets/ardour_fader.cc index b086de64b6..e833640fcf 100644 --- a/libs/widgets/ardour_fader.cc +++ b/libs/widgets/ardour_fader.cc @@ -61,6 +61,8 @@ ArdourFader::ArdourFader (Gtk::Adjustment& adj, int orientation, int fader_lengt { update_unity_position (); + add_events (Gdk::TOUCH_UPDATE_MASK); + if (_orien == VERT) { CairoWidget::set_size_request(_girth, _span); } else { @@ -464,6 +466,18 @@ ArdourFader::on_motion_notify_event (GdkEventMotion* ev) return true; } +bool +ArdourFader::on_touch_update_event (GdkEventTouch* ev) +{ + GdkEventMotion mev; + mev.window = ev->window; + mev.time = ev->time; + mev.x = ev->x; + mev.y = ev->y; + mev.state = 0; + return ArdourFader::on_motion_notify_event (&mev); +} + /** @return pixel offset of the current value from the right or bottom of the fader */ int ArdourFader::display_span () diff --git a/libs/widgets/fader_widget.cc b/libs/widgets/fader_widget.cc index bcbe904234..a226bbda95 100644 --- a/libs/widgets/fader_widget.cc +++ b/libs/widgets/fader_widget.cc @@ -41,6 +41,8 @@ FaderWidget::FaderWidget (Gtk::Adjustment& adj, int orien) | Gdk::SCROLL_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK + | Gdk::TOUCH_BEGIN_MASK + | Gdk::TOUCH_END_MASK ); _adjustment.signal_value_changed().connect (mem_fun (*this, &FaderWidget::adjustment_changed)); @@ -100,6 +102,29 @@ FaderWidget::on_button_press_event (GdkEventButton* ev) return (_tweaks & NoButtonForward) ? true : false; } +bool +FaderWidget::on_touch_begin_event (GdkEventTouch *ev) +{ + StartGesture (0); + _grab_loc = (_orien == VERT) ? ev->y : ev->x; + _grab_start = (_orien == VERT) ? ev->y : ev->x; + _grab_window = ev->window; + _dragging = true; + return true; +} + +bool +FaderWidget::on_touch_end_event (GdkEventTouch *ev) +{ + if (!_dragging) { + return true; + } + _dragging = false; + StopGesture (0); + + return true; +} + bool FaderWidget::on_enter_notify_event (GdkEventCrossing*) { diff --git a/libs/widgets/widgets/ardour_fader.h b/libs/widgets/widgets/ardour_fader.h index cfcb15570f..bcbd59af9a 100644 --- a/libs/widgets/widgets/ardour_fader.h +++ b/libs/widgets/widgets/ardour_fader.h @@ -55,6 +55,7 @@ protected: void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool on_motion_notify_event (GdkEventMotion*); + bool on_touch_update_event (GdkEventTouch*); void on_state_changed (Gtk::StateType); void on_style_changed (const Glib::RefPtr&); diff --git a/libs/widgets/widgets/fader_widget.h b/libs/widgets/widgets/fader_widget.h index baff3d9cbb..cd21dd0f83 100644 --- a/libs/widgets/widgets/fader_widget.h +++ b/libs/widgets/widgets/fader_widget.h @@ -62,6 +62,8 @@ public: protected: bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); + bool on_touch_begin_event (GdkEventTouch*); + bool on_touch_end_event (GdkEventTouch*); bool on_enter_notify_event (GdkEventCrossing* ev); bool on_leave_notify_event (GdkEventCrossing* ev); bool on_scroll_event (GdkEventScroll* ev);