[gimp] app: pass the cursor's PangoRectangle to gimp_draw_tool_draw_text_cursor()



commit 2e5de8f6abcfab32b07cebc344110c44b5e44b89
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 7 01:15:04 2010 +0100

    app: pass the cursor's PangoRectangle to gimp_draw_tool_draw_text_cursor()
    
    and let the drawing function decide everything instead of doing some
    cursor extents fiddling in the text tool.

 app/tools/gimpdrawtool.c |   49 +++++++++++++++++++++++++++------------------
 app/tools/gimpdrawtool.h |    5 +---
 app/tools/gimptexttool.c |    8 +------
 3 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 9b4e405..e9ee01e 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -1463,13 +1463,10 @@ gimp_draw_tool_draw_boundary (GimpDrawTool   *draw_tool,
 }
 
 void
-gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool,
-                                 gdouble       x1,
-                                 gdouble       y1,
-                                 gdouble       x2,
-                                 gdouble       y2,
-                                 gboolean      overwrite,
-                                 gboolean      use_offsets)
+gimp_draw_tool_draw_text_cursor (GimpDrawTool   *draw_tool,
+                                 PangoRectangle *cursor,
+                                 gboolean        overwrite,
+                                 gboolean        use_offsets)
 {
   GimpDisplayShell *shell;
   gdouble           tx1, ty1;
@@ -1480,31 +1477,43 @@ gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool,
   shell = gimp_display_get_shell (draw_tool->display);
 
   gimp_display_shell_transform_xy_f (shell,
-                                     x1, y1,
+                                     cursor->x, cursor->y,
                                      &tx1, &ty1,
                                      use_offsets);
-  gimp_display_shell_transform_xy_f (shell,
-                                     x2, y2,
-                                     &tx2, &ty2,
-                                     use_offsets);
 
   if (overwrite)
     {
+      gint x, y;
+      gint width, height;
+
+      gimp_display_shell_transform_xy_f (shell,
+                                         cursor->x + cursor->width,
+                                         cursor->y + cursor->height,
+                                         &tx2, &ty2,
+                                         use_offsets);
+
+      x      = PROJ_ROUND (tx1);
+      y      = PROJ_ROUND (ty1);
+      width  = PROJ_ROUND (tx2 - tx1);
+      height = PROJ_ROUND (ty2 - ty1);
+
       gimp_canvas_draw_rectangle (GIMP_CANVAS (shell->canvas),
                                   GIMP_CANVAS_STYLE_XOR, FALSE,
-                                  PROJ_ROUND (tx1),
-                                  PROJ_ROUND (ty1),
-                                  PROJ_ROUND (tx2 - tx1),
-                                  PROJ_ROUND (ty2 - ty1));
+                                  x, y,
+                                  width, height);
       gimp_canvas_draw_rectangle (GIMP_CANVAS (shell->canvas),
                                   GIMP_CANVAS_STYLE_XOR, FALSE,
-                                  PROJ_ROUND (tx1) + 1,
-                                  PROJ_ROUND (ty1) + 1,
-                                  PROJ_ROUND (tx2 - tx1) - 2,
-                                  PROJ_ROUND (ty2 - ty1) - 2);
+                                  x + 1, y + 1,
+                                  width - 2, height - 2);
     }
   else
     {
+      gimp_display_shell_transform_xy_f (shell,
+                                         cursor->x,
+                                         cursor->y + cursor->height,
+                                         &tx2, &ty2,
+                                         use_offsets);
+
       /*  vertical line  */
       gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas),
                              GIMP_CANVAS_STYLE_XOR,
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index 508a99c..738caf6 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -203,10 +203,7 @@ void       gimp_draw_tool_draw_boundary            (GimpDrawTool     *draw_tool,
                                                     gboolean          use_offsets);
 
 void       gimp_draw_tool_draw_text_cursor         (GimpDrawTool     *draw_tool,
-                                                    gdouble           x1,
-                                                    gdouble           y1,
-                                                    gdouble           x2,
-                                                    gdouble           y2,
+                                                    PangoRectangle   *cursor,
                                                     gboolean          overwrite,
                                                     gboolean          use_offsets);
 
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 16258cf..94b3666 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -773,13 +773,7 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
       overwrite = text_tool->overwrite_mode && cursor_rect.width > 0;
 
       gimp_draw_tool_draw_text_cursor (draw_tool,
-                                       cursor_rect.x,
-                                       cursor_rect.y,
-                                       overwrite ?
-                                       cursor_rect.x + cursor_rect.width :
-                                       cursor_rect.x,
-                                       cursor_rect.y + cursor_rect.height,
-                                       overwrite,
+                                       &cursor_rect, overwrite,
                                        TRUE);
     }
 }



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