gimp r25782 - in trunk: . app/tools



Author: martinn
Date: Fri May 23 21:46:13 2008
New Revision: 25782
URL: http://svn.gnome.org/viewvc/gimp?rev=25782&view=rev

Log:
2008-05-23  Martin Nordholts  <martinn svn gnome org>

	* app/tools/gimpfreeselecttool.c
	(gimp_free_select_tool_draw): Draw handles within HANDLE_SIZE * 7
	distance from cursor instead of only showing the hovered handle.
	(gimp_free_select_tool_oper_update): Remember last coordinates
	given here, so we can do above calculations.


Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpfreeselecttool.c

Modified: trunk/app/tools/gimpfreeselecttool.c
==============================================================================
--- trunk/app/tools/gimpfreeselecttool.c	(original)
+++ trunk/app/tools/gimpfreeselecttool.c	Fri May 23 21:46:13 2008
@@ -50,6 +50,7 @@
 
 #define HANDLE_SIZE             12
 #define POINT_GRAB_THRESHOLD_SQ SQR(HANDLE_SIZE / 2)
+#define POINT_SHOW_THRESHOLD_SQ SQR(HANDLE_SIZE * 7)
 #define N_ITEMS_PER_ALLOC       1024
 #define INVALID_INDEX           (-1)
 
@@ -105,6 +106,9 @@
 
   gboolean           constrain_angle;
 
+  /* Last _oper_update coords */
+  GimpVector2        last_coords;
+
 } Private;
 
 
@@ -266,14 +270,6 @@
               1;
 }
 
-static GimpVector2
-gimp_free_select_tool_get_grabbed_point (GimpFreeSelectTool *fst)
-{
-  Private *priv = GET_PRIVATE (fst);
-
-  return priv->points[priv->segment_indices[priv->grabbed_segment_index]];
-}
-
 static void
 gimp_free_select_tool_get_last_point (GimpFreeSelectTool *fst,
                                       gdouble            *start_point_x,
@@ -927,6 +923,9 @@
 
   gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
+  priv->last_coords.x = coords->x;
+  priv->last_coords.y = coords->y;
+
   if (priv->n_points == 0 ||
       (gimp_free_select_tool_is_point_grabbed (fst) &&
        ! hovering_first_point))
@@ -1208,23 +1207,44 @@
 {
   GimpFreeSelectTool *fst  = GIMP_FREE_SELECT_TOOL (draw_tool);
   Private            *priv = GET_PRIVATE (fst);
+  GimpTool           *tool = GIMP_TOOL (draw_tool);
+
+  if (! tool->display)
+    return;
 
   gimp_draw_tool_draw_lines (draw_tool,
                              priv->points, priv->n_points,
                              FALSE, FALSE);
 
-  if (gimp_free_select_tool_is_point_grabbed (fst) &&
-      ! priv->button1_down)
+  /* Draw handles around segment vertices in the proximity */
+  if (! priv->button1_down)
     {
-      GimpVector2 grabbed_point;
+      gint i;
 
-      grabbed_point = gimp_free_select_tool_get_grabbed_point (fst);
+      for (i = 0; i < priv->n_segment_indices; i++)
+        {
+          gdouble      dist;
+          GimpVector2 *point;
+
+          point = &priv->points[priv->segment_indices[i]];
 
-      gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_CIRCLE,
-                                  grabbed_point.x,
-                                  grabbed_point.y,
-                                  HANDLE_SIZE, HANDLE_SIZE,
-                                  GTK_ANCHOR_CENTER, FALSE);
+          dist  = gimp_draw_tool_calc_distance_square (draw_tool,
+                                                       tool->display,
+                                                       priv->last_coords.x,
+                                                       priv->last_coords.y,
+                                                       point->x,
+                                                       point->y);
+
+          if (dist < POINT_SHOW_THRESHOLD_SQ)
+            {
+              gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_CIRCLE,
+                                          point->x,
+                                          point->y,
+                                          HANDLE_SIZE, HANDLE_SIZE,
+                                          GTK_ANCHOR_CENTER, FALSE);
+
+            }
+        }
     }
 
   if (priv->show_pending_point)



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