app: add gimp_draw_tool_add_transform_preview() and use it

This commit is contained in:
Michael Natterer 2011-03-28 02:18:00 +02:00
parent fd80b90cf0
commit 20bed2c609
3 changed files with 48 additions and 14 deletions

View File

@ -26,6 +26,7 @@
#include "tools-types.h" #include "tools-types.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "vectors/gimpanchor.h" #include "vectors/gimpanchor.h"
@ -47,6 +48,7 @@
#include "display/gimpcanvasrectangle.h" #include "display/gimpcanvasrectangle.h"
#include "display/gimpcanvassamplepoint.h" #include "display/gimpcanvassamplepoint.h"
#include "display/gimpcanvastextcursor.h" #include "display/gimpcanvastextcursor.h"
#include "display/gimpcanvastransformpreview.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-items.h" #include "display/gimpdisplayshell-items.h"
@ -836,6 +838,34 @@ gimp_draw_tool_add_text_cursor (GimpDrawTool *draw_tool,
return item; 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 gboolean
gimp_draw_tool_on_handle (GimpDrawTool *draw_tool, gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *display, GimpDisplay *display,

View File

@ -129,6 +129,15 @@ GimpCanvasItem * gimp_draw_tool_add_arc (GimpDrawTool *draw_too
gdouble height, gdouble height,
gdouble start_angle, gdouble start_angle,
gdouble slice_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, GimpCanvasItem * gimp_draw_tool_add_handle (GimpDrawTool *draw_tool,
GimpHandleType type, GimpHandleType type,

View File

@ -52,7 +52,6 @@
#include "widgets/gimpdialogfactory.h" #include "widgets/gimpdialogfactory.h"
#include "display/gimpcanvasgroup.h" #include "display/gimpcanvasgroup.h"
#include "display/gimpcanvastransformpreview.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-transform.h" #include "display/gimpdisplayshell-transform.h"
@ -735,19 +734,15 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
if (gimp_transform_options_show_preview (options)) if (gimp_transform_options_show_preview (options))
{ {
GimpCanvasItem *item; gimp_draw_tool_add_transform_preview (draw_tool,
tool->drawable,
item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display), &tr_tool->transform,
tool->drawable, tr_tool->x1,
&tr_tool->transform, tr_tool->y1,
tr_tool->x1, tr_tool->x2,
tr_tool->y1, tr_tool->y2,
tr_tool->x2, GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
tr_tool->y2, options->preview_opacity);
GIMP_IS_PERSPECTIVE_TOOL (tr_tool),
options->preview_opacity);
gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item);
} }
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);