Modifier keys

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

 



Hi,

I think we aggreed that for the paint tools it would be nice to have
only one modifier key to restrict lines to certain angles. Before I 
implement this, I want you to give me your opinion, how this 
restriction to multiples of 15 degrees should feel like. Since this 
is quite difficult to explain, I have just checked in a modification 
to the blend tool:

Holding <Shift> restricts you to 15 degrees and puts the endpoint 
on the circle you are defining with your mouse and the startpoint.

Holding <Ctrl> restricts you to 15 degrees too, but puts the endpoint
on a rectangle defined by your mouse and the closest 15-degrees angle.

The latter mimics the behaviour of the selection tools (which I think
shouldn't be changed). So please give this a try and tell me which 
version you prefer. And please, don't tell me to make it configurable...

For those of you that don't update their gimp regulary from CVS, I 
have attached a patch that should work against the latest release 
(and probably earlier releases too).


Salut, Sven


Index: app/blend.c
===================================================================
RCS file: /cvs/gnome/gimp/app/blend.c,v
retrieving revision 1.59
diff -u -r1.59 blend.c
--- app/blend.c	1999/10/26 18:27:23	1.59
+++ app/blend.c	1999/11/18 17:50:49
@@ -588,10 +588,10 @@
 
 
   /* Restrict to multiples of 15 degrees if shift is pressed */
-  if (mevent->state & GDK_SHIFT_MASK) 
+  if (mevent->state & GDK_SHIFT_MASK)
     {
-      int tangens[6] = { 34, 106, 196, 334, 618, 1944 };
-      int cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 };
+      int tangens2[6] = {  34, 106, 196, 334, 618, 1944 };
+      int cosinus[7]  = { 256, 247, 222, 181, 128, 66, 0 };
       int dx, dy, i, radius, frac;
 
       dx = blend_tool->endx - blend_tool->startx;
@@ -603,7 +603,7 @@
 	  frac = abs ((dx << 8) / dy);
 	  for (i = 0; i < 6; i++)
 	    {
-	      if (frac < tangens[i])
+	      if (frac < tangens2[i])
 		break;  
 	    }
 	  dx = dx > 0 ? (cosinus[6-i] * radius) >> 8 : - ((cosinus[6-i] * radius) >> 8);
@@ -612,27 +612,58 @@
       blend_tool->endx = blend_tool->startx + dx;
       blend_tool->endy = blend_tool->starty + dy;
     }
-  
-  /* restrict to horizontal/vertical blend, if modifiers are pressed */
-  if (mevent->state & GDK_MOD1_MASK)
+  /* Use another way to restrict to multiples of 15 degrees if ctrl is pressed */
+  else if (mevent->state & GDK_CONTROL_MASK)
     {
-      if (mevent->state & GDK_CONTROL_MASK)
+      int tangens[5]  = { 69, 148, 256, 443, 955 };
+      int tangens2[6] = { 34, 106, 196, 334, 618, 1944 };
+      int dx, dy, i, frac;
+
+      dx = blend_tool->endx - blend_tool->startx;
+      dy = blend_tool->endy - blend_tool->starty;
+
+      if (dy)
 	{
-	  int dx, dy;
-	  
-	  dx = blend_tool->endx - blend_tool->startx;
-	  dy = blend_tool->endy - blend_tool->starty;
-	  
-	  blend_tool->endx = blend_tool->startx +
-	    (dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
-	  blend_tool->endy = blend_tool->starty + 
-	    (dy > 0  ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
+	  frac = abs ((dx << 8) / dy);
+	  for (i = 0; i < 6; i++)
+	    {
+	      if (frac < tangens2[i])
+		break;  
+	    }
+	  switch (i)
+	    {
+	    case (0):
+	      dx = 0;
+	      break;
+	    case (1):
+	    case (2):
+	      dx = dx * dy > 0 ? 
+		(tangens[i-1] * dy) / 256 : - ((tangens[i-1] * dy) / 256);
+	      break;
+	    case (3):
+	      if (abs (dx) < abs (dy))
+		dx = dx * dy > 0 ? 
+		  (tangens[i-1] * dy) / 256 : - ((tangens[i-1] * dy) / 256);
+	      else
+		dy = dx * dy > 0 ? 
+		  (tangens[5-i] * dx) / 256 : - ((tangens[5-i] * dx) / 256);
+	      break;
+	    case (4):
+	    case (5):
+	      dy = dx * dy > 0 ? 
+		  (tangens[5-i] * dx) / 256 : - ((tangens[5-i] * dx) / 256);
+	      break;
+	    case (6):
+	      dy = 0;
+	      break;
+	    default:
+	      g_warning ("blend_motion: should never be reached!");
+	      break;
+	    }
 	}
-      else
-	blend_tool->endx = blend_tool->startx;
+      blend_tool->endx = blend_tool->startx + dx;
+      blend_tool->endy = blend_tool->starty + dy;
     }
-  else if (mevent->state & GDK_CONTROL_MASK)
-    blend_tool->endy = blend_tool->starty;
 
   gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
   if (gdisp->dot_for_dot)

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux