[gimp] app: improve GimpSpinScale cursors.



commit 7b0d553511ac772b9ecd8ac5115e7333aef6b5ba
Author: Jehan <jehan girinstud io>
Date:   Wed Dec 16 17:34:56 2020 +0100

    app: improve GimpSpinScale cursors.
    
    Aryeom noted that current top arrow cursor comes from a time when the
    interaction with this widget depended on a lower versus upper region and
    doesn't gives anymore any idea of what the click would do.
    So let's replace the top-arrow cursor with a "grab" cursor, which even
    becomes a "grabbing" cursor when a grab is in progress.
    
    Also let's now use gdk_cursor_new_from_name() with standard names from
    the CSS specification, because it is the recommended way. According to
    GDK docs, GDK cursor list is taken from the X cursor font and apparently
    not all cursors are available on all platforms. So let's use the
    standard CSS list, whose cursors are said to be available accross
    platforms (at least very very likely, I guess).
    
    Finally I renamed the target enum for the widget to be more semantic
    than upper/lower which don't mean anything anymore in our new
    interaction rules.

 app/widgets/gimpspinscale.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index 8ab166121f..1bc4ffb227 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -49,8 +49,9 @@ typedef enum
 {
   TARGET_NONE,
   TARGET_NUMBER,
-  TARGET_UPPER,
-  TARGET_LOWER
+  TARGET_GRAB,
+  TARGET_GRABBING,
+  TARGET_RELATIVE
 } SpinScaleTarget;
 
 
@@ -568,7 +569,7 @@ gimp_spin_scale_get_target (GtkWidget *widget,
       gint           layout_y;
 
       if (! event)
-        return TARGET_UPPER;
+        return TARGET_GRAB;
 
       gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y);
       pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)),
@@ -585,12 +586,13 @@ gimp_spin_scale_get_target (GtkWidget *widget,
             {
             case 1:
               if (event_button->state & GDK_SHIFT_MASK)
-                return TARGET_LOWER;
+                return TARGET_RELATIVE;
               else
+                /* Button 1 target depends on the cursor position. */
                 break;
 
             case 3:
-              return TARGET_LOWER;
+              return TARGET_RELATIVE;
 
             default:
               return TARGET_NUMBER;
@@ -605,9 +607,13 @@ gimp_spin_scale_get_target (GtkWidget *widget,
         {
           return TARGET_NUMBER;
         }
+      else if (event->type == GDK_MOTION_NOTIFY)
+        {
+          return TARGET_GRAB;
+        }
       else
         {
-          return TARGET_UPPER;
+          return TARGET_GRABBING;
         }
     }
 
@@ -625,15 +631,19 @@ gimp_spin_scale_update_cursor (GtkWidget *widget,
   switch (private->target)
     {
     case TARGET_NUMBER:
-      cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
+      cursor = gdk_cursor_new_from_name (display, "text");
+      break;
+
+    case TARGET_GRAB:
+      cursor = gdk_cursor_new_from_name (display, "grab");
       break;
 
-    case TARGET_UPPER:
-      cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW);
+    case TARGET_GRABBING:
+      cursor = gdk_cursor_new_from_name (display, "grabbing");
       break;
 
-    case TARGET_LOWER:
-      cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW);
+    case TARGET_RELATIVE:
+      cursor = gdk_cursor_new_from_name (display, "col-resize");
       break;
 
     default:
@@ -801,7 +811,8 @@ gimp_spin_scale_button_press (GtkWidget      *widget,
 
   switch (private->target)
     {
-    case TARGET_UPPER:
+    case TARGET_GRAB:
+    case TARGET_GRABBING:
       private->changing_value = TRUE;
 
       gtk_widget_grab_focus (widget);
@@ -812,7 +823,7 @@ gimp_spin_scale_button_press (GtkWidget      *widget,
 
       return TRUE;
 
-    case TARGET_LOWER:
+    case TARGET_RELATIVE:
       private->changing_value = TRUE;
 
       gtk_widget_grab_focus (widget);


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