Commit 16e7aada authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

app/gimpunit.c libgimp/gimpunit.[ch] libgimp/gimpunitmenu.c enabled

1999-04-06  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/gimpunit.c
	* libgimp/gimpunit.[ch]
	* libgimp/gimpunitmenu.c
	* libgimp/gimpsizeentry.[ch]: enabled "percent" pseudo-unit.
	New function gimp_size_entry_set_size() to set the values which
	will be treated as 0% and 100%.

	* app/crop.c
	* app/rotate_tool.c
	* app/scale_tool.c: enable "percent".

	* app/rect_select.c fixed size selections can be made in units and
	percent now, table layout, label adjustment.
parent 67dbf49b
1999-04-06 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/gimpunit.c
* libgimp/gimpunit.[ch]
* libgimp/gimpunitmenu.c
* libgimp/gimpsizeentry.[ch]: enabled "percent" pseudo-unit.
New function gimp_size_entry_set_size() to set the values which
will be treated as 0% and 100%.
* app/crop.c
* app/rotate_tool.c
* app/scale_tool.c: enable "percent".
* app/rect_select.c fixed size selections can be made in units and
percent now, table layout, label adjustment.
Mon Apr 5 23:24:30 BST 1999 Andy Thomas <alt@gimp.org>
Changed:-
* app/bezier_select.c
* app/bezier_selectP.h
* app/paths_cmds.c
......
......@@ -65,6 +65,13 @@ static GimpUnitDef gimp_unit_defs[UNIT_END] =
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
};
/* not a unit at all but kept here to have the strings in one place
*/
static GimpUnitDef gimp_unit_percent =
{
FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
};
static GSList* user_units = NULL;
static gint number_of_user_units = 0;
......@@ -176,12 +183,16 @@ gchar *
gimp_unit_get_identifier (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].identifier );
if (unit < UNIT_END)
return gimp_unit_defs[unit].identifier;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.identifier;
return gimp_unit_get_user_unit (unit)->identifier;
}
......@@ -190,12 +201,16 @@ gchar *
gimp_unit_get_symbol (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].symbol );
if (unit < UNIT_END)
return gimp_unit_defs[unit].symbol;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.symbol;
return gimp_unit_get_user_unit (unit)->symbol;
}
......@@ -204,12 +219,16 @@ gchar *
gimp_unit_get_abbreviation (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].abbreviation );
if (unit < UNIT_END)
return gimp_unit_defs[unit].abbreviation;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.abbreviation;
return gimp_unit_get_user_unit (unit)->abbreviation;
}
......@@ -218,12 +237,16 @@ gchar *
gimp_unit_get_singular (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gettext(gimp_unit_defs[UNIT_INCH].singular) );
if (unit < UNIT_END)
return gettext (gimp_unit_defs[unit].singular);
if (unit == UNIT_PERCENT)
return gettext (gimp_unit_percent.singular);
return gimp_unit_get_user_unit (unit)->singular;
}
......@@ -232,12 +255,16 @@ gchar *
gimp_unit_get_plural (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gettext(gimp_unit_defs[UNIT_INCH].plural) );
if (unit < UNIT_END)
return gettext (gimp_unit_defs[unit].plural);
if (unit == UNIT_PERCENT)
return gettext (gimp_unit_percent.plural);
return gimp_unit_get_user_unit (unit)->plural;
}
......
......@@ -67,10 +67,13 @@ struct _crop
/* speed of key movement */
#define ARROW_VELOCITY 25
static InfoDialog * crop_info = NULL;
static InfoDialog *crop_info = NULL;
static gfloat orig_vals[2];
static gfloat size_vals[2];
static GtkWidget *origin_sizeentry;
static GtkWidget *size_sizeentry;
/* crop action functions */
static void crop_button_press (Tool *, GdkEventButton *, gpointer);
static void crop_button_release (Tool *, GdkEventButton *, gpointer);
......@@ -788,18 +791,40 @@ crop_start (Tool *tool,
gdisp = (GDisplay *) tool->gdisp_ptr;
crop_recalc (tool, crop);
/* if the crop information dialog already exists, delete it */
if (crop_info && (gdisp != old_gdisp))
if (! crop_info)
crop_info_create (tool);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
0, gdisp->gimage->width);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
gdisp->gimage->yresolution, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
0, gdisp->gimage->height);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0,
0, gdisp->gimage->width);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1,
gdisp->gimage->yresolution, FALSE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1,
0, gdisp->gimage->height);
if (old_gdisp != gdisp)
{
info_dialog_popdown (crop_info);
info_dialog_free (crop_info);
crop_info = NULL;
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry),
(gdisp->dot_for_dot ? UNIT_PIXEL :
gdisp->gimage->unit));
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry),
(gdisp->dot_for_dot ? UNIT_PIXEL :
gdisp->gimage->unit));
}
old_gdisp = gdisp;
if (! crop_info)
crop_info_create (tool);
/* initialize the statusbar display */
crop->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop");
......@@ -825,8 +850,7 @@ static void
crop_info_create (Tool *tool)
{
GDisplay *gdisp;
GtkWidget *sizeentry;
GtkWidget *spinbutton2;
GtkWidget *spinbutton;
gdisp = (GDisplay *) tool->gdisp_ptr;
......@@ -834,51 +858,61 @@ crop_info_create (Tool *tool)
crop_info = info_dialog_new (_("Crop Information"));
/* add the information fields */
spinbutton2 = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL,
spinbutton = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL,
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
sizeentry =
origin_sizeentry =
info_dialog_add_sizeentry (crop_info, _("Y:"), orig_vals, 1,
gdisp->dot_for_dot ?
UNIT_PIXEL : gdisp->gimage->unit, "%a",
TRUE, FALSE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
crop_orig_changed, tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
GTK_SPIN_BUTTON (spinbutton2), NULL);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (origin_sizeentry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
-65536, 65536);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, orig_vals[0]);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
0, gdisp->gimage->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
orig_vals[0]);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
-65536, 65536);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
gdisp->gimage->yresolution, FALSE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1, orig_vals[1]);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
0, gdisp->gimage->height);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
orig_vals[1]);
spinbutton2 = info_dialog_add_spinbutton (crop_info, _("Width:"), NULL,
spinbutton = info_dialog_add_spinbutton (crop_info, _("Width:"), NULL,
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
sizeentry =
size_sizeentry =
info_dialog_add_sizeentry (crop_info, _("Height:"), size_vals, 1,
gdisp->dot_for_dot ?
UNIT_PIXEL : gdisp->gimage->unit, "%a",
TRUE, FALSE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
crop_size_changed, tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
GTK_SPIN_BUTTON (spinbutton2), NULL);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (size_sizeentry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_sizeentry), 0,
-65536, 65536);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, size_vals[0]);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0,
0, gdisp->gimage->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (size_sizeentry), 0, size_vals[0]);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_sizeentry), 1,
-65536, 65536);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1,
gdisp->gimage->yresolution, FALSE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1, size_vals[1]);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1,
0, gdisp->gimage->height);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (size_sizeentry), 1, size_vals[1]);
gtk_table_set_row_spacing (GTK_TABLE (crop_info->info_table), 0, 0);
gtk_table_set_row_spacing (GTK_TABLE (crop_info->info_table), 1, 6);
......
......@@ -65,6 +65,13 @@ static GimpUnitDef gimp_unit_defs[UNIT_END] =
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
};
/* not a unit at all but kept here to have the strings in one place
*/
static GimpUnitDef gimp_unit_percent =
{
FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
};
static GSList* user_units = NULL;
static gint number_of_user_units = 0;
......@@ -176,12 +183,16 @@ gchar *
gimp_unit_get_identifier (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].identifier );
if (unit < UNIT_END)
return gimp_unit_defs[unit].identifier;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.identifier;
return gimp_unit_get_user_unit (unit)->identifier;
}
......@@ -190,12 +201,16 @@ gchar *
gimp_unit_get_symbol (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].symbol );
if (unit < UNIT_END)
return gimp_unit_defs[unit].symbol;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.symbol;
return gimp_unit_get_user_unit (unit)->symbol;
}
......@@ -204,12 +219,16 @@ gchar *
gimp_unit_get_abbreviation (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gimp_unit_defs[UNIT_INCH].abbreviation );
if (unit < UNIT_END)
return gimp_unit_defs[unit].abbreviation;
if (unit == UNIT_PERCENT)
return gimp_unit_percent.abbreviation;
return gimp_unit_get_user_unit (unit)->abbreviation;
}
......@@ -218,12 +237,16 @@ gchar *
gimp_unit_get_singular (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gettext(gimp_unit_defs[UNIT_INCH].singular) );
if (unit < UNIT_END)
return gettext (gimp_unit_defs[unit].singular);
if (unit == UNIT_PERCENT)
return gettext (gimp_unit_percent.singular);
return gimp_unit_get_user_unit (unit)->singular;
}
......@@ -232,12 +255,16 @@ gchar *
gimp_unit_get_plural (GUnit unit)
{
g_return_val_if_fail ( (unit >= UNIT_PIXEL) &&
(unit < (UNIT_END + number_of_user_units)),
(unit < (UNIT_END + number_of_user_units)) ||
(unit == UNIT_PERCENT),
gettext(gimp_unit_defs[UNIT_INCH].plural) );
if (unit < UNIT_END)
return gettext (gimp_unit_defs[unit].plural);
if (unit == UNIT_PERCENT)
return gettext (gimp_unit_percent.plural);
return gimp_unit_get_user_unit (unit)->plural;
}
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpunitmenu.h"
#define NO 0
#define YES 1
......@@ -60,13 +61,36 @@ selection_toggle_update (GtkWidget *w,
}
static void
selection_spinbutton_update (GtkWidget *widget,
selection_adjustment_update (GtkWidget *widget,
gpointer data)
{
int *val;
val = data;
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
val = (int *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
static void
selection_unitmenu_update (GtkWidget *widget,
gpointer data)
{
GUnit *val;
GtkSpinButton *spinbutton;
int digits;
val = (GUnit *) data;
*val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
digits = ((*val == UNIT_PIXEL) ? 0 :
((*val == UNIT_PERCENT) ? 2 :
(MIN (6, MAX (3, gimp_unit_get_digits (*val))))));
spinbutton = GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT (widget),
"fixed_width_spinbutton"));
gtk_spin_button_set_digits (spinbutton, digits);
spinbutton = GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT (widget),
"fixed_height_spinbutton"));
gtk_spin_button_set_digits (spinbutton, digits);
}
static void
......@@ -90,7 +114,6 @@ create_selection_options (ToolType tool_type)
GtkObject *feather_scale_data;
GtkWidget *fixed_size_toggle;
GtkAdjustment *adj;
GtkWidget *spinbutton;
/* the new options structure */
options = (SelectionOptions *) g_malloc (sizeof (SelectionOptions));
......@@ -101,6 +124,7 @@ create_selection_options (ToolType tool_type)
options->fixed_size = FALSE;
options->fixed_height = 1;
options->fixed_width = 1;
options->fixed_unit = UNIT_PIXEL;
options->sample_merged = TRUE;
/* the main vbox */
......@@ -175,6 +199,12 @@ create_selection_options (ToolType tool_type)
/* Widgets for fixed size select */
if (tool_type == RECT_SELECT || tool_type == ELLIPSE_SELECT)
{
GtkWidget *alignment;
GtkWidget *table;
GtkWidget *width_spinbutton;
GtkWidget *height_spinbutton;
GtkWidget *unitmenu;
fixed_size_toggle = gtk_check_button_new_with_label (_("Fixed size / aspect ratio"));
gtk_box_pack_start (GTK_BOX(vbox), fixed_size_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT(fixed_size_toggle), "toggled",
......@@ -183,42 +213,78 @@ create_selection_options (ToolType tool_type)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fixed_size_toggle),
options->fixed_size);
gtk_widget_show(fixed_size_toggle);
hbox = gtk_hbox_new (TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Width: "));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (options->fixed_width, 1.0,
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
gtk_widget_show (alignment);
table = gtk_table_new (3, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
gtk_container_add (GTK_CONTAINER (alignment), table);
label = gtk_label_new (_("Width:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (options->fixed_width, 1e-5,
32767.0, 1.0, 50.0, 0.0);
spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (spinbutton), "changed",
(GtkSignalFunc) selection_spinbutton_update,
width_spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(width_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (width_spinbutton), TRUE);
gtk_widget_set_usize (width_spinbutton, 75, 0);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
(GtkSignalFunc) selection_adjustment_update,
&options->fixed_width);
gtk_table_attach (GTK_TABLE (table), width_spinbutton,
1, 2, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
gtk_widget_show (spinbutton);
gtk_widget_show (hbox);
gtk_widget_show (width_spinbutton);
hbox = gtk_hbox_new (TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Height: "));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (options->fixed_height, 1.0,
label = gtk_label_new (_("Height:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (options->fixed_height, 1e-5,
32767.0, 1.0, 50.0, 0.0);
spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (spinbutton), "changed",
(GtkSignalFunc) selection_spinbutton_update,
height_spinbutton = gtk_spin_button_new (adj, 1.0, 0.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(height_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(height_spinbutton), TRUE);
gtk_widget_set_usize (height_spinbutton, 75, 0);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
(GtkSignalFunc) selection_adjustment_update,
&options->fixed_height);
gtk_table_attach (GTK_TABLE (table), height_spinbutton,
1, 2, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
gtk_widget_show (spinbutton);
gtk_widget_show (hbox);
gtk_widget_show (height_spinbutton);
label = gtk_label_new (_("Unit:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
unitmenu = gimp_unit_menu_new ("%a", UNIT_PIXEL, TRUE, TRUE, TRUE);
gtk_signal_connect (GTK_OBJECT (unitmenu), "unit_changed",
(GtkSignalFunc) selection_unitmenu_update,
&options->fixed_unit);
gtk_object_set_data (GTK_OBJECT (unitmenu), "fixed_width_spinbutton",
width_spinbutton);
gtk_object_set_data (GTK_OBJECT (unitmenu), "fixed_height_spinbutton",
height_spinbutton);
gtk_table_attach (GTK_TABLE (table), unitmenu,
1, 2, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
gtk_widget_show (unitmenu);
gtk_widget_show (table);
}
/* the feather toggle button */
......@@ -231,10 +297,11 @@ create_selection_options (ToolType tool_type)
gtk_widget_show (feather_toggle);
/* the feather radius scale */
hbox = gtk_hbox_new (FALSE, 1);
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Feather Radius: "));
label = gtk_label_new (_("Feather Radius:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
......@@ -308,6 +375,8 @@ rect_select_button_press (Tool *tool,
RectSelect * rect_sel;
gchar select_mode[STATUSBAR_SIZE];
int x, y;
GUnit unit = UNIT_PIXEL;
float unit_factor;
gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private;
......@@ -322,16 +391,40 @@ rect_select_button_press (Tool *tool,
rect_sel->fixed_size = rect_options->fixed_size;
rect_sel->fixed_width = rect_options->fixed_width;
rect_sel->fixed_height = rect_options->fixed_height;
unit = rect_options->fixed_unit;
break;
case ELLIPSE_SELECT:
rect_sel->fixed_size = ellipse_options->fixed_size;
rect_sel->fixed_width = ellipse_options->fixed_width;
rect_sel->fixed_height = ellipse_options->fixed_height;
unit = ellipse_options->fixed_unit;
break;
default:
break;
}
switch (unit)
{
case UNIT_PIXEL:
break;
case UNIT_PERCENT:
rect_sel->fixed_width =
gdisp->gimage->width * rect_sel->fixed_width / 100;
rect_sel->fixed_height =
gdisp->gimage->height * rect_sel->fixed_height / 100;
break;
default:
unit_factor = gimp_unit_get_factor (unit);
rect_sel->fixed_width =
rect_sel->fixed_width * gdisp->gimage->xresolution / unit_factor;
rect_sel->fixed_height =
rect_sel->fixed_height * gdisp->gimage->yresolution / unit_factor;
break;
}
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
rect_sel->w = 0;
rect_sel->h = 0;
......
......@@ -51,6 +51,9 @@
static gfloat angle_val;
static gfloat center_vals[2];
/* needed for size update */
static GtkWidget *sizeentry;
/* forward function declarations */
static void * rotate_tool_rotate (GImage *, GimpDrawable *, GDisplay *,
double, TileManager *, int, GimpMatrix);
......@@ -100,31 +103,31 @@ rotate_tool_transform (Tool *tool,
spinbutton2 =
info_dialog_add_spinbutton (transform_info, _("Center X:"), NULL,
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
widget =
sizeentry =
info_dialog_add_sizeentry (transform_info, _("Y:"),
center_vals, 1,
gdisp->dot_for_dot ?
UNIT_PIXEL : gdisp->gimage->unit, "%a",
TRUE, FALSE, FALSE,
TRUE, TRUE, FALSE,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
rotate_center_changed, tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (widget),
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
GTK_SPIN_BUTTON (spinbutton2), NULL);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (widget), 0,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
-4096,
4096 + gdisp->gimage->width);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (widget), 0,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
center_vals[0]);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (widget), 1,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
-4096,
4096 + gdisp->gimage->height);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (widget), 1,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,