gimp r27497 - in trunk: . app/tools



Author: mitch
Date: Fri Oct 31 16:48:29 2008
New Revision: 27497
URL: http://svn.gnome.org/viewvc/gimp?rev=27497&view=rev

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

	* app/tools/gimpdrawtool.[ch]: add gimp_draw_tool_draw_text_cursor()
	which draws a properly transformed cursor that always has the same
	line width.

	* app/tools/gimptexttool.c (gimp_text_tool_draw): use it instead
	of drawing a cursor here that is broken at anything but 1:1 zoom.



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	Fri Oct 31 16:48:29 2008
@@ -1878,6 +1878,56 @@
   g_free (gdk_points);
 }
 
+void
+gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool,
+                                 gdouble       x1,
+                                 gdouble       y1,
+                                 gdouble       x2,
+                                 gdouble       y2,
+                                 gboolean      use_offsets)
+{
+  GimpDisplayShell *shell;
+  gdouble           tx1, ty1;
+  gdouble           tx2, ty2;
+
+  g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
+
+  shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
+
+  gimp_display_shell_transform_xy_f (shell,
+                                     x1, y1,
+                                     &tx1, &ty1,
+                                     use_offsets);
+  gimp_display_shell_transform_xy_f (shell,
+                                     x2, y2,
+                                     &tx2, &ty2,
+                                     use_offsets);
+
+  /*  vertical line  */
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx1), PROJ_ROUND (ty1) + 2,
+                         PROJ_ROUND (tx2), PROJ_ROUND (ty2) - 2);
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx1) - 1, PROJ_ROUND (ty1) + 2,
+                         PROJ_ROUND (tx2) - 1, PROJ_ROUND (ty2) - 2);
+
+  /*  top serif  */
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx1) - 3, PROJ_ROUND (ty1),
+                         PROJ_ROUND (tx1) + 3, PROJ_ROUND (ty1));
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx1) - 3, PROJ_ROUND (ty1) + 1,
+                         PROJ_ROUND (tx1) + 3, PROJ_ROUND (ty1) + 1);
+
+  /*  bottom serif  */
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx2) - 3, PROJ_ROUND (ty2) - 1,
+                         PROJ_ROUND (tx2) + 3, PROJ_ROUND (ty2) - 1);
+  gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
+                         PROJ_ROUND (tx2) - 3, PROJ_ROUND (ty2) - 2,
+                         PROJ_ROUND (tx2) + 3, PROJ_ROUND (ty2) - 2);
+}
+
 
 /*  private functions  */
 

Modified: trunk/app/tools/gimpdrawtool.h
==============================================================================
--- trunk/app/tools/gimpdrawtool.h	(original)
+++ trunk/app/tools/gimpdrawtool.h	Fri Oct 31 16:48:29 2008
@@ -251,5 +251,12 @@
                                                     gdouble           offset_y,
                                                     gboolean          use_offsets);
 
+void       gimp_draw_tool_draw_text_cursor         (GimpDrawTool     *draw_tool,
+                                                    gdouble           x1,
+                                                    gdouble           y1,
+                                                    gdouble           x2,
+                                                    gdouble           y2,
+                                                    gboolean          use_offsets);
+
 
 #endif  /*  __GIMP_DRAW_TOOL_H__  */

Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c	(original)
+++ trunk/app/tools/gimptexttool.c	Fri Oct 31 16:48:29 2008
@@ -1089,18 +1089,10 @@
       crect.y      = PANGO_PIXELS (crect.y) + logical_off_y;
       crect.height = PANGO_PIXELS (crect.height);
 
-      gimp_draw_tool_draw_rectangle (draw_tool, TRUE,
-                                     crect.x - 1, crect.y + 2,
-                                     3, crect.height - 4,
-                                     TRUE);
-      gimp_draw_tool_draw_rectangle (draw_tool, TRUE,
-                                     crect.x - 3, crect.y,
-                                     7, 3,
-                                     TRUE);
-      gimp_draw_tool_draw_rectangle (draw_tool, TRUE,
-                                     crect.x - 3, crect.y + crect.height - 3,
-                                     7, 3,
-                                     TRUE);
+      gimp_draw_tool_draw_text_cursor (draw_tool,
+                                       crect.x, crect.y,
+                                       crect.x, crect.y + crect.height,
+                                       TRUE);
 
       if (text_tool->preedit_string && text_tool->preedit_len > 0)
         gimp_text_tool_draw_preedit (draw_tool, logical_off_x, logical_off_y);



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