libgimp/Makefile.am new file. Currently contains constants for image size

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

	* libgimp/Makefile.am
	* libgimp/gimplimits.h: new file. Currently contains constants for
	image size and resolution.

	* app/file_new_dialog.c
	* app/resize.c: use the new constants.

	* app/layers_dialog.c: use a sizeentry in the "New Layer" query
	box. Folded the "Layer Fill Type" callbacks into one function.

	* app/text_tool.c
	* app/text_tool_cmds.c
	* tools/pdbgen/pdb/text_tool.pdb: did the calculations for
	resolutions < 1.0 right this time.

	* app/gimage_cmds.c
	* tool/pdbgen/pdb/gimage.pdb: fixed a typo.
This commit is contained in:
Michael Natterer 1999-05-09 16:38:05 +00:00 committed by Michael Natterer
parent 928dd48af7
commit 5711df6a9d
20 changed files with 540 additions and 344 deletions

View file

@ -1,3 +1,23 @@
1999-05-09 Michael Natterer <mitschel@cs.tu-berlin.de>
* libgimp/Makefile.am
* libgimp/gimplimits.h: new file. Currently contains constants for
image size and resolution.
* app/file_new_dialog.c
* app/resize.c: use the new constants.
* app/layers_dialog.c: use a sizeentry in the "New Layer" query
box. Folded the "Layer Fill Type" callbacks into one function.
* app/text_tool.c
* app/text_tool_cmds.c
* tools/pdbgen/pdb/text_tool.pdb: did the calculations for
resolutions < 1.0 right this time.
* app/gimage_cmds.c
* tool/pdbgen/pdb/gimage.pdb: fixed a typo.
Sun May 9 16:23:47 BST 1999 Adam D. Moss <adam@gimp.org>
* app/tile.c

View file

