Commit 26b9002c authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer
Browse files

app/commands.c app/layers_dialog.c new scale/resize ui: Use size entries

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

	* app/commands.c
	* app/layers_dialog.c
	* app/resize.[ch]: new scale/resize ui:
	Use size entries instead of text entries, chainbuttons instead of
	check buttons. Put the stuff into frames. Added labels for the
	original width and height.
	It's possible to change resolution/unit now, please test if it
	does the right thing.

	* libgimp/gimpsizeentry.c: allow lower == upper when checking
	boundaries.
parent 26a9e377
1999-05-02 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/commands.c
* app/layers_dialog.c
* app/resize.[ch]: new scale/resize ui:
Use size entries instead of text entries, chainbuttons instead of
check buttons. Put the stuff into frames. Added labels for the
original width and height.
It's possible to change resolution/unit now, please test if it
does the right thing.
* libgimp/gimpsizeentry.c: allow lower == upper when checking
boundaries.
Sat May 1 14:43:42 PDT 1999 Manish Singh <yosh@gimp.org>
* tools/pdbgen/pdb/fileops.pdb
......
......@@ -785,6 +785,8 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_resize_callback,
image_cancel_callback,
image_delete_callback,
......@@ -816,6 +818,8 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_scale_callback,
image_cancel_callback,
image_delete_callback,
......@@ -1110,8 +1114,8 @@ image_resize_callback (GtkWidget *w,
gimage_resize (gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->off_x,
image_resize->resize->off_y);
image_resize->resize->offset_x,
image_resize->resize->offset_y);
gdisplays_flush ();
}
else
......@@ -1131,26 +1135,44 @@ image_scale_callback (GtkWidget *w,
{
ImageResize *image_scale;
GImage *gimage;
gboolean flush = FALSE;
image_scale = (ImageResize *) client_data;
if ((gimage = image_scale->gimage) != NULL &&
(image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height))
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
gdisplays_flush ();
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
else
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
g_message (_("Scale Error: Both width and height must be greater than zero."));
return;
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
flush = TRUE;
}
else
{
g_message (_("Scale Error: Both width and height must be "
"greater than zero."));
return;
}
}
if (flush)
gdisplays_flush ();
}
resize_widget_free (image_scale->resize);
......
......@@ -785,6 +785,8 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_resize_callback,
image_cancel_callback,
image_delete_callback,
......@@ -816,6 +818,8 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_scale_callback,
image_cancel_callback,
image_delete_callback,
......@@ -1110,8 +1114,8 @@ image_resize_callback (GtkWidget *w,
gimage_resize (gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->off_x,
image_resize->resize->off_y);
image_resize->resize->offset_x,
image_resize->resize->offset_y);
gdisplays_flush ();
}
else
......@@ -1131,26 +1135,44 @@ image_scale_callback (GtkWidget *w,
{
ImageResize *image_scale;
GImage *gimage;
gboolean flush = FALSE;
image_scale = (ImageResize *) client_data;
if ((gimage = image_scale->gimage) != NULL &&
(image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height))
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
gdisplays_flush ();
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
else
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
g_message (_("Scale Error: Both width and height must be greater than zero."));
return;
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
flush = TRUE;
}
else
{
g_message (_("Scale Error: Both width and height must be "
"greater than zero."));
return;
}
}
if (flush)
gdisplays_flush ();
}
resize_widget_free (image_scale->resize);
......
This diff is collapsed.
......@@ -18,6 +18,8 @@
#ifndef __RESIZE_H__
#define __RESIZE_H__
#include "libgimp/gimpunit.h"
typedef enum
{
ScaleWidget,
......@@ -35,17 +37,23 @@ typedef struct _Resize Resize;
struct _Resize
{
/* The calling procedure is respondible for showing this widget */
GtkWidget *resize_shell;
GtkWidget *resize_shell;
ResizeType type;
ResizeTarget target;
int width;
int height;
float resolution_x;
float resolution_y;
GUnit unit;
double ratio_x;
double ratio_y;
ResizeType type;
int width;
int height;
float resolution_x;
float resolution_y;
double ratio_x;
double ratio_y;
int off_x;
int off_y;
int offset_x;
int offset_y;
/* Don't touch this :) */
void * private_part;
......@@ -61,6 +69,8 @@ Resize * resize_widget_new (ResizeType type,
int height,
float resolution_x,
float resolution_y,
GUnit unit,
gboolean dot_for_dot,
GtkSignalFunc ok_cb,
GtkSignalFunc cancel_cb,
gint (*delete_cb) (GtkWidget *,
......
......@@ -785,6 +785,8 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_resize_callback,
image_cancel_callback,
image_delete_callback,
......@@ -816,6 +818,8 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_scale_callback,
image_cancel_callback,
image_delete_callback,
......@@ -1110,8 +1114,8 @@ image_resize_callback (GtkWidget *w,
gimage_resize (gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->off_x,
image_resize->resize->off_y);
image_resize->resize->offset_x,
image_resize->resize->offset_y);
gdisplays_flush ();
}
else
......@@ -1131,26 +1135,44 @@ image_scale_callback (GtkWidget *w,
{
ImageResize *image_scale;
GImage *gimage;
gboolean flush = FALSE;
image_scale = (ImageResize *) client_data;
if ((gimage = image_scale->gimage) != NULL &&
(image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height))
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
gdisplays_flush ();
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
else
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
g_message (_("Scale Error: Both width and height must be greater than zero."));
return;
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
flush = TRUE;
}
else
{
g_message (_("Scale Error: Both width and height must be "
"greater than zero."));
return;
}
}
if (flush)
gdisplays_flush ();
}
resize_widget_free (image_scale->resize);
......
......@@ -785,6 +785,8 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_resize_callback,
image_cancel_callback,
image_delete_callback,
......@@ -816,6 +818,8 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage->height,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
image_scale_callback,
image_cancel_callback,
image_delete_callback,
......@@ -1110,8 +1114,8 @@ image_resize_callback (GtkWidget *w,
gimage_resize (gimage,
image_resize->resize->width,
image_resize->resize->height,
image_resize->resize->off_x,
image_resize->resize->off_y);
image_resize->resize->offset_x,
image_resize->resize->offset_y);
gdisplays_flush ();
}
else
......@@ -1131,26 +1135,44 @@ image_scale_callback (GtkWidget *w,
{
ImageResize *image_scale;
GImage *gimage;
gboolean flush = FALSE;
image_scale = (ImageResize *) client_data;
if ((gimage = image_scale->gimage) != NULL &&
(image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height))
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution ||
image_scale->resize->unit != gimage->unit)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
gdisplays_flush ();
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
gimage_set_unit (gimage, image_scale->resize->unit);
flush = TRUE;
}
else
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
g_message (_("Scale Error: Both width and height must be greater than zero."));
return;
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
flush = TRUE;
}
else
{
g_message (_("Scale Error: Both width and height must be "
"greater than zero."));
return;
}
}
if (flush)
gdisplays_flush ();
}
resize_widget_free (image_scale->resize);
......
......@@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdk/gdkkeysyms.h"
......@@ -196,8 +195,8 @@ static void layers_dialog_new_layer_query (GimpImage*);
static void layers_dialog_edit_layer_query (LayerWidget *);
static void layers_dialog_add_mask_query (Layer *);
static void layers_dialog_apply_mask_query (Layer *);
static void layers_dialog_scale_layer_query (Layer *);
static void layers_dialog_resize_layer_query (Layer *);
static void layers_dialog_scale_layer_query (GImage *, Layer *);
static void layers_dialog_resize_layer_query (GImage *, Layer *);
void layers_dialog_layer_merge_query (GImage *, int);
......@@ -1795,7 +1794,7 @@ layers_dialog_scale_layer_callback (GtkWidget *w,
if (! (gimage = layersD->gimage))
return;
layers_dialog_scale_layer_query (gimage->active_layer);
layers_dialog_scale_layer_query (gimage, gimage->active_layer);
}
......@@ -1812,7 +1811,7 @@ layers_dialog_resize_layer_callback (GtkWidget *w,
if (! (gimage = layersD->gimage))
return;
layers_dialog_resize_layer_query (gimage->active_layer);
layers_dialog_resize_layer_query (gimage, gimage->active_layer);
}
......@@ -3226,7 +3225,7 @@ layers_dialog_new_layer_query (GimpImage* gimage)
gtk_widget_show (options->name_entry);
/* the xsize entry hbox, label and entry */
sprintf (size, "%d", gimage->width);
g_snprintf (size, 12, "%d", gimage->width);
label = gtk_label_new (_("Layer width: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
......@@ -3240,7 +3239,7 @@ layers_dialog_new_layer_query (GimpImage* gimage)
gtk_widget_show (options->xsize_entry);
/* the ysize entry hbox, label and entry */
sprintf (size, "%d", gimage->height);
g_snprintf (size, 12, "%d", gimage->height);
label = gtk_label_new (_("Layer height: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
......@@ -3761,7 +3760,8 @@ scale_layer_query_delete_callback (GtkWidget *w,
}
static void
layers_dialog_scale_layer_query (Layer *layer)
layers_dialog_scale_layer_query (GImage *gimage,
Layer *layer)
{
ScaleLayerOptions *options;
......@@ -3773,7 +3773,10 @@ layers_dialog_scale_layer_query (Layer *layer)
GTK_OBJECT (layer),
drawable_width (GIMP_DRAWABLE(layer)),
drawable_height (GIMP_DRAWABLE(layer)),
0.0, 0.0, /* no resolution, please */
gimage->xresolution,
gimage->yresolution,
gimage->unit,
TRUE,
scale_layer_query_ok_callback,
scale_layer_query_cancel_callback,
scale_layer_query_delete_callback,
......@@ -3816,7 +3819,7 @@ resize_layer_query_ok_callback (GtkWidget *w,
layer_resize (layer,
options->resize->width, options->resize->height,
options->resize->off_x, options->resize->off_y);
options->resize->offset_x, options->resize->offset_y);
if (layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
......@@ -3855,7 +3858,8 @@ resize_layer_query_delete_callback (GtkWidget *w,
}
static void
layers_dialog_resize_layer_query (Layer *layer)
layers_dialog_resize_layer_query (GImage * gimage,
Layer * layer)
{
ResizeLayerOptions *options;
......@@ -3867,7 +3871,10 @@ layers_dialog_resize_layer_query (Layer *layer)
GTK_OBJECT (layer),
drawable_width (GIMP_DRAWABLE(layer)),
drawable_height (GIMP_DRAWABLE(layer)),
0.0, 0.0, /* no resolution, please */
gimage->xresolution,
gimage->yresolution,
gimage->unit,
TRUE,
resize_layer_query_ok_callback,
resize_layer_query_cancel_callback,
resize_layer_query_delete_callback,
......
This diff is collapsed.
......@@ -18,6 +18,8 @@
#ifndef __RESIZE_H__
#define __RESIZE_H__
#include "libgimp/gimpunit.h"
typedef enum
{
ScaleWidget,
......@@ -35,17 +37,23 @@ typedef struct _Resize Resize;
struct _Resize
{
/* The calling procedure is respondible for showing this widget */
GtkWidget *resize_shell;
GtkWidget *resize_shell;
ResizeType type;
ResizeTarget target;
int width;
int height;
float resolution_x;
float resolution_y;
GUnit unit;
double ratio_x;
double ratio_y;
ResizeType type;
int width;
int height;
float resolution_x;
float resolution_y;
double ratio_x;
double ratio_y;
int off_x;
int off_y;
int offset_x;
int offset_y;
/* Don't touch this :) */
void * private_part;
......@@ -61,6 +69,8 @@ Resize * resize_widget_new (ResizeType type,
int height,
float resolution_x,
float resolution_y,
GUnit unit,
gboolean dot_for_dot,
GtkSignalFunc ok_cb,
GtkSignalFunc cancel_cb,
gint (*delete_cb) (GtkWidget *,
......
......@@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdk/gdkkeysyms.h"
......@@ -196,8 +195,8 @@ static void layers_dialog_new_layer_query (GimpImage*);
static void layers_dialog_edit_layer_query (LayerWidget *);
static void layers_dialog_add_mask_query (Layer *);
static void layers_dialog_apply_mask_query (Layer *);
static void layers_dialog_scale_layer_query (Layer *);
static void layers_dialog_resize_layer_query (Layer *);
static void layers_dialog_scale_layer_query (GImage *, Layer *);
static void layers_dialog_resize_layer_query (GImage *, Layer *);
void layers_dialog_layer_merge_query (GImage *, int);
......@@ -1795,7 +1794,7 @@ layers_dialog_scale_layer_callback (GtkWidget *w,
if (! (gimage = layersD->gimage))
return;
layers_dialog_scale_layer_query (gimage->active_layer);
layers_dialog_scale_layer_query (gimage, gimage->active_layer);
}
......@@ -1812,7 +1811,7 @@ layers_dialog_resize_layer_callback (GtkWidget *w,
if (! (gimage = layersD->gimage))
return;
layers_dialog_resize_layer_query (gimage->active_layer);
layers_dialog_resize_layer_query (gimage, gimage->active_layer);
}
......@@ -3226,7 +3225,7 @@ layers_dialog_new_layer_query (GimpImage* gimage)
gtk_widget_show (options->name_entry);
/* the xsize entry hbox, label and entry */
sprintf (size, "%d", gimage->width);
g_snprintf (size, 12, "%d", gimage->width);
label = gtk_label_new (_("Layer width: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
......@@ -3240,7 +3239,7 @@ layers_dialog_new_layer_query (GimpImage* gimage)
gtk_widget_show (options->xsize_entry);
/* the ysize entry hbox, label and entry */
sprintf (size, "%d", gimage->height);
g_snprintf (size, 12, "%d", gimage->height);
label = gtk_label_new (_("Layer height: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
......@@ -3761,7 +3760,8 @@ scale_layer_query_delete_callback (GtkWidget *w,
}
static void
layers_dialog_scale_layer_query (Layer *layer)