[gimp] Bug 773334 - GimpColorScale's scrolling behaviour is inverted...



commit 8e65aca4526bebb491ef132c931663ed77b565dc
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 23 18:35:57 2016 +0200

    Bug 773334 - GimpColorScale's scrolling behaviour is inverted...
    
    ...(scroll up decreases the value)
    
    Implement GtkWidget::scroll_event() and turn GDK_SCROLL_UP into RIGHT
    and DOWN into LEFT. The default behaviour or good for scrollbars but
    not for widgets where "right" == "higher value" == "up" like
    GimpColorScale.

 libgimpwidgets/gimpcolorscale.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 9810ce6..4064659 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -87,6 +87,8 @@ static gboolean gimp_color_scale_button_press      (GtkWidget        *widget,
                                                     GdkEventButton   *event);
 static gboolean gimp_color_scale_button_release    (GtkWidget        *widget,
                                                     GdkEventButton   *event);
+static gboolean gimp_color_scale_scroll            (GtkWidget        *widget,
+                                                    GdkEventScroll   *event);
 static gboolean gimp_color_scale_expose            (GtkWidget        *widget,
                                                     GdkEventExpose   *event);
 
@@ -118,6 +120,7 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
   widget_class->state_changed        = gimp_color_scale_state_changed;
   widget_class->button_press_event   = gimp_color_scale_button_press;
   widget_class->button_release_event = gimp_color_scale_button_release;
+  widget_class->scroll_event         = gimp_color_scale_scroll;
   widget_class->expose_event         = gimp_color_scale_expose;
 
   /**
@@ -355,6 +358,42 @@ gimp_color_scale_button_release (GtkWidget      *widget,
 }
 
 static gboolean
+gimp_color_scale_scroll (GtkWidget      *widget,
+                         GdkEventScroll *event)
+{
+  if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) ==
+      GTK_ORIENTATION_HORIZONTAL)
+    {
+      GdkEventScroll *my_event;
+      gboolean        retval;
+
+      my_event = (GdkEventScroll *) gdk_event_copy ((GdkEvent *) event);
+
+      switch (my_event->direction)
+        {
+        case GDK_SCROLL_UP:
+          my_event->direction = GDK_SCROLL_RIGHT;
+          break;
+
+        case GDK_SCROLL_DOWN:
+          my_event->direction = GDK_SCROLL_LEFT;
+          break;
+
+        default:
+          break;
+        }
+
+      retval = GTK_WIDGET_CLASS (parent_class)->scroll_event (widget, my_event);
+
+      gdk_event_free ((GdkEvent *) my_event);
+
+      return retval;
+    }
+
+  return GTK_WIDGET_CLASS (parent_class)->scroll_event (widget, event);
+}
+
+static gboolean
 gimp_color_scale_expose (GtkWidget      *widget,
                          GdkEventExpose *event)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]