gimp r24978 - in trunk: . app/tools



Author: mitch
Date: Tue Feb 26 16:41:24 2008
New Revision: 24978
URL: http://svn.gnome.org/viewvc/gimp?rev=24978&view=rev

Log:
2008-02-26  Michael Natterer  <mitch gimp org>

	* app/tools/gimppolygonselecttool.c: rename member num_points to
	n_points and various small cleanups all over the place.



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

Modified: trunk/app/tools/gimppolygonselecttool.c
==============================================================================
--- trunk/app/tools/gimppolygonselecttool.c	(original)
+++ trunk/app/tools/gimppolygonselecttool.c	Tue Feb 26 16:41:24 2008
@@ -74,7 +74,7 @@
   GimpVector2       *points;
 
   /* The number of points used for the actual selection. */
-  gint               num_points;
+  gint               n_points;
 
   gint               max_segs;
 };
@@ -136,7 +136,6 @@
 G_DEFINE_TYPE (GimpPolygonSelectTool, gimp_polygon_select_tool,
                GIMP_TYPE_SELECTION_TOOL);
 
-
 #define parent_class gimp_polygon_select_tool_parent_class
 
 
@@ -189,6 +188,7 @@
                                      GIMP_TOOL_CURSOR_FREE_SELECT);
 
   poly_sel_tool->points   = NULL;
+  poly_sel_tool->n_points = 0;
   poly_sel_tool->max_segs = 0;
 }
 
@@ -248,7 +248,7 @@
 
       gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
-      if (poly_sel_tool->num_points == 0 ||
+      if (poly_sel_tool->n_points == 0 ||
           (poly_sel_tool->grabbed_point && !hovering_first_point))
         {
           poly_sel_tool->show_pending_point = FALSE;
@@ -349,8 +349,7 @@
                                                  display,
                                                  coords))
         {
-          gimp_polygon_select_tool_commit (poly_sel_tool,
-                                           display);
+          gimp_polygon_select_tool_commit (poly_sel_tool, display);
           break;
         }
 
@@ -359,7 +358,8 @@
     case GIMP_BUTTON_RELEASE_NORMAL:
       if (! poly_sel_tool->grabbed_point)
         {
-          gimp_polygon_select_tool_add_point (poly_sel_tool, coords->x, coords->y);
+          gimp_polygon_select_tool_add_point (poly_sel_tool,
+                                              coords->x, coords->y);
         }
       else
         {
@@ -403,33 +403,28 @@
                                     GimpDisplay *display)
 {
   GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
-  gboolean            handled_key   = FALSE;
 
   switch (kevent->keyval)
     {
     case GDK_BackSpace:
       gimp_polygon_select_tool_remove_last (poly_sel_tool);
-      handled_key = TRUE;
-      break;
+      return TRUE;
 
     case GDK_Return:
     case GDK_KP_Enter:
     case GDK_ISO_Enter:
       gimp_polygon_select_tool_commit (poly_sel_tool, display);
-      handled_key = TRUE;
-      break;
+      return TRUE;
 
     case GDK_Escape:
       gimp_polygon_select_tool_halt (poly_sel_tool);
-      handled_key = TRUE;
-      break;
+      return TRUE;
 
     default:
-      handled_key = FALSE;
       break;
     }
 
-  return handled_key;
+  return FALSE;
 }
 
 static void
@@ -445,7 +440,7 @@
 
   tool->display = display;
 
-  poly_sel_tool->num_points         = 0;
+  poly_sel_tool->n_points           = 0;
   poly_sel_tool->grabbed_point      = NULL;
   poly_sel_tool->show_pending_point = FALSE;
 
@@ -456,7 +451,7 @@
 gimp_polygon_select_tool_commit (GimpPolygonSelectTool *poly_sel_tool,
                                  GimpDisplay           *display)
 {
-  if (poly_sel_tool->num_points >= 3)
+  if (poly_sel_tool->n_points >= 3)
     {
       gimp_polygon_select_tool_select (poly_sel_tool, display);
     }
@@ -480,9 +475,9 @@
 
   poly_sel_tool->grabbed_point      = NULL;
   poly_sel_tool->show_pending_point = FALSE;
-  poly_sel_tool->num_points         = 0;
+  poly_sel_tool->n_points           = 0;
 
-  tool->display            = NULL;
+  tool->display = NULL;
 }
 
 static void
@@ -492,14 +487,14 @@
 
   gimp_draw_tool_draw_lines (draw_tool,
                              (const gdouble *) poly_sel_tool->points,
-                             poly_sel_tool->num_points,
+                             poly_sel_tool->n_points,
                              FALSE, FALSE);
 
   if (poly_sel_tool->show_pending_point)
     {
       gimp_draw_tool_draw_line (draw_tool,
-                                poly_sel_tool->points[poly_sel_tool->num_points - 1].x,
-                                poly_sel_tool->points[poly_sel_tool->num_points - 1].y,
+                                poly_sel_tool->points[poly_sel_tool->n_points - 1].x,
+                                poly_sel_tool->points[poly_sel_tool->n_points - 1].y,
                                 poly_sel_tool->pending_point.x,
                                 poly_sel_tool->pending_point.y,
                                 FALSE);
@@ -513,10 +508,10 @@
   g_return_if_fail (GIMP_IS_POLYGON_SELECT_TOOL (poly_sel_tool));
   g_return_if_fail (GIMP_IS_DISPLAY (display));
 
-  GIMP_POLYGON_SELECT_TOOL_GET_CLASS (poly_sel_tool)->select (poly_sel_tool, display);
+  GIMP_POLYGON_SELECT_TOOL_GET_CLASS (poly_sel_tool)->select (poly_sel_tool,
+                                                              display);
 }
 
