gimp r27431 - in trunk: . app/tools



Author: mitch
Date: Mon Oct 27 00:10:13 2008
New Revision: 27431
URL: http://svn.gnome.org/viewvc/gimp?rev=27431&view=rev

Log:
2008-10-27  Michael Natterer  <mitch gimp org>

	* app/tools/gimpdrawtool.[ch]: add gimp_draw_tool_set_clip_rect()
	which transforms the passed in GdkRectangle before setting it
	on the canvas.

	* app/tools/gimptexttool.c (gimp_text_tool_draw): use it instead
	of gimp_canvas_set_clip_rect().



Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpdrawtool.c
   trunk/app/tools/gimpdrawtool.h
   trunk/app/tools/gimptexttool.c

Modified: trunk/app/tools/gimpdrawtool.c
==============================================================================
--- trunk/app/tools/gimpdrawtool.c	(original)
+++ trunk/app/tools/gimpdrawtool.c	Mon Oct 27 00:10:13 2008
@@ -452,6 +452,44 @@
                                                x1, y1, x2, y2) < SQR (radius));
 }
 
+void
+gimp_draw_tool_set_clip_rect (GimpDrawTool *draw_tool,
+                              GdkRectangle *rect,
+                              gboolean      use_offsets)
+{
+  GimpDisplayShell *shell;
+
+  g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
+
+  shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
+
+  if (rect)
+    {
+      GdkRectangle r;
+
+      gimp_display_shell_transform_xy (shell,
+                                       rect->x + rect->width,
+                                       rect->y + rect->height,
+                                       &r.width, &r.height,
+                                       use_offsets);
+      gimp_display_shell_transform_xy (shell,
+                                       rect->x, rect->y,
+                                       &r.x, &r.y,
+                                       use_offsets);
+
+      r.width  -= r.x;
+      r.height -= r.y;
+
+      gimp_canvas_set_clip_rect (GIMP_CANVAS (shell->canvas),
+                                 GIMP_CANVAS_STYLE_XOR, &r);
+    }
+  else
+    {
+      gimp_canvas_set_clip_rect (GIMP_CANVAS (shell->canvas),
+                                 GIMP_CANVAS_STYLE_XOR, NULL);
+    }
+}
+
 /**
  * gimp_draw_tool_draw_line:
  * @draw_tool:   the #GimpDrawTool

Modified: trunk/app/tools/gimpdrawtool.h
==============================================================================
--- trunk/app/tools/gimpdrawtool.h	(original)
+++ trunk/app/tools/gimpdrawtool.h	Mon Oct 27 00:10:13 2008
@@ -106,6 +106,10 @@
                                                     gdouble           y2,
                                                     gint              radius);
 
+void       gimp_draw_tool_set_clip_rect            (GimpDrawTool     *draw_tool,
+                                                    GdkRectangle     *rect,
+                                                    gboolean          use_offsets);
+
 void       gimp_draw_tool_draw_line                (GimpDrawTool     *draw_tool,
                                                     gdouble           x1,
                                                     gdouble           y1,

Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c	(original)
+++ trunk/app/tools/gimptexttool.c	Mon Oct 27 00:10:13 2008
@@ -2145,10 +2145,10 @@
 {
   GimpTextTool     *text_tool = GIMP_TEXT_TOOL (draw_tool);
   GimpTool         *tool      = GIMP_TOOL (draw_tool);
-  GimpDisplayShell *shell     = GIMP_DISPLAY_SHELL (tool->display->shell);
   GdkRectangle      cliprect;
   gint              width, height;
-  gint              x1, x2, y1, y2;
+  gint              x1, x2;
+  gint              y1, y2;
   GtkTextIter       start;
 
   g_object_set (text_tool,
@@ -2177,8 +2177,7 @@
   cliprect.width  = x2 - x1;
   cliprect.y      = y1;
   cliprect.height = y2 - y1;
-  gimp_canvas_set_clip_rect (GIMP_CANVAS (shell->canvas),
-                             GIMP_CANVAS_STYLE_XOR, &cliprect);
+  gimp_draw_tool_set_clip_rect (draw_tool, &cliprect, FALSE);
 
   gtk_text_buffer_get_start_iter (text_tool->text_buffer, &start);
 
@@ -2229,8 +2228,7 @@
     }
 
   /* Turn off clipping when done */
-  gimp_canvas_set_clip_rect (GIMP_CANVAS (shell->canvas),
-                             GIMP_CANVAS_STYLE_XOR, NULL);
+  gimp_draw_tool_set_clip_rect (draw_tool, NULL, FALSE);
 }
 
 static void



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