Fix fader jumps when releasing button 2 on drags; move to mouse position on button down, instead (#3743).
git-svn-id: svn://localhost/ardour2/branches/3.0@8615 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
3ac765121f
commit
eb4ec4ca0a
@ -70,8 +70,8 @@ class PixFader : public Gtk::DrawingArea
|
|||||||
int unity_loc;
|
int unity_loc;
|
||||||
|
|
||||||
void adjustment_changed ();
|
void adjustment_changed ();
|
||||||
|
|
||||||
int display_span ();
|
int display_span ();
|
||||||
|
void set_adjustment_from_event (GdkEventButton *);
|
||||||
|
|
||||||
static int fine_scale_modifier;
|
static int fine_scale_modifier;
|
||||||
static int extra_fine_scale_modifier;
|
static int extra_fine_scale_modifier;
|
||||||
|
@ -126,29 +126,27 @@ PixFader::on_button_press_event (GdkEventButton* ev)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ev->button) {
|
if (ev->button != 1 && ev->button != 2) {
|
||||||
case 1:
|
return false;
|
||||||
case 2:
|
}
|
||||||
add_modal_grab();
|
|
||||||
|
add_modal_grab ();
|
||||||
grab_loc = (_orien == VERT) ? ev->y : ev->x;
|
grab_loc = (_orien == VERT) ? ev->y : ev->x;
|
||||||
grab_start = (_orien == VERT) ? ev->y : ev->x;
|
grab_start = (_orien == VERT) ? ev->y : ev->x;
|
||||||
grab_window = ev->window;
|
grab_window = ev->window;
|
||||||
dragging = true;
|
dragging = true;
|
||||||
return true;
|
|
||||||
default:
|
if (ev->button == 2) {
|
||||||
break;
|
set_adjustment_from_event (ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PixFader::on_button_release_event (GdkEventButton* ev)
|
PixFader::on_button_release_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
double fract, ev_pos;
|
double const ev_pos = (_orien == VERT) ? ev->y : ev->x;
|
||||||
|
|
||||||
ev_pos = (_orien == VERT) ? ev->y : ev->x;
|
|
||||||
|
|
||||||
switch (ev->button) {
|
switch (ev->button) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -179,13 +177,7 @@ PixFader::on_button_release_event (GdkEventButton* ev)
|
|||||||
if (dragging) {
|
if (dragging) {
|
||||||
remove_modal_grab();
|
remove_modal_grab();
|
||||||
dragging = false;
|
dragging = false;
|
||||||
|
set_adjustment_from_event (ev);
|
||||||
fract = 1.0 - (ev_pos / span); // inverted X Window coordinates, grrr
|
|
||||||
|
|
||||||
fract = min (1.0, fract);
|
|
||||||
fract = max (0.0, fract);
|
|
||||||
|
|
||||||
adjustment.set_value (fract * (adjustment.get_upper() - adjustment.get_lower()));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -338,3 +330,14 @@ PixFader::on_leave_notify_event (GdkEventCrossing*)
|
|||||||
Keyboard::magic_widget_drop_focus();
|
Keyboard::magic_widget_drop_focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PixFader::set_adjustment_from_event (GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
double fract = (_orien == VERT) ? (1.0 - (ev->y / span)) : (ev->x / span);
|
||||||
|
|
||||||
|
fract = min (1.0, fract);
|
||||||
|
fract = max (0.0, fract);
|
||||||
|
|
||||||
|
adjustment.set_value (fract * (adjustment.get_upper () - adjustment.get_lower ()));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user