[gimp] app: add gimp_draw_tool_add_transform_preview() and use it



commit 20bed2c609a6edb816a1fffeb7ab017a6c183b1b
Author: Michael Natterer <mitch gimp org>
Date:   Mon Mar 28 02:18:00 2011 +0200

    app: add gimp_draw_tool_add_transform_preview() and use it

 app/tools/gimpdrawtool.c      |   30 ++++++++++++++++++++++++++++++
 app/tools/gimpdrawtool.h      |    9 +++++++++
 app/tools/gimptransformtool.c |   23 +++++++++--------------
 3 files changed, 48 insertions(+), 14 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index bd28467..cd6edad 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -26,6 +26,7 @@
 
 #include "tools-types.h"
 
+#include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
 
 #include "vectors/gimpanchor.h"
@@ -47,6 +48,7 @@
 #include "display/gimpcanvasrectangle.h"
 #include "display/gimpcanvassamplepoint.h"
 #include "display/gimpcanvastextcursor.h"
+#include "display/gimpcanvastransformpreview.h"
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
 #include "display/gimpdisplayshell-items.h"
@@ -836,6 +838,34 @@ gimp_draw_tool_add_text_cursor (GimpDrawTool   *draw_tool,
   return item;
 }
 
+GimpCanvasItem *
+gimp_draw_tool_add_transform_preview (GimpDrawTool      *draw_tool,
+                                      GimpDrawable      *drawable,
+                                      const GimpMatrix3 *transform,
+                                      gdouble            x1,
+                                      gdouble            y1,
+                                      gdouble            x2,
+                                      gdouble            y2,
+                                      gboolean           perspective,
+                                      gdouble            opacity)
+{
+  GimpCanvasItem *item;
+
+  g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
+  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
+  g_return_val_if_fail (transform != NULL, NULL);
+
+  item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
+                                            drawable, transform,
+                                            x1, y1, x2, y2,
+                                            perspective, opacity);
+
+  gimp_draw_tool_add_item (draw_tool, item);
+  g_object_unref (item);
+
+  return item;
+}
+
 gboolean
 gimp_draw_tool_on_handle (GimpDrawTool     *draw_tool,
                           GimpDisplay      *display,
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index f96ae7d..9bf8dc9 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -129,6 +129,15 @@ GimpCanvasItem * gimp_draw_tool_add_arc              (GimpDrawTool     *draw_too
                                                       gdouble           height,
                                                       gdouble           start_angle,
                                                       gdouble           slice_angle);
+GimpCanvasItem * gimp_draw_tool_add_transform_preview(GimpDrawTool     *draw_tool,
+                                                      GimpDrawable     *drawable,
+                                                      const GimpMatrix3 *transform,
+                                                      gdouble           x1,
+                                                      gdouble           y1,
+                                                      gdouble           x2,
+                                                      gdouble           y2,
+                                                      gboolean          perspective,
+                                                      gdouble            opacity);
 
 GimpCanvasItem * gimp_draw_tool_add_handle           (GimpDrawTool     *draw_tool,
                                                       GimpHandleType    type,
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index fe70fa9..09f3fff 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -52,7 +52,6 @@
 #include "widgets/gimpdialogfactory.h"
 
 #include "display/gimpcanvasgroup.h"
-#include "display/gimpcanvastransformpreview.h"
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
 #include "display/gimpdisplayshell-transform.h"
@@ -735,19 +734,15 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
 
       if (gimp_transform_options_show_preview (options))
         {
-          GimpCanvasItem *item;
-
-          item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
-                                                    tool->drawable,
-                                                    &tr_tool->transform,
-                                                    tr_tool->x1,
-                                                    tr_tool->y1,
-                                                    tr_tool->x2,
-                                                    tr_tool->y2,
-                                                    GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
-                                                    options->preview_opacity);
-          gimp_draw_tool_add_item (draw_tool, item);
-          g_object_unref (item);
+          gimp_draw_tool_add_transform_preview (draw_tool,
+                                                tool->drawable,
+                                                &tr_tool->transform,
+                                                tr_tool->x1,
+                                                tr_tool->y1,
+                                                tr_tool->x2,
+                                                tr_tool->y2,
+                                                GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
+                                                options->preview_opacity);
         }
 
       stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);



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