[gimp] app: allow snapping GimpPolar to 15 degree intervals



commit 1f6629f4b6521daccf8abf641a679c8d95d625cf
Author: woob <thetoastcaper gmail com>
Date:   Thu Dec 26 14:45:43 2019 -0500

    app: allow snapping GimpPolar to 15 degree intervals
    
    Similar to GimpDial, snaps GimpPolar's angle to the nearest fifteen
    degree interval by holding the shift key while adjusting

 app/widgets/gimppolar.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/app/widgets/gimppolar.c b/app/widgets/gimppolar.c
index 06484c0de5..2cf3abd805 100644
--- a/app/widgets/gimppolar.c
+++ b/app/widgets/gimppolar.c
@@ -38,6 +38,8 @@
 
 #include "gimppolar.h"
 
+/* round n to the nearest multiple of m */
+#define SNAP(n, m) (RINT((n) / (m)) * (m))
 
 enum
 {
@@ -235,6 +237,9 @@ gimp_polar_button_press_event (GtkWidget      *widget,
       angle = _gimp_circle_get_angle_and_distance (GIMP_CIRCLE (polar),
                                                    bevent->x, bevent->y,
                                                    &radius);
+      if (bevent->state & GDK_SHIFT_MASK)
+        angle = SNAP (angle, G_PI / 12.0);
+
       radius = MIN (radius, 1.0);
 
       g_object_set (polar,
@@ -262,6 +267,9 @@ gimp_polar_motion_notify_event (GtkWidget      *widget,
     {
       radius = MIN (radius, 1.0);
 
+      if (mevent->state & GDK_SHIFT_MASK)
+        angle = SNAP (angle, G_PI / 12.0);
+
       g_object_set (polar,
                     "angle",  angle,
                     "radius", radius,


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