@ -12,8 +12,9 @@
#include "gdisplay.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
typedef struct {
GtkWidget *dlg;
@ -373,10 +374,12 @@ file_new_cmd_callback (GtkWidget *widget,
vals->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
vals->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
vals->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
@ -403,8 +406,9 @@ file_new_cmd_callback (GtkWidget *widget,
vals->simple_res = gimp_size_entry_new (1, vals->res_unit, "%s",
FALSE, FALSE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->simple_res),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->simple_res), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->simple_res), 0,
MIN(vals->xresolution, vals->yresolution));
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (vals->simple_res),
@ -426,10 +430,12 @@ file_new_cmd_callback (GtkWidget *widget,
gimp_size_entry_new (2, vals->res_unit, "%s",
FALSE, FALSE, TRUE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
vals->xresolution);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
@ -499,7 +505,6 @@ file_new_cmd_callback (GtkWidget *widget,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_widget_show (button);
/* frame for fill type */
frame = gtk_frame_new (_("Fill Type"));
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

View file

@ -22,18 +22,10 @@
#include "gimprc.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
/* TODO: - move size/resolution constants to a central place
* - agree on reasonable values ;)
*/
#define MIN_IMAGE_SIZE 1
#define MAX_IMAGE_SIZE 65536
#define MIN_RESOLUTION (1.0 / 65536.0)
#define MAX_RESOLUTION 65536.0
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
#define DRAWING_AREA_SIZE 200
#define TEXT_WIDTH 35
@ -305,10 +297,12 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
resolution_y, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 0,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 1,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 0, 0, width);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 1, 0, height);
@ -352,8 +346,8 @@ resize_widget_new (ResizeType type,
/* the scale ratio spinbuttons */
private->ratio_x_adj =
gtk_adjustment_new (resize->ratio_x,
(double) MIN_IMAGE_SIZE / (double) resize->width,
(double) MAX_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->width,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_x_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -368,8 +362,8 @@ resize_widget_new (ResizeType type,
private->ratio_y_adj =
gtk_adjustment_new (resize->ratio_y,
(double) MIN_IMAGE_SIZE / (double) resize->height,
(double) MAX_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->height,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_y_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -546,10 +540,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
0, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
1, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
0, resize->width);
@ -601,10 +595,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
0, MIN_RESOLUTION, MAX_RESOLUTION);
0, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
1, MIN_RESOLUTION, MAX_RESOLUTION);
1, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->resolution_se),
0, resize->resolution_x);
@ -884,13 +878,13 @@ size_callback (GtkWidget *w,
{
ratio_y = ratio_x;
height = (double) private->old_height * ratio_y;
height = BOUNDS (height, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height = BOUNDS (height, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
else
{
ratio_x = ratio_y;
width = (double) private->old_width * ratio_x;
width = BOUNDS (width, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (width, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
}
@ -929,10 +923,10 @@ ratio_callback (GtkWidget *w,
}
}
width =
BOUNDS (private->old_width * ratio_x, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height =
BOUNDS (private->old_height * ratio_y, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (private->old_width * ratio_x,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
height = BOUNDS (private->old_height * ratio_y,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
size_update (resize, width, height, ratio_x, ratio_y);
}
@ -1032,9 +1026,9 @@ printsize_update (GtkWidget *w,
* resolution.
*/
res_x = BOUNDS (resize->resolution_x * width / print_width,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
res_y = BOUNDS (resize->resolution_y * height / print_height,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (private->equal_res)))
{

View file

@ -12,8 +12,9 @@
#include "gdisplay.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
typedef struct {
GtkWidget *dlg;
@ -373,10 +374,12 @@ file_new_cmd_callback (GtkWidget *widget,
vals->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
vals->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
vals->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
@ -403,8 +406,9 @@ file_new_cmd_callback (GtkWidget *widget,
vals->simple_res = gimp_size_entry_new (1, vals->res_unit, "%s",
FALSE, FALSE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->simple_res),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->simple_res), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->simple_res), 0,
MIN(vals->xresolution, vals->yresolution));
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (vals->simple_res),
@ -426,10 +430,12 @@ file_new_cmd_callback (GtkWidget *widget,
gimp_size_entry_new (2, vals->res_unit, "%s",
FALSE, FALSE, TRUE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
vals->xresolution);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
@ -499,7 +505,6 @@ file_new_cmd_callback (GtkWidget *widget,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_widget_show (button);
/* frame for fill type */
frame = gtk_frame_new (_("Fill Type"));
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

View file

@ -3096,8 +3096,8 @@ static ProcRecord image_get_unit_proc =
"gimp_image_get_unit",
"Returns the unit of the specified image.",
"This procedure returns the specified image's unit. This value is independent of any of the layers in this image. See the gimp_unit_* procedure definitions for the valid range of unit IDs and a description of the unit system.",
"Michael Naterrer",
"Michael Naterrer",
"Michael Natterer",
"Michael Natterer",
"1998",
PDB_INTERNAL,
1,
@ -3147,8 +3147,8 @@ static ProcRecord image_set_unit_proc =
"gimp_image_set_unit",
"Set the unit of the specified image.",
"This procedure sets the specified image's unit. No scaling or resizing is performed. This value is independent of any of the layers in this image. See the gimp_unit_* procedure definitions for the valid range of unit IDs and a description of the unit system.",
"Michael Naterrer",
"Michael Naterrer",
"Michael Natterer",
"Michael Natterer",
"1998",
PDB_INTERNAL,
2,

View file

@ -12,8 +12,9 @@
#include "gdisplay.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
typedef struct {
GtkWidget *dlg;
@ -373,10 +374,12 @@ file_new_cmd_callback (GtkWidget *widget,
vals->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
vals->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->size_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 0,
vals->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->size_sizeentry), 1,
@ -403,8 +406,9 @@ file_new_cmd_callback (GtkWidget *widget,
vals->simple_res = gimp_size_entry_new (1, vals->res_unit, "%s",
FALSE, FALSE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->simple_res),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->simple_res), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->simple_res), 0,
MIN(vals->xresolution, vals->yresolution));
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (vals->simple_res),
@ -426,10 +430,12 @@ file_new_cmd_callback (GtkWidget *widget,
gimp_size_entry_new (2, vals->res_unit, "%s",
FALSE, FALSE, TRUE, 75,
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
0, 1, 32767);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (vals->resolution_sizeentry),
1, 1, 32767);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 0,
vals->xresolution);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (vals->resolution_sizeentry), 1,
@ -499,7 +505,6 @@ file_new_cmd_callback (GtkWidget *widget,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_widget_show (button);
/* frame for fill type */
frame = gtk_frame_new (_("Fill Type"));
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

View file

@ -45,6 +45,8 @@
#include "session.h"
#include "undo.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/eye.xbm"
@ -3034,8 +3036,7 @@ typedef struct _NewLayerOptions NewLayerOptions;
struct _NewLayerOptions {
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *xsize_entry;
GtkWidget *ysize_entry;
GtkWidget *size_se;
int fill_type;
int xsize;
int ysize;
@ -3059,8 +3060,10 @@ new_layer_query_ok_callback (GtkWidget *w,
g_free (layer_name);
layer_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
fill_type = options->fill_type;
options->xsize = atoi (gtk_entry_get_text (GTK_ENTRY (options->xsize_entry)));
options->ysize = atoi (gtk_entry_get_text (GTK_ENTRY (options->ysize_entry)));
options->xsize =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0);
options->ysize =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1);
if ((gimage = options->gimage))
{
@ -3113,44 +3116,14 @@ new_layer_query_delete_callback (GtkWidget *w,
static void
new_layer_background_callback (GtkWidget *w,
gpointer client_data)
new_layer_query_fill_type_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = BACKGROUND_FILL;
}
static void
new_layer_foreground_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = FOREGROUND_FILL;
}
static void
new_layer_white_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = WHITE_FILL;
}
static void
new_layer_transparent_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = TRANSPARENT_FILL;
options->fill_type =
(int) gtk_object_get_data (GTK_OBJECT (w), "layer_fill_type");
}
static void
@ -3165,12 +3138,13 @@ layers_dialog_new_layer_query (GimpImage* gimage)
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkObject *adjustment;
GtkWidget *spinbutton;
GtkWidget *radio_frame;
GtkWidget *radio_box;
GtkWidget *radio_button;
GSList *group = NULL;
int i;
char size[12];
char *button_names[4] =
{
N_("Foreground"),
@ -3178,13 +3152,6 @@ layers_dialog_new_layer_query (GimpImage* gimage)
N_("White"),
N_("Transparent")
};
ActionCallback button_callbacks[4] =
{
new_layer_foreground_callback,
new_layer_background_callback,
new_layer_white_callback,
new_layer_transparent_callback
};
/* the new options structure */
options = (NewLayerOptions *) g_malloc (sizeof (NewLayerOptions));
@ -3203,54 +3170,84 @@ layers_dialog_new_layer_query (GimpImage* gimage)
options);
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (options->query_box)->vbox), vbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (options->query_box)->vbox), vbox,
TRUE, TRUE, 0);
table = gtk_table_new (3, 2, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* the name entry hbox, label and entry */
label = gtk_label_new (_("Layer name:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
/* the name label and entry */
label = gtk_label_new (_("Layer Name:"));
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, 0, 1);
gtk_widget_show (label);
options->name_entry = gtk_entry_new ();
gtk_widget_set_usize (options->name_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry), (layer_name ? layer_name : _("New Layer")));
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
(layer_name ? layer_name : _("New Layer")));
gtk_widget_show (options->name_entry);
/* the xsize entry hbox, label and entry */
g_snprintf (size, 12, "%d", gimage->width);
label = gtk_label_new (_("Layer width: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
/* the size labels */
label = gtk_label_new (_("Layer Width:"));
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, 0, 1);
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
gtk_widget_show (label);
options->xsize_entry = gtk_entry_new ();
gtk_widget_set_usize (options->xsize_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->xsize_entry, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->xsize_entry), size);
gtk_widget_show (options->xsize_entry);
/* the ysize entry hbox, label and entry */
g_snprintf (size, 12, "%d", gimage->height);
label = gtk_label_new (_("Layer height: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
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, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 1);
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
gtk_widget_show (label);
options->ysize_entry = gtk_entry_new ();
gtk_widget_set_usize (options->ysize_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->ysize_entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->ysize_entry), size);
gtk_widget_show (options->ysize_entry);
/* the size sizeentry */
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
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);
options->size_se = gimp_size_entry_new (1, UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (options->size_se),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (options->size_se), spinbutton,
1, 2, 0, 1);
gtk_widget_show (spinbutton);
gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (options->size_se);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
gimage->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 1,
gimage->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 0,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 1,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 0,
0, gimage->width);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 1,
0, gimage->height);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 0,
gimage->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 1,
gimage->height);
gtk_widget_show (table);
@ -3264,11 +3261,14 @@ layers_dialog_new_layer_query (GimpImage* gimage)
/* the radio buttons */
for (i = 0; i < 4; i++)
{
radio_button = gtk_radio_button_new_with_label (group, gettext(button_names[i]));
radio_button =
gtk_radio_button_new_with_label (group, gettext(button_names[i]));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0);
gtk_object_set_data (GTK_OBJECT (radio_button), "layer_fill_type",
(gpointer) i);
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
(GtkSignalFunc) button_callbacks[i],
(GtkSignalFunc) new_layer_query_fill_type_callback,
options);
/* set the correct radio button */

