structure of the cage tool, with an options object

This commit is contained in:
Michael Muré 2010-06-30 20:27:52 +02:00
parent 24652b4fbd
commit f6316285be
18 changed files with 241 additions and 24 deletions

View File

@ -1,6 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* gimpcage.c
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
*
* gimpcage.h
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,4 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationcage.c
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
@ -35,7 +34,6 @@
static gboolean gimp_operation_cage_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi);
G_DEFINE_TYPE (GimpOperationCage, gimp_operation_cage,
@ -47,7 +45,16 @@ G_DEFINE_TYPE (GimpOperationCage, gimp_operation_cage,
static void
gimp_operation_cage_class_init (GimpOperationCageClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class->name = "gimp:cage";
operation_class->description = "GIMP cage transform";
filter_class->process = gimp_operation_cage_process;
}
static void
@ -59,8 +66,21 @@ static gboolean
gimp_operation_cage_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi)
{
gfloat *in = in_buf;
gfloat *out = out_buf;
/*while (samples--)
{
out[RED] = in[RED];
out[GREEN] = in[GREEN];
out[BLUE] = in[BLUE];
out[ALPHA] = in[ALPHA];
in += 4;
out += 4;
}*/
return TRUE;
}

View File

@ -1,5 +1,4 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationcage.h
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>

View File

@ -42,6 +42,8 @@ libapptools_a_sources = \
gimpbucketfilltool.h \
gimpbycolorselecttool.c \
gimpbycolorselecttool.h \
gimpcageoptions.c \
gimpcageoptions.h \
gimpcagetool.c \
gimpcagetool.h \
gimpclonetool.c \

View File

@ -0,0 +1,58 @@
/* GIMP - The GNU Image Manipulation Program
*
* gimpcageoptions.c
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcagetool.h"
#include "gimpcageoptions.h"
#include "gimp-intl.h"
G_DEFINE_TYPE (GimpCageOptions, gimp_cage_options,
GIMP_TYPE_TRANSFORM_OPTIONS)
#define parent_class gimp_cage_options_parent_class
static void
gimp_cage_options_class_init (GimpCageOptionsClass *klass)
{
}
static void
gimp_cage_options_init (GimpCageOptions *options)
{
}

View File

@ -0,0 +1,51 @@
/* GIMP - The GNU Image Manipulation Program
*
* gimpcageoptions.h
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CAGE_OPTIONS_H__
#define __GIMP_CAGE_OPTIONS_H__
#include "tools/gimptransformoptions.h"
#define GIMP_TYPE_CAGE_OPTIONS (gimp_cage_options_get_type ())
#define GIMP_CAGE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CAGE_OPTIONS, GimpCageOptions))
#define GIMP_CAGE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CAGE_OPTIONS, GimpCageOptionsClass))
#define GIMP_IS_CAGE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CAGE_OPTIONS))
#define GIMP_IS_CAGE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CAGE_OPTIONS))
#define GIMP_CAGE_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CAGE_OPTIONS, GimpCageOptionsClass))
typedef struct _GimpCageOptionsClass GimpCageOptionsClass;
typedef struct _GimpCageOptions GimpCageOptions;
struct _GimpCageOptions
{
GimpTransformOptions parent_instance;
};
struct _GimpCageOptionsClass
{
GimpToolOptionsClass parent_class;
};
GType gimp_cage_options_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_CAGE_OPTIONS_H__ */

View File

@ -1,5 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
*
* gimpcagetool.c
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,17 +32,29 @@
#include "core/gimp-transform-utils.h"
#include "widgets/gimphelp-ids.h"
#include "gimpcagetool.h"
#include "gimpcageoptions.h"
#include "gimptransformoptions.h"
#include "gimp-intl.h"
static void gimp_cage_tool_finalize (GObject *object);
static void gimp_cage_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display);
static void gimp_cage_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_cage_tool_draw (GimpDrawTool *draw_tool);
G_DEFINE_TYPE (GimpCageTool, gimp_cage_tool, GIMP_TYPE_TRANSFORM_TOOL)
@ -52,22 +66,32 @@ gimp_cage_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_CAGE_TOOL,
GIMP_TYPE_TRANSFORM_OPTIONS,
gimp_transform_options_gui,
GIMP_CONTEXT_BACKGROUND_MASK,
GIMP_TYPE_CAGE_OPTIONS,
0, //options_gui_func
0, //context_props
"gimp-cage-tool",
_("Rotate"),
_("Rotate Tool: Rotate the layer, selection or path"),
N_("_Rotate"), "<shift>R",
NULL, GIMP_HELP_TOOL_ROTATE,
GIMP_STOCK_TOOL_ROTATE,
_("Cage Transform"),
_("Cage Transform: Deform a selection with a cage"),
N_("_Cage Transform"), "<shift>R",
NULL, GIMP_HELP_TOOL_CAGE,
GIMP_STOCK_TOOL_CAGE,
data);
}
static void
gimp_cage_tool_class_init (GimpCageToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
GimpTransformToolClass *transformtool_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
object_class->finalize = gimp_cage_tool_finalize;
tool_class->button_press = gimp_cage_tool_button_press;
tool_class->button_release = gimp_cage_tool_button_release;
draw_tool_class->draw = gimp_cage_tool_draw;
}
static void
@ -77,3 +101,50 @@ gimp_cage_tool_init (GimpCageTool *self)
}
static void
gimp_cage_tool_finalize (GObject *object)
{
GimpCageTool *ct = GIMP_CAGE_TOOL (object);
//GimpCageToolPrivate *priv = GET_PRIVATE (ct);
/*g_free (priv->points);
g_free (priv->segment_indices);
g_free (priv->saved_points_lower_segment);
g_free (priv->saved_points_higher_segment);*/
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void gimp_cage_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display)
{
}
static void gimp_cage_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
}
static void gimp_cage_tool_draw (GimpDrawTool *draw_tool)
{
GimpCageTool *fst = GIMP_CAGE_TOOL (draw_tool);
//GimpCageToolPrivate *priv = GET_PRIVATE (fst);
GimpTool *tool = GIMP_TOOL (draw_tool);
gimp_draw_tool_draw_line(draw_tool, 10, 10, 10, 40, FALSE);
gimp_draw_tool_draw_line(draw_tool, 10, 40, 40, 40, FALSE);
gimp_draw_tool_draw_line(draw_tool, 40, 40, 40, 10, FALSE);
gimp_draw_tool_draw_line(draw_tool, 40, 10, 10, 10, FALSE);
}