-
 static void
 gimp_polygon_select_tool_real_select (GimpPolygonSelectTool *poly_sel_tool,
                                       GimpDisplay           *display)
@@ -525,7 +520,7 @@
 
   gimp_channel_select_polygon (gimp_image_get_mask (display->image),
                                Q_("command|Polygon Select"),
-                               poly_sel_tool->num_points,
+                               poly_sel_tool->n_points,
                                poly_sel_tool->points,
                                options->operation,
                                options->antialias,
@@ -540,7 +535,7 @@
                                     gdouble                x,
                                     gdouble                y)
 {
-  if (poly_sel_tool->num_points >= poly_sel_tool->max_segs)
+  if (poly_sel_tool->n_points >= poly_sel_tool->max_segs)
     {
       poly_sel_tool->max_segs += DEFAULT_MAX_INC;
 
@@ -548,10 +543,10 @@
                                          sizeof (GimpVector2) * poly_sel_tool->max_segs);
     }
 
-  poly_sel_tool->points[poly_sel_tool->num_points].x = x;
-  poly_sel_tool->points[poly_sel_tool->num_points].y = y;
+  poly_sel_tool->points[poly_sel_tool->n_points].x = x;
+  poly_sel_tool->points[poly_sel_tool->n_points].y = y;
 
-  return &poly_sel_tool->points[poly_sel_tool->num_points++];
+  return &poly_sel_tool->points[poly_sel_tool->n_points++];
 }
 
 static void
@@ -561,9 +556,9 @@
 
   gimp_draw_tool_pause (draw_tool);
 
-  poly_sel_tool->num_points--;
+  poly_sel_tool->n_points--;
 
-  if (poly_sel_tool->num_points == 0)
+  if (poly_sel_tool->n_points == 0)
     {
       gimp_polygon_select_tool_halt (poly_sel_tool);
     }
@@ -576,24 +571,24 @@
                                               GimpDisplay           *display,
                                               GimpCoords            *coords)
 {
-  GimpDrawTool *draw_tool        = GIMP_DRAW_TOOL (poly_sel_tool);
-  gdouble       shortest_dist_sq;
+  GimpDrawTool *draw_tool     = GIMP_DRAW_TOOL (poly_sel_tool);
+  gdouble       shortest_dist = POINT_GRAB_THRESHOLD_SQ;
   int           i;
 
   poly_sel_tool->grabbed_point = NULL;
-  shortest_dist_sq    = POINT_GRAB_THRESHOLD_SQ;
 
-  for (i = 0; i < poly_sel_tool->num_points; i++)
+  for (i = 0; i < poly_sel_tool->n_points; i++)
     {
-      gdouble dist_sq;
+      gdouble dist;
 
-      dist_sq = gimp_draw_tool_calc_distance_square (draw_tool,
-                                                     display,
-                                                     coords->x,
-                                                     coords->y,
-                                                     poly_sel_tool->points[i].x,
-                                                     poly_sel_tool->points[i].y);
-      if (dist_sq < shortest_dist_sq)
+      dist = gimp_draw_tool_calc_distance_square (draw_tool,
+                                                  display,
+                                                  coords->x,
+                                                  coords->y,
+                                                  poly_sel_tool->points[i].x,
+                                                  poly_sel_tool->points[i].y);
+
+      if (dist < shortest_dist)
         {
           poly_sel_tool->grabbed_point = &poly_sel_tool->points[i];
         }
@@ -605,19 +600,20 @@
                                        GimpDisplay           *display,
                                        GimpCoords            *coords)
 {
-  gboolean should_close  = FALSE;
+  gboolean should_close = FALSE;
 
-  if (poly_sel_tool->num_points > 0)
+  if (poly_sel_tool->n_points > 0)
     {
-      gdouble dist_sq;
+      gdouble dist;
 
-      dist_sq = gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (poly_sel_tool),
-                                                     display,
-                                                     coords->x,
-                                                     coords->y,
-                                                     poly_sel_tool->points[0].x,
-                                                     poly_sel_tool->points[0].y);
-      should_close = dist_sq < POINT_GRAB_THRESHOLD_SQ;
+      dist = gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (poly_sel_tool),
+                                                  display,
+                                                  coords->x,
+                                                  coords->y,
+                                                  poly_sel_tool->points[0].x,
+                                                  poly_sel_tool->points[0].y);
+
+      should_close = dist < POINT_GRAB_THRESHOLD_SQ;
     }
 
   return should_close;



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