mirror of https://github.com/GNOME/gimp.git
cache the round-corners and corner-radius properties in the
2006-11-05 Michael Natterer <mitch@gimp.org> * app/tools/gimprectangleselecttool.[ch]: cache the round-corners and corner-radius properties in the GimpRectSelectTool struct, connect to "notify" of GimpRectSelectOptions and update display drawing when the options change. * app/tools/gimpcroptool.c * app/tools/gimprectangleoptions.c: whitespace stuff.
This commit is contained in:
parent
24aebd07c4
commit
2a64b58c97
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2006-11-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimprectangleselecttool.[ch]: cache the round-corners
|
||||
and corner-radius properties in the GimpRectSelectTool struct,
|
||||
connect to "notify" of GimpRectSelectOptions and update display
|
||||
drawing when the options change.
|
||||
|
||||
* app/tools/gimpcroptool.c
|
||||
* app/tools/gimprectangleoptions.c: whitespace stuff.
|
||||
|
||||
2006-11-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/tileit.c: applied patch from Saul Goode to fix
|
||||
|
|
|
@ -169,7 +169,7 @@ gimp_crop_tool_initialize (GimpTool *tool,
|
|||
GError **error)
|
||||
{
|
||||
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
||||
GObject *options = G_OBJECT (gimp_tool_get_options (tool));
|
||||
GObject *options = G_OBJECT (gimp_tool_get_options (tool));
|
||||
gboolean layer_only;
|
||||
|
||||
g_object_get (options,
|
||||
|
@ -181,9 +181,11 @@ gimp_crop_tool_initialize (GimpTool *tool,
|
|||
tool, 0);
|
||||
|
||||
if (layer_only)
|
||||
gimp_rectangle_tool_set_constraint (rectangle, GIMP_RECTANGLE_CONSTRAIN_DRAWABLE);
|
||||
gimp_rectangle_tool_set_constraint (rectangle,
|
||||
GIMP_RECTANGLE_CONSTRAIN_DRAWABLE);
|
||||
else
|
||||
gimp_rectangle_tool_set_constraint (rectangle, GIMP_RECTANGLE_CONSTRAIN_IMAGE);
|
||||
gimp_rectangle_tool_set_constraint (rectangle,
|
||||
GIMP_RECTANGLE_CONSTRAIN_IMAGE);
|
||||
|
||||
return gimp_rectangle_tool_initialize (tool, display, error);
|
||||
}
|
||||
|
@ -310,7 +312,7 @@ gimp_crop_tool_notify_layer_only (GimpCropOptions *options,
|
|||
GParamSpec *pspec,
|
||||
GimpTool *tool)
|
||||
{
|
||||
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
||||
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
||||
gboolean layer_only;
|
||||
|
||||
g_object_get (options,
|
||||
|
|
|
@ -36,42 +36,43 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define GIMP_RECTANGLE_OPTIONS_GET_PRIVATE(obj) (gimp_rectangle_options_get_private ((GimpRectangleOptions *) (obj)))
|
||||
#define GIMP_RECTANGLE_OPTIONS_GET_PRIVATE(obj) \
|
||||
(gimp_rectangle_options_get_private (GIMP_RECTANGLE_OPTIONS (obj)))
|
||||
|
||||
typedef struct _GimpRectangleOptionsPrivate GimpRectangleOptionsPrivate;
|
||||
|
||||
struct _GimpRectangleOptionsPrivate
|
||||
{
|
||||
gboolean auto_shrink;
|
||||
gboolean shrink_merged;
|
||||
gboolean auto_shrink;
|
||||
gboolean shrink_merged;
|
||||
|
||||
gboolean highlight;
|
||||
gboolean highlight;
|
||||
GimpRectangleGuide guide;
|
||||
|
||||
gdouble x0;
|
||||
gdouble y0;
|
||||
gdouble x0;
|
||||
gdouble y0;
|
||||
|
||||
gboolean fixed_width;
|
||||
gdouble width;
|
||||
gboolean fixed_width;
|
||||
gdouble width;
|
||||
|
||||
gboolean fixed_height;
|
||||
gdouble height;
|
||||
gboolean fixed_height;
|
||||
gdouble height;
|
||||
|
||||
gboolean fixed_aspect;
|
||||
gdouble aspect_numerator;
|
||||
gdouble aspect_denominator;
|
||||
gboolean fixed_aspect;
|
||||
gdouble aspect_numerator;
|
||||
gdouble aspect_denominator;
|
||||
|
||||
gboolean fixed_center;
|
||||
gdouble center_x;
|
||||
gdouble center_y;
|
||||
gboolean fixed_center;
|
||||
gdouble center_x;
|
||||
gdouble center_y;
|
||||
|
||||
GimpUnit unit;
|
||||
GimpUnit unit;
|
||||
};
|
||||
|
||||
static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface);
|
||||
static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface);
|
||||
|
||||
static GimpRectangleOptionsPrivate *
|
||||
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
|
||||
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
|
||||
|
||||
|
||||
GType
|
||||
|
|
|
@ -110,6 +110,9 @@ static void gimp_rect_select_tool_real_select (GimpRectSelectTool *r
|
|||
gint w,
|
||||
gint h);
|
||||
|
||||
static void gimp_rect_select_tool_round_corners_notify (GimpRectSelectOptions *options,
|
||||
GParamSpec *pspec,
|
||||
GimpRectSelectTool *rect_sel);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectTool, gimp_rect_select_tool,
|
||||
|
@ -193,14 +196,26 @@ gimp_rect_select_tool_constructor (GType type,
|
|||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpTool *tool;
|
||||
GObject *object;
|
||||
GimpRectSelectTool *rect_sel;
|
||||
GimpRectSelectOptions *options;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
gimp_rectangle_tool_constructor (object);
|
||||
rect_sel = GIMP_RECT_SELECT_TOOL (object);
|
||||
options = GIMP_RECT_SELECT_TOOL_GET_OPTIONS (rect_sel);
|
||||
|
||||
tool = GIMP_TOOL (object);
|
||||
rect_sel->round_corners = options->round_corners;
|
||||
rect_sel->corner_radius = options->corner_radius;
|
||||
|
||||
g_signal_connect_object (options, "notify::round-corners",
|
||||
G_CALLBACK (gimp_rect_select_tool_round_corners_notify),
|
||||
object, 0);
|
||||
g_signal_connect_object (options, "notify::corner-radius",
|
||||
G_CALLBACK (gimp_rect_select_tool_round_corners_notify),
|
||||
object, 0);
|
||||
|
||||
gimp_rectangle_tool_constructor (object);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -218,24 +233,24 @@ gimp_rect_select_tool_control (GimpTool *tool,
|
|||
static void
|
||||
gimp_rect_select_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
||||
GimpRectSelectOptions *options = GIMP_RECT_SELECT_TOOL_GET_OPTIONS (rect_sel);
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
||||
|
||||
g_object_get (rect_sel,
|
||||
"x1", &x1,
|
||||
"y1", &y1,
|
||||
"x2", &x2,
|
||||
"y2", &y2,
|
||||
NULL);
|
||||
gimp_rectangle_tool_draw (draw_tool);
|
||||
|
||||
if (options->round_corners)
|
||||
if (rect_sel->round_corners)
|
||||
{
|
||||
gint x1, y1, x2, y2;
|
||||
gdouble radius;
|
||||
gint square_size;
|
||||
|
||||
radius = MIN (options->corner_radius,
|
||||
g_object_get (rect_sel,
|
||||
"x1", &x1,
|
||||
"y1", &y1,
|
||||
"x2", &x2,
|
||||
"y2", &y2,
|
||||
NULL);
|
||||
|
||||
radius = MIN (rect_sel->corner_radius,
|
||||
MIN ((x2 - x1) / 2.0, (y2 - y1) / 2.0));
|
||||
|
||||
square_size = (int) (radius * 2);
|
||||
|
@ -264,8 +279,6 @@ gimp_rect_select_tool_draw (GimpDrawTool *draw_tool)
|
|||
180 * 64, 90 * 64,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
gimp_rectangle_tool_draw (draw_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -752,3 +765,16 @@ gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_round_corners_notify (GimpRectSelectOptions *options,
|
||||
GParamSpec *pspec,
|
||||
GimpRectSelectTool *rect_sel)
|
||||
{
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (rect_sel));
|
||||
|
||||
rect_sel->round_corners = options->round_corners;
|
||||
rect_sel->corner_radius = options->corner_radius;
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rect_sel));
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ struct _GimpRectSelectTool
|
|||
gboolean saved_show_selection; /* used to remember existing value */
|
||||
GimpUndo *undo;
|
||||
GimpUndo *redo;
|
||||
|
||||
gboolean round_corners;
|
||||
gdouble corner_radius;
|
||||
};
|
||||
|
||||
struct _GimpRectSelectToolClass
|
||||
|
|
Loading…
Reference in New Issue