app: update the tool's state after the wheel controller has handled the event

This commit is contained in:
Michael Natterer 2011-04-06 22:50:20 +02:00
parent febc1da4be
commit 7fae1b3c50
1 changed files with 59 additions and 60 deletions

View File

@ -709,78 +709,77 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_SCROLL: case GDK_SCROLL:
{ {
GdkEventScroll *sevent = (GdkEventScroll *) event; GdkEventScroll *sevent = (GdkEventScroll *) event;
GdkScrollDirection direction;
GimpController *wheel; GimpController *wheel;
wheel = gimp_controllers_get_wheel (gimp); wheel = gimp_controllers_get_wheel (gimp);
if (wheel && if (! wheel ||
gimp_controller_wheel_scroll (GIMP_CONTROLLER_WHEEL (wheel), ! gimp_controller_wheel_scroll (GIMP_CONTROLLER_WHEEL (wheel),
sevent)) sevent))
return TRUE;
direction = sevent->direction;
if (state & GDK_CONTROL_MASK)
{ {
switch (direction) GdkScrollDirection direction = sevent->direction;
if (state & GDK_CONTROL_MASK)
{ {
case GDK_SCROLL_UP: switch (direction)
gimp_display_shell_scale (shell, {
GIMP_ZOOM_IN, case GDK_SCROLL_UP:
0.0, gimp_display_shell_scale (shell,
GIMP_ZOOM_FOCUS_BEST_GUESS); GIMP_ZOOM_IN,
break; 0.0,
GIMP_ZOOM_FOCUS_BEST_GUESS);
break;
case GDK_SCROLL_DOWN: case GDK_SCROLL_DOWN:
gimp_display_shell_scale (shell, gimp_display_shell_scale (shell,
GIMP_ZOOM_OUT, GIMP_ZOOM_OUT,
0.0, 0.0,
GIMP_ZOOM_FOCUS_BEST_GUESS); GIMP_ZOOM_FOCUS_BEST_GUESS);
break; break;
default: default:
break; break;
}
} }
} else
else
{
GtkAdjustment *adj = NULL;
gdouble value;
if (state & GDK_SHIFT_MASK)
switch (direction)
{
case GDK_SCROLL_UP: direction = GDK_SCROLL_LEFT; break;
case GDK_SCROLL_DOWN: direction = GDK_SCROLL_RIGHT; break;
case GDK_SCROLL_LEFT: direction = GDK_SCROLL_UP; break;
case GDK_SCROLL_RIGHT: direction = GDK_SCROLL_DOWN; break;
}
switch (direction)
{ {
case GDK_SCROLL_LEFT: GtkAdjustment *adj = NULL;
case GDK_SCROLL_RIGHT: gdouble value;
adj = shell->hsbdata;
break;
case GDK_SCROLL_UP: if (state & GDK_SHIFT_MASK)
case GDK_SCROLL_DOWN: switch (direction)
adj = shell->vsbdata; {
break; case GDK_SCROLL_UP: direction = GDK_SCROLL_LEFT; break;
case GDK_SCROLL_DOWN: direction = GDK_SCROLL_RIGHT; break;
case GDK_SCROLL_LEFT: direction = GDK_SCROLL_UP; break;
case GDK_SCROLL_RIGHT: direction = GDK_SCROLL_DOWN; break;
}
switch (direction)
{
case GDK_SCROLL_LEFT:
case GDK_SCROLL_RIGHT:
adj = shell->hsbdata;
break;
case GDK_SCROLL_UP:
case GDK_SCROLL_DOWN:
adj = shell->vsbdata;
break;
}
value = (gtk_adjustment_get_value (adj) +
((direction == GDK_SCROLL_UP ||
direction == GDK_SCROLL_LEFT) ?
-gtk_adjustment_get_page_increment (adj) / 2 :
gtk_adjustment_get_page_increment (adj) / 2));
value = CLAMP (value,
gtk_adjustment_get_lower (adj),
gtk_adjustment_get_upper (adj) -
gtk_adjustment_get_page_size (adj));
gtk_adjustment_set_value (adj, value);
} }
value = (gtk_adjustment_get_value (adj) +
((direction == GDK_SCROLL_UP ||
direction == GDK_SCROLL_LEFT) ?
-gtk_adjustment_get_page_increment (adj) / 2 :
gtk_adjustment_get_page_increment (adj) / 2));
value = CLAMP (value,
gtk_adjustment_get_lower (adj),
gtk_adjustment_get_upper (adj) -
gtk_adjustment_get_page_size (adj));
gtk_adjustment_set_value (adj, value);
} }
gimp_display_shell_untransform_event_coords (shell, gimp_display_shell_untransform_event_coords (shell,