make knob respond to X & Y axis drags
This commit is contained in:
@@ -57,6 +57,7 @@ ArdourKnob::Element ArdourKnob::default_elements = ArdourKnob::Element (ArdourKn
|
|||||||
ArdourKnob::ArdourKnob (Element e, bool arc_to_zero)
|
ArdourKnob::ArdourKnob (Element e, bool arc_to_zero)
|
||||||
: _elements (e)
|
: _elements (e)
|
||||||
, _hovering (false)
|
, _hovering (false)
|
||||||
|
, _grabbed_x (0)
|
||||||
, _grabbed_y (0)
|
, _grabbed_y (0)
|
||||||
, _val (0)
|
, _val (0)
|
||||||
, _zero (0)
|
, _zero (0)
|
||||||
@@ -320,18 +321,19 @@ ArdourKnob::on_motion_notify_event (GdkEventMotion *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//calculate the travel of the mouse
|
//calculate the travel of the mouse
|
||||||
int y_delta = 0;
|
int delta = 0;
|
||||||
if (ev->state & Gdk::BUTTON1_MASK) {
|
if (ev->state & Gdk::BUTTON1_MASK) {
|
||||||
y_delta = _grabbed_y - ev->y;
|
delta = (_grabbed_y - ev->y) - (_grabbed_x - ev->x);
|
||||||
|
_grabbed_x = ev->x;
|
||||||
_grabbed_y = ev->y;
|
_grabbed_y = ev->y;
|
||||||
if (y_delta == 0) return TRUE;
|
if (delta == 0) return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//step the value of the controllable
|
//step the value of the controllable
|
||||||
boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
|
boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
|
||||||
if (c) {
|
if (c) {
|
||||||
float val = c->get_interface();
|
float val = c->get_interface();
|
||||||
val += y_delta * scale;
|
val += delta * scale;
|
||||||
c->set_interface(val);
|
c->set_interface(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +343,7 @@ ArdourKnob::on_motion_notify_event (GdkEventMotion *ev)
|
|||||||
bool
|
bool
|
||||||
ArdourKnob::on_button_press_event (GdkEventButton *ev)
|
ArdourKnob::on_button_press_event (GdkEventButton *ev)
|
||||||
{
|
{
|
||||||
|
_grabbed_x = ev->x;
|
||||||
_grabbed_y = ev->y;
|
_grabbed_y = ev->y;
|
||||||
_tooltip.start_drag();
|
_tooltip.start_drag();
|
||||||
|
|
||||||
@@ -356,7 +359,7 @@ ArdourKnob::on_button_press_event (GdkEventButton *ev)
|
|||||||
bool
|
bool
|
||||||
ArdourKnob::on_button_release_event (GdkEventButton *ev)
|
ArdourKnob::on_button_release_event (GdkEventButton *ev)
|
||||||
{
|
{
|
||||||
if ( (_grabbed_y == ev->y) && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { //no move, shift-click sets to default
|
if ( (_grabbed_y == ev->y && _grabbed_x == ev->x) && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { //no move, shift-click sets to default
|
||||||
boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
|
boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
|
||||||
if (!c) return false;
|
if (!c) return false;
|
||||||
c->set_value (c->normal());
|
c->set_value (c->normal());
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public:
|
|||||||
BindingProxy binding_proxy;
|
BindingProxy binding_proxy;
|
||||||
|
|
||||||
bool _hovering;
|
bool _hovering;
|
||||||
|
float _grabbed_x;
|
||||||
float _grabbed_y;
|
float _grabbed_y;
|
||||||
|
|
||||||
float _val; // current value [0..1]
|
float _val; // current value [0..1]
|
||||||
|
|||||||
Reference in New Issue
Block a user