Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/widgets/gimppropwidgets.c (gimp_prop_aspect_ratio_new):
	some small bug-fixes.

	* app/tools/gimprectangleoptions.[ch]: major revision.  Got
	rid of lots of unneeded getter/setter-clutter, simplified
	set of options and appearance of gui.  Still work in progress.

	* app/tools/gimprectangleselectoptions.c
	* app/tools/gimprectangletool.c: corresponding changes.
This commit is contained in:
William Skaggs 2006-09-21 20:16:25 +00:00
parent 43eb155668
commit 24546bc818
6 changed files with 187 additions and 852 deletions

View File

@ -1,3 +1,15 @@
2006-09-21 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/widgets/gimppropwidgets.c (gimp_prop_aspect_ratio_new):
some small bug-fixes.
* app/tools/gimprectangleoptions.[ch]: major revision. Got
rid of lots of unneeded getter/setter-clutter, simplified
set of options and appearance of gui. Still work in progress.
* app/tools/gimprectangleselectoptions.c
* app/tools/gimprectangletool.c: corresponding changes.
2006-09-21 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimpselectionoptions.[ch]: remove

View File

@ -45,6 +45,9 @@ struct _GimpRectangleOptionsPrivate
gboolean highlight;
GimpRectangleGuide guide;
gdouble x0;
gdouble y0;
gboolean fixed_width;
gdouble width;
@ -54,17 +57,12 @@ struct _GimpRectangleOptionsPrivate
gboolean fixed_aspect;
gdouble aspect_numerator;
gdouble aspect_denominator;
gboolean aspect_square; /* if set, overrides fixed-aspect setting */
gboolean fixed_center;
gdouble center_x;
gdouble center_y;
GimpUnit unit;
gboolean controls_expanded; /* show entries for width, height, etc */
GtkWidget *dimensions_entry;
};
static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface);
@ -72,68 +70,6 @@ static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInte
static GimpRectangleOptionsPrivate *
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
gboolean gimp_rectangle_options_get_highlight (GimpRectangleOptions *options);
void gimp_rectangle_options_set_guide (GimpRectangleOptions *options,
GimpRectangleGuide guide);
GimpRectangleGuide
gimp_rectangle_options_get_guide (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_width (GimpRectangleOptions *options,
gboolean fixed_width);
gboolean gimp_rectangle_options_get_fixed_width (GimpRectangleOptions *options);
void gimp_rectangle_options_set_width (GimpRectangleOptions *options,
gdouble width);
gdouble gimp_rectangle_options_get_width (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_height (GimpRectangleOptions *options,
gboolean fixed_height);
gboolean gimp_rectangle_options_get_fixed_height (GimpRectangleOptions *options);
void gimp_rectangle_options_set_height (GimpRectangleOptions *options,
gdouble height);
gdouble gimp_rectangle_options_get_height (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_aspect (GimpRectangleOptions *options,
gboolean fixed_aspect);
gboolean gimp_rectangle_options_get_fixed_aspect (GimpRectangleOptions *options);
void gimp_rectangle_options_set_aspect_numerator
(GimpRectangleOptions *options,
gdouble val);
gdouble gimp_rectangle_options_get_aspect_numerator
(GimpRectangleOptions *options);
void gimp_rectangle_options_set_aspect_denominator
(GimpRectangleOptions *options,
gdouble val);
gdouble gimp_rectangle_options_get_aspect_denominator
(GimpRectangleOptions *options);
void gimp_rectangle_options_set_aspect_square (GimpRectangleOptions *options,
gboolean square);
gboolean gimp_rectangle_options_get_aspect_square (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_center (GimpRectangleOptions *options,
gboolean fixed_center);
gboolean gimp_rectangle_options_get_fixed_center (GimpRectangleOptions *options);
void gimp_rectangle_options_set_center_x (GimpRectangleOptions *options,
gdouble center_x);
gdouble gimp_rectangle_options_get_center_x (GimpRectangleOptions *options);
void gimp_rectangle_options_set_center_y (GimpRectangleOptions *options,
gdouble center_y);
gdouble gimp_rectangle_options_get_center_y (GimpRectangleOptions *options);
void gimp_rectangle_options_set_unit (GimpRectangleOptions *options,
GimpUnit unit);
GimpUnit gimp_rectangle_options_get_unit (GimpRectangleOptions *options);
void gimp_rectangle_options_set_controls_expanded (GimpRectangleOptions *options,
gboolean expanded);
gboolean gimp_rectangle_options_get_controls_expanded (GimpRectangleOptions *options);
void gimp_rectangle_options_set_entry (GimpRectangleOptions *options,
GtkWidget *entry);
GtkWidget * gimp_rectangle_options_get_entry (GimpRectangleOptions *options);
static void rectangle_dimensions_changed (GtkWidget *widget,
GimpRectangleOptions *options);
GType
gimp_rectangle_options_interface_get_type (void)
@ -181,7 +117,23 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("new-fixed-width",
g_param_spec_double ("x0",
NULL, NULL,
0.0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("y0",
NULL, NULL,
0.0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("fixed-width",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
@ -195,7 +147,7 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("new-fixed-height",
g_param_spec_boolean ("fixed-height",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
@ -220,7 +172,7 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
g_param_spec_double ("aspect-numerator",
NULL, NULL,
0.0, GIMP_MAX_IMAGE_SIZE,
0.0,
1.0,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
@ -232,13 +184,6 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("aspect-square",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("fixed-center",
NULL, NULL,
@ -264,7 +209,7 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_object_interface_install_property (iface,
gimp_param_spec_unit ("unit",
NULL, NULL,
TRUE, TRUE,
@ -272,29 +217,10 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("controls-expanded",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_object ("dimensions-entry",
NULL, NULL,
GTK_TYPE_WIDGET,
GIMP_PARAM_READWRITE));
initialized = TRUE;
}
}
/*static void
gimp_rectangle_options_private_dispose (GimpRectangleOptions *options,
GimpRectangleOptionsPrivate *private)
{
}*/
static void
gimp_rectangle_options_private_finalize (GimpRectangleOptionsPrivate *private)
{
@ -321,10 +247,6 @@ gimp_rectangle_options_get_private (GimpRectangleOptions *options)
g_object_set_qdata_full (G_OBJECT (options), private_key, private,
(GDestroyNotify) gimp_rectangle_options_private_finalize);
/*g_signal_connect (options, "destroy",
G_CALLBACK (gimp_rectangle_options_private_dispose),
private);*/
}
return private;
@ -350,15 +272,21 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
"guide");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_X0,
"x0");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_Y0,
"y0");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH,
"new-fixed-width");
"fixed-width");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_WIDTH,
"width");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT,
"new-fixed-height");
"fixed-height");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT,
"height");
@ -371,9 +299,6 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
"aspect-denominator");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE,
"aspect-square");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
"fixed-center");
@ -386,428 +311,6 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_UNIT,
"unit");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_CONTROLS_EXPANDED,
"controls-expanded");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY,
"dimensions-entry");
}
void
gimp_rectangle_options_set_highlight (GimpRectangleOptions *options,
gboolean highlight)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->highlight = highlight;
g_object_notify (G_OBJECT (options), "highlight");
}
gboolean
gimp_rectangle_options_get_highlight (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->highlight;
}
void
gimp_rectangle_options_set_guide (GimpRectangleOptions *options,
GimpRectangleGuide guide)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->guide = guide;
g_object_notify (G_OBJECT (options), "guide");
}
GimpRectangleGuide
gimp_rectangle_options_get_guide (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->guide;
}
void
gimp_rectangle_options_set_fixed_width (GimpRectangleOptions *options,
gboolean fixed_width)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->fixed_width = fixed_width;
g_object_notify (G_OBJECT (options), "new-fixed-width");
}
gboolean
gimp_rectangle_options_get_fixed_width (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->fixed_width;
}
void
gimp_rectangle_options_set_width (GimpRectangleOptions *options,
gdouble width)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->width = width;
g_object_notify (G_OBJECT (options), "width");
}
gdouble
gimp_rectangle_options_get_width (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->width;
}
void
gimp_rectangle_options_set_fixed_height (GimpRectangleOptions *options,
gboolean fixed_height)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->fixed_height = fixed_height;
g_object_notify (G_OBJECT (options), "new-fixed-height");
}
gboolean
gimp_rectangle_options_get_fixed_height (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->fixed_height;
}
void
gimp_rectangle_options_set_height (GimpRectangleOptions *options,
gdouble height)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->height = height;
g_object_notify (G_OBJECT (options), "height");
}
gdouble
gimp_rectangle_options_get_height (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->height;
}
void
gimp_rectangle_options_set_fixed_aspect (GimpRectangleOptions *options,
gboolean fixed_aspect)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->fixed_aspect = fixed_aspect;
g_object_notify (G_OBJECT (options), "fixed-aspect");
}
gboolean
gimp_rectangle_options_get_fixed_aspect (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->fixed_aspect;
}
void
gimp_rectangle_options_set_aspect_numerator (GimpRectangleOptions *options,
gdouble val)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->aspect_numerator = val;
g_object_notify (G_OBJECT (options), "aspect-numerator");
}
gdouble
gimp_rectangle_options_get_aspect_numerator (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->aspect_numerator;
}
void
gimp_rectangle_options_set_aspect_denominator (GimpRectangleOptions *options,
gdouble val)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->aspect_denominator = val;
g_object_notify (G_OBJECT (options), "aspect-denominator");
}
gdouble
gimp_rectangle_options_get_aspect_denominator (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->aspect_denominator;
}
void
gimp_rectangle_options_set_aspect_square (GimpRectangleOptions *options,
gboolean square)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->aspect_square = square;
g_object_notify (G_OBJECT (options), "aspect-square");
}
gboolean
gimp_rectangle_options_get_aspect_square (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->aspect_square;
}
void
gimp_rectangle_options_set_fixed_center (GimpRectangleOptions *options,
gboolean fixed_center)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->fixed_center = fixed_center;
g_object_notify (G_OBJECT (options), "fixed-center");
}
gboolean
gimp_rectangle_options_get_fixed_center (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->fixed_center;
}
void
gimp_rectangle_options_set_center_x (GimpRectangleOptions *options,
gdouble center_x)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->center_x = center_x;
g_object_notify (G_OBJECT (options), "center-x");
}
gdouble
gimp_rectangle_options_get_center_x (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->center_x;
}
void
gimp_rectangle_options_set_center_y (GimpRectangleOptions *options,
gdouble center_y)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->center_y = center_y;
g_object_notify (G_OBJECT (options), "center-y");
}
gdouble
gimp_rectangle_options_get_center_y (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), 0);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->center_y;
}
void
gimp_rectangle_options_set_unit (GimpRectangleOptions *options,
GimpUnit unit)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->unit = unit;
g_object_notify (G_OBJECT (options), "unit");
}
GimpUnit
gimp_rectangle_options_get_unit (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), GIMP_UNIT_PIXEL);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->unit;
}
void
gimp_rectangle_options_set_controls_expanded (GimpRectangleOptions *options,
gboolean expanded)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->controls_expanded = expanded;
g_object_notify (G_OBJECT (options), "controls-expanded");
}
gboolean
gimp_rectangle_options_get_controls_expanded (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->controls_expanded;
}
void
gimp_rectangle_options_set_entry (GimpRectangleOptions *options,
GtkWidget *entry)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->dimensions_entry = entry;
g_object_notify (G_OBJECT (options), "dimensions-entry");
}
GtkWidget *
gimp_rectangle_options_get_entry (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), NULL);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->dimensions_entry;
}
void
@ -816,57 +319,57 @@ gimp_rectangle_options_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptionsPrivate *private;
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
switch (property_id)
{
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
gimp_rectangle_options_set_highlight (options, g_value_get_boolean (value));
private->highlight = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
gimp_rectangle_options_set_guide (options, g_value_get_enum (value));
private->guide = g_value_get_enum (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_X0:
private->x0 = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_Y0:
private->y0 = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
gimp_rectangle_options_set_fixed_width (options, g_value_get_boolean (value));
private->fixed_width = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
gimp_rectangle_options_set_width (options, g_value_get_double (value));
private->width = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:
gimp_rectangle_options_set_fixed_height (options, g_value_get_boolean (value));
private->fixed_height = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT:
gimp_rectangle_options_set_height (options, g_value_get_double (value));
private->height = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT:
gimp_rectangle_options_set_fixed_aspect (options, g_value_get_boolean (value));
private->fixed_aspect = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR:
gimp_rectangle_options_set_aspect_numerator (options, g_value_get_double (value));
private->aspect_numerator = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
gimp_rectangle_options_set_aspect_denominator (options, g_value_get_double (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE:
gimp_rectangle_options_set_aspect_square (options, g_value_get_boolean (value));
private->aspect_denominator = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
gimp_rectangle_options_set_fixed_center (options, g_value_get_boolean (value));
private->fixed_center = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
gimp_rectangle_options_set_center_x (options, g_value_get_double (value));
private->center_x = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
gimp_rectangle_options_set_center_y (options, g_value_get_double (value));
private->center_y = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_UNIT:
gimp_rectangle_options_set_unit (options, g_value_get_int (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CONTROLS_EXPANDED:
gimp_rectangle_options_set_controls_expanded (options, g_value_get_boolean (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY:
gimp_rectangle_options_set_entry (options, g_value_get_object (value));
private->unit = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -880,57 +383,58 @@ gimp_rectangle_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
GimpRectangleOptionsPrivate *private;
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
switch (property_id)
{
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
g_value_set_boolean (value, gimp_rectangle_options_get_highlight (options));
g_value_set_boolean (value, private->highlight);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
g_value_set_enum (value, gimp_rectangle_options_get_guide (options));
g_value_set_enum (value, private->guide);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_X0:
g_value_set_double (value, private->x0);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_Y0:
g_value_set_double (value, private->y0);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_width (options));
g_value_set_boolean (value, private->fixed_width);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
g_value_set_double (value, gimp_rectangle_options_get_width (options));
g_value_set_double (value, private->width);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_height (options));
g_value_set_boolean (value, private->fixed_height);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT:
g_value_set_double (value, gimp_rectangle_options_get_height (options));
g_value_set_double (value, private->height);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_aspect (options));
g_value_set_boolean (value, private->fixed_aspect);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR:
g_value_set_double (value, gimp_rectangle_options_get_aspect_numerator (options));
g_value_set_double (value, private->aspect_numerator);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
g_value_set_double (value, gimp_rectangle_options_get_aspect_denominator (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE:
g_value_set_boolean (value, gimp_rectangle_options_get_aspect_square (options));
g_value_set_double (value, private->aspect_denominator);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_center (options));
g_value_set_boolean (value, private->fixed_center);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
g_value_set_double (value, gimp_rectangle_options_get_center_x (options));
g_value_set_double (value, private->center_x);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
g_value_set_double (value, gimp_rectangle_options_get_center_y (options));
g_value_set_double (value, private->center_y);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_UNIT:
g_value_set_int (value, gimp_rectangle_options_get_unit (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CONTROLS_EXPANDED:
g_value_set_boolean (value, gimp_rectangle_options_get_controls_expanded (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY:
g_value_set_object (value, gimp_rectangle_options_get_entry (options));
g_value_set_int (value, private->unit);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -949,131 +453,84 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
GtkWidget *entry;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *vbox2;
GtkWidget *expander;
GtkObject *adjustment;
button = gimp_prop_check_button_new (config, "fixed-center",
_("Expand from center"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gimp_prop_check_button_new (config, "aspect-square",
_("Make square"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gimp_prop_check_button_new (config, "highlight",
_("Highlight"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
combo = gimp_prop_enum_combo_box_new (config, "guide", 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
expander = gimp_prop_expander_new (config, "controls-expanded",
_("Rectangle Controls"));
gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
gtk_widget_show (expander);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (expander), vbox2);
gtk_widget_show (vbox2);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
table = gtk_table_new (4, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 5);
label = gtk_label_new (_("Fix"));
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
gtk_widget_show (label);
button = gimp_prop_check_button_new (config, "new-fixed-width",
_("Width"));
/* Height */
button = gimp_prop_toggle_button_new (config, "fixed-width",
_("Fix"), FALSE);
gtk_widget_show (button);
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 1, 2);
entry = gimp_prop_size_entry_new (config, "width", "unit", "%a",
GIMP_SIZE_ENTRY_UPDATE_SIZE, 300);
label = gtk_label_new (_("Width"));
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
gtk_widget_show (label);
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (entry), FALSE);
gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 1, 2);
gtk_table_attach_defaults (GTK_TABLE (table), entry, 2, 3, 1, 2);
gtk_widget_show (entry);
button = gimp_prop_check_button_new (config, "new-fixed-height",
_("Height"));
/* Height */
button = gimp_prop_toggle_button_new (config, "fixed-height",
_("Fix"), FALSE);
gtk_widget_show (button);
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 2, 3);
label = gtk_label_new (_("Height"));
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);
gtk_widget_show (label);
entry = gimp_prop_size_entry_new (config, "height", "unit", "%a",
GIMP_SIZE_ENTRY_UPDATE_SIZE, 300);
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (entry), FALSE);
gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 2, 3);
gtk_table_attach_defaults (GTK_TABLE (table), entry, 2, 3, 2, 3);
gtk_widget_show (entry);
button = gimp_prop_check_button_new (config, "fixed-aspect",
_("Aspect"));
/* Aspect */
button = gimp_prop_toggle_button_new (config, "fixed-aspect",
_("Fix"), FALSE);
gtk_widget_show (button);
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 3, 4);
label = gtk_label_new (_("Aspect"));
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4);
gtk_widget_show (label);
hbox = gimp_prop_aspect_ratio_new (config,
"aspect-numerator",
"aspect-denominator",
3);
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 3, 4);
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 2, 3, 3, 4);
gtk_widget_show (hbox);
gtk_widget_show (table);
entry = gimp_size_entry_new (2, GIMP_UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE, 4,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
g_object_set (tool_options, "dimensions-entry", entry, NULL);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 10);
gtk_widget_show (hbox);
gtk_table_set_row_spacings (GTK_TABLE (entry), 3);
gtk_table_set_col_spacings (GTK_TABLE (entry), 3);
spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2);
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 1, 2, 2, 3);
gtk_widget_show (spinbutton);
spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2);
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 2, 3, 2, 3);
gtk_widget_show (spinbutton);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("1 "), 1, 0, 0.0);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("2 "), 2, 0, 0.0);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("X"), 0, 1, 0.5);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("Y"), 0, 2, 0.5);
gtk_box_pack_start (GTK_BOX (vbox2), entry, FALSE, FALSE, 0);
g_signal_connect (entry, "value-changed",
G_CALLBACK (rectangle_dimensions_changed),
tool_options);
gtk_widget_show (entry);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 0, 0);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 1, 0);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 2, 0);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 3, 0);
combo = gimp_prop_enum_combo_box_new (config, "guide", 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
return vbox;
}
static void
rectangle_dimensions_changed (GtkWidget *widget,
GimpRectangleOptions *options)
{
g_object_notify (G_OBJECT (options), "dimensions-entry");
}