View file

@ -22,18 +22,10 @@
#include "gimprc.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
/* TODO: - move size/resolution constants to a central place
* - agree on reasonable values ;)
*/
#define MIN_IMAGE_SIZE 1
#define MAX_IMAGE_SIZE 65536
#define MIN_RESOLUTION (1.0 / 65536.0)
#define MAX_RESOLUTION 65536.0
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
#define DRAWING_AREA_SIZE 200
#define TEXT_WIDTH 35
@ -305,10 +297,12 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
resolution_y, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 0,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 1,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 0, 0, width);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 1, 0, height);
@ -352,8 +346,8 @@ resize_widget_new (ResizeType type,
/* the scale ratio spinbuttons */
private->ratio_x_adj =
gtk_adjustment_new (resize->ratio_x,
(double) MIN_IMAGE_SIZE / (double) resize->width,
(double) MAX_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->width,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_x_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -368,8 +362,8 @@ resize_widget_new (ResizeType type,
private->ratio_y_adj =
gtk_adjustment_new (resize->ratio_y,
(double) MIN_IMAGE_SIZE / (double) resize->height,
(double) MAX_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->height,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_y_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -546,10 +540,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
0, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
1, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
0, resize->width);
@ -601,10 +595,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
0, MIN_RESOLUTION, MAX_RESOLUTION);
0, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
1, MIN_RESOLUTION, MAX_RESOLUTION);
1, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->resolution_se),
0, resize->resolution_x);
@ -884,13 +878,13 @@ size_callback (GtkWidget *w,
{
ratio_y = ratio_x;
height = (double) private->old_height * ratio_y;
height = BOUNDS (height, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height = BOUNDS (height, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
else
{
ratio_x = ratio_y;
width = (double) private->old_width * ratio_x;
width = BOUNDS (width, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (width, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
}
@ -929,10 +923,10 @@ ratio_callback (GtkWidget *w,
}
}
width =
BOUNDS (private->old_width * ratio_x, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height =
BOUNDS (private->old_height * ratio_y, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (private->old_width * ratio_x,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
height = BOUNDS (private->old_height * ratio_y,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
size_update (resize, width, height, ratio_x, ratio_y);
}
@ -1032,9 +1026,9 @@ printsize_update (GtkWidget *w,
* resolution.
*/
res_x = BOUNDS (resize->resolution_x * width / print_width,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
res_y = BOUNDS (resize->resolution_y * height / print_height,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (private->equal_res)))
{

View file

@ -45,6 +45,8 @@
#include "session.h"
#include "undo.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/eye.xbm"
@ -3034,8 +3036,7 @@ typedef struct _NewLayerOptions NewLayerOptions;
struct _NewLayerOptions {
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *xsize_entry;
GtkWidget *ysize_entry;
GtkWidget *size_se;
int fill_type;
int xsize;
int ysize;
@ -3059,8 +3060,10 @@ new_layer_query_ok_callback (GtkWidget *w,
g_free (layer_name);
layer_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
fill_type = options->fill_type;
options->xsize = atoi (gtk_entry_get_text (GTK_ENTRY (options->xsize_entry)));
options->ysize = atoi (gtk_entry_get_text (GTK_ENTRY (options->ysize_entry)));
options->xsize =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0);
options->ysize =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1);
if ((gimage = options->gimage))
{
@ -3113,44 +3116,14 @@ new_layer_query_delete_callback (GtkWidget *w,
static void
new_layer_background_callback (GtkWidget *w,
gpointer client_data)
new_layer_query_fill_type_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = BACKGROUND_FILL;
}
static void
new_layer_foreground_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = FOREGROUND_FILL;
}
static void
new_layer_white_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = WHITE_FILL;
}
static void
new_layer_transparent_callback (GtkWidget *w,
gpointer client_data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options->fill_type = TRANSPARENT_FILL;
options->fill_type =
(int) gtk_object_get_data (GTK_OBJECT (w), "layer_fill_type");
}
static void
@ -3165,12 +3138,13 @@ layers_dialog_new_layer_query (GimpImage* gimage)
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkObject *adjustment;
GtkWidget *spinbutton;
GtkWidget *radio_frame;
GtkWidget *radio_box;
GtkWidget *radio_button;
GSList *group = NULL;
int i;
char size[12];
char *button_names[4] =
{
N_("Foreground"),
@ -3178,13 +3152,6 @@ layers_dialog_new_layer_query (GimpImage* gimage)
N_("White"),
N_("Transparent")
};
ActionCallback button_callbacks[4] =
{
new_layer_foreground_callback,
new_layer_background_callback,
new_layer_white_callback,
new_layer_transparent_callback
};
/* the new options structure */
options = (NewLayerOptions *) g_malloc (sizeof (NewLayerOptions));
@ -3203,54 +3170,84 @@ layers_dialog_new_layer_query (GimpImage* gimage)
options);
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (options->query_box)->vbox), vbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (options->query_box)->vbox), vbox,
TRUE, TRUE, 0);
table = gtk_table_new (3, 2, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* the name entry hbox, label and entry */
label = gtk_label_new (_("Layer name:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
/* the name label and entry */
label = gtk_label_new (_("Layer Name:"));
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, 0, 1);
gtk_widget_show (label);
options->name_entry = gtk_entry_new ();
gtk_widget_set_usize (options->name_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry), (layer_name ? layer_name : _("New Layer")));
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry, 1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
(layer_name ? layer_name : _("New Layer")));
gtk_widget_show (options->name_entry);
/* the xsize entry hbox, label and entry */
g_snprintf (size, 12, "%d", gimage->width);
label = gtk_label_new (_("Layer width: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
/* the size labels */
label = gtk_label_new (_("Layer Width:"));
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, 0, 1);
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
gtk_widget_show (label);
options->xsize_entry = gtk_entry_new ();
gtk_widget_set_usize (options->xsize_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->xsize_entry, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->xsize_entry), size);
gtk_widget_show (options->xsize_entry);
/* the ysize entry hbox, label and entry */
g_snprintf (size, 12, "%d", gimage->height);
label = gtk_label_new (_("Layer height: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
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, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 1);
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
gtk_widget_show (label);
options->ysize_entry = gtk_entry_new ();
gtk_widget_set_usize (options->ysize_entry, 75, 0);
gtk_table_attach (GTK_TABLE (table), options->ysize_entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_SHRINK, 1, 1);
gtk_entry_set_text (GTK_ENTRY (options->ysize_entry), size);
gtk_widget_show (options->ysize_entry);
/* the size sizeentry */
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
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);
options->size_se = gimp_size_entry_new (1, UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (options->size_se),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (options->size_se), spinbutton,
1, 2, 0, 1);
gtk_widget_show (spinbutton);
gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (options->size_se);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
gimage->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 1,
gimage->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 0,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 1,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 0,
0, gimage->width);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 1,
0, gimage->height);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 0,
gimage->width);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 1,
gimage->height);
gtk_widget_show (table);
@ -3264,11 +3261,14 @@ layers_dialog_new_layer_query (GimpImage* gimage)
/* the radio buttons */
for (i = 0; i < 4; i++)
{
radio_button = gtk_radio_button_new_with_label (group, gettext(button_names[i]));
radio_button =
gtk_radio_button_new_with_label (group, gettext(button_names[i]));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0);
gtk_object_set_data (GTK_OBJECT (radio_button), "layer_fill_type",
(gpointer) i);
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
(GtkSignalFunc) button_callbacks[i],
(GtkSignalFunc) new_layer_query_fill_type_callback,
options);
/* set the correct radio button */

