From fcd156014a60c713687b88a0bbee20fc76c0cdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Thu, 22 Jul 2010 00:07:27 +0200 Subject: [PATCH] gimpcagetool: beginning of the link tool/gegl op --- app/tools/gimpcagetool.c | 47 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c index 1de699f040..9aa2e90b96 100644 --- a/app/tools/gimpcagetool.c +++ b/app/tools/gimpcagetool.c @@ -22,6 +22,7 @@ #include +#include #include #include @@ -32,8 +33,15 @@ #include "tools/tools-enums.h" #include "gimptoolcontrol.h" +#include "core/gimp.h" +#include "core/gimpimage.h" +#include "core/gimplayer.h" +#include "display/gimpdisplay.h" #include "core/gimp-transform-utils.h" +#include "core/gimpdrawable.h" +#include "core/gimpdrawable-operation.h" + #include "widgets/gimphelp-ids.h" #include "gimpcagetool.h" @@ -81,8 +89,12 @@ static void gimp_cage_tool_oper_update (GimpTool *tool, gboolean proximity, GimpDisplay *display); static void gimp_cage_tool_draw (GimpDrawTool *draw_tool); -static void gimp_cage_tool_switch_to_deform (GimpCageTool *ct); -static void gimp_cage_tool_remove_last_handle (GimpCageTool *ct); +static void gimp_cage_tool_switch_to_deform + (GimpCageTool *ct); +static void gimp_cage_tool_remove_last_handle + (GimpCageTool *ct); +static void gimp_cage_tool_process (GimpCageTool *ct, + GimpImage *image); G_DEFINE_TYPE (GimpCageTool, gimp_cage_tool, GIMP_TYPE_DRAW_TOOL) @@ -247,9 +259,11 @@ gimp_cage_tool_button_press (GimpTool *tool, // user is clicking on the first handle, we close the cage and switch to deform mode if (ct->handle_moved == 0) - { + { ct->cage_complete = TRUE; gimp_cage_tool_switch_to_deform (ct); + + gimp_cage_tool_process (ct, display); } gimp_draw_tool_resume (GIMP_DRAW_TOOL (ct)); @@ -518,4 +532,29 @@ gimp_cage_tool_remove_last_handle (GimpCageTool *ct) gimp_draw_tool_pause (GIMP_DRAW_TOOL (ct)); gimp_cage_remove_last_cage_point (cage); gimp_draw_tool_resume (GIMP_DRAW_TOOL (ct)); -} \ No newline at end of file +} + +static void +gimp_cage_tool_process (GimpCageTool *ct, + GimpDisplay *display) +{ + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); + GimpProgress *progress = gimp_progress_start (GIMP_PROGRESS (display), + _("Blending"), + FALSE); + + + if (GIMP_IS_LAYER (drawable)) + { + GeglNode *node; + + node = g_object_new (GEGL_TYPE_NODE, + "operation", "gegl:cage", + NULL); + + gimp_drawable_apply_operation (drawable, progress, _("Cage transform"), + node, TRUE); + g_object_unref (node); + } +}