Commit e7c8de57 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer
Browse files

call gdisplays_resize_cursor_label(gimage) after changing the image's

1999-05-02  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/commands.c: call gdisplays_resize_cursor_label(gimage)
	after changing the image's unit.

	* app/gdisplay.c: update the cursor label after resizing it's
	frame, so the old (wrong) value gets overwritten.

	* app/resize.c: it makes more sense to take the image's unit from
	the "print size" frame rather than from "pixel dimensions".
	Set reasonable boundaries to avoid over/underflows with crazy
	resolutions. Code and gui cleanup.
	The constants for min/max image size/resolution should probably go
	to a central place.

	* app/text_tool.c: set the resolution in the X font spec only if
	the size is specified in points (reported by Austin).

	* libgimp/gimpsizeentry.c: fixed a bad bug in the boundary and
	resolution setting code (was not noticable before the new
	resize/scale ui).

	* plug-ins/gdyntext/*: version 1.4.3

	* plug-ins/png/png.c: gcc suggested parentheses.
parent 2618ad37
1999-05-02 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/commands.c: call gdisplays_resize_cursor_label(gimage)
after changing the image's unit.
* app/gdisplay.c: update the cursor label after resizing it's
frame, so the old (wrong) value gets overwritten.
* app/resize.c: it makes more sense to take the image's unit from
the "print size" frame rather than from "pixel dimensions".
Set reasonable boundaries to avoid over/underflows with crazy
resolutions. Code and gui cleanup.
The constants for min/max image size/resolution should probably go
to a central place.
* app/text_tool.c: set the resolution in the X font spec only if
the size is specified in points (reported by Austin).
* libgimp/gimpsizeentry.c: fixed a bad bug in the boundary and
resolution setting code (was not noticable before the new
resize/scale ui).
* plug-ins/gdyntext/*: version 1.4.3
* plug-ins/png/png.c: gcc suggested parentheses.
Mon May 3 15:38:54 PDT 1999 Manish Singh <yosh@gimp.org>
* Made 1.1.5 release
......
......@@ -1142,16 +1142,20 @@ image_scale_callback (GtkWidget *w,
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
image_scale->resize->resolution_y != gimage->yresolution)
{
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......
......@@ -1142,16 +1142,20 @@ image_scale_callback (GtkWidget *w,
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
image_scale->resize->resolution_y != gimage->yresolution)
{
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......
......@@ -1102,6 +1102,8 @@ gdisplay_resize_cursor_label (GDisplay *gdisp)
if (label_frame_size_difference) /* don't resize if this is a new display */
gtk_widget_set_usize (gdisp->cursor_label->parent,
cursor_label_width + label_frame_size_difference, -1);
gdisplay_update_cursor (gdisp, gdisp->cursor_x, gdisp->cursor_y);
}
void
......@@ -1761,7 +1763,7 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_resize_cursor_label(gdisp);
gdisplay_resize_cursor_label (gdisp);
list = g_slist_next (list);
}
......
This diff is collapsed.
......@@ -1102,6 +1102,8 @@ gdisplay_resize_cursor_label (GDisplay *gdisp)
if (label_frame_size_difference) /* don't resize if this is a new display */
gtk_widget_set_usize (gdisp->cursor_label->parent,
cursor_label_width + label_frame_size_difference, -1);
gdisplay_update_cursor (gdisp, gdisp->cursor_x, gdisp->cursor_y);
}
void
......@@ -1761,7 +1763,7 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_resize_cursor_label(gdisp);
gdisplay_resize_cursor_label (gdisp);
list = g_slist_next (list);
}
......
......@@ -1102,6 +1102,8 @@ gdisplay_resize_cursor_label (GDisplay *gdisp)
if (label_frame_size_difference) /* don't resize if this is a new display */
gtk_widget_set_usize (gdisp->cursor_label->parent,
cursor_label_width + label_frame_size_difference, -1);
gdisplay_update_cursor (gdisp, gdisp->cursor_x, gdisp->cursor_y);
}
void
......@@ -1761,7 +1763,7 @@ gdisplays_resize_cursor_label (GimpImage *gimage)
{
gdisp = (GDisplay *) list->data;
if (gdisp->gimage == gimage)
gdisplay_resize_cursor_label(gdisp);
gdisplay_resize_cursor_label (gdisp);
list = g_slist_next (list);
}
......
......@@ -1142,16 +1142,20 @@ image_scale_callback (GtkWidget *w,
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
image_scale->resize->resolution_y != gimage->yresolution)
{
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......
......@@ -1142,16 +1142,20 @@ image_scale_callback (GtkWidget *w,
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
image_scale->resize->resolution_y != gimage->yresolution)
{
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -869,7 +869,8 @@ text_field_edges(char *fontname,
/* Multiply the point and pixel sizes in *fontname by "mul", which
* must be positive. If either point or pixel sizes are "*" then they
* are left untouched. The memory *fontname is g_free()d, and
* *fontname is replaced by a fresh allocation of the correct size. */
* *fontname is replaced by a fresh allocation of the correct size.
*/
static void
text_size_multiply(char **fontname,
int mul)
......@@ -915,6 +916,7 @@ text_set_resolution (char **fontname,
int xres,
int yres)
{
char *point_str;
char *xres_str;
char *yres_str;
char *newfont;
......@@ -922,6 +924,13 @@ text_set_resolution (char **fontname,
char new_xres[16];
char new_yres[16];
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
return;
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
......
......@@ -869,7 +869,8 @@ text_field_edges(char *fontname,
/* Multiply the point and pixel sizes in *fontname by "mul", which
* must be positive. If either point or pixel sizes are "*" then they
* are left untouched. The memory *fontname is g_free()d, and
* *fontname is replaced by a fresh allocation of the correct size. */
* *fontname is replaced by a fresh allocation of the correct size.
*/
static void
text_size_multiply(char **fontname,
int mul)
......@@ -915,6 +916,7 @@ text_set_resolution (char **fontname,
int xres,
int yres)
{
char *point_str;
char *xres_str;
char *yres_str;
char *newfont;
......@@ -922,6 +924,13 @@ text_set_resolution (char **fontname,
char new_xres[16];
char new_yres[16];
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
return;
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
......
......@@ -869,7 +869,8 @@ text_field_edges(char *fontname,
/* Multiply the point and pixel sizes in *fontname by "mul", which
* must be positive. If either point or pixel sizes are "*" then they
* are left untouched. The memory *fontname is g_free()d, and
* *fontname is replaced by a fresh allocation of the correct size. */
* *fontname is replaced by a fresh allocation of the correct size.
*/
static void
text_size_multiply(char **fontname,
int mul)
......@@ -915,6 +916,7 @@ text_set_resolution (char **fontname,
int xres,
int yres)
{
char *point_str;
char *xres_str;
char *yres_str;
char *newfont;
......@@ -922,6 +924,13 @@ text_set_resolution (char **fontname,
char new_xres[16];
char new_yres[16];
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
return;
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
......
......@@ -64,6 +64,8 @@ struct _GimpSizeEntryField
gfloat min_refval;
gfloat max_refval;
gint refval_digits;
gint stop_recursion;
};
......@@ -71,10 +73,6 @@ static gint gimp_size_entry_signals[LAST_SIGNAL] = { 0 };
static GtkTableClass *parent_class = NULL;
/* this is a hack to avoid infinite recursion when calling the
* boundary functions
*/
static gint gimp_size_entry_stop_recursion = 0;
static void
gimp_size_entry_class_destroy (GtkObject *object)
......@@ -237,6 +235,7 @@ gimp_size_entry_new (gint number_of_fields,
gsef->max_refval = SIZE_MAX_VALUE;
gsef->refval_digits =
(update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3;
gsef->stop_recursion = 0;
gsef->value_adjustment = gtk_adjustment_new (gsef->value,
gsef->min_value,
......@@ -356,6 +355,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse,
gsef->max_refval = SIZE_MAX_VALUE;
gsef->refval_digits =
(gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3;
gsef->stop_recursion = 0;
gsef->value_adjustment =
GTK_OBJECT (gtk_spin_button_get_adjustment (value_spinbutton));
......@@ -435,6 +435,7 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse,
guint keep_size)
{
GimpSizeEntryField *gsef;
float val;
g_return_if_fail (gse != NULL);
g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
......@@ -444,10 +445,14 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse,
gsef = (GimpSizeEntryField*) g_slist_nth_data (gse->fields, field);
gsef->resolution = resolution;
if (keep_size)
gimp_size_entry_set_refval (gse, field, gsef->refval);
else
gimp_size_entry_set_value (gse, field, gsef->value);
val = gsef->value;
gsef->stop_recursion = 0;
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_refval, gsef->max_refval);
if (! keep_size)
gimp_size_entry_set_value (gse, field, val);
}
......@@ -496,12 +501,10 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
GTK_ADJUSTMENT (gsef->value_adjustment)->lower = gsef->min_value;
GTK_ADJUSTMENT (gsef->value_adjustment)->upper = gsef->max_value;
gimp_size_entry_set_value (gse, field, gsef->value);
if (gimp_size_entry_stop_recursion) /* this is a hack (but useful ;-) */
if (gsef->stop_recursion) /* this is a hack (but useful ;-) */
return;
gimp_size_entry_stop_recursion++;
gsef->stop_recursion++;
switch (gsef->gse->update_policy)
{
case GIMP_SIZE_ENTRY_UPDATE_NONE:
......@@ -510,6 +513,11 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
switch (gse->unit)
{
case UNIT_PIXEL:
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_value,
gsef->max_value);
break;
case UNIT_PERCENT:
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->lower +
(gsef->upper - gsef->lower) *
......@@ -518,11 +526,6 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
(gsef->upper - gsef->lower) *
gsef->max_value / 100);
break;
case UNIT_PERCENT:
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_value,
gsef->max_value);
break;
default:
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_value *
......@@ -544,7 +547,9 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
default:
break;
}
gimp_size_entry_stop_recursion--;
gsef->stop_recursion--;
gimp_size_entry_set_value (gse, field, gsef->value);
}
gfloat
......@@ -561,11 +566,11 @@ gimp_size_entry_get_value (GimpSizeEntry *gse,
return gsef->value;
}
void
static void
gimp_size_entry_update_value (GimpSizeEntryField *gsef,
gfloat value)
{
if (gimp_size_entry_stop_recursion > 1)
if (gsef->stop_recursion > 1)
return;
gsef->value = value;
......@@ -583,11 +588,14 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
break;
case UNIT_PERCENT:
gsef->refval =
gsef->lower + (gsef->upper - gsef->lower) * value / 100;
CLAMP (gsef->lower + (gsef->upper - gsef->lower) * value / 100,
gsef->min_refval, gsef->max_refval);
break;
default:
gsef->refval = value * gsef->resolution /
gimp_unit_get_factor (gsef->gse->unit);
gsef->refval =
CLAMP (value * gsef->resolution /
gimp_unit_get_factor (gsef->gse->unit),
gsef->min_refval, gsef->max_refval);
break;
}
if (gsef->gse->show_refval)
......@@ -595,7 +603,9 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
gsef->refval);
break;
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gsef->refval = value * gimp_unit_get_factor (gsef->gse->unit);
gsef->refval =
CLAMP (value * gimp_unit_get_factor (gsef->gse->unit),
gsef->min_refval, gsef->max_refval);
if (gsef->gse->show_refval)
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->refval_adjustment),
gsef->refval);
......@@ -619,12 +629,10 @@ gimp_size_entry_set_value (GimpSizeEntry *gse,
gsef = (GimpSizeEntryField*) g_slist_nth_data (gse->fields, field);
if (value < gsef->min_value)
value = gsef->min_value;
if (value > gsef->max_value)
value = gsef->max_value;
value = CLAMP (value, gsef->min_value, gsef->max_value);
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment), value);
gimp_size_entry_update_value (gsef, value);
}
......@@ -673,12 +681,11 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
GTK_ADJUSTMENT (gsef->refval_adjustment)->lower = gsef->min_refval;
GTK_ADJUSTMENT (gsef->refval_adjustment)->upper = gsef->max_refval;
}
gimp_size_entry_set_refval (gse, field, gsef->refval);
if (gimp_size_entry_stop_recursion) /* this is a hack (but useful ;-) */
if (gsef->stop_recursion) /* this is a hack (but useful ;-) */
return;
gimp_size_entry_stop_recursion++;
gsef->stop_recursion++;
switch (gsef->gse->update_policy)
{
case GIMP_SIZE_ENTRY_UPDATE_NONE:
......@@ -688,6 +695,11 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
switch (gse->unit)
{
case UNIT_PIXEL:
gimp_size_entry_set_value_boundaries (gse, field,
gsef->min_refval,
gsef->max_refval);
break;
case UNIT_PERCENT:
gimp_size_entry_set_value_boundaries (gse, field,
100 * (gsef->min_refval -
gsef->lower) /
......@@ -696,18 +708,13 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
gsef->lower) /
(gsef->upper - gsef->lower));
break;
case UNIT_PERCENT:
gimp_size_entry_set_value_boundaries (gse, field,
gsef->min_refval,
gsef->max_refval);
break;
default:
gimp_size_entry_set_value_boundaries (gse, field,
gsef->min_refval *
gimp_unit_get_factor (gse->unit) /
gimp_unit_get_factor(gse->unit) /
gsef->resolution,
gsef->max_refval *
gimp_unit_get_factor (gse->unit) /
gimp_unit_get_factor(gse->unit) /
gsef->resolution);
break;
}
......@@ -723,7 +730,9 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
default:
break;
}
gimp_size_entry_stop_recursion--;
gsef->stop_recursion--;
gimp_size_entry_set_refval (gse, field, gsef->refval);
}
void
......@@ -767,11 +776,11 @@ gimp_size_entry_get_refval (GimpSizeEntry *gse,
return gsef->refval;
}
void
static void
gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
gfloat refval)
{
if (gimp_size_entry_stop_recursion > 1)
if (gsef->stop_recursion > 1)
return;
gsef->refval = refval;
......@@ -789,18 +798,23 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
break;
case UNIT_PERCENT:
gsef->value =
100 * (refval - gsef->lower) / (gsef->upper - gsef->lower);
CLAMP (100 * (refval - gsef->lower) / (gsef->upper - gsef->lower),
gsef->min_value, gsef->max_value);
break;
default:
gsef->value = refval * gimp_unit_get_factor (gsef->gse->unit) /
gsef->resolution;
gsef->value =
CLAMP (refval * gimp_unit_get_factor (gsef->gse->unit) /
gsef->resolution,
gsef->min_value, gsef->max_value);
break;
}
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment),
gsef->value);
break;
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gsef->value = refval / gimp_unit_get_factor (gsef->gse->unit);
gsef->value =
CLAMP (refval / gimp_unit_get_factor (gsef->gse->unit),
gsef->min_value, gsef->max_value);
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment),
gsef->value);
break;
......@@ -823,13 +837,14 @@ gimp_size_entry_set_refval (GimpSizeEntry *gse,
gsef = (GimpSizeEntryField*) g_slist_nth_data (gse->fields, field);
if (refval < gsef->min_refval)
refval = gsef->min_refval;
if (refval > gsef->max_refval)
refval = gsef->max_refval;
refval = CLAMP (refval, gsef->min_refval, gsef->max_refval);
if (gse->show_refval)
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->refval_adjustment), refval);
{
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->refval_adjustment),
refval);
}
gimp_size_entry_update_refval (gsef, refval);
}
......@@ -840,7 +855,7 @@ gimp_size_entry_refval_callback (GtkWidget *widget,
GimpSizeEntryField *gsef;
gfloat new_refval;
gsef = (GimpSizeEntryField*)data;
gsef = (GimpSizeEntryField*) data;
new_refval = GTK_ADJUSTMENT (widget)->value;
......@@ -898,7 +913,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
MAX(3 + digits, 3));
}
gimp_size_entry_stop_recursion = 0; /* hack !!! */
gsef->stop_recursion = 0; /* hack !!! */
gimp_size_entry_set_refval_boundaries (gse, i,
gsef->min_refval, gsef->max_refval);
}
......
......@@ -64,6 +64,8 @@ struct _GimpSizeEntryField
gfloat min_refval;
gfloat max_refval;
gint refval_digits;
gint stop_recursion;
};
......@@ -71,10 +73,6 @@ static gint gimp_size_entry_signals[LAST_SIGNAL] = { 0 };
static GtkTableClass *parent_class = NULL;
/* this is a hack to avoid infinite recursion when calling the
* boundary functions
*/
static gint gimp_size_entry_stop_recursion = 0;
static void
gimp_size_entry_class_destroy (GtkObject *object)
......@@ -237,6 +235,7 @@ gimp_size_entry_new (gint number_of_fields,
gsef->max_refval = SIZE_MAX_VALUE;
gsef->refval_digits =
(update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3;
gsef->stop_recursion = 0;
gsef->value_adjustment = gtk_adjustment_new (gsef->value,
gsef->min_value,
......@@ -356,6 +355,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse,
gsef->max_refval = SIZE_MAX_VALUE;
gsef->refval_digits =
(gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3;
gsef->stop_recursion = 0;
gsef->value_adjustment =
GTK_OBJECT (gtk_spin_button_get_adjustment (value_spinbutton));
......@@ -435,6 +435,7 @@ gimp_size_entry_set_resolution (GimpSizeEntry *gse,
guint keep_size)
{
GimpSizeEntryField *gsef;
float val;
g_return_if_fail (gse != NULL);