gimp r24985 - in trunk: . app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24985 - in trunk: . app/tools
- Date: Tue, 26 Feb 2008 20:14:10 +0000 (GMT)
Author: mitch
Date: Tue Feb 26 20:14:10 2008
New Revision: 24985
URL: http://svn.gnome.org/viewvc/gimp?rev=24985&view=rev
Log:
2008-02-26 Michael Natterer <mitch gimp org>
* app/tools/gimppolygonselecttool.c: draw handles at the corners
and use the MOVE cursor modifier when we are moving them. Fix draw
tool pause/resume in button_press() plus some minor cleanup.
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 20:14:10 2008
@@ -49,7 +49,8 @@
#define DEFAULT_MAX_INC 1024
-#define POINT_GRAB_THRESHOLD_SQ 100
+#define HANDLE_SIZE 10
+#define POINT_GRAB_THRESHOLD_SQ SQR(HANDLE_SIZE / 2)
struct _GimpPolygonSelectTool
@@ -81,6 +82,7 @@
static void gimp_polygon_select_tool_finalize (GObject *object);
+
static void gimp_polygon_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
@@ -89,6 +91,10 @@
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
+static void gimp_polygon_select_tool_cursor_update (GimpTool *tool,
+ GimpCoords *coords,
+ GdkModifierType state,
+ GimpDisplay *display);
static void gimp_polygon_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
@@ -124,7 +130,7 @@
gdouble x,
gdouble y);
static void gimp_polygon_select_tool_remove_last (GimpPolygonSelectTool *poly_sel_tool);
-static void gimp_polygon_select_tool_select_closet_point
+static void gimp_polygon_select_tool_select_closest_point
(GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display,
GimpCoords *coords);
@@ -167,6 +173,7 @@
tool_class->control = gimp_polygon_select_tool_control;
tool_class->oper_update = gimp_polygon_select_tool_oper_update;
+ tool_class->cursor_update = gimp_polygon_select_tool_cursor_update;
tool_class->button_press = gimp_polygon_select_tool_button_press;
tool_class->motion = gimp_polygon_select_tool_motion;
tool_class->button_release = gimp_polygon_select_tool_button_release;
@@ -238,9 +245,9 @@
{
gboolean hovering_first_point;
- gimp_polygon_select_tool_select_closet_point (poly_sel_tool,
- display,
- coords);
+ gimp_polygon_select_tool_select_closest_point (poly_sel_tool,
+ display,
+ coords);
hovering_first_point = gimp_polygon_select_tool_should_close (poly_sel_tool,
display,
@@ -249,7 +256,7 @@
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if (poly_sel_tool->n_points == 0 ||
- (poly_sel_tool->grabbed_point && !hovering_first_point))
+ (poly_sel_tool->grabbed_point && ! hovering_first_point))
{
poly_sel_tool->show_pending_point = FALSE;
}
@@ -273,6 +280,28 @@
}
static void
+gimp_polygon_select_tool_cursor_update (GimpTool *tool,
+ GimpCoords *coords,
+ GdkModifierType state,
+ GimpDisplay *display)
+{
+ GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
+
+ if (poly_sel_tool->grabbed_point &&
+ ! gimp_polygon_select_tool_should_close (poly_sel_tool, display, coords))
+ {
+ gimp_tool_set_cursor (tool, display,
+ gimp_tool_control_get_cursor (tool->control),
+ gimp_tool_control_get_tool_cursor (tool->control),
+ GIMP_CURSOR_MODIFIER_MOVE);
+
+ return;
+ }
+
+ GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
+}
+
+static void
gimp_polygon_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
@@ -342,6 +371,8 @@
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
+ gimp_draw_tool_pause (GIMP_DRAW_TOOL (poly_sel_tool));
+
switch (release_type)
{
case GIMP_BUTTON_RELEASE_CLICK:
@@ -370,16 +401,10 @@
break;
case GIMP_BUTTON_RELEASE_CANCEL:
- {
- gimp_draw_tool_pause (GIMP_DRAW_TOOL (poly_sel_tool));
-
- if (poly_sel_tool->grabbed_point)
- {
- *poly_sel_tool->grabbed_point = poly_sel_tool->saved_grabbed_point;
- }
-
- gimp_draw_tool_resume (GIMP_DRAW_TOOL (poly_sel_tool));
- }
+ if (poly_sel_tool->grabbed_point)
+ {
+ *poly_sel_tool->grabbed_point = poly_sel_tool->saved_grabbed_point;
+ }
break;
case GIMP_BUTTON_RELEASE_NO_MOTION:
@@ -395,6 +420,8 @@
}
break;
}
+
+ gimp_draw_tool_resume (GIMP_DRAW_TOOL (poly_sel_tool));
}
static gboolean
@@ -484,16 +511,28 @@
gimp_polygon_select_tool_draw (GimpDrawTool *draw_tool)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (draw_tool);
+ gint i;
gimp_draw_tool_draw_lines (draw_tool,
poly_sel_tool->points, poly_sel_tool->n_points,
FALSE, FALSE);
+ for (i = 0; i < poly_sel_tool->n_points; i++)
+ {
+ gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_CIRCLE,
+ poly_sel_tool->points[i].x,
+ poly_sel_tool->points[i].y,
+ HANDLE_SIZE, HANDLE_SIZE,
+ GTK_ANCHOR_CENTER, FALSE);
+ }
+
if (poly_sel_tool->show_pending_point)
{
+ GimpVector2 last = poly_sel_tool->points[poly_sel_tool->n_points - 1];
+
gimp_draw_tool_draw_line (draw_tool,
- poly_sel_tool->points[poly_sel_tool->n_points - 1].x,
- poly_sel_tool->points[poly_sel_tool->n_points - 1].y,
+ last.x,
+ last.y,
poly_sel_tool->pending_point.x,
poly_sel_tool->pending_point.y,
FALSE);
@@ -566,9 +605,9 @@
}
static void
-gimp_polygon_select_tool_select_closet_point (GimpPolygonSelectTool *poly_sel_tool,
- GimpDisplay *display,
- GimpCoords *coords)
+gimp_polygon_select_tool_select_closest_point (GimpPolygonSelectTool *poly_sel_tool,
+ GimpDisplay *display,
+ GimpCoords *coords)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool);
gdouble shortest_dist = POINT_GRAB_THRESHOLD_SQ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]