From 0ec0514ba21c8d29c96537bd68ea62d9e2f4672a Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 18 Nov 2005 20:00:02 +0000 Subject: [PATCH] changed wheel scrolling to be HIG-compliant (control zooms). Also handle 2005-11-18 Michael Natterer * app/widgets/gimpgradienteditor.c (view_events): * app/widgets/gimpnavigationview.c (gimp_navigation_view_scroll): changed wheel scrolling to be HIG-compliant (control zooms). Also handle GDK_SCROLL_LEFT/RIGHT correctly and made shift switch the scroll axis. The widgets behave as the image window now. --- ChangeLog | 8 ++++++ app/widgets/gimpgradienteditor.c | 42 +++++++++++++++++++++++--------- app/widgets/gimpnavigationview.c | 38 +++++++++++++++-------------- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7a1e77920..ca3da54419 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-11-18 Michael Natterer + + * app/widgets/gimpgradienteditor.c (view_events): + * app/widgets/gimpnavigationview.c (gimp_navigation_view_scroll): + changed wheel scrolling to be HIG-compliant (control zooms). Also + handle GDK_SCROLL_LEFT/RIGHT correctly and made shift switch the + scroll axis. The widgets behave as the image window now. + 2005-11-18 Jakub Steiner * data/palettes/Tango.gpl: Made the greens more vibrant. diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c index d02e0c2b9b..646876dab6 100644 --- a/app/widgets/gimpgradienteditor.c +++ b/app/widgets/gimpgradienteditor.c @@ -889,24 +889,44 @@ view_events (GtkWidget *widget, { GdkEventScroll *sevent = (GdkEventScroll *) event; - if (sevent->state & GDK_SHIFT_MASK) + if (sevent->state & GDK_CONTROL_MASK) { - if (sevent->direction == GDK_SCROLL_UP) - gimp_gradient_editor_zoom (editor, GIMP_ZOOM_IN); - else - gimp_gradient_editor_zoom (editor, GIMP_ZOOM_OUT); + switch (sevent->direction) + { + case GDK_SCROLL_UP: + gimp_gradient_editor_zoom (editor, GIMP_ZOOM_IN); + break; + + case GDK_SCROLL_DOWN: + gimp_gradient_editor_zoom (editor, GIMP_ZOOM_OUT); + break; + + default: + break; + } } else { - GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data); + GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data); + gfloat value = adj->value; - gfloat new_value = adj->value + ((sevent->direction == GDK_SCROLL_UP) ? - -adj->page_increment / 2 : - adj->page_increment / 2); + switch (sevent->direction) + { + case GDK_SCROLL_UP: + value -= adj->page_increment / 2; + break; - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); + case GDK_SCROLL_DOWN: + value += adj->page_increment / 2; + break; - gtk_adjustment_set_value (adj, new_value); + deafult: + break; + } + + value = CLAMP (value, adj->lower, adj->upper - adj->page_size); + + gtk_adjustment_set_value (adj, value); } } break; diff --git a/app/widgets/gimpnavigationview.c b/app/widgets/gimpnavigationview.c index 6576bab89c..7a06102ccb 100644 --- a/app/widgets/gimpnavigationview.c +++ b/app/widgets/gimpnavigationview.c @@ -377,32 +377,34 @@ static gboolean gimp_navigation_view_scroll (GtkWidget *widget, GdkEventScroll *sevent) { - if (sevent->state & GDK_SHIFT_MASK) + if (sevent->state & GDK_CONTROL_MASK) { - if (sevent->direction == GDK_SCROLL_UP) + switch (sevent->direction) { + case GDK_SCROLL_UP: g_signal_emit (widget, view_signals[ZOOM], 0, GIMP_ZOOM_IN); - } - else - { + break; + + case GDK_SCROLL_DOWN: g_signal_emit (widget, view_signals[ZOOM], 0, GIMP_ZOOM_OUT); + break; + + default: + break; } } else { - GdkScrollDirection direction; - - if (sevent->state & GDK_CONTROL_MASK) - { - if (sevent->direction == GDK_SCROLL_UP) - direction = GDK_SCROLL_LEFT; - else - direction = GDK_SCROLL_RIGHT; - } - else - { - direction = sevent->direction; - } + GdkScrollDirection direction = sevent->direction; + + if (sevent->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; + } g_signal_emit (widget, view_signals[SCROLL], 0, direction); } -- GitLab