Commit fec7ca95 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

removed one of the two constrain properties.

2006-05-19  Sven Neumann  <sven@gimp.org>

	* app/tools/gimptransformoptions.[ch]: removed one of the two
	constrain properties.

	* app/tools/gimprotatetool.c
	* app/tools/gimptransformtool.c: changed accordingly.

	* app/tools/gimpscaletool.c: sync "constrain" with the size-box's
	"keep-aspect" property.
parent 414e6616
2006-05-19 Sven Neumann <sven@gimp.org>
* app/tools/gimptransformoptions.[ch]: removed one of the two
constrain properties.
* app/tools/gimprotatetool.c
* app/tools/gimptransformtool.c: changed accordingly.
* app/tools/gimpscaletool.c: sync "constrain" with the size-box's
"keep-aspect" property.
2006-05-19 Sven Neumann <sven@gimp.org>
 
* app/widgets/gimpsizebox.c: connect to the chain-button and
......
......@@ -286,7 +286,7 @@ gimp_rotate_tool_motion (GimpTransformTool *tr_tool,
tr_tool->trans_info[REAL_ANGLE] - 2.0 * G_PI;
/* constrain the angle to 15-degree multiples if ctrl is held down */
if (options->constrain_1)
if (options->constrain)
{
tr_tool->trans_info[ANGLE] =
FIFTEEN_DEG * (int) ((tr_tool->trans_info[REAL_ANGLE] +
......
......@@ -128,12 +128,17 @@ gimp_scale_tool_dialog (GimpTransformTool *tr_tool)
static void
gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpTransformOptions *options;
gint width = (gint) tr_tool->trans_info[X1] - (gint) tr_tool->trans_info[X0];
gint height = (gint) tr_tool->trans_info[Y1] - (gint) tr_tool->trans_info[Y0];
options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (tr_tool)->tool_info->tool_options);
g_object_set (GIMP_SCALE_TOOL (tr_tool)->box,
"width", width,
"height", height,
"width", width,
"height", height,
"keep-aspect", options->constrain,
NULL);
gtk_widget_show (tr_tool->dialog);
......@@ -151,8 +156,6 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool,
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y2;
g_object_set (scale->box,
"width", tr_tool->x2 - tr_tool->x1,
"height", tr_tool->y2 - tr_tool->y1,
"unit", GIMP_DISPLAY_SHELL (display->shell)->unit,
"xresolution", display->image->xresolution,
"yresolution", display->image->yresolution,
......@@ -230,18 +233,8 @@ gimp_scale_tool_motion (GimpTransformTool *tr_tool,
return;
}
/* if just the mod1 key is down, affect only the height */
if (options->constrain_2 && ! options->constrain_1)
{
diff_x = 0;
}
/* if just the control key is down, affect only the width */
else if (options->constrain_1 && ! options->constrain_2)
{
diff_y = 0;
}
/* if control and mod1 are both down, constrain the aspect ratio */
else if (options->constrain_1 && options->constrain_2)
/* if control is being held, constrain the aspect ratio */
if (options->constrain)
{
mag = hypot ((gdouble) (tr_tool->x2 - tr_tool->x1),
(gdouble) (tr_tool->y2 - tr_tool->y1));
......@@ -303,14 +296,26 @@ gimp_scale_tool_size_notify (GtkWidget *box,
GParamSpec *pspec,
GimpTransformTool *tr_tool)
{
gint width;
gint height;
GimpTransformOptions *options;
gint width;
gint height;
gboolean constrain;
options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (tr_tool)->tool_info->tool_options);
g_object_get (box,
"width", &width,
"height", &height,
"width", &width,
"height", &height,
"keep-aspect", &constrain,
NULL);
if (constrain != options->constrain)
{
g_object_set (options,
"constrain", constrain,
NULL);
}
if ((width != (tr_tool->trans_info[X1] - tr_tool->trans_info[X0])) ||
(height != (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0])))
{
......
......@@ -53,8 +53,7 @@ enum
PROP_PREVIEW_TYPE,
PROP_GRID_TYPE,
PROP_GRID_SIZE,
PROP_CONSTRAIN_1,
PROP_CONSTRAIN_2
PROP_CONSTRAIN
};
......@@ -72,11 +71,6 @@ static void gimp_transform_options_reset (GimpToolOptions *tool_optio
static void gimp_transform_options_preview_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *density_box);
static void gimp_scale_options_constrain_callback (GtkWidget *widget,
GObject *config);
static void gimp_scale_options_constrain_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *vbox);
G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
......@@ -148,12 +142,8 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
"grid-size", NULL,
1, 128, 15,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_1,
"constrain-1", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_2,
"constrain-2", NULL,
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN,
"constrain", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
......@@ -200,11 +190,8 @@ gimp_transform_options_set_property (GObject *object,
case PROP_GRID_SIZE:
options->grid_size = g_value_get_int (value);
break;
case PROP_CONSTRAIN_1:
options->constrain_1 = g_value_get_boolean (value);
break;
case PROP_CONSTRAIN_2:
options->constrain_2 = g_value_get_boolean (value);
case PROP_CONSTRAIN:
options->constrain = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -249,11 +236,8 @@ gimp_transform_options_get_property (GObject *object,
case PROP_GRID_SIZE:
g_value_set_int (value, options->grid_size);
break;
case PROP_CONSTRAIN_1:
g_value_set_boolean (value, options->constrain_1);
break;
case PROP_CONSTRAIN_2:
g_value_set_boolean (value, options->constrain_2);
case PROP_CONSTRAIN:
g_value_set_boolean (value, options->constrain);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -288,6 +272,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
GtkWidget *table;
GtkWidget *combo;
GtkWidget *button;
const gchar *constrain = NULL;
vbox = gimp_tool_options_gui (tool_options);
......@@ -378,78 +363,25 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
1.0, 8.0, 0,
FALSE, 0.0, 0.0);
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL ||
tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
{
constrain = (_("15 degrees (%s)"));
}
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
{
constrain = (_("Keep aspect (%s)"));
}
if (constrain)
{
GtkWidget *vbox2;
GtkWidget *vbox3;
/* the constraints frame */
frame = gimp_frame_new (_("Constraints"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
vbox2 = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_widget_show (vbox2);
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
{
gchar *str;
str = g_strdup_printf (_("15 degrees (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
button = gimp_prop_check_button_new (config, "constrain-1", str);
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_free (str);
}
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
{
GtkWidget *button;
gchar *str1;
gchar *str2;
gchar *str3;
gint initial;
initial = ((options->constrain_1 ? 1 : 0) +
(options->constrain_2 ? 2 : 0));
str1 = g_strdup_printf (_("Keep height (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK));
str2 = g_strdup_printf (_("Keep width (%s)"),
gimp_get_mod_string (GDK_MOD1_MASK));
str3 = g_strdup_printf (_("Keep aspect (%s)"),
gimp_get_mod_string (GDK_CONTROL_MASK |
GDK_MOD1_MASK));
vbox3 = gimp_int_radio_group_new (FALSE, NULL,
G_CALLBACK (gimp_scale_options_constrain_callback),
config, initial,
_("None"), 0, &button,
str1, 1, NULL,
str2, 2, NULL,
str3, 3, NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
gtk_widget_show (vbox3);
g_signal_connect_object (config, "notify::constrain-1",
G_CALLBACK (gimp_scale_options_constrain_notify),
G_OBJECT (button), 0);
g_signal_connect_object (config, "notify::constrain-2",
G_CALLBACK (gimp_scale_options_constrain_notify),
G_OBJECT (button), 0);
g_free (str1);
g_free (str2);
g_free (str3);
}
gchar *label = g_strdup_printf (constrain,
gimp_get_mod_string (GDK_CONTROL_MASK));
button = gimp_prop_check_button_new (config, "constrain", label);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_free (label);
}
return vbox;
......@@ -469,43 +401,3 @@ gimp_transform_options_preview_notify (GimpTransformOptions *options,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
}
static void
gimp_scale_options_constrain_callback (GtkWidget *widget,
GObject *config)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
{
gint value;
gboolean c0;
gboolean c1;
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
c0 = c1 = FALSE;
if (value == 1 || value == 3)
c0 = TRUE;
if (value == 2 || value == 3)
c1 = TRUE;
g_object_set (config,
"constrain-1", c0,
"constrain-2", c1,
NULL);
}
}
static void
gimp_scale_options_constrain_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *button)
{
gint value;
value = ((options->constrain_1 ? 1 : 0) +
(options->constrain_2 ? 2 : 0));
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), value);
}
......@@ -47,8 +47,7 @@ struct _GimpTransformOptions
GimpTransformPreviewType preview_type;
GimpTransformGridType grid_type;
gint grid_size;
gboolean constrain_1;
gboolean constrain_2;
gboolean constrain;
};
......
......@@ -115,6 +115,8 @@ static void gimp_transform_tool_cursor_update (GimpTool *tool,
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
static void gimp_transform_tool_dialog_update (GimpTransformTool *tr_tool);
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
......@@ -253,6 +255,7 @@ gimp_transform_tool_constructor (GType type,
"notify::type",
G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::direction",
G_CALLBACK (gimp_transform_tool_notify_type),
......@@ -261,6 +264,7 @@ gimp_transform_tool_constructor (GType type,
"notify::direction",
G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::preview-type",
G_CALLBACK (gimp_transform_tool_notify_preview),
......@@ -275,6 +279,11 @@ gimp_transform_tool_constructor (GType type,
tr_tool, 0);
}
g_signal_connect_object (tool->tool_info->tool_options,
"notify::constrain",
G_CALLBACK (gimp_transform_tool_dialog_update),
tr_tool, G_CONNECT_SWAPPED);
return object;
}
......@@ -528,17 +537,9 @@ gimp_transform_tool_modifier_key (GimpTool *tool,
options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
if (key == GDK_CONTROL_MASK)
{
g_object_set (options,
"constrain-1", ! options->constrain_1,
NULL);
}
else if (key == GDK_MOD1_MASK)
{
g_object_set (options,
"constrain-2", ! options->constrain_2,
NULL);
}
g_object_set (options,
"constrain", ! options->constrain,
NULL);
}
static void
......@@ -814,6 +815,13 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
}
}
static void
gimp_transform_tool_dialog_update (GimpTransformTool *tr_tool)
{
if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->dialog_update)
GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->dialog_update (tr_tool);
}
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
......@@ -1457,8 +1465,7 @@ gimp_transform_tool_recalc (GimpTransformTool *tr_tool,
gimp_transform_tool_transform_bounding_box (tr_tool);
if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->dialog_update)
GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->dialog_update (tr_tool);
gimp_transform_tool_dialog_update (tr_tool);
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment