13
0

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:
Carl Hetherington 2011-01-30 01:39:57 +00:00
parent 3ac765121f
commit eb4ec4ca0a
2 changed files with 29 additions and 26 deletions

View File

@ -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;

View File

@ -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();
grab_loc = (_orien == VERT) ? ev->y : ev->x;
grab_start = (_orien == VERT) ? ev->y : ev->x;
grab_window = ev->window;
dragging = true;
return true;
default:
break;
} }
add_modal_grab ();
grab_loc = (_orien == VERT) ? ev->y : ev->x;
grab_start = (_orien == VERT) ? ev->y : ev->x;
grab_window = ev->window;
dragging = true;
return false; if (ev->button == 2) {
set_adjustment_from_event (ev);
}
return true;
} }
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 ()));
}