diff --git a/ChangeLog b/ChangeLog index 9b3a62e333..aff07d4976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-08-08 Martin Nordholts + + * app/tools/gimprectangleoptions.[ch]: Use separate + desired-fixed-size-width/height properties for Fixed: Size instead + of sharing properties with Fixed: Width/Height. + + * app/tools/gimprectangletool.c: Use the two new properties for + Fixed: Size. + 2007-08-07 Sven Neumann * plug-ins/print/print-page-layout.c: added entries for the right diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c index e0f25d2630..79ff42012f 100644 --- a/app/tools/gimprectangleoptions.c +++ b/app/tools/gimprectangleoptions.c @@ -199,6 +199,22 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface) GIMP_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_interface_install_property (iface, + g_param_spec_double ("desired-fixed-size-width", + NULL, NULL, + 0.0, GIMP_MAX_IMAGE_SIZE, + 100.0, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + + g_object_interface_install_property (iface, + g_param_spec_double ("desired-fixed-size-height", + NULL, NULL, + 0.0, GIMP_MAX_IMAGE_SIZE, + 100.0, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + g_object_interface_install_property (iface, g_param_spec_double ("center-x", NULL, NULL, @@ -323,6 +339,12 @@ gimp_rectangle_options_install_properties (GObjectClass *klass) g_object_class_override_property (klass, GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT, "desired-fixed-height"); + g_object_class_override_property (klass, + GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH, + "desired-fixed-size-width"); + g_object_class_override_property (klass, + GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT, + "desired-fixed-size-height"); g_object_class_override_property (klass, GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER, "fixed-center"); @@ -395,6 +417,12 @@ gimp_rectangle_options_set_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT: private->desired_fixed_height = g_value_get_double (value); break; + case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH: + private->desired_fixed_size_width = g_value_get_double (value); + break; + case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT: + private->desired_fixed_size_height = g_value_get_double (value); + break; case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X: private->center_x = g_value_get_double (value); break; @@ -469,6 +497,12 @@ gimp_rectangle_options_get_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT: g_value_set_double (value, private->desired_fixed_height); break; + case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH: + g_value_set_double (value, private->desired_fixed_size_width); + break; + case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT: + g_value_set_double (value, private->desired_fixed_size_height); + break; case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X: g_value_set_double (value, private->center_x); break; @@ -733,8 +767,8 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) /* TODO: This should not be an aspect speciallized entry. */ private->fixed_size_entry = gimp_prop_aspect_ratio_new (config, - "desired-fixed-width", - "desired-fixed-height", + "desired-fixed-size-width", + "desired-fixed-size-height", NULL); g_object_ref_sink (private->fixed_size_entry); gtk_widget_show (private->fixed_size_entry); diff --git a/app/tools/gimprectangleoptions.h b/app/tools/gimprectangleoptions.h index 7bcc822c4e..f9450061c4 100644 --- a/app/tools/gimprectangleoptions.h +++ b/app/tools/gimprectangleoptions.h @@ -33,6 +33,8 @@ typedef enum GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT, GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_WIDTH, GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT, + GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH, + GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT, GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR, GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR, GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE, @@ -75,9 +77,14 @@ struct _GimpRectangleOptionsPrivate gdouble width; gdouble height; + /* Width and height for Fixed: Width and Fixed: Height */ gdouble desired_fixed_width; gdouble desired_fixed_height; + /* Width and height for Fixed: Size */ + gdouble desired_fixed_size_width; + gdouble desired_fixed_size_height; + gdouble aspect_numerator; gdouble aspect_denominator; diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index ad7d59cd74..d495c80305 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -239,9 +239,11 @@ static void gimp_rectangle_tool_keep_inside_vertically GimpRectangleConstraint constraint); static void gimp_rectangle_tool_apply_fixed_width (GimpRectangleTool *rectangle_tool, - GimpRectangleConstraint constraint); + GimpRectangleConstraint constraint, + gint width); static void gimp_rectangle_tool_apply_fixed_height (GimpRectangleTool *rectangle_tool, - GimpRectangleConstraint constraint); + GimpRectangleConstraint constraint, + gint height); static void gimp_rectangle_tool_apply_aspect (GimpRectangleTool *rectangle_tool, gdouble aspect, @@ -2695,13 +2697,15 @@ gimp_rectangle_tool_keep_inside_vertically (GimpRectangleTool *rectangle_to * gimp_rectangle_tool_apply_fixed_width: * @rectangle_tool: A #GimpRectangleTool. * @constraint: Constraint to use. + * @width: * * Makes the rectangle have a fixed_width, following the constrainment rules * of fixed widths as well. Please refer to the rectangle tools spec. */ static void gimp_rectangle_tool_apply_fixed_width (GimpRectangleTool *rectangle_tool, - GimpRectangleConstraint constraint) + GimpRectangleConstraint constraint, + gint width) { GimpRectangleToolPrivate *private; GimpRectangleOptions *options; @@ -2721,8 +2725,8 @@ gimp_rectangle_tool_apply_fixed_width (GimpRectangleTool *rectangle_tool, * anchor point to be directly on the opposite side. */ private->x1 = private->center_x_on_fixed_center - - options_private->desired_fixed_width / 2; - private->x2 = private->x1 + options_private->desired_fixed_width; + width / 2; + private->x2 = private->x1 + width; break; @@ -2734,8 +2738,8 @@ gimp_rectangle_tool_apply_fixed_width (GimpRectangleTool *rectangle_tool, * anchor point to be directly on the opposite side. */ private->x1 = private->center_x_on_fixed_center - - options_private->desired_fixed_width / 2; - private->x2 = private->x1 + options_private->desired_fixed_width; + width / 2; + private->x2 = private->x1 + width; break; } @@ -2751,13 +2755,15 @@ gimp_rectangle_tool_apply_fixed_width (GimpRectangleTool *rectangle_tool, * gimp_rectangle_tool_apply_fixed_height: * @rectangle_tool: A #GimpRectangleTool. * @constraint: Constraint to use. + * @height: * * Makes the rectangle have a fixed_height, following the constrainment rules * of fixed heights as well. Please refer to the rectangle tools spec. */ static void gimp_rectangle_tool_apply_fixed_height (GimpRectangleTool *rectangle_tool, - GimpRectangleConstraint constraint) + GimpRectangleConstraint constraint, + gint height) { GimpRectangleToolPrivate *private; @@ -2778,8 +2784,8 @@ gimp_rectangle_tool_apply_fixed_height (GimpRectangleTool *rectangle_tool, * anchor point to be directly on the opposite side. */ private->y1 = private->center_y_on_fixed_center - - options_private->desired_fixed_height / 2; - private->y2 = private->y1 + options_private->desired_fixed_height; + height / 2; + private->y2 = private->y1 + height; break; @@ -2791,8 +2797,8 @@ gimp_rectangle_tool_apply_fixed_height (GimpRectangleTool *rectangle_tool, * anchor point to be directly on the opposite side. */ private->y1 = private->center_y_on_fixed_center - - options_private->desired_fixed_height / 2; - private->y2 = private->y1 + options_private->desired_fixed_height; + height / 2; + private->y2 = private->y1 + height; break; } @@ -3145,7 +3151,9 @@ gimp_rectangle_tool_update_with_coord (GimpRectangleTool *rectangle_tool, if (constraint_to_use == GIMP_RECTANGLE_CONSTRAIN_NONE) constraint_to_use = GIMP_RECTANGLE_CONSTRAIN_IMAGE; - /* fixed_aspect and fixed_width/height are mutually exclusive. */ + + /* Apply the active fixed-rule */ + if (gimp_rectangle_options_fixed_rule_active (options, GIMP_RECTANGLE_TOOL_FIXED_ASPECT)) { @@ -3191,31 +3199,29 @@ gimp_rectangle_tool_update_with_coord (GimpRectangleTool *rectangle_tool, constraint_to_use); } } - else /* !options_private->fixed_aspect */ + else if (gimp_rectangle_options_fixed_rule_active (options, + GIMP_RECTANGLE_TOOL_FIXED_SIZE)) { - gboolean fixed_width; - gboolean fixed_height; - gboolean fixed_size; - - fixed_width = - gimp_rectangle_options_fixed_rule_active (options, - GIMP_RECTANGLE_TOOL_FIXED_WIDTH); - fixed_height = - gimp_rectangle_options_fixed_rule_active (options, - GIMP_RECTANGLE_TOOL_FIXED_HEIGHT); - fixed_size = - gimp_rectangle_options_fixed_rule_active (options, - GIMP_RECTANGLE_TOOL_FIXED_SIZE); - if (fixed_width || fixed_size) - { - gimp_rectangle_tool_apply_fixed_width (rectangle_tool, - constraint_to_use); - } - if (fixed_height || fixed_size) - { - gimp_rectangle_tool_apply_fixed_height (rectangle_tool, - constraint_to_use); - } + gimp_rectangle_tool_apply_fixed_width (rectangle_tool, + constraint_to_use, + options_private->desired_fixed_size_width); + gimp_rectangle_tool_apply_fixed_height (rectangle_tool, + constraint_to_use, + options_private->desired_fixed_size_height); + } + else if (gimp_rectangle_options_fixed_rule_active (options, + GIMP_RECTANGLE_TOOL_FIXED_WIDTH)) + { + gimp_rectangle_tool_apply_fixed_width (rectangle_tool, + constraint_to_use, + options_private->desired_fixed_width); + } + else if (gimp_rectangle_options_fixed_rule_active (options, + GIMP_RECTANGLE_TOOL_FIXED_HEIGHT)) + { + gimp_rectangle_tool_apply_fixed_height (rectangle_tool, + constraint_to_use, + options_private->desired_fixed_height); } }