View File

@ -1,5 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
*
* gimpcagetool.h
* Copyright (C) 2010 Michael Muré <batolettre@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,6 +30,7 @@
#define GIMP_IS_CAGE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CAGE_TOOL))
#define GIMP_CAGE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CAGE_TOOL, GimpCageToolClass))
#define GIMP_CAGE_TOOL_GET_OPTIONS(t) (GIMP_CAGE_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpCageToolClass GimpCageToolClass;
typedef struct _GimpCageTool GimpCageTool;

View File

@ -37,6 +37,7 @@ OBJECTS = \
gimpbucketfilltool.obj \
gimpbycolorselecttool.obj \
gimpcagetool.obj \
gimpcageoptions.obj \
gimpclonetool.obj \
gimpcolorbalancetool.obj \
gimpcolorizetool.obj \

View File

@ -246,6 +246,7 @@
#define GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST "gimp-tool-brightness-contrast"
#define GIMP_HELP_TOOL_BUCKET_FILL "gimp-tool-bucket-fill"
#define GIMP_HELP_TOOL_BY_COLOR_SELECT "gimp-tool-by-color-select"
#define GIMP_HELP_TOOL_CAGE "gimp-tool-cage"
#define GIMP_HELP_TOOL_CLONE "gimp-tool-clone"
#define GIMP_HELP_TOOL_COLORIZE "gimp-tool-colorize"
#define GIMP_HELP_TOOL_COLOR_BALANCE "gimp-tool-color-balance"

View File

@ -289,6 +289,7 @@ static const GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_BUCKET_FILL, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_BY_COLOR_SELECT, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_CAGE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_CLONE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_COLOR_PICKER, NULL, 0, 0, LIBGIMP_DOMAIN },
@ -441,6 +442,7 @@ gimp_stock_button_pixbufs[] =
{ GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST, stock_tool_brightness_contrast_22 },
{ GIMP_STOCK_TOOL_BUCKET_FILL, stock_tool_bucket_fill_22 },
{ GIMP_STOCK_TOOL_BY_COLOR_SELECT, stock_tool_by_color_select_22 },
{ GIMP_STOCK_TOOL_CAGE, stock_tool_cage_22 },
{ GIMP_STOCK_TOOL_CLONE, stock_tool_clone_22 },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, stock_tool_color_balance_22 },
{ GIMP_STOCK_TOOL_COLOR_PICKER, stock_tool_color_picker_22 },
@ -605,6 +607,7 @@ gimp_stock_menu_pixbufs[] =
{ GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST, stock_tool_brightness_contrast_16 },
{ GIMP_STOCK_TOOL_BUCKET_FILL, stock_tool_bucket_fill_16 },
{ GIMP_STOCK_TOOL_BY_COLOR_SELECT, stock_tool_by_color_select_16 },
{ GIMP_STOCK_TOOL_CAGE, stock_tool_cage_16 },
{ GIMP_STOCK_TOOL_CLONE, stock_tool_clone_16 },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, stock_tool_color_balance_16 },
{ GIMP_STOCK_TOOL_COLOR_PICKER, stock_tool_color_picker_16 },

View File

@ -104,6 +104,7 @@ G_BEGIN_DECLS
#define GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST "gimp-tool-brightness-contrast"
#define GIMP_STOCK_TOOL_BUCKET_FILL "gimp-tool-bucket-fill"
#define GIMP_STOCK_TOOL_BY_COLOR_SELECT "gimp-tool-by-color-select"
#define GIMP_STOCK_TOOL_CAGE "gimp-tool-cage"
#define GIMP_STOCK_TOOL_CLONE "gimp-tool-clone"
#define GIMP_STOCK_TOOL_COLOR_BALANCE "gimp-tool-color-balance"
#define GIMP_STOCK_TOOL_COLOR_PICKER "gimp-tool-color-picker"

View File

@ -273,6 +273,8 @@ STOCK_TOOL_IMAGES = \
tools/stock-tool-bucket-fill-22.png \
tools/stock-tool-by-color-select-16.png \
tools/stock-tool-by-color-select-22.png \
tools/stock-tool-cage-16.png \
tools/stock-tool-cage-22.png \
tools/stock-tool-clone-16.png \
tools/stock-tool-clone-22.png \
tools/stock-tool-color-balance-16.png \

View File

@ -246,6 +246,8 @@ STOCK_TOOL_VARIABLES = \
stock_tool_bucket_fill_22 tools/stock-tool-bucket-fill-22.png \
stock_tool_by_color_select_16 tools/stock-tool-by-color-select-16.png \
stock_tool_by_color_select_22 tools/stock-tool-by-color-select-22.png \
stock_tool_cage_16 tools/stock-tool-cage-16.png \
stock_tool_cage_22 tools/stock-tool-cage-22.png \
stock_tool_clone_16 tools/stock-tool-clone-16.png \
stock_tool_clone_22 tools/stock-tool-clone-22.png \
stock_tool_color_balance_16 tools/stock-tool-color-balance-16.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.