View file

@ -22,18 +22,10 @@
#include "gimprc.h"
#include "libgimp/gimpchainbutton.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpsizeentry.h"
#include "libgimp/gimpintl.h"
/* TODO: - move size/resolution constants to a central place
* - agree on reasonable values ;)
*/
#define MIN_IMAGE_SIZE 1
#define MAX_IMAGE_SIZE 65536
#define MIN_RESOLUTION (1.0 / 65536.0)
#define MAX_RESOLUTION 65536.0
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
#define DRAWING_AREA_SIZE 200
#define TEXT_WIDTH 35
@ -305,10 +297,12 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
resolution_y, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 0,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 1,
GIMP_MIN_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 0, 0, width);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 1, 0, height);
@ -352,8 +346,8 @@ resize_widget_new (ResizeType type,
/* the scale ratio spinbuttons */
private->ratio_x_adj =
gtk_adjustment_new (resize->ratio_x,
(double) MIN_IMAGE_SIZE / (double) resize->width,
(double) MAX_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->width,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->width,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_x_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -368,8 +362,8 @@ resize_widget_new (ResizeType type,
private->ratio_y_adj =
gtk_adjustment_new (resize->ratio_y,
(double) MIN_IMAGE_SIZE / (double) resize->height,
(double) MAX_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MIN_IMAGE_SIZE / (double) resize->height,
(double) GIMP_MAX_IMAGE_SIZE / (double) resize->height,
0.01, 0.1, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_y_adj), 1, 4);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
@ -546,10 +540,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
0, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
0, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->printsize_se),
1, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
1, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
0, resize->width);
@ -601,10 +595,10 @@ resize_widget_new (ResizeType type,
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
0, MIN_RESOLUTION, MAX_RESOLUTION);
0, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval_boundaries
(GIMP_SIZE_ENTRY (private->resolution_se),
1, MIN_RESOLUTION, MAX_RESOLUTION);
1, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->resolution_se),
0, resize->resolution_x);
@ -884,13 +878,13 @@ size_callback (GtkWidget *w,
{
ratio_y = ratio_x;
height = (double) private->old_height * ratio_y;
height = BOUNDS (height, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height = BOUNDS (height, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
else
{
ratio_x = ratio_y;
width = (double) private->old_width * ratio_x;
width = BOUNDS (width, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (width, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
}
}
@ -929,10 +923,10 @@ ratio_callback (GtkWidget *w,
}
}
width =
BOUNDS (private->old_width * ratio_x, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
height =
BOUNDS (private->old_height * ratio_y, MIN_IMAGE_SIZE, MAX_IMAGE_SIZE);
width = BOUNDS (private->old_width * ratio_x,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
height = BOUNDS (private->old_height * ratio_y,
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
size_update (resize, width, height, ratio_x, ratio_y);
}
@ -1032,9 +1026,9 @@ printsize_update (GtkWidget *w,
* resolution.
*/
res_x = BOUNDS (resize->resolution_x * width / print_width,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
res_y = BOUNDS (resize->resolution_y * height / print_height,
MIN_RESOLUTION, MAX_RESOLUTION);
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (private->equal_res)))
{

View file

@ -53,6 +53,7 @@
#include "tile_manager_pvt.h"
#include "drawable_pvt.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpintl.h"
#define FOUNDRY 0
@ -119,7 +120,7 @@ static gint text_delete_callback (GtkWidget *, GdkEvent *, gpointer);
static void text_init_render (TextTool *);
static void text_gdk_image_to_region (GdkImage *, int, PixelRegion *);
static void text_size_multiply (char **fontname, int);
static void text_set_resolution (char **fontname, int, int);
static void text_set_resolution (char **fontname, double, double);
Layer * text_render (GImage *, GimpDrawable *,
int, int, char *, char *, int, int);
@ -495,7 +496,7 @@ text_init_render (TextTool *text_tool)
* correctly according to the image's resolution.
* FIXME: this currently can't be activated for the PDB, as the text has
* to be rendered in the size "text_get_extents" returns.
* TODO: add an image parameter to "text_get_extents"
* TODO: add resolution parameters to "text_get_extents"
*/
text_set_resolution (&fontname,
gdisp->gimage->xresolution,
@ -922,37 +923,74 @@ text_size_multiply(char **fontname,
}
static void
text_set_resolution (char **fontname,
int xres,
int yres)
text_set_resolution (char **fontname,
double xresolution,
double yresolution)
{
char *point_str;
char *size_str;
char *xres_str;
char *yres_str;
char *newfont;
char *end;
char new_size[16];
char new_xres[16];
char new_yres[16];
double points;
int size;
int xres;
int yres;
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
text_field_edges (*fontname, POINT_SIZE, &size_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
if (xresolution < GIMP_MIN_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION ||
*size_str == '*')
return;
points = atof (size_str);
/* X allows only integer resolution values, so we do some
* ugly calculations (starting with yres because the size of
* a font is it's height)
*/
if (yresolution < 1.0)
{
points /= (1.0 / yresolution);
xresolution *= (1.0 / yresolution);
yresolution = 1.0;
}
/* res may be != (int) res
* (important only for very small resolutions)
*/
points *= yresolution / (double) (int) yresolution;
xresolution /= yresolution / (double) (int) yresolution;
/* finally, if xres became invalid by the above calculations */
xresolution = BOUNDS (xresolution, 1.0, GIMP_MAX_RESOLUTION);
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
*(size_str - 1) = 0;
*(xres_str - 1) = 0;
*(yres_str - 1) = 0;
/* convert the resolutions to text */
size = (int) points;
xres = (int) xresolution;
yres = (int) yresolution;
TO_TXT (size);
TO_TXT (xres);
TO_TXT (yres);
newfont = g_strdup_printf ("%s-%s-%s%s", *fontname, new_xres, new_yres, end);
newfont = g_strdup_printf ("%s-%s-%s-%s%s",
*fontname, new_size, new_xres, new_yres, end);
g_free (*fontname);

View file

@ -28,6 +28,8 @@
#include "layer.h"
#include "text_tool.h"
#include "libgimp/gimplimits.h"
static ProcRecord text_fontname_proc;
static ProcRecord text_get_extents_fontname_proc;
static ProcRecord text_proc;
@ -59,16 +61,16 @@ text_xlfd_insert_size (gchar *fontname,
if (size <= 0)
return NULL;
if (xresolution < (1.0 / 65536.0) ||
yresolution < (1.0 / 65536.0) ||
if (xresolution < GIMP_MIN_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION ||
metric == PIXELS)
{
xresolution = yresolution = 0.0;
}
else
{
xresolution = MIN (xresolution, 65536.0);
yresolution = MIN (yresolution, 65536.0);
xresolution = MIN (xresolution, GIMP_MAX_RESOLUTION);
yresolution = MIN (yresolution, GIMP_MAX_RESOLUTION);
}
if (antialias)
@ -80,13 +82,16 @@ text_xlfd_insert_size (gchar *fontname,
*/
if (metric == POINTS && xresolution != 0.0)
{
/* the xlfd uses decipoints */
size *= 10;
/* X allows only integer resolution values, so we do some
* ugly calculations (starting with yres because the size of
* a font is it's height)
*/
if (yresolution < 1.0)
{
size *= (1.0 / yresolution);
size /= (1.0 / yresolution);
xresolution *= (1.0 / yresolution);
yresolution = 1.0;
}
@ -94,14 +99,11 @@ text_xlfd_insert_size (gchar *fontname,
/* res may be != (int) res
* (important only for very small resolutions)
*/
size *= yresolution / (double) (int) yresolution;
xresolution /= yresolution / (double) (int) yresolution;
size /= yresolution / (double) (int) yresolution;
/* finally, if xres became invalid by the above calculations */
xresolution = BOUNDS (xresolution, 1.0, 65536.0);
/* the xlfd uses decipoints */
size *= 10;
xresolution = BOUNDS (xresolution, 1.0, GIMP_MAX_RESOLUTION);
}
sprintf (size_buffer, "%d", (int) size);

View file

@ -53,6 +53,7 @@
#include "tile_manager_pvt.h"
#include "drawable_pvt.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpintl.h"
#define FOUNDRY 0
@ -119,7 +120,7 @@ static gint text_delete_callback (GtkWidget *, GdkEvent *, gpointer);
static void text_init_render (TextTool *);
static void text_gdk_image_to_region (GdkImage *, int, PixelRegion *);
static void text_size_multiply (char **fontname, int);
static void text_set_resolution (char **fontname, int, int);
static void text_set_resolution (char **fontname, double, double);
Layer * text_render (GImage *, GimpDrawable *,
int, int, char *, char *, int, int);
@ -495,7 +496,7 @@ text_init_render (TextTool *text_tool)
* correctly according to the image's resolution.
* FIXME: this currently can't be activated for the PDB, as the text has
* to be rendered in the size "text_get_extents" returns.
* TODO: add an image parameter to "text_get_extents"
* TODO: add resolution parameters to "text_get_extents"
*/
text_set_resolution (&fontname,
gdisp->gimage->xresolution,
@ -922,37 +923,74 @@ text_size_multiply(char **fontname,
}
static void
text_set_resolution (char **fontname,
int xres,
int yres)
text_set_resolution (char **fontname,
double xresolution,
double yresolution)
{
char *point_str;
char *size_str;
char *xres_str;
char *yres_str;
char *newfont;
char *end;
char new_size[16];
char new_xres[16];
char new_yres[16];
double points;
int size;
int xres;
int yres;
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
text_field_edges (*fontname, POINT_SIZE, &size_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
if (xresolution < GIMP_MIN_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION ||
*size_str == '*')
return;
points = atof (size_str);
/* X allows only integer resolution values, so we do some
* ugly calculations (starting with yres because the size of
* a font is it's height)
*/
if (yresolution < 1.0)
{
points /= (1.0 / yresolution);
xresolution *= (1.0 / yresolution);
yresolution = 1.0;
}
/* res may be != (int) res
* (important only for very small resolutions)
*/
points *= yresolution / (double) (int) yresolution;
xresolution /= yresolution / (double) (int) yresolution;
/* finally, if xres became invalid by the above calculations */
xresolution = BOUNDS (xresolution, 1.0, GIMP_MAX_RESOLUTION);
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
*(size_str - 1) = 0;
*(xres_str - 1) = 0;
*(yres_str - 1) = 0;
/* convert the resolutions to text */
size = (int) points;
xres = (int) xresolution;
yres = (int) yresolution;
TO_TXT (size);
TO_TXT (xres);
TO_TXT (yres);
newfont = g_strdup_printf ("%s-%s-%s%s", *fontname, new_xres, new_yres, end);
newfont = g_strdup_printf ("%s-%s-%s-%s%s",
*fontname, new_size, new_xres, new_yres, end);
g_free (*fontname);

View file

@ -53,6 +53,7 @@
#include "tile_manager_pvt.h"
#include "drawable_pvt.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpintl.h"
#define FOUNDRY 0
@ -119,7 +120,7 @@ static gint text_delete_callback (GtkWidget *, GdkEvent *, gpointer);
static void text_init_render (TextTool *);
static void text_gdk_image_to_region (GdkImage *, int, PixelRegion *);
static void text_size_multiply (char **fontname, int);
static void text_set_resolution (char **fontname, int, int);
static void text_set_resolution (char **fontname, double, double);
Layer * text_render (GImage *, GimpDrawable *,
int, int, char *, char *, int, int);
@ -495,7 +496,7 @@ text_init_render (TextTool *text_tool)
* correctly according to the image's resolution.
* FIXME: this currently can't be activated for the PDB, as the text has
* to be rendered in the size "text_get_extents" returns.
* TODO: add an image parameter to "text_get_extents"
* TODO: add resolution parameters to "text_get_extents"
*/
text_set_resolution (&fontname,
gdisp->gimage->xresolution,
@ -922,37 +923,74 @@ text_size_multiply(char **fontname,
}
static void
text_set_resolution (char **fontname,
int xres,
int yres)
text_set_resolution (char **fontname,
double xresolution,
double yresolution)
{
char *point_str;
char *size_str;
char *xres_str;
char *yres_str;
char *newfont;
char *end;
char new_size[16];
char new_xres[16];
char new_yres[16];
double points;
int size;
int xres;
int yres;
/* get the point size string */
text_field_edges(*fontname, POINT_SIZE, &point_str, &end);
text_field_edges (*fontname, POINT_SIZE, &size_str, &end);
/* don't set the resolution if the point size is unspecified */
if (*point_str == '*')
if (xresolution < GIMP_MIN_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION ||
*size_str == '*')
return;
points = atof (size_str);
/* X allows only integer resolution values, so we do some
* ugly calculations (starting with yres because the size of
* a font is it's height)
*/
if (yresolution < 1.0)
{
points /= (1.0 / yresolution);
xresolution *= (1.0 / yresolution);
yresolution = 1.0;
}
/* res may be != (int) res
* (important only for very small resolutions)
*/
points *= yresolution / (double) (int) yresolution;
xresolution /= yresolution / (double) (int) yresolution;
/* finally, if xres became invalid by the above calculations */
xresolution = BOUNDS (xresolution, 1.0, GIMP_MAX_RESOLUTION);
/* slice the font spec around the resolution fields */
text_field_edges (*fontname, XRESOLUTION, &xres_str, &end);
text_field_edges (*fontname, YRESOLUTION, &yres_str, &end);
*(size_str - 1) = 0;
*(xres_str - 1) = 0;
*(yres_str - 1) = 0;
/* convert the resolutions to text */
size = (int) points;
xres = (int) xresolution;
yres = (int) yresolution;
TO_TXT (size);
TO_TXT (xres);
TO_TXT (yres);
newfont = g_strdup_printf ("%s-%s-%s%s", *fontname, new_xres, new_yres, end);
newfont = g_strdup_printf ("%s-%s-%s-%s%s",
*fontname, new_size, new_xres, new_yres, end);
g_free (*fontname);

View file

@ -98,6 +98,7 @@ gimpinclude_HEADERS = \
gimpenv.h \
gimpfeatures.h \
gimpfileselection.h \
gimplimits.h \
gimpmatrix.h \
gimpmenu.h \
gimpmodule.h \

35
libgimp/gimplimits.h Normal file
View file

@ -0,0 +1,35 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
*
* gimplimits.h
* Copyright (C) 1999 Michael Natterer <mitschel@cs.tu-berlin.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_LIMITS_H__
#define __GIMP_LIMITS_H__
/* pixel sizes
*/
#define GIMP_MIN_IMAGE_SIZE 1
#define GIMP_MAX_IMAGE_SIZE 65536
/* dots per inch
*/
#define GIMP_MIN_RESOLUTION (1.0 / 65536.0)
#define GIMP_MAX_RESOLUTION 65536.0
#endif /* __GIMP_LIMITS_H__ */

35
libgimpbase/gimplimits.h Normal file
View file

@ -0,0 +1,35 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
*
* gimplimits.h
* Copyright (C) 1999 Michael Natterer <mitschel@cs.tu-berlin.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_LIMITS_H__
#define __GIMP_LIMITS_H__
/* pixel sizes
*/
#define GIMP_MIN_IMAGE_SIZE 1
#define GIMP_MAX_IMAGE_SIZE 65536
/* dots per inch
*/
#define GIMP_MIN_RESOLUTION (1.0 / 65536.0)
#define GIMP_MAX_RESOLUTION 65536.0
#endif /* __GIMP_LIMITS_H__ */

View file

@ -1132,7 +1132,7 @@ description of the unit system.
HELP
my $unit_misc = <<'CODE';
$author = $copyright = 'Michael Naterrer';
$author = $copyright = 'Michael Natterer';
$date = '1998';
CODE
&image_accessors('unit', 'unit (min UNIT_INCH)', 'unit', 0,

View file

@ -1132,7 +1132,7 @@ description of the unit system.
HELP
my $unit_misc = <<'CODE';
$author = $copyright = 'Michael Naterrer';
$author = $copyright = 'Michael Natterer';
$date = '1998';
CODE
&image_accessors('unit', 'unit (min UNIT_INCH)', 'unit', 0,

View file

@ -45,15 +45,6 @@ sub size_args () {(
desc => 'The units of specified size: %%desc%%' }
)}
sub res_args () {(
{ name => 'xresolution', type => '(1.0 / 65536.0) < float < 65536.0',
desc => 'The horizontal resolution (in dpi) of the image the
text will be rendered to' },
{ name => 'yersolution', type => '(1.0 / 65536.0) < float < 65536.0',
desc => 'The vertical resolution (in dpi) of the image the
text will be rendered to' }
)}
sub render_args () {(
&std_image_arg,
{ name => 'drawable', type => 'drawable',
@ -257,7 +248,8 @@ HELP
);
}
@headers = qw("appenv.h" "text_tool.h" <stdio.h> <string.h>);
@headers = qw("appenv.h" "text_tool.h" "libgimp/gimplimits.h"
<stdio.h> <string.h>);
$extra{app}->{code} = <<'CODE';
static gchar *
@ -277,16 +269,16 @@ text_xlfd_insert_size (gchar *fontname,
if (size <= 0)
return NULL;
if (xresolution < (1.0 / 65536.0) ||
yresolution < (1.0 / 65536.0) ||
if (xresolution < GIMP_MIN_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION ||
metric == PIXELS)
{
xresolution = yresolution = 0.0;
}
else
{
xresolution = MIN (xresolution, 65536.0);
yresolution = MIN (yresolution, 65536.0);
xresolution = MIN (xresolution, GIMP_MAX_RESOLUTION);
yresolution = MIN (yresolution, GIMP_MAX_RESOLUTION);
}
if (antialias)
@ -298,13 +290,16 @@ text_xlfd_insert_size (gchar *fontname,
*/
if (metric == POINTS && xresolution != 0.0)
{
/* the xlfd uses decipoints */
size *= 10;
/* X allows only integer resolution values, so we do some
* ugly calculations (starting with yres because the size of
* a font is it's height)
*/
if (yresolution < 1.0)
{
size *= (1.0 / yresolution);
size /= (1.0 / yresolution);
xresolution *= (1.0 / yresolution);
yresolution = 1.0;
}
@ -312,14 +307,11 @@ text_xlfd_insert_size (gchar *fontname,
/* res may be != (int) res
* (important only for very small resolutions)
*/
size *= yresolution / (double) (int) yresolution;
xresolution /= yresolution / (double) (int) yresolution;
size /= yresolution / (double) (int) yresolution;
/* finally, if xres became invalid by the above calculations */
xresolution = BOUNDS (xresolution, 1.0, 65536.0);
/* the xlfd uses decipoints */
size *= 10;
xresolution = BOUNDS (xresolution, 1.0, GIMP_MAX_RESOLUTION);
}
sprintf (size_buffer, "%d", (int) size);