View File

@ -25,6 +25,8 @@ typedef enum
GIMP_RECTANGLE_OPTIONS_PROP_0,
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT,
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
GIMP_RECTANGLE_OPTIONS_PROP_X0,
GIMP_RECTANGLE_OPTIONS_PROP_Y0,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT,
@ -32,14 +34,11 @@ typedef enum
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y,
GIMP_RECTANGLE_OPTIONS_PROP_UNIT,
GIMP_RECTANGLE_OPTIONS_PROP_CONTROLS_EXPANDED,
GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY,
GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY
GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_UNIT
} GimpRectangleOptionsProp;
@ -74,7 +73,5 @@ void gimp_rectangle_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
void gimp_rectangle_options_set_highlight (GimpRectangleOptions *options,
gboolean highlight);
#endif /* __GIMP_RECTANGLE_OPTIONS_H__ */

View File

@ -76,8 +76,9 @@ gimp_rect_select_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), vbox_rectangle, FALSE, FALSE, 0);
gtk_widget_show (vbox_rectangle);
gimp_rectangle_options_set_highlight (GIMP_RECTANGLE_OPTIONS (tool_options),
FALSE);
g_object_set (GIMP_RECTANGLE_OPTIONS (tool_options),
"highlight", FALSE,
NULL);
return vbox;
}

