Commit 1358fafb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Implemented "Flip Image". Fixes bug #23179:

2003-05-18  Michael Natterer  <mitch@gimp.org>

	Implemented "Flip Image". Fixes bug #23179:

	* app/core/core-enums.[ch]: added GIMP_UNDO_GROUP_IMAGE_FLIP.

	* app/core/Makefile.am
	* app/core/gimpimage-flip.[ch]: new files implementing
	gimp_image_flip().

	* app/gui/image-menu.c
	* app/gui/image-commands.[ch]: added it to the "Image" menu.

	* themes/Default/images/Makefile.am
	* themes/Default/images/stock-flip-horizontal-16.png
	* themes/Default/images/stock-flip-vertical-16.png
	* libgimpwidgets/gimpstock.[ch]: added icons for the new
	menu items.

	Bugs found while hacking the stuff above:

	* app/core/gimpdrawable-transform.c (gimp_drawable_transform_paste):
	only call gimp_layer_add_alpha() if the pasted tiles have alpha.

	* app/core/gimpimage-undo-push.c (undo_pop_channel_mod): fixed to
	do the right thing if the channel is the selection mask.
parent 1a8b0d3b
2003-05-18 Michael Natterer <mitch@gimp.org>
Implemented "Flip Image". Fixes bug #23179:
* app/core/core-enums.[ch]: added GIMP_UNDO_GROUP_IMAGE_FLIP.
* app/core/Makefile.am
* app/core/gimpimage-flip.[ch]: new files implementing
gimp_image_flip().
* app/gui/image-menu.c
* app/gui/image-commands.[ch]: added it to the "Image" menu.
* themes/Default/images/Makefile.am
* themes/Default/images/stock-flip-horizontal-16.png
* themes/Default/images/stock-flip-vertical-16.png
* libgimpwidgets/gimpstock.[ch]: added icons for the new
menu items.
Bugs found while hacking the stuff above:
* app/core/gimpdrawable-transform.c (gimp_drawable_transform_paste):
only call gimp_layer_add_alpha() if the pasted tiles have alpha.
* app/core/gimpimage-undo-push.c (undo_pop_channel_mod): fixed to
do the right thing if the channel is the selection mask.
2003-05-18 Pedro Gimeno <pggimeno@wanadoo.es>
* plug-ins/common/psd_save.c: Translated Spanish comments to
......@@ -29,6 +29,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-crop.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-flip.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-resize.h"
......@@ -201,6 +202,25 @@ image_scale_cmd_callback (GtkWidget *widget,
gtk_widget_show (image_scale->resize->resize_shell);
}
void
image_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpProgress *progress;
return_if_no_display (gdisp, data);
progress = gimp_progress_start (gdisp, _("Flipping..."), TRUE, NULL, NULL);
gimp_image_flip (gdisp->gimage, (GimpOrientationType) action,
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
gimp_image_flush (gdisp->gimage);
}
void
image_crop_cmd_callback (GtkWidget *widget,
gpointer data)
......@@ -216,6 +236,7 @@ image_crop_cmd_callback (GtkWidget *widget,
}
gimp_image_crop (gdisp->gimage, x1, y1, x2, y2, FALSE, TRUE);
gimp_image_flush (gdisp->gimage);
}
void
......
......@@ -31,6 +31,9 @@ void image_resize_cmd_callback (GtkWidget *widget,
gpointer data);
void image_scale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void image_crop_cmd_callback (GtkWidget *widget,
gpointer data);
......
......@@ -99,6 +99,8 @@ libappcore_a_sources = \
gimpimage-crop.h \
gimpimage-duplicate.c \
gimpimage-duplicate.h \
gimpimage-flip.c \
gimpimage-flip.h \
gimpimage-guides.c \
gimpimage-guides.h \
gimpimage-mask.c \
......
......@@ -430,6 +430,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_NONE, N_("<<invalid>>"), "group-none" },
{ GIMP_UNDO_GROUP_IMAGE_SCALE, N_("Scale Image"), "group-image-scale" },
{ GIMP_UNDO_GROUP_IMAGE_RESIZE, N_("Resize Image"), "group-image-resize" },
{ GIMP_UNDO_GROUP_IMAGE_FLIP, N_("Flip Image"), "group-image-flip" },
{ GIMP_UNDO_GROUP_IMAGE_CONVERT, N_("Convert Image"), "group-image-convert" },
{ GIMP_UNDO_GROUP_IMAGE_CROP, N_("Crop Image"), "group-image-crop" },
{ GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, N_("Merge Layers"), "group-image-layers-merge" },
......
......@@ -317,6 +317,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_IMAGE_SCALE, /*< desc="Scale Image" >*/
GIMP_UNDO_GROUP_IMAGE_RESIZE, /*< desc="Resize Image" >*/
GIMP_UNDO_GROUP_IMAGE_FLIP, /*< desc="Flip Image" >*/
GIMP_UNDO_GROUP_IMAGE_CONVERT, /*< desc="Convert Image" >*/
GIMP_UNDO_GROUP_IMAGE_CROP, /*< desc="Crop Image" >*/
GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, /*< desc="Merge Layers" >*/
......
......@@ -770,8 +770,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
else
return FALSE;
if (layer)
gimp_layer_add_alpha (layer);
if (layer && (tile_manager_bpp (tiles) == 2 ||
tile_manager_bpp (tiles) == 4))
{
gimp_layer_add_alpha (layer);
}
floating_layer = gimp_image_floating_sel (gimage);
......
......@@ -770,8 +770,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
else
return FALSE;
if (layer)
gimp_layer_add_alpha (layer);
if (layer && (tile_manager_bpp (tiles) == 2 ||
tile_manager_bpp (tiles) == 4))
{
gimp_layer_add_alpha (layer);
}
floating_layer = gimp_image_floating_sel (gimage);
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimp.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-projection.h"
#include "gimpimage-flip.h"
#include "gimpimage-guides.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpitem.h"
#include "gimplayer-floating-sel.h"
#include "gimplist.h"
#include "gimp-intl.h"
void
gimp_image_flip (GimpImage *gimage,
GimpOrientationType flip_type,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpLayer *floating_layer;
GimpItem *item;
GList *list;
gdouble axis;
gint num_channels;
gint num_layers;
gint num_vectors;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_set_busy (gimage->gimp);
switch (flip_type)
{
case GIMP_ORIENTATION_HORIZONTAL:
axis = (gdouble) gimage->width / 2.0;
break;
case GIMP_ORIENTATION_VERTICAL:
axis = (gdouble) gimage->height / 2.0;
break;
default:
g_warning ("gimp_image_flip(): unknown flip_type");
return;
}
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
num_vectors = gimage->vectors->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_FLIP, NULL);
/* Relax the floating selection */
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* Flip all channels */
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
item = (GimpItem *) list->data;
gimp_item_flip (item, flip_type, axis, TRUE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
}
/* Flip all vectors */
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
item = (GimpItem *) list->data;
gimp_item_flip (item, flip_type, axis, FALSE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
}
/* Don't forget the selection mask! */
gimp_item_flip (GIMP_ITEM (gimage->selection_mask), flip_type, axis, TRUE);
gimp_image_mask_invalidate (gimage);
/* Flip all layers */
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
item = (GimpItem *) list->data;
gimp_item_flip (item, flip_type, axis, FALSE);
if (progress_func)
(* progress_func) (0, num_vectors + num_channels + num_layers,
progress_current++,
progress_data);
}
/* Flip all Guides */
for (list = gimage->guides; list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
switch (guide->orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
if (flip_type == GIMP_ORIENTATION_VERTICAL)
gimp_image_move_guide (gimage, guide,
gimage->height - guide->position, TRUE);
break;
case GIMP_ORIENTATION_VERTICAL:
if (flip_type == GIMP_ORIENTATION_HORIZONTAL)
gimp_image_move_guide (gimage, guide,
gimage->width - guide->position, TRUE);
break;
default:
break;
}
}
/* Make sure the projection matches the gimage size */
gimp_image_projection_allocate (gimage);
/* Rigor the floating selection */
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
gimp_image_undo_group_end (gimage);
gimp_image_mask_changed (gimage);
gimp_unset_busy (gimage->gimp);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_IMAGE_FLIP_H__
#define __GIMP_IMAGE_FLIP_H__
void gimp_image_flip (GimpImage *gimage,
GimpOrientationType flip_type,
GimpProgressFunc progress_func,
gpointer progress_data);
#endif /* __GIMP_IMAGE_FLIP_H__ */
......@@ -938,7 +938,6 @@ undo_pop_mask (GimpUndo *undo,
else
{
channel->boundary_known = FALSE;
GIMP_DRAWABLE (channel)->preview_valid = FALSE;
}
if (mu->tiles)
......@@ -2216,20 +2215,30 @@ undo_pop_channel_mod (GimpUndo *undo,
channel = GIMP_CHANNEL (GIMP_ITEM_UNDO (undo)->item);
/* Issue the first update */
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
if (channel != gimp_image_get_mask (undo->gimage))
{
/* Issue the first update */
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
channel->boundary_known = FALSE;
}
else
{
/* invalidate the current bounds and boundary of the mask */
gimp_image_mask_invalidate (undo->gimage);
}
tiles = cmu->tiles;
cmu->tiles = GIMP_DRAWABLE (channel)->tiles;
GIMP_DRAWABLE (channel)->tiles = tiles;
GIMP_ITEM (channel)->width = tile_manager_width (tiles);
GIMP_ITEM (channel)->height = tile_manager_height (tiles);
GIMP_CHANNEL (channel)->bounds_known = FALSE;
GIMP_DRAWABLE (channel)->tiles = tiles;
GIMP_ITEM (channel)->width = tile_manager_width (tiles);
GIMP_ITEM (channel)->height = tile_manager_height (tiles);
channel->bounds_known = FALSE;
if (GIMP_ITEM (channel)->width != tile_manager_width (cmu->tiles) ||
GIMP_ITEM (channel)->height != tile_manager_height (cmu->tiles))
......@@ -2237,11 +2246,18 @@ undo_pop_channel_mod (GimpUndo *undo,
gimp_viewable_size_changed (GIMP_VIEWABLE (channel));
}
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
if (channel != gimp_image_get_mask (undo->gimage))
{
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
}
else
{
accum->mask_changed = TRUE;
}
return TRUE;
}
......
......@@ -29,6 +29,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-crop.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-flip.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-resize.h"
......@@ -201,6 +202,25 @@ image_scale_cmd_callback (GtkWidget *widget,
gtk_widget_show (image_scale->resize->resize_shell);
}
void
image_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpProgress *progress;
return_if_no_display (gdisp, data);
progress = gimp_progress_start (gdisp, _("Flipping..."), TRUE, NULL, NULL);
gimp_image_flip (gdisp->gimage, (GimpOrientationType) action,
gimp_progress_update_and_flush, progress);
gimp_progress_end (progress);
gimp_image_flush (gdisp->gimage);
}
void
image_crop_cmd_callback (GtkWidget *widget,
gpointer data)
......@@ -216,6 +236,7 @@ image_crop_cmd_callback (GtkWidget *widget,
}
gimp_image_crop (gdisp->gimage, x1, y1, x2, y2, FALSE, TRUE);
gimp_image_flush (gdisp->gimage);
}
void
......
......@@ -31,6 +31,9 @@ void image_resize_cmd_callback (GtkWidget *widget,
gpointer data);
void image_scale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void image_crop_cmd_callback (GtkWidget *widget,
gpointer data);
......
......@@ -480,11 +480,21 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SCALE },
NULL,
"image/dialogs/scale_image.html", NULL },
{ { N_("/Image/Flip Image Horizontally"), NULL,
image_flip_cmd_callback, GIMP_ORIENTATION_HORIZONTAL,
"<StockItem>", GIMP_STOCK_FLIP_HORIZONTAL },
NULL,
"image/dialogs/flip_image.html", NULL },
{ { N_("/Image/Flip Image Vertically"), NULL,
image_flip_cmd_callback, GIMP_ORIENTATION_VERTICAL,
"<StockItem>", GIMP_STOCK_FLIP_VERTICAL },
NULL,
"image/dialogs/flip_image.html", NULL },
{ { N_("/Image/Crop Image"), NULL,
image_crop_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_CROP },
NULL,
"image/dialogs/scale_image.html", NULL },
"image/dialogs/crop_image.html", NULL },
{ { N_("/Image/Duplicate"), "<control>D",
image_duplicate_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_DUPLICATE },
......
......@@ -480,11 +480,21 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SCALE },
NULL,
"image/dialogs/scale_image.html", NULL },
{ { N_("/Image/Flip Image Horizontally"), NULL,
image_flip_cmd_callback, GIMP_ORIENTATION_HORIZONTAL,
"<StockItem>", GIMP_STOCK_FLIP_HORIZONTAL },
NULL,
"image/dialogs/flip_image.html", NULL },
{ { N_("/Image/Flip Image Vertically"), NULL,
image_flip_cmd_callback, GIMP_ORIENTATION_VERTICAL,
"<StockItem>", GIMP_STOCK_FLIP_VERTICAL },
NULL,
"image/dialogs/flip_image.html", NULL },
{ { N_("/Image/Crop Image"), NULL,
image_crop_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_CROP },
NULL,
"image/dialogs/scale_image.html", NULL },
"image/dialogs/crop_image.html", NULL },
{ { N_("/Image/Duplicate"), "<control>D",
image_duplicate_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_DUPLICATE },
......
......@@ -170,6 +170,8 @@ static GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_ROTATE_270, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_RESIZE, N_("_Resize"), 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_SCALE, N_("_Scale"), 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_FLIP_HORIZONTAL, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_FLIP_VERTICAL, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_OPTIONS, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_DEVICE_STATUS, NULL, 0, 0, LIBGIMP_DOMAIN },
......@@ -394,6 +396,8 @@ gimp_stock_menu_pixbufs[] =
{ GIMP_STOCK_ROTATE_270, stock_rotate_270_16 },
{ GIMP_STOCK_RESIZE, stock_resize_16 },
{ GIMP_STOCK_SCALE, stock_scale_16 },
{ GIMP_STOCK_FLIP_HORIZONTAL, stock_flip_horizontal_16 },
{ GIMP_STOCK_FLIP_VERTICAL, stock_flip_vertical_16 },
{ GIMP_STOCK_TOOL_OPTIONS, stock_tool_options_16 },
{ GIMP_STOCK_DEVICE_STATUS, stock_device_status_16 },
......
......@@ -145,6 +145,8 @@ G_BEGIN_DECLS
#define GIMP_STOCK_ROTATE_270 "gimp-rotate-270"
#define GIMP_STOCK_RESIZE "gimp-resize"
#define GIMP_STOCK_SCALE "gimp-scale"
#define GIMP_STOCK_FLIP_HORIZONTAL "gimp-flip-horizontal"
#define GIMP_STOCK_FLIP_VERTICAL "gimp-flip-vertical"
#define GIMP_STOCK_IMAGE "gimp-image"
#define GIMP_STOCK_LAYER "gimp-layer"
......
......@@ -23,65 +23,67 @@ WILBER_VARIABLES = \
## Below are compiled in stock icons
STOCK_MENU_IMAGES = \
stock-channel-16.png \
stock-channel-alpha-16.png \
stock-channel-blue-16.png \
stock-channel-gray-16.png \
stock-channel-green-16.png \
stock-channel-red-16.png \
stock-channels-16.png \
stock-convert-grayscale-16.png \
stock-convert-indexed-16.png \
stock-convert-rgb-16.png \
stock-default-colors-12.png \
stock-device-status-16.png \
stock-eye-12.png \
stock-gradient-bilinear-16.png \
stock-gradient-conical-asymmetric-16.png\
stock-gradient-conical-symmetric-16.png \
stock-gradient-linear-16.png \
stock-gradient-radial-16.png \
stock-gradient-shapeburst-angular-16.png\
stock-gradient-shapeburst-dimpled-16.png\
stock-gradient-shapeburst-spherical-16.png\
stock-gradient-spiral-anticlockwise-16.png\
stock-gradient-spiral-clockwise-16.png \
stock-gradient-square-16.png \
stock-grid-16.png \
stock-image-16.png \
stock-images-16.png \
stock-info-16.png \
stock-invert-16.png \
stock-landscape-16.png \
stock-layer-16.png \
stock-layer-to-imagesize-16.png \
stock-layers-16.png \
stock-list-16.png \
stock-merge-down-16.png \
stock-navigation-16.png \
stock-paths-16.png \
stock-plugin-16.png \
stock-portrait-16.png \
stock-qmask-off-16.png \
stock-qmask-on-16.png \
stock-reshow-filter-16.png \
stock-resize-16.png \
stock-rotate-180-16.png \
stock-rotate-270-16.png \
stock-rotate-90-16.png \
stock-scale-16.png \
stock-selection-all-16.png \
stock-selection-grow-16.png \
stock-selection-none-16.png \
stock-selection-shrink-16.png \
stock-swap-colors-12.png \
stock-template-16.png \
stock-text-layer-16.png \
stock-toilet-paper-16.png \
stock-tool-options-16.png \
stock-video-16.png \
stock-warning-16.png \
stock-wilber-16.png \
stock-channel-16.png \
stock-channel-alpha-16.png \
stock-channel-blue-16.png \
stock-channel-gray-16.png \
stock-channel-green-16.png \
stock-channel-red-16.png \
stock-channels-16.png \
stock-convert-grayscale-16.png \
stock-convert-indexed-16.png \
stock-convert-rgb-16.png \
stock-default-colors-12.png \
stock-device-status-16.png \
stock-eye-12.png \
stock-flip-horizontal-16.png \
stock-flip-vertical-16.png \
stock-gradient-bilinear-16.png \