Commit 5a9f83bd authored by Karine Delvare's avatar Karine Delvare Committed by Karine Delvare

app/tools/gimprectangletool.[ch] transform into an interface.

2005-08-15  Karine Delvare  <kdelvare@nerim.net>

        * app/tools/gimprectangletool.[ch]
        * app/tools/gimprectangleoptions.[ch]: transform into an interface.

        * app/tools/gimpcroptool.[ch]
        * app/tools/gimpnewrectselecttool.[ch]: use the rectangletool interface.

        * app/tools/gimpcropoptions.[ch]
        * app/tools/gimpnewrectselectoptions.[ch]: use the rectangleoptions
        interface.

        * app/tools/Makefile.am: added gimpnewrectselectionoptions.[ch]
parent 47f84a8b
2005-08-15 Karine Delvare <kdelvare@nerim.net>
* app/tools/gimprectangletool.[ch]
* app/tools/gimprectangleoptions.[ch]: transform into an interface.
* app/tools/gimpcroptool.[ch]
* app/tools/gimpnewrectselecttool.[ch]: use the rectangletool interface.
* app/tools/gimpcropoptions.[ch]
* app/tools/gimpnewrectselectoptions.[ch]: use the rectangleoptions
interface.
* app/tools/Makefile.am: added gimpnewrectselectionoptions.[ch]
2005-08-15 Sven Neumann <sven@gimp.org>
* plug-ins/rcm/rcm_callback.c
......
......@@ -118,6 +118,8 @@ libapptools_a_sources = \
gimpposterizetool.h \
gimpnewrectselecttool.c \
gimpnewrectselecttool.h \
gimpnewrectselectoptions.c \
gimpnewrectselectoptions.h \
gimprectangletool.c \
gimprectangletool.h \
gimprectangleoptions.c \
......
This diff is collapsed.
......@@ -39,9 +39,24 @@ struct _GimpCropOptions
GimpToolOptions parent_instence;
gboolean layer_only;
gboolean allow_enlarge;
gboolean keep_aspect;
GimpCropMode crop_mode;
gboolean highlight;
gboolean fixed_width;
gdouble width;
gboolean fixed_height;
gdouble height;
gboolean fixed_aspect;
gdouble aspect;
gboolean fixed_center;
gdouble center_x;
gdouble center_y;
GimpUnit unit;
};
......
This diff is collapsed.
......@@ -19,12 +19,6 @@
#ifndef __GIMP_CROP_TOOL_H__
#define __GIMP_CROP_TOOL_H__
#ifdef __GNUC__
#warning FIXME #include "gui/gui-types.h"
#endif
#include "gui/gui-types.h"
#include "gimpdrawtool.h"
......@@ -32,7 +26,8 @@
#define GIMP_CROP_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CROP_TOOL, GimpCropTool))
#define GIMP_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CROP_TOOL, GimpCropToolClass))
#define GIMP_IS_CROP_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CROP_TOOL))
#define GIMP_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CROP_TOOL, GimpCropToolClass))
#define GIMP_IS_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CROP_TOOL))
#define GIMP_CROP_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CROP_TOOL, GimpCropToolClass))
typedef struct _GimpCropTool GimpCropTool;
......@@ -42,12 +37,18 @@ struct _GimpCropTool
{
GimpDrawTool parent_instance;
GtkWidget *controls;
GtkWidget *dimensions_entry;
gint startx; /* starting x coord */
gint starty; /* starting y coord */
gint lastx; /* previous x coord */
gint lasty; /* previous y coord */
gint pressx; /* x where button pressed */
gint pressy; /* y where button pressed */
gint x1, y1; /* upper left hand coordinate */
gint x2, y2; /* lower right hand coords */
......@@ -56,22 +57,10 @@ struct _GimpCropTool
gint dx1, dy1; /* display coords */
gint dx2, dy2; /* */
gint dcw, dch; /* width and height of corners */
/* the crop dialog */
InfoDialog *crop_info;
gdouble orig_vals[2];
gdouble size_vals[2];
gdouble aspect_ratio;
gboolean change_aspect_ratio; /* Boolean for the crop_info_update function */
/* aspect_ratio should not be chaget whith */
/* crop_info_update when is called from */
/* crop_aspect_changed, due to the innacurate*/
/* decimal precision */
gint dcw, dch; /* width and height of edges */
GtkWidget *origin_sizeentry;
GtkWidget *size_sizeentry;
gdouble origx, origy;
gdouble sizew, sizeh;
};
struct _GimpCropToolClass
......
This diff is collapsed.
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_NEW_RECT_SELECT_OPTIONS_H__
#define __GIMP_NEW_RECT_SELECT_OPTIONS_H__
#include "gimpselectionoptions.h"
#define GIMP_TYPE_NEW_RECT_SELECT_OPTIONS (gimp_new_rect_select_options_get_type ())
#define GIMP_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptions))
#define GIMP_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
#define GIMP_NEW_RECT_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
typedef struct _GimpNewRectSelectOptions GimpNewRectSelectOptions;
typedef struct _GimpToolOptionsClass GimpNewRectSelectOptionsClass;
struct _GimpNewRectSelectOptions
{
GimpSelectionOptions parent_instence;
gboolean highlight;
gboolean fixed_width;
gdouble width;
gboolean fixed_height;
gdouble height;
gboolean fixed_aspect;
gdouble aspect;
gboolean fixed_center;
gdouble center_x;
gdouble center_y;
GimpUnit unit;
};
GType gimp_new_rect_select_options_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_new_rect_select_options_gui (GimpToolOptions *tool_options);
#endif /* __GIMP_NEW_RECT_SELECT_OPTIONS_H__ */
This diff is collapsed.
......@@ -19,14 +19,14 @@
#ifndef __GIMP_NEW_RECT_SELECT_TOOL_H__
#define __GIMP_NEW_RECT_SELECT_TOOL_H__
#include "gimprectangletool.h"
#include "gimpselectiontool.h"
#define GIMP_TYPE_NEW_RECT_SELECT_TOOL (gimp_new_rect_select_tool_get_type ())
#define GIMP_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectTool))
#define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
#define GIMP_IS_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
#define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
#define GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
......@@ -35,17 +35,42 @@ typedef struct _GimpNewRectSelectToolClass GimpNewRectSelectToolClass;
struct _GimpNewRectSelectTool
{
GimpRectangleTool parent_instance;
GimpSelectionTool parent_instance;
GtkWidget *controls;
GtkWidget *dimensions_entry;
gint startx; /* starting x coord */
gint starty; /* starting y coord */
gint lastx; /* previous x coord */
gint lasty; /* previous y coord */
gint pressx; /* x where button pressed */
gint pressy; /* y where button pressed */
gint x1, y1; /* upper left hand coordinate */
gint x2, y2; /* lower right hand coords */
guint function; /* moving or resizing */
gint dx1, dy1; /* display coords */
gint dx2, dy2; /* */
gint dcw, dch; /* width and height of edges */
gdouble origx, origy;
gdouble sizew, sizeh;
};
struct _GimpNewRectSelectToolClass
{
GimpRectangleToolClass parent_class;
GimpSelectionToolClass parent_class;
};
void gimp_new_rect_select_tool_register (GimpToolRegisterCallback callback,
gpointer data);
gpointer data);
GType gimp_new_rect_select_tool_get_type (void) G_GNUC_CONST;
......
......@@ -26,13 +26,6 @@
#include "tools-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimprectangleoptions.h"
#include "gimptooloptions-gui.h"
......@@ -56,202 +49,360 @@ enum
};
static void gimp_rectangle_options_class_init (GimpRectangleOptionsClass *options_class);
static void gimp_rectangle_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_rectangle_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpToolOptionsClass *parent_class = NULL;
static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface);
GType
gimp_rectangle_options_get_type (void)
gimp_rectangle_options_interface_get_type (void)
{
static GType type = 0;
static GType rectangle_options_iface_type = 0;
if (! type)
if (!rectangle_options_iface_type)
{
static const GTypeInfo info =
static const GTypeInfo rectangle_options_iface_info =
{
sizeof (GimpRectangleOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_rectangle_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpRectangleOptions),
0, /* n_preallocs */
(GInstanceInitFunc) NULL
sizeof (GimpRectangleOptionsInterface),
(GBaseInitFunc) gimp_rectangle_options_iface_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (GIMP_TYPE_SELECTION_OPTIONS,
"GimpRectangleOptions",
&info, 0);
rectangle_options_iface_type = g_type_register_static (G_TYPE_INTERFACE,
"GimpRectangleOptionsInterface",
&rectangle_options_iface_info,
0);
}
return type;
return rectangle_options_iface_type;
}
static void
gimp_rectangle_options_class_init (GimpRectangleOptionsClass *klass)
gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_rectangle_options_set_property;
object_class->get_property = gimp_rectangle_options_get_property;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HIGHLIGHT,
"highlight",
N_("Highlight rectangle"),
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FIXED_WIDTH,
"fixed-width", N_("Fixed width"),
FALSE, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_WIDTH,
"width", N_("Width"),
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FIXED_HEIGHT,
"fixed-height", N_("Fixed height"),
FALSE, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_HEIGHT,
"height", N_("Height"),
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FIXED_ASPECT,
"fixed-aspect", N_("Fixed aspect"),
FALSE, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_ASPECT,
"aspect", N_("Aspect"),
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FIXED_CENTER,
"fixed-center", N_("Fixed center"),
FALSE, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_CENTER_X,
"center-x", N_("Center X"),
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_CENTER_Y,
"center-y", N_("Center Y"),
0.0, GIMP_MAX_IMAGE_SIZE, 1.0,
0);
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_UNIT,
"unit", NULL,
TRUE, FALSE, GIMP_UNIT_PIXEL, 0);
static gboolean initialized = FALSE;
if (! initialized)
{
initialized = TRUE;
}
}
static void
gimp_rectangle_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
void
gimp_rectangle_options_set_highlight (GimpRectangleOptions *options,
gboolean highlight)
{
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptionsInterface *options_iface;
switch (property_id)
{
case PROP_HIGHLIGHT:
options->highlight = g_value_get_boolean (value);
break;
case PROP_FIXED_WIDTH:
options->fixed_width = g_value_get_boolean (value);
break;
case PROP_WIDTH:
options->width = g_value_get_double (value);
break;
case PROP_FIXED_HEIGHT:
options->fixed_height = g_value_get_boolean (value);
break;
case PROP_HEIGHT:
options->height = g_value_get_double (value);
break;
case PROP_FIXED_ASPECT:
options->fixed_aspect = g_value_get_boolean (value);
break;
case PROP_ASPECT:
options->aspect = g_value_get_double (value);
break;
case PROP_FIXED_CENTER:
options->fixed_center = g_value_get_boolean (value);
break;
case PROP_CENTER_X:
options->center_x = g_value_get_double (value);
break;
case PROP_CENTER_Y:
options->center_y = g_value_get_double (value);
break;
case PROP_UNIT:
options->unit = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->set_highlight)
options_iface->set_highlight (options, highlight);
}
static void
gimp_rectangle_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
gboolean
gimp_rectangle_options_get_highlight (GimpRectangleOptions *options)
{
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptionsInterface *options_iface;
switch (property_id)
{
case PROP_HIGHLIGHT:
g_value_set_boolean (value, options->highlight);
break;
case PROP_FIXED_WIDTH:
g_value_set_boolean (value, options->fixed_width);
break;
case PROP_WIDTH:
g_value_set_double (value, options->width);
break;
case PROP_FIXED_HEIGHT:
g_value_set_boolean (value, options->fixed_height);
break;
case PROP_HEIGHT:
g_value_set_double (value, options->height);
break;
case PROP_FIXED_ASPECT:
g_value_set_boolean (value, options->fixed_aspect);
break;
case PROP_ASPECT:
g_value_set_double (value, options->aspect);
break;
case PROP_FIXED_CENTER:
g_value_set_boolean (value, options->fixed_center);
break;
case PROP_CENTER_X:
g_value_set_double (value, options->center_x);
break;
case PROP_CENTER_Y:
g_value_set_double (value, options->center_y);
break;
case PROP_UNIT:
g_value_set_int (value, options->unit);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->get_highlight)
return options_iface->get_highlight (options);
return FALSE;
}
void
gimp_rectangle_options_set_fixed_width (GimpRectangleOptions *options,
gboolean fixed_width)
{
GimpRectangleOptionsInterface *options_iface;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->set_fixed_width)
options_iface->set_fixed_width (options, fixed_width);
}
gboolean
gimp_rectangle_options_get_fixed_width (GimpRectangleOptions *options)
{
GimpRectangleOptionsInterface *options_iface;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->get_fixed_width)
return options_iface->get_fixed_width (options);
return FALSE;
}
void
gimp_rectangle_options_set_width (GimpRectangleOptions *options,
gdouble width)
{
GimpRectangleOptionsInterface *options_iface;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->set_width)
options_iface->set_width (options, width);
}
gdouble
gimp_rectangle_options_get_width (GimpRectangleOptions *options)
{
GimpRectangleOptionsInterface *options_iface;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->get_width)
return options_iface->get_width (options);
return 0;
}
void
gimp_rectangle_options_set_fixed_height (GimpRectangleOptions *options,
gboolean fixed_height)
{
GimpRectangleOptionsInterface *options_iface;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->set_fixed_height)
options_iface->set_fixed_height (options, fixed_height);
}
gboolean
gimp_rectangle_options_get_fixed_height (GimpRectangleOptions *options)
{
GimpRectangleOptionsInterface *options_iface;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->get_fixed_height)
return options_iface->get_fixed_height (options);
return FALSE;
}
void
gimp_rectangle_options_set_height (GimpRectangleOptions *options,
gdouble height)
{
GimpRectangleOptionsInterface *options_iface;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
options_iface = GIMP_RECTANGLE_OPTIONS_GET_INTERFACE (options);
if (options_iface->set_height)
options_iface->set_height (options, height);
}
gdouble
gimp_rectangle_options_get_height (GimpRectangleOptions *options)
{
GimpRectangleOptionsInterface *options_iface;