mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
some s/0/FALSE/
2001-06-05 Michael Natterer <mitch@gimp.org> * app/global_edit.c: some s/0/FALSE/ * app/resize.[ch]: removed resize_scale_implement() and resize_check_layer_scaling(), cleanup. * app/core/gimpimage.[ch]: added gimp_image_check_scaling(). * app/gui/commands.c: added image_scale_implement() as static function. * app/gui/tool-options-dialog.[ch]: add the tool options widgets to the dialog when they are first needed. Removed tool_options_dialog_add(). * app/tools/tool_manager.c: don't call tool_options_dialog_add().
This commit is contained in:
parent
f1e229ab0c
commit
80dad0fcfa
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2001-06-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/global_edit.c: some s/0/FALSE/
|
||||
|
||||
* app/resize.[ch]: removed resize_scale_implement() and
|
||||
resize_check_layer_scaling(), cleanup.
|
||||
|
||||
* app/core/gimpimage.[ch]: added gimp_image_check_scaling().
|
||||
|
||||
* app/gui/commands.c: added image_scale_implement() as static
|
||||
function.
|
||||
|
||||
* app/gui/tool-options-dialog.[ch]: add the tool options widgets
|
||||
to the dialog when they are first needed. Removed
|
||||
tool_options_dialog_add().
|
||||
|
||||
* app/tools/tool_manager.c: don't call tool_options_dialog_add().
|
||||
|
||||
2001-06-03 Dave Neary <dneary@eircom.net>
|
||||
|
||||
* app/gimprc.[ch]: Made all the global options members of one
|
||||
|
|
|
@ -76,26 +76,30 @@
|
|||
|
||||
|
||||
/* local functions */
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
static void image_scale_implement (ImageResize *image_scale);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
@ -1097,11 +1101,132 @@ image_scale_callback (GtkWidget *widget,
|
|||
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, FALSE);
|
||||
|
||||
if (resize_check_layer_scaling (image_scale))
|
||||
if (gimp_image_check_scaling (image_scale->gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height))
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
image_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale;
|
||||
GimpImage *gimage;
|
||||
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -223,7 +223,7 @@ edit_cut (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (cut && empty == FALSE)
|
||||
{
|
||||
cropped_cut = crop_buffer (cut, 0);
|
||||
cropped_cut = crop_buffer (cut, FALSE);
|
||||
|
||||
if (cropped_cut != cut)
|
||||
tile_manager_destroy (cut);
|
||||
|
@ -274,7 +274,7 @@ edit_copy (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (copy && empty == FALSE)
|
||||
{
|
||||
cropped_copy = crop_buffer (copy, 0);
|
||||
cropped_copy = crop_buffer (copy, FALSE);
|
||||
|
||||
if (cropped_copy != copy)
|
||||
tile_manager_destroy (copy);
|
||||
|
|
|
@ -223,7 +223,7 @@ edit_cut (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (cut && empty == FALSE)
|
||||
{
|
||||
cropped_cut = crop_buffer (cut, 0);
|
||||
cropped_cut = crop_buffer (cut, FALSE);
|
||||
|
||||
if (cropped_cut != cut)
|
||||
tile_manager_destroy (cut);
|
||||
|
@ -274,7 +274,7 @@ edit_copy (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (copy && empty == FALSE)
|
||||
{
|
||||
cropped_copy = crop_buffer (copy, 0);
|
||||
cropped_copy = crop_buffer (copy, FALSE);
|
||||
|
||||
if (cropped_copy != copy)
|
||||
tile_manager_destroy (copy);
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
|
||||
else
|
||||
*/
|
||||
|
||||
|
||||
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
|
||||
gimage_mask_invalidate (gimage);
|
||||
|
||||
|
@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
|
|||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
|
||||
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
|
||||
{
|
||||
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
|
||||
* vanishing scaled layer dimensions. Implicit delete implemented
|
||||
* here. Upstream warning implemented in resize_check_layer_scaling()
|
||||
* [resize.c line 1295], which offers the user the chance to bail out.
|
||||
*/
|
||||
|
||||
remove = g_slist_append (remove, layer);
|
||||
}
|
||||
}
|
||||
/* We defer removing layers lost to scaling until now */
|
||||
/* so as not to mix the operations of iterating over and removal */
|
||||
/* from gimage->layers. */
|
||||
|
||||
/* We defer removing layers lost to scaling until now so as not to mix
|
||||
* the operations of iterating over and removal from gimage->layers.
|
||||
*/
|
||||
for (slist = remove; slist; slist = g_slist_next (slist))
|
||||
{
|
||||
layer = slist->data;
|
||||
|
@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
|
|||
gimp_unset_busy ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_check_scaling:
|
||||
* @gimage: A #GimpImage.
|
||||
* @new_width: The new width.
|
||||
* @new_height: The new height.
|
||||
*
|
||||
* Inventory the layer list in gimage and return #TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
*
|
||||
* Return value: #TRUE if scaling the image will shrink none of it's
|
||||
* layers completely away.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
for (list = GIMP_LIST (gimage->layers)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
layer = (GimpLayer *) list->data;
|
||||
|
||||
if (! gimp_layer_check_scaling (layer, new_width, new_height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
|
|
|
@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
|
|||
void gimp_image_scale (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
|
|
|
@ -28,12 +28,9 @@
|
|||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "gdisplay.h"
|
||||
#include "gimprc.h"
|
||||
#include "resize.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
@ -42,6 +39,8 @@ typedef struct _ResizePrivate ResizePrivate;
|
|||
|
||||
struct _ResizePrivate
|
||||
{
|
||||
Resize resize;
|
||||
|
||||
/* size frame */
|
||||
GtkWidget *orig_width_label;
|
||||
GtkWidget *orig_height_label;
|
||||
|
@ -97,9 +96,6 @@ static void resolution_callback (GtkWidget *widget,
|
|||
static void resolution_update (Resize *resize,
|
||||
gdouble res_x,
|
||||
gdouble res_y);
|
||||
static void resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
|
||||
|
||||
Resize *
|
||||
|
@ -117,31 +113,32 @@ resize_widget_new (ResizeType type,
|
|||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
|
||||
abox = NULL;
|
||||
frame = NULL;
|
||||
|
||||
private = g_new0 (ResizePrivate, 1);
|
||||
|
||||
private->old_width = width;
|
||||
private->old_height = height;
|
||||
private->old_res_x = resolution_x;
|
||||
private->old_res_y = resolution_y;
|
||||
|
||||
resize = g_new (Resize, 1);
|
||||
resize = (Resize *) private;
|
||||
|
||||
resize->type = type;
|
||||
resize->target = target;
|
||||
resize->private_part = private;
|
||||
resize->width = width;
|
||||
resize->height = height;
|
||||
resize->resolution_x = resolution_x;
|
||||
|
@ -218,9 +215,6 @@ resize_widget_new (ResizeType type,
|
|||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) private);
|
||||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) resize);
|
||||
}
|
||||
|
||||
/* handle the image disappearing under our feet */
|
||||
|
@ -656,7 +650,7 @@ resize_bound_off_x (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_width <= resize->width)
|
||||
off_x = CLAMP (off_x, 0, (resize->width - private->old_width));
|
||||
|
@ -672,7 +666,7 @@ resize_bound_off_y (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_height <= resize->height)
|
||||
off_y = CLAMP (off_y, 0, (resize->height - private->old_height));
|
||||
|
@ -694,8 +688,8 @@ orig_labels_update (GtkWidget *widget,
|
|||
|
||||
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget));
|
||||
|
||||
|
@ -739,11 +733,11 @@ static void
|
|||
offset_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = resize_bound_off_x (resize,
|
||||
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se), 0)));
|
||||
|
@ -755,19 +749,15 @@ offset_update (GtkWidget *widget,
|
|||
resize->offset_x, resize->offset_y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback function for "Reset" button.
|
||||
* Data must be a pointer pointer to a Resize structure.
|
||||
*/
|
||||
static void
|
||||
reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *)data;
|
||||
private = (ResizePrivate *)resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *)resize;
|
||||
|
||||
/* restore size and ratio settings */
|
||||
size_update (resize, private->old_width, private->old_height, 1.0, 1.0);
|
||||
|
@ -784,15 +774,15 @@ static void
|
|||
size_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -823,15 +813,15 @@ static void
|
|||
ratio_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -868,7 +858,7 @@ size_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->width = (gint) (width + 0.5);
|
||||
resize->height = (gint) (height + 0.5);
|
||||
|
@ -876,8 +866,9 @@ size_update (Resize *resize,
|
|||
resize->ratio_x = ratio_x;
|
||||
resize->ratio_y = ratio_y;
|
||||
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
if (private->offset_area)
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (private->size_se), resize);
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se),
|
||||
|
@ -928,7 +919,7 @@ offset_area_offsets_changed (GtkWidget *offset_area,
|
|||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = offset_x;
|
||||
resize->offset_y = offset_y;
|
||||
|
@ -944,17 +935,17 @@ static void
|
|||
printsize_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -1025,13 +1016,13 @@ static void
|
|||
resolution_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
res_x =
|
||||
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->resolution_se), 0);
|
||||
|
@ -1061,7 +1052,7 @@ resolution_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->resolution_x = res_x;
|
||||
resize->resolution_y = res_y;
|
||||
|
@ -1089,162 +1080,3 @@ resolution_update (Resize *resize,
|
|||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->printsize_se),
|
||||
resize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
resize_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale = NULL;
|
||||
GimpImage *gimage = NULL;
|
||||
|
||||
g_assert (data != NULL);
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
resize_check_layer_scaling (ImageResize *image_scale)
|
||||
{
|
||||
/* Inventory the layer list in gimage and return TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
* Otherwise, put up a modal boolean dialog box and ask the user if
|
||||
* she wishes to proceed. Return FALSE in the dialog case; the dialog box
|
||||
* callback will complete the job if the user really wants to
|
||||
* proceed. <02/22/2000 gosgood@idt.net>
|
||||
*/
|
||||
|
||||
gboolean success = FALSE;
|
||||
GimpImage *gimage = NULL;
|
||||
GList *list = NULL;
|
||||
GimpLayer *layer = NULL;
|
||||
GtkWidget *dialog = NULL;
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
|
||||
if (NULL != (gimage = image_scale->gimage))
|
||||
{
|
||||
/* Step through layers; test scaled dimensions. */
|
||||
|
||||
success = TRUE;
|
||||
list = GIMP_LIST (gimage->layers)->list;
|
||||
|
||||
while (list && success == TRUE)
|
||||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
success = gimp_layer_check_scaling (layer,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
list = g_list_next (list);
|
||||
}
|
||||
|
||||
/* Warn user on failure */
|
||||
if (success == FALSE)
|
||||
{
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
resize_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef enum
|
|||
ResizeLayer
|
||||
} ResizeTarget;
|
||||
|
||||
|
||||
typedef struct _Resize Resize;
|
||||
|
||||
struct _Resize
|
||||
|
@ -53,9 +54,6 @@ struct _Resize
|
|||
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
/* Don't touch this :) */
|
||||
void * private_part;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -64,6 +62,7 @@ typedef struct
|
|||
GimpImage *gimage;
|
||||
} ImageResize;
|
||||
|
||||
|
||||
/* If resolution_x is zero, then don't show resolution modification
|
||||
* parts of the dialog.
|
||||
*
|
||||
|
@ -72,24 +71,19 @@ typedef struct
|
|||
* If cancel_callback is NULL, then the dialog will be destroyed on "Cancel".
|
||||
*/
|
||||
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
/* Layer scaling sanity check and warning dialogs */
|
||||
|
||||
gboolean resize_check_layer_scaling (ImageResize *image_resize);
|
||||
void resize_scale_implement (ImageResize *image_resize);
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __RESIZE_H__ */
|
||||
|
|
|
@ -223,7 +223,7 @@ edit_cut (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (cut && empty == FALSE)
|
||||
{
|
||||
cropped_cut = crop_buffer (cut, 0);
|
||||
cropped_cut = crop_buffer (cut, FALSE);
|
||||
|
||||
if (cropped_cut != cut)
|
||||
tile_manager_destroy (cut);
|
||||
|
@ -274,7 +274,7 @@ edit_copy (GimpImage *gimage,
|
|||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (copy && empty == FALSE)
|
||||
{
|
||||
cropped_copy = crop_buffer (copy, 0);
|
||||
cropped_copy = crop_buffer (copy, FALSE);
|
||||
|
||||
if (cropped_copy != copy)
|
||||
tile_manager_destroy (copy);
|
||||
|
|
|
@ -76,26 +76,30 @@
|
|||
|
||||
|
||||
/* local functions */
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
static void image_scale_implement (ImageResize *image_scale);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
@ -1097,11 +1101,132 @@ image_scale_callback (GtkWidget *widget,
|
|||
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, FALSE);
|
||||
|
||||
if (resize_check_layer_scaling (image_scale))
|
||||
if (gimp_image_check_scaling (image_scale->gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height))
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
image_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale;
|
||||
GimpImage *gimage;
|
||||
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -76,26 +76,30 @@
|
|||
|
||||
|
||||
/* local functions */
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void image_resize_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
static void image_scale_implement (ImageResize *image_scale);
|
||||
static void gimage_mask_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
static void gimage_mask_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
@ -1097,11 +1101,132 @@ image_scale_callback (GtkWidget *widget,
|
|||
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, FALSE);
|
||||
|
||||
if (resize_check_layer_scaling (image_scale))
|
||||
if (gimp_image_check_scaling (image_scale->gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height))
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
image_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale;
|
||||
GimpImage *gimage;
|
||||
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
image_scale_implement (image_scale);
|
||||
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
image_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -28,12 +28,9 @@
|
|||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "gdisplay.h"
|
||||
#include "gimprc.h"
|
||||
#include "resize.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
@ -42,6 +39,8 @@ typedef struct _ResizePrivate ResizePrivate;
|
|||
|
||||
struct _ResizePrivate
|
||||
{
|
||||
Resize resize;
|
||||
|
||||
/* size frame */
|
||||
GtkWidget *orig_width_label;
|
||||
GtkWidget *orig_height_label;
|
||||
|
@ -97,9 +96,6 @@ static void resolution_callback (GtkWidget *widget,
|
|||
static void resolution_update (Resize *resize,
|
||||
gdouble res_x,
|
||||
gdouble res_y);
|
||||
static void resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
|
||||
|
||||
Resize *
|
||||
|
@ -117,31 +113,32 @@ resize_widget_new (ResizeType type,
|
|||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
|
||||
abox = NULL;
|
||||
frame = NULL;
|
||||
|
||||
private = g_new0 (ResizePrivate, 1);
|
||||
|
||||
private->old_width = width;
|
||||
private->old_height = height;
|
||||
private->old_res_x = resolution_x;
|
||||
private->old_res_y = resolution_y;
|
||||
|
||||
resize = g_new (Resize, 1);
|
||||
resize = (Resize *) private;
|
||||
|
||||
resize->type = type;
|
||||
resize->target = target;
|
||||
resize->private_part = private;
|
||||
resize->width = width;
|
||||
resize->height = height;
|
||||
resize->resolution_x = resolution_x;
|
||||
|
@ -218,9 +215,6 @@ resize_widget_new (ResizeType type,
|
|||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) private);
|
||||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) resize);
|
||||
}
|
||||
|
||||
/* handle the image disappearing under our feet */
|
||||
|
@ -656,7 +650,7 @@ resize_bound_off_x (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_width <= resize->width)
|
||||
off_x = CLAMP (off_x, 0, (resize->width - private->old_width));
|
||||
|
@ -672,7 +666,7 @@ resize_bound_off_y (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_height <= resize->height)
|
||||
off_y = CLAMP (off_y, 0, (resize->height - private->old_height));
|
||||
|
@ -694,8 +688,8 @@ orig_labels_update (GtkWidget *widget,
|
|||
|
||||
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget));
|
||||
|
||||
|
@ -739,11 +733,11 @@ static void
|
|||
offset_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = resize_bound_off_x (resize,
|
||||
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se), 0)));
|
||||
|
@ -755,19 +749,15 @@ offset_update (GtkWidget *widget,
|
|||
resize->offset_x, resize->offset_y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback function for "Reset" button.
|
||||
* Data must be a pointer pointer to a Resize structure.
|
||||
*/
|
||||
static void
|
||||
reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *)data;
|
||||
private = (ResizePrivate *)resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *)resize;
|
||||
|
||||
/* restore size and ratio settings */
|
||||
size_update (resize, private->old_width, private->old_height, 1.0, 1.0);
|
||||
|
@ -784,15 +774,15 @@ static void
|
|||
size_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -823,15 +813,15 @@ static void
|
|||
ratio_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -868,7 +858,7 @@ size_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->width = (gint) (width + 0.5);
|
||||
resize->height = (gint) (height + 0.5);
|
||||
|
@ -876,8 +866,9 @@ size_update (Resize *resize,
|
|||
resize->ratio_x = ratio_x;
|
||||
resize->ratio_y = ratio_y;
|
||||
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
if (private->offset_area)
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (private->size_se), resize);
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se),
|
||||
|
@ -928,7 +919,7 @@ offset_area_offsets_changed (GtkWidget *offset_area,
|
|||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = offset_x;
|
||||
resize->offset_y = offset_y;
|
||||
|
@ -944,17 +935,17 @@ static void
|
|||
printsize_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -1025,13 +1016,13 @@ static void
|
|||
resolution_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
res_x =
|
||||
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->resolution_se), 0);
|
||||
|
@ -1061,7 +1052,7 @@ resolution_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->resolution_x = res_x;
|
||||
resize->resolution_y = res_y;
|
||||
|
@ -1089,162 +1080,3 @@ resolution_update (Resize *resize,
|
|||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->printsize_se),
|
||||
resize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
resize_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale = NULL;
|
||||
GimpImage *gimage = NULL;
|
||||
|
||||
g_assert (data != NULL);
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
resize_check_layer_scaling (ImageResize *image_scale)
|
||||
{
|
||||
/* Inventory the layer list in gimage and return TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
* Otherwise, put up a modal boolean dialog box and ask the user if
|
||||
* she wishes to proceed. Return FALSE in the dialog case; the dialog box
|
||||
* callback will complete the job if the user really wants to
|
||||
* proceed. <02/22/2000 gosgood@idt.net>
|
||||
*/
|
||||
|
||||
gboolean success = FALSE;
|
||||
GimpImage *gimage = NULL;
|
||||
GList *list = NULL;
|
||||
GimpLayer *layer = NULL;
|
||||
GtkWidget *dialog = NULL;
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
|
||||
if (NULL != (gimage = image_scale->gimage))
|
||||
{
|
||||
/* Step through layers; test scaled dimensions. */
|
||||
|
||||
success = TRUE;
|
||||
list = GIMP_LIST (gimage->layers)->list;
|
||||
|
||||
while (list && success == TRUE)
|
||||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
success = gimp_layer_check_scaling (layer,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
list = g_list_next (list);
|
||||
}
|
||||
|
||||
/* Warn user on failure */
|
||||
if (success == FALSE)
|
||||
{
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
resize_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef enum
|
|||
ResizeLayer
|
||||
} ResizeTarget;
|
||||
|
||||
|
||||
typedef struct _Resize Resize;
|
||||
|
||||
struct _Resize
|
||||
|
@ -53,9 +54,6 @@ struct _Resize
|
|||
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
/* Don't touch this :) */
|
||||
void * private_part;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -64,6 +62,7 @@ typedef struct
|
|||
GimpImage *gimage;
|
||||
} ImageResize;
|
||||
|
||||
|
||||
/* If resolution_x is zero, then don't show resolution modification
|
||||
* parts of the dialog.
|
||||
*
|
||||
|
@ -72,24 +71,19 @@ typedef struct
|
|||
* If cancel_callback is NULL, then the dialog will be destroyed on "Cancel".
|
||||
*/
|
||||
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
/* Layer scaling sanity check and warning dialogs */
|
||||
|
||||
gboolean resize_check_layer_scaling (ImageResize *image_resize);
|
||||
void resize_scale_implement (ImageResize *image_resize);
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __RESIZE_H__ */
|
||||
|
|
|
@ -80,7 +80,6 @@ tool_options_dialog_create (void)
|
|||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GList *list;
|
||||
|
||||
if (options_shell)
|
||||
return options_shell;
|
||||
|
@ -173,16 +172,6 @@ tool_options_dialog_create (void)
|
|||
GIMP_TYPE_TOOL_INFO,
|
||||
tool_options_dialog_drag_tool, NULL);
|
||||
|
||||
for (list = GIMP_LIST (global_tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
tool_info = GIMP_TOOL_INFO (list->data);
|
||||
|
||||
if (tool_info->tool_options)
|
||||
tool_options_dialog_add (tool_info->tool_options);
|
||||
}
|
||||
|
||||
gtk_signal_connect_while_alive
|
||||
(GTK_OBJECT (gimp_context_get_user ()), "tool_changed",
|
||||
GTK_SIGNAL_FUNC (tool_options_dialog_tool_changed),
|
||||
|
@ -208,21 +197,6 @@ tool_options_dialog_free (void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tool_options_dialog_add (ToolOptions *tool_options)
|
||||
{
|
||||
g_return_if_fail (tool_options != NULL);
|
||||
|
||||
if (options_vbox)
|
||||
{
|
||||
if (! GTK_WIDGET_VISIBLE (tool_options->main_vbox))
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (options_vbox), tool_options->main_vbox,
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -243,6 +217,11 @@ tool_options_dialog_tool_changed (GimpContext *context,
|
|||
{
|
||||
if (tool_info->tool_options)
|
||||
{
|
||||
if (! tool_info->tool_options->main_vbox->parent)
|
||||
gtk_box_pack_start (GTK_BOX (options_vbox),
|
||||
tool_info->tool_options->main_vbox,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show (tool_info->tool_options->main_vbox);
|
||||
|
||||
visible_tool_options = tool_info->tool_options;
|
||||
|
|
|
@ -23,7 +23,5 @@
|
|||
GtkWidget * tool_options_dialog_create (void);
|
||||
void tool_options_dialog_free (void);
|
||||
|
||||
void tool_options_dialog_add (ToolOptions *tool_options);
|
||||
|
||||
|
||||
#endif /* __TOOL_OPTIONS_DIALOG_H__ */
|
||||
|
|
280
app/resize.c
280
app/resize.c
|
@ -28,12 +28,9 @@
|
|||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "gdisplay.h"
|
||||
#include "gimprc.h"
|
||||
#include "resize.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
@ -42,6 +39,8 @@ typedef struct _ResizePrivate ResizePrivate;
|
|||
|
||||
struct _ResizePrivate
|
||||
{
|
||||
Resize resize;
|
||||
|
||||
/* size frame */
|
||||
GtkWidget *orig_width_label;
|
||||
GtkWidget *orig_height_label;
|
||||
|
@ -97,9 +96,6 @@ static void resolution_callback (GtkWidget *widget,
|
|||
static void resolution_update (Resize *resize,
|
||||
gdouble res_x,
|
||||
gdouble res_y);
|
||||
static void resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data);
|
||||
|
||||
|
||||
Resize *
|
||||
|
@ -117,31 +113,32 @@ resize_widget_new (ResizeType type,
|
|||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *table2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *abox;
|
||||
GtkObject *adjustment;
|
||||
|
||||
abox = NULL;
|
||||
frame = NULL;
|
||||
|
||||
private = g_new0 (ResizePrivate, 1);
|
||||
|
||||
private->old_width = width;
|
||||
private->old_height = height;
|
||||
private->old_res_x = resolution_x;
|
||||
private->old_res_y = resolution_y;
|
||||
|
||||
resize = g_new (Resize, 1);
|
||||
resize = (Resize *) private;
|
||||
|
||||
resize->type = type;
|
||||
resize->target = target;
|
||||
resize->private_part = private;
|
||||
resize->width = width;
|
||||
resize->height = height;
|
||||
resize->resolution_x = resolution_x;
|
||||
|
@ -218,9 +215,6 @@ resize_widget_new (ResizeType type,
|
|||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) private);
|
||||
gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
|
||||
GTK_SIGNAL_FUNC (g_free),
|
||||
(GtkObject *) resize);
|
||||
}
|
||||
|
||||
/* handle the image disappearing under our feet */
|
||||
|
@ -656,7 +650,7 @@ resize_bound_off_x (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_width <= resize->width)
|
||||
off_x = CLAMP (off_x, 0, (resize->width - private->old_width));
|
||||
|
@ -672,7 +666,7 @@ resize_bound_off_y (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
if (private->old_height <= resize->height)
|
||||
off_y = CLAMP (off_y, 0, (resize->height - private->old_height));
|
||||
|
@ -694,8 +688,8 @@ orig_labels_update (GtkWidget *widget,
|
|||
|
||||
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget));
|
||||
|
||||
|
@ -739,11 +733,11 @@ static void
|
|||
offset_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = resize_bound_off_x (resize,
|
||||
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se), 0)));
|
||||
|
@ -755,19 +749,15 @@ offset_update (GtkWidget *widget,
|
|||
resize->offset_x, resize->offset_y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback function for "Reset" button.
|
||||
* Data must be a pointer pointer to a Resize structure.
|
||||
*/
|
||||
static void
|
||||
reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *)data;
|
||||
private = (ResizePrivate *)resize->private_part;
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *)resize;
|
||||
|
||||
/* restore size and ratio settings */
|
||||
size_update (resize, private->old_width, private->old_height, 1.0, 1.0);
|
||||
|
@ -784,15 +774,15 @@ static void
|
|||
size_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -823,15 +813,15 @@ static void
|
|||
ratio_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble ratio_x;
|
||||
gdouble ratio_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -868,7 +858,7 @@ size_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->width = (gint) (width + 0.5);
|
||||
resize->height = (gint) (height + 0.5);
|
||||
|
@ -876,8 +866,9 @@ size_update (Resize *resize,
|
|||
resize->ratio_x = ratio_x;
|
||||
resize->ratio_y = ratio_y;
|
||||
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
if (private->offset_area)
|
||||
gimp_offset_area_set_size (GIMP_OFFSET_AREA (private->offset_area),
|
||||
resize->width, resize->height);
|
||||
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (private->size_se), resize);
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se),
|
||||
|
@ -928,7 +919,7 @@ offset_area_offsets_changed (GtkWidget *offset_area,
|
|||
ResizePrivate *private;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->offset_x = offset_x;
|
||||
resize->offset_y = offset_y;
|
||||
|
@ -944,17 +935,17 @@ static void
|
|||
printsize_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
gdouble print_width;
|
||||
gdouble print_height;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
|
||||
|
@ -1025,13 +1016,13 @@ static void
|
|||
resolution_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Resize *resize;
|
||||
Resize *resize;
|
||||
ResizePrivate *private;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
gdouble res_x;
|
||||
gdouble res_y;
|
||||
|
||||
resize = (Resize *) data;
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
res_x =
|
||||
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->resolution_se), 0);
|
||||
|
@ -1061,7 +1052,7 @@ resolution_update (Resize *resize,
|
|||
{
|
||||
ResizePrivate *private;
|
||||
|
||||
private = (ResizePrivate *) resize->private_part;
|
||||
private = (ResizePrivate *) resize;
|
||||
|
||||
resize->resolution_x = res_x;
|
||||
resize->resolution_y = res_y;
|
||||
|
@ -1089,162 +1080,3 @@ resolution_update (Resize *resize,
|
|||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->printsize_se),
|
||||
resize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
resize_scale_implement (ImageResize *image_scale)
|
||||
{
|
||||
GimpImage *gimage = NULL;
|
||||
gboolean rulers_flush = FALSE;
|
||||
gboolean display_flush = FALSE; /* this is a bit ugly:
|
||||
we hijack the flush variable
|
||||
to check if an undo_group was
|
||||
already started */
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (image_scale->resize->resolution_x != gimage->xresolution ||
|
||||
image_scale->resize->resolution_y != gimage->yresolution)
|
||||
{
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_resolution (gimage,
|
||||
image_scale->resize->resolution_x,
|
||||
image_scale->resize->resolution_y);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->unit != gimage->unit)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
|
||||
rulers_flush = TRUE;
|
||||
display_flush = TRUE;
|
||||
}
|
||||
|
||||
if (image_scale->resize->width != gimage->width ||
|
||||
image_scale->resize->height != gimage->height)
|
||||
{
|
||||
if (image_scale->resize->width > 0 &&
|
||||
image_scale->resize->height > 0)
|
||||
{
|
||||
if (!display_flush)
|
||||
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
|
||||
|
||||
gimp_image_scale (gimage,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
|
||||
display_flush = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message (_("Scale Error: Both width and height must be "
|
||||
"greater than zero."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rulers_flush)
|
||||
{
|
||||
gdisplays_setup_scale (gimage);
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
}
|
||||
|
||||
if (display_flush)
|
||||
{
|
||||
undo_push_group_end (gimage);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
resize_scale_warn_callback (GtkWidget *widget,
|
||||
gboolean do_scale,
|
||||
gpointer data)
|
||||
{
|
||||
ImageResize *image_scale = NULL;
|
||||
GimpImage *gimage = NULL;
|
||||
|
||||
g_assert (data != NULL);
|
||||
image_scale = (ImageResize *) data;
|
||||
gimage = image_scale->gimage;
|
||||
g_assert (gimage != NULL);
|
||||
|
||||
if (do_scale == TRUE) /* User doesn't mind losing layers... */
|
||||
{
|
||||
resize_scale_implement (image_scale);
|
||||
gtk_widget_destroy (image_scale->resize->resize_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
resize_check_layer_scaling (ImageResize *image_scale)
|
||||
{
|
||||
/* Inventory the layer list in gimage and return TRUE if, after
|
||||
* scaling, they all retain positive x and y pixel dimensions.
|
||||
* Otherwise, put up a modal boolean dialog box and ask the user if
|
||||
* she wishes to proceed. Return FALSE in the dialog case; the dialog box
|
||||
* callback will complete the job if the user really wants to
|
||||
* proceed. <02/22/2000 gosgood@idt.net>
|
||||
*/
|
||||
|
||||
gboolean success = FALSE;
|
||||
GimpImage *gimage = NULL;
|
||||
GList *list = NULL;
|
||||
GimpLayer *layer = NULL;
|
||||
GtkWidget *dialog = NULL;
|
||||
|
||||
g_assert (image_scale != NULL);
|
||||
|
||||
if (NULL != (gimage = image_scale->gimage))
|
||||
{
|
||||
/* Step through layers; test scaled dimensions. */
|
||||
|
||||
success = TRUE;
|
||||
list = GIMP_LIST (gimage->layers)->list;
|
||||
|
||||
while (list && success == TRUE)
|
||||
{
|
||||
layer = (GimpLayer *) list->data;
|
||||
success = gimp_layer_check_scaling (layer,
|
||||
image_scale->resize->width,
|
||||
image_scale->resize->height);
|
||||
list = g_list_next (list);
|
||||
}
|
||||
|
||||
/* Warn user on failure */
|
||||
if (success == FALSE)
|
||||
{
|
||||
dialog =
|
||||
gimp_query_boolean_box (_("Layer Too Small"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/scale_layer_warn.html",
|
||||
FALSE,
|
||||
_("The chosen image size will shrink\n"
|
||||
"some layers completely away.\n"
|
||||
"Is this what you want?"),
|
||||
_("OK"), _("Cancel"),
|
||||
GTK_OBJECT (image_scale->resize->resize_shell),
|
||||
"destroy",
|
||||
resize_scale_warn_callback,
|
||||
image_scale);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
36
app/resize.h
36
app/resize.h
|
@ -32,6 +32,7 @@ typedef enum
|
|||
ResizeLayer
|
||||
} ResizeTarget;
|
||||
|
||||
|
||||
typedef struct _Resize Resize;
|
||||
|
||||
struct _Resize
|
||||
|
@ -53,9 +54,6 @@ struct _Resize
|
|||
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
/* Don't touch this :) */
|
||||
void * private_part;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -64,6 +62,7 @@ typedef struct
|
|||
GimpImage *gimage;
|
||||
} ImageResize;
|
||||
|
||||
|
||||
/* If resolution_x is zero, then don't show resolution modification
|
||||
* parts of the dialog.
|
||||
*
|
||||
|
@ -72,24 +71,19 @@ typedef struct
|
|||
* If cancel_callback is NULL, then the dialog will be destroyed on "Cancel".
|
||||
*/
|
||||
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
/* Layer scaling sanity check and warning dialogs */
|
||||
|
||||
gboolean resize_check_layer_scaling (ImageResize *image_resize);
|
||||
void resize_scale_implement (ImageResize *image_resize);
|
||||
Resize * resize_widget_new (ResizeType type,
|
||||
ResizeTarget target,
|
||||
GtkObject *object,
|
||||
gchar *signal,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble resolution_x,
|
||||
gdouble resolution_y,
|
||||
GimpUnit unit,
|
||||
gboolean dot_for_dot,
|
||||
GtkSignalFunc ok_cb,
|
||||
GtkSignalFunc cancel_cb,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __RESIZE_H__ */
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
#include "core/gimplist.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
/* FIXME: let the tool options dialog update itself */
|
||||
#include "gui/tool-options-dialog.h"
|
||||
|
||||
#include "gimptool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
|
@ -48,7 +45,6 @@
|
|||
|
||||
#include "appenv.h"
|
||||
#include "context_manager.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gdisplay.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -315,8 +311,6 @@ tool_manager_register_tool_options (GtkType tool_type,
|
|||
}
|
||||
|
||||
tool_info->tool_options = tool_options;
|
||||
|
||||
tool_options_dialog_add (tool_options);
|
||||
}
|
||||
|
||||
GimpToolInfo *
|
||||
|
|
|
@ -80,7 +80,6 @@ tool_options_dialog_create (void)
|
|||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GList *list;
|
||||
|
||||
if (options_shell)
|
||||
return options_shell;
|
||||
|
@ -173,16 +172,6 @@ tool_options_dialog_create (void)
|
|||
GIMP_TYPE_TOOL_INFO,
|
||||
tool_options_dialog_drag_tool, NULL);
|
||||
|
||||
for (list = GIMP_LIST (global_tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
tool_info = GIMP_TOOL_INFO (list->data);
|
||||
|
||||
if (tool_info->tool_options)
|
||||
tool_options_dialog_add (tool_info->tool_options);
|
||||
}
|
||||
|
||||
gtk_signal_connect_while_alive
|
||||
(GTK_OBJECT (gimp_context_get_user ()), "tool_changed",
|
||||
GTK_SIGNAL_FUNC (tool_options_dialog_tool_changed),
|
||||
|
@ -208,21 +197,6 @@ tool_options_dialog_free (void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tool_options_dialog_add (ToolOptions *tool_options)
|
||||
{
|
||||
g_return_if_fail (tool_options != NULL);
|
||||
|
||||
if (options_vbox)
|
||||
{
|
||||
if (! GTK_WIDGET_VISIBLE (tool_options->main_vbox))
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (options_vbox), tool_options->main_vbox,
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -243,6 +217,11 @@ tool_options_dialog_tool_changed (GimpContext *context,
|
|||
{
|
||||
if (tool_info->tool_options)
|
||||
{
|
||||
if (! tool_info->tool_options->main_vbox->parent)
|
||||
gtk_box_pack_start (GTK_BOX (options_vbox),
|
||||
tool_info->tool_options->main_vbox,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show (tool_info->tool_options->main_vbox);
|
||||
|
||||
visible_tool_options = tool_info->tool_options;
|
||||
|
|
Loading…
Reference in a new issue