View File

@ -149,9 +149,6 @@ static void gimp_rectangle_tool_notify_highlight (GimpRectangleOptions *op
static void gimp_rectangle_tool_notify_guide (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle);
static void gimp_rectangle_tool_check_function (GimpRectangleTool *rectangle,
gint curx,
gint cury);
@ -658,6 +655,9 @@ gimp_rectangle_tool_constructor (GObject *object)
g_signal_connect_object (options, "notify::height",
G_CALLBACK (gimp_rectangle_tool_notify_height),
rectangle, 0);
g_signal_connect_object (options, "notify::fixed-aspect",
G_CALLBACK (gimp_rectangle_tool_notify_aspect),
rectangle, 0);
g_signal_connect_object (options, "notify::aspect-numerator",
G_CALLBACK (gimp_rectangle_tool_notify_aspect),
rectangle, 0);
@ -670,9 +670,6 @@ gimp_rectangle_tool_constructor (GObject *object)
g_signal_connect_object (options, "notify::guide",
G_CALLBACK (gimp_rectangle_tool_notify_guide),
rectangle, 0);
g_signal_connect_object (options, "notify::dimensions-entry",
G_CALLBACK (gimp_rectangle_tool_notify_dimensions),
rectangle, 0);
gimp_rectangle_tool_set_constraint (rectangle, GIMP_RECTANGLE_CONSTRAIN_NONE);
}
@ -696,9 +693,6 @@ gimp_rectangle_tool_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (options,
G_CALLBACK (gimp_rectangle_tool_notify_highlight),
rectangle);
g_signal_handlers_disconnect_by_func (options,
G_CALLBACK (gimp_rectangle_tool_notify_dimensions),
rectangle);
}
gboolean
@ -707,42 +701,11 @@ gimp_rectangle_tool_initialize (GimpTool *tool,
{
GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
GObject *options = G_OBJECT (gimp_tool_get_options (tool));
GimpSizeEntry *entry;
g_object_get (options,
"dimensions-entry", &entry,
"guide", &private->guide,
NULL);
if (display != tool->display)
{
gint width = gimp_image_get_width (display->image);
gint height = gimp_image_get_height (display->image);
GimpUnit unit;
gdouble xres;
gdouble yres;
gimp_size_entry_set_refval_boundaries (entry, 0, 0, height);
gimp_size_entry_set_refval_boundaries (entry, 1, 0, width);
gimp_size_entry_set_refval_boundaries (entry, 2, 0, width);
gimp_size_entry_set_refval_boundaries (entry, 3, 0, height);
gimp_size_entry_set_size (entry, 0, 0, height);
gimp_size_entry_set_size (entry, 1, 0, width);
gimp_size_entry_set_size (entry, 2, 0, width);
gimp_size_entry_set_size (entry, 3, 0, height);
gimp_image_get_resolution (display->image, &xres, &yres);
gimp_size_entry_set_resolution (entry, 0, yres, TRUE);
gimp_size_entry_set_resolution (entry, 1, xres, TRUE);
gimp_size_entry_set_resolution (entry, 2, xres, TRUE);
gimp_size_entry_set_resolution (entry, 3, yres, TRUE);
unit = gimp_display_shell_get_unit (GIMP_DISPLAY_SHELL (display->shell));
gimp_size_entry_set_unit (entry, unit);
}
return TRUE;
}
@ -938,7 +901,6 @@ gimp_rectangle_tool_motion (GimpTool *tool,
gboolean fixed_center;
gdouble width, height;
gdouble center_x, center_y;
gboolean aspect_square;
gdouble alpha;
gdouble beta;
@ -969,11 +931,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
return;
g_object_get (options,
"new-fixed-width", &fixed_width,
"new-fixed-height", &fixed_height,
"fixed-width", &fixed_width,
"fixed-height", &fixed_height,
"fixed-aspect", &fixed_aspect,
"fixed-center", &fixed_center,
"aspect-square", &aspect_square,
NULL);
g_object_get (options,
@ -1080,24 +1041,18 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break;
}
if (fixed_aspect || aspect_square)
if (fixed_aspect)
{
gdouble aspect;
gdouble numerator, denominator;
if (aspect_square)
aspect = 1;
else
{
gdouble numerator, denominator;
g_object_get (options,
"aspect-numerator", &numerator,
"aspect-denominator", &denominator,
NULL);
aspect = CLAMP (numerator / denominator,
1.0 / display->image->height,
display->image->width);
}
g_object_get (options,
"aspect-numerator", &numerator,
"aspect-denominator", &denominator,
NULL);
aspect = CLAMP (numerator / denominator,
1.0 / display->image->height,
display->image->width);
switch (function)
{
@ -1414,14 +1369,14 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
if (key == GDK_SHIFT_MASK)
{
gboolean aspect_square;
gboolean fixed_aspect;
g_object_get (options,
"aspect-square", &aspect_square,
"fixed-aspect", &fixed_aspect,
NULL);
g_object_set (options,
"aspect-square", ! aspect_square,
"fixed-aspect", ! fixed_aspect,
NULL);
}
@ -2261,14 +2216,10 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
GimpRectangleOptions *options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rectangle);
gdouble width;
gdouble height;
gdouble aspect;
gdouble center_x, center_y;
GimpSizeEntry *entry;
gint x1, y1, x2, y2;
gboolean fixed_width;
gboolean fixed_height;
gboolean fixed_aspect;
gboolean aspect_square;
g_object_get (rectangle,
"x1", &x1,
@ -2278,44 +2229,22 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
NULL);
g_object_get (options,
"new-fixed-width", &fixed_width,
"new-fixed-height", &fixed_height,
"fixed-aspect", &fixed_aspect,
"aspect-square", &aspect_square,
"dimensions-entry", &entry,
"fixed-width", &fixed_width,
"fixed-height", &fixed_height,
NULL);
width = x2 - x1;
height = y2 - y1;
if (aspect_square)
aspect = 1;
else if (height > 0.01)
aspect = width / height;
else
aspect = 0.0;
center_x = (x1 + x2) / 2.0;
center_y = (y1 + y2) / 2.0;
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_dimensions,
rectangle);
gimp_size_entry_set_refval (entry, 0, y2);
gimp_size_entry_set_refval (entry, 1, x2);
gimp_size_entry_set_refval (entry, 2, x1);
gimp_size_entry_set_refval (entry, 3, y1);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_width,
rectangle);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_height,
rectangle);
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_notify_aspect,
rectangle);
if (! fixed_width)
g_object_set (options,
@ -2327,30 +2256,18 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
"height", height,
NULL);
if (aspect_square || ! fixed_aspect)
g_object_set (options,
"aspect-numerator", aspect,
"aspect-denominator", 1.0,
NULL);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_width,
rectangle);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_height,
rectangle);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_aspect,
rectangle);
g_object_set (options,
"center-x", center_x,
"center-y", center_y,
NULL);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_dimensions,
rectangle);
}
/*
@ -2550,87 +2467,6 @@ gimp_rectangle_tool_notify_guide (GimpRectangleOptions *options,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rectangle));
}
static void
gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *options,
GParamSpec *pspec,
GimpRectangleTool *rectangle)
{
GimpRectangleToolPrivate *private;
gint rx1, rx2, ry1, ry2;
GimpCoords coords;
GimpSizeEntry *entry;
gdouble x1, y1, x2, y2;
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rectangle);
g_object_get (options, "dimensions-entry", &entry, NULL);
if (! GIMP_TOOL (rectangle)->display)
return;
g_object_get (rectangle,
"x1", &rx1,
"y1", &ry1,
"x2", &rx2,
"y2", &ry2,
NULL);
x1 = gimp_size_entry_get_refval (entry, 2);
y1 = gimp_size_entry_get_refval (entry, 3);
x2 = gimp_size_entry_get_refval (entry, 1);
y2 = gimp_size_entry_get_refval (entry, 0);
if (x1 != rx1)
{
coords.x = x1;
coords.y = y1;
g_object_set (rectangle,
"function", RECT_RESIZING_LEFT,
NULL);
private->startx = rx1;
private->starty = ry1;
}
else if (y1 != ry1)
{
coords.x = x1;
coords.y = y1;
g_object_set (rectangle,
"function", RECT_RESIZING_TOP,
NULL);
private->startx = rx1;
private->starty = ry1;
}
else if (x2 != rx2)
{
coords.x = x2;
coords.y = y2;
g_object_set (rectangle,
"function", RECT_RESIZING_RIGHT,
NULL);
private->startx = rx2;
private->starty = ry2;
}
else if (y2 != ry2)
{
coords.x = x2;
coords.y = y2;
g_object_set (rectangle,
"function", RECT_RESIZING_BOTTOM,
NULL);
private->startx = rx2;
private->starty = ry2;
}
else
return;
/* use the motion handler to handle this, to avoid duplicating
a bunch of code */
gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0,
GIMP_TOOL (rectangle)->display);
g_signal_emit_by_name (rectangle, "rectangle-changed", NULL);
}
gboolean
gimp_rectangle_tool_no_movement (GimpRectangleTool *rectangle)
{

View File

@ -500,12 +500,16 @@ connect_notify (GObject *config,
}
static void gimp_prop_numeric_entry_notify (GObject *config,
GParamSpec *param_spec,
GtkEntry *entry);
static void gimp_prop_numeric_entry_notify (GObject *config,
GParamSpec *param_spec,
GtkEntry *entry);
static void gimp_prop_numeric_entry_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_numeric_entry_callback (GtkWidget *widget,
GObject *config);
static gboolean gimp_prop_numeric_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event,
GObject *config);
/**
* gimp_prop_aspect_ratio_new:
@ -531,20 +535,33 @@ gimp_prop_aspect_ratio_new (GObject *config,
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
gdouble numerator;
gdouble denominator;
gchar num_string[20];
hbox = gtk_hbox_new (FALSE, 0);
g_object_get (config,
numerator_property, &numerator,
denominator_property, &denominator,
NULL);
/* numerator entry */
param_spec = find_param_spec (config, numerator_property, G_STRFUNC);
if (! param_spec)
return NULL;
entry = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (entry), 5);
sprintf (num_string, "%lg", numerator);
gtk_entry_set_text (GTK_ENTRY (entry), num_string);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
set_param_spec (G_OBJECT (entry), entry, param_spec);
g_signal_connect (entry, "activate",
G_CALLBACK (gimp_prop_numeric_entry_callback),
config);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (gimp_prop_numeric_entry_focus_out),
config);
connect_notify (config, numerator_property,
G_CALLBACK (gimp_prop_numeric_entry_notify),
entry);
@ -561,11 +578,16 @@ gimp_prop_aspect_ratio_new (GObject *config,
return NULL;
entry = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (entry), 5);
sprintf (num_string, "%lg", denominator);
gtk_entry_set_text (GTK_ENTRY (entry), num_string);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
set_param_spec (G_OBJECT (entry), entry, param_spec);
g_signal_connect (entry, "activate",
G_CALLBACK (gimp_prop_numeric_entry_callback),
config);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (gimp_prop_numeric_entry_focus_out),
config);
connect_notify (config, denominator_property,
G_CALLBACK (gimp_prop_numeric_entry_notify),
entry);
@ -590,6 +612,16 @@ gimp_prop_numeric_entry_notify (GObject *config,
gtk_entry_set_text (entry, text);
}
static gboolean
gimp_prop_numeric_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event,
GObject *config)
{
gimp_prop_numeric_entry_callback (widget, config);
return FALSE;
}
static void
gimp_prop_numeric_entry_callback (GtkWidget *widget,
GObject *config)