[gimp] app: add gimp_draw_tool_add_sample_point()



commit 2ced18cc87c7cdb03395d6b1937f5035c5ae7692
Author: Michael Natterer <mitch gimp org>
Date:   Thu Sep 30 02:03:16 2010 +0200

    app: add gimp_draw_tool_add_sample_point()
    
    and use it in the color tool. Also rename
    gimp_draw_tool_add_guide_line() to gimp_draw_tool_add_guide().

 app/tools/gimpcolortool.c |   12 +++++-------
 app/tools/gimpdrawtool.c  |   34 +++++++++++++++++++++++++++++++---
 app/tools/gimpdrawtool.h  |    6 +++++-
 app/tools/gimpmovetool.c  |   12 ++++++------
 4 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 759ed79..88247be 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -43,7 +43,7 @@
 #include "widgets/gimppaletteeditor.h"
 #include "widgets/gimpsessioninfo.h"
 
-#include "display/gimpcanvassamplepoint.h"
+#include "display/gimpcanvasitem.h"
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
 #include "display/gimpdisplayshell-appearance.h"
@@ -533,14 +533,12 @@ gimp_color_tool_draw (GimpDrawTool *draw_tool)
           index = g_list_index (gimp_image_get_sample_points (image),
                                 color_tool->sample_point) + 1;
 
-          item = gimp_canvas_sample_point_new (color_tool->sample_point->x,
-                                               color_tool->sample_point->y,
-                                               index);
+          item = gimp_draw_tool_add_sample_point (draw_tool,
+                                                  color_tool->sample_point->x,
+                                                  color_tool->sample_point->y,
+                                                  index);
           g_object_set (item, "sample-point-style", TRUE, NULL);
           gimp_canvas_item_set_highlight (item, TRUE);
-
-          gimp_draw_tool_add_item (draw_tool, item);
-          g_object_unref (item);
         }
 
       if (color_tool->moving_sample_point)
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 7e99785..38540f0 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -42,6 +42,7 @@
 #include "display/gimpcanvasline.h"
 #include "display/gimpcanvaspolygon.h"
 #include "display/gimpcanvasrectangle.h"
+#include "display/gimpcanvassamplepoint.h"
 #include "display/gimpcanvastextcursor.h"
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
@@ -401,9 +402,9 @@ gimp_draw_tool_add_line (GimpDrawTool *draw_tool,
  * This function draws a guide line across the canvas.
  **/
 GimpCanvasItem *
-gimp_draw_tool_add_guide_line (GimpDrawTool        *draw_tool,
-                               GimpOrientationType  orientation,
-                               gint                 position)
+gimp_draw_tool_add_guide (GimpDrawTool        *draw_tool,
+                          GimpOrientationType  orientation,
+                          gint                 position)
 {
   GimpCanvasItem *item;
 
@@ -418,6 +419,33 @@ gimp_draw_tool_add_guide_line (GimpDrawTool        *draw_tool,
 }
 
 /**
+ * gimp_draw_tool_draw_sample_point:
+ * @draw_tool: the #GimpDrawTool
+ * @x:         X position of the sample point
+ * @y:         Y position of the sample point
+ * @index:     Index of the sample point
+ *
+ * This function draws a sample point
+ **/
+GimpCanvasItem *
+gimp_draw_tool_add_sample_point (GimpDrawTool *draw_tool,
+                                 gint          x,
+                                 gint          y,
+                                 gint          index)
+{
+  GimpCanvasItem *item;
+
+  g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
+
+  item = gimp_canvas_sample_point_new (x, y, index);
+
+  gimp_draw_tool_add_item (draw_tool, item);
+  g_object_unref (item);
+
+  return item;
+}
+
+/**
  * gimp_draw_tool_add_rectangle:
  * @draw_tool:   the #GimpDrawTool
  * @filled:      whether to fill the rectangle
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index d5279b7..55bde3c 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -89,9 +89,13 @@ GimpCanvasItem * gimp_draw_tool_add_line             (GimpDrawTool     *draw_too
                                                       gdouble           y1,
                                                       gdouble           x2,
                                                       gdouble           y2);
-GimpCanvasItem * gimp_draw_tool_add_guide_line       (GimpDrawTool     *draw_tool,
+GimpCanvasItem * gimp_draw_tool_add_guide            (GimpDrawTool     *draw_tool,
                                                       GimpOrientationType  orientation,
                                                       gint              position);
+GimpCanvasItem * gimp_draw_tool_add_sample_point     (GimpDrawTool     *draw_tool,
+                                                      gint              x,
+                                                      gint              y,
+                                                      gint              index);
 GimpCanvasItem * gimp_draw_tool_add_rectangle        (GimpDrawTool     *draw_tool,
                                                       gboolean          filled,
                                                       gdouble           x,
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 037f822..97c7cd3 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -755,9 +755,9 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
     {
       GimpCanvasItem *item;
 
-      item = gimp_draw_tool_add_guide_line (draw_tool,
-                                            gimp_guide_get_orientation (move->guide),
-                                            gimp_guide_get_position (move->guide));
+      item = gimp_draw_tool_add_guide (draw_tool,
+                                       gimp_guide_get_orientation (move->guide),
+                                       gimp_guide_get_position (move->guide));
 
       g_object_set (item, "guide-style", TRUE, NULL);
       gimp_canvas_item_set_highlight (item, TRUE);
@@ -765,9 +765,9 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
 
   if (move->moving_guide && move->guide_position != -1)
     {
-      gimp_draw_tool_add_guide_line (draw_tool,
-                                     move->guide_orientation,
-                                     move->guide_position);
+      gimp_draw_tool_add_guide (draw_tool,
+                                move->guide_orientation,
+                                move->guide_position);
     }
 }
 



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