app/commands.c app/desaturate.[ch] no need to pass the image as a void

1999-07-27  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/commands.c
	* app/desaturate.[ch]
	* app/equalize.[ch]: no need to pass the image as a void pointer
	to desaturate and equalize.

	* app/gimage.h
	* app/gimpimage.[ch]: new function gimp_image_position_layer().

	* app/layers_dialog.c: move layers with drag'n'drop.
This commit is contained in:
Michael Natterer 1999-07-27 02:41:34 +00:00 committed by Michael Natterer
parent 21e0ceb948
commit acffb96f7b
36 changed files with 1721 additions and 643 deletions

View File

@ -1,3 +1,15 @@
1999-07-27 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/commands.c
* app/desaturate.[ch]
* app/equalize.[ch]: no need to pass the image as a void pointer
to desaturate and equalize.
* app/gimage.h
* app/gimpimage.[ch]: new function gimp_image_position_layer().
* app/layers_dialog.c: drag'n'drop movement of layers.
1999-07-27 Tomas Ogren <stric@ing.umu.se>
* app/transform_tool.c: Fixed a typo

View File

@ -15,22 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "appenv.h"
#include "about_dialog.h"
#include "app_procs.h"
#include "brightness_contrast.h"
#include "gimpbrushlist.h"
#include "by_color_select.h"
#include "colormaps.h"
#include "colormap_dialog.i.h"
#include "color_area.h"
#include "color_balance.h"
#include "commands.h"
#include "convert.h"
#include "curves.h"
#include "desaturate.h"
#include "devices.h"
#include "channel_ops.h"
@ -44,23 +37,18 @@
#include "gimprc.h"
#include "global_edit.h"
#include "gradient.h"
#include "histogram_tool.h"
#include "hue_saturation.h"
#include "image_render.h"
#include "info_window.h"
#include "interface.h"
#include "invert.h"
#include "lc_dialog.h"
#include "layer_select.h"
#include "levels.h"
#include "module_db.h"
#include "palette.h"
#include "patterns.h"
#include "plug_in.h"
#include "posterize.h"
#include "resize.h"
#include "scale.h"
#include "threshold.h"
#include "tips_dialog.h"
#include "tools.h"
#include "undo.h"
@ -78,7 +66,7 @@ typedef struct
} ImageResize;
/* external functions */
extern void layers_dialog_layer_merge_query (GImage *, int);
extern void layers_dialog_layer_merge_query (GImage *, gboolean);
/* local functions */
static void image_resize_callback (GtkWidget *, gpointer);
@ -686,7 +674,7 @@ image_equalize_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_equalize ((void *) gdisp->gimage);
image_equalize (gdisp->gimage);
gdisplays_flush ();
}
@ -697,7 +685,7 @@ image_invert_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_invert ((void *) gdisp->gimage);
image_invert (gdisp->gimage);
gdisplays_flush ();
}
@ -708,7 +696,7 @@ image_desaturate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_desaturate ((void *) gdisp->gimage);
image_desaturate (gdisp->gimage);
gdisplays_flush ();
}
@ -719,7 +707,7 @@ channel_ops_duplicate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_duplicate ((void *) gdisp->gimage);
channel_ops_duplicate (gdisp->gimage);
}
void
@ -729,7 +717,7 @@ channel_ops_offset_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_offset ((void *) gdisp->gimage);
channel_ops_offset (gdisp->gimage);
}
void
@ -739,7 +727,7 @@ image_convert_rgb_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_rgb ((void *) gdisp->gimage);
convert_to_rgb (gdisp->gimage);
}
void
@ -749,7 +737,7 @@ image_convert_grayscale_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_grayscale ((void *) gdisp->gimage);
convert_to_grayscale (gdisp->gimage);
}
void
@ -759,7 +747,7 @@ image_convert_indexed_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_indexed ((void *) gdisp->gimage);
convert_to_indexed (gdisp->gimage);
}
void
@ -775,7 +763,7 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize = g_new (ImageResize, 1);
image_resize->gimage = gimage;
image_resize->resize = resize_widget_new (ResizeWidget,
ResizeImage,
@ -807,7 +795,7 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale = g_new (ImageResize, 1);
image_scale->gimage = gimage;
image_scale->resize = resize_widget_new (ScaleWidget,
ResizeImage,
@ -1102,7 +1090,7 @@ dialogs_indexed_palette_cmd_callback (GtkWidget *widget,
{
static ColormapDialog * cmap_dlg;
if(!cmap_dlg)
if (!cmap_dlg)
{
cmap_dlg = colormap_dialog_create (image_context);
colormap_dialog_connect_selected (cmap_dlg_sel_cb, NULL, cmap_dlg);
@ -1169,7 +1157,7 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
/*********************/
static void
image_resize_callback (GtkWidget *w,
image_resize_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_resize;
@ -1191,7 +1179,8 @@ image_resize_callback (GtkWidget *w,
}
else
{
g_message (_("Resize Error: Both width and height must be greater than zero."));
g_message (_("Resize Error: Both width and height must be "
"greater than zero."));
return;
}
}
@ -1201,7 +1190,7 @@ image_resize_callback (GtkWidget *w,
}
static void
image_scale_callback (GtkWidget *w,
image_scale_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_scale;
@ -1255,18 +1244,18 @@ image_scale_callback (GtkWidget *w,
}
static gint
image_delete_callback (GtkWidget *w,
GdkEvent *e,
image_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
image_cancel_callback (w, client_data);
image_cancel_callback (widget, client_data);
return TRUE;
}
static void
image_cancel_callback (GtkWidget *w,
image_cancel_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize *image_resize;

View File

@ -15,22 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "appenv.h"
#include "about_dialog.h"
#include "app_procs.h"
#include "brightness_contrast.h"
#include "gimpbrushlist.h"
#include "by_color_select.h"
#include "colormaps.h"
#include "colormap_dialog.i.h"
#include "color_area.h"
#include "color_balance.h"
#include "commands.h"
#include "convert.h"
#include "curves.h"
#include "desaturate.h"
#include "devices.h"
#include "channel_ops.h"
@ -44,23 +37,18 @@
#include "gimprc.h"
#include "global_edit.h"
#include "gradient.h"
#include "histogram_tool.h"
#include "hue_saturation.h"
#include "image_render.h"
#include "info_window.h"
#include "interface.h"
#include "invert.h"
#include "lc_dialog.h"
#include "layer_select.h"
#include "levels.h"
#include "module_db.h"
#include "palette.h"
#include "patterns.h"
#include "plug_in.h"
#include "posterize.h"
#include "resize.h"
#include "scale.h"
#include "threshold.h"
#include "tips_dialog.h"
#include "tools.h"
#include "undo.h"
@ -78,7 +66,7 @@ typedef struct
} ImageResize;
/* external functions */
extern void layers_dialog_layer_merge_query (GImage *, int);
extern void layers_dialog_layer_merge_query (GImage *, gboolean);
/* local functions */
static void image_resize_callback (GtkWidget *, gpointer);
@ -686,7 +674,7 @@ image_equalize_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_equalize ((void *) gdisp->gimage);
image_equalize (gdisp->gimage);
gdisplays_flush ();
}
@ -697,7 +685,7 @@ image_invert_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_invert ((void *) gdisp->gimage);
image_invert (gdisp->gimage);
gdisplays_flush ();
}
@ -708,7 +696,7 @@ image_desaturate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_desaturate ((void *) gdisp->gimage);
image_desaturate (gdisp->gimage);
gdisplays_flush ();
}
@ -719,7 +707,7 @@ channel_ops_duplicate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_duplicate ((void *) gdisp->gimage);
channel_ops_duplicate (gdisp->gimage);
}
void
@ -729,7 +717,7 @@ channel_ops_offset_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_offset ((void *) gdisp->gimage);
channel_ops_offset (gdisp->gimage);
}
void
@ -739,7 +727,7 @@ image_convert_rgb_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_rgb ((void *) gdisp->gimage);
convert_to_rgb (gdisp->gimage);
}
void
@ -749,7 +737,7 @@ image_convert_grayscale_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_grayscale ((void *) gdisp->gimage);
convert_to_grayscale (gdisp->gimage);
}
void
@ -759,7 +747,7 @@ image_convert_indexed_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_indexed ((void *) gdisp->gimage);
convert_to_indexed (gdisp->gimage);
}
void
@ -775,7 +763,7 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize = g_new (ImageResize, 1);
image_resize->gimage = gimage;
image_resize->resize = resize_widget_new (ResizeWidget,
ResizeImage,
@ -807,7 +795,7 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale = g_new (ImageResize, 1);
image_scale->gimage = gimage;
image_scale->resize = resize_widget_new (ScaleWidget,
ResizeImage,
@ -1102,7 +1090,7 @@ dialogs_indexed_palette_cmd_callback (GtkWidget *widget,
{
static ColormapDialog * cmap_dlg;
if(!cmap_dlg)
if (!cmap_dlg)
{
cmap_dlg = colormap_dialog_create (image_context);
colormap_dialog_connect_selected (cmap_dlg_sel_cb, NULL, cmap_dlg);
@ -1169,7 +1157,7 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
/*********************/
static void
image_resize_callback (GtkWidget *w,
image_resize_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_resize;
@ -1191,7 +1179,8 @@ image_resize_callback (GtkWidget *w,
}
else
{
g_message (_("Resize Error: Both width and height must be greater than zero."));
g_message (_("Resize Error: Both width and height must be "
"greater than zero."));
return;
}
}
@ -1201,7 +1190,7 @@ image_resize_callback (GtkWidget *w,
}
static void
image_scale_callback (GtkWidget *w,
image_scale_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_scale;
@ -1255,18 +1244,18 @@ image_scale_callback (GtkWidget *w,
}
static gint
image_delete_callback (GtkWidget *w,
GdkEvent *e,
image_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
image_cancel_callback (w, client_data);
image_cancel_callback (widget, client_data);
return TRUE;
}
static void
image_cancel_callback (GtkWidget *w,
image_cancel_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize *image_resize;

View File

@ -15,27 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "drawable.h"
#include "desaturate.h"
#include "interface.h"
#include "paint_funcs.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
void
image_desaturate (gimage_ptr)
void *gimage_ptr;
image_desaturate (GimpImage *gimage)
{
GImage *gimage;
GimpDrawable *drawable;
gimage = (GImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (! drawable_color (drawable))

View File

@ -18,10 +18,11 @@
#ifndef __DESATURATE_H__
#define __DESATURATE_H__
#include "gimpimageF.h"
#include "gimpdrawableF.h"
/* desaturate functions */
void image_desaturate (void *);
void desaturate (GimpDrawable *);
void image_desaturate (GimpImage *gimage);
void desaturate (GimpDrawable *drawable);
#endif /* __DESATURATE_H__ */

View File

@ -15,10 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "drawable.h"
#include "equalize.h"
#include "gimage.h"
@ -28,14 +24,11 @@
#include "libgimp/gimpintl.h"
void
image_equalize (void *gimage_ptr)
image_equalize (GimpImage *gimage)
{
GimpImage *gimage;
GimpDrawable *drawable;
gimage = (GimpImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (gimp_drawable_indexed (drawable))
@ -43,6 +36,7 @@ image_equalize (void *gimage_ptr)
g_message (_("Equalize does not operate on indexed drawables."));
return;
}
equalize (gimage, drawable, TRUE);
}

View File

@ -22,7 +22,9 @@
#include "gimpdrawableF.h"
/* equalize functions */
void image_equalize (void *);
void equalize (GimpImage *, GimpDrawable *, gboolean);
void image_equalize (GimpImage *gimage);
void equalize (GimpImage *gimage,
GimpDrawable *drawable,
gboolean mask_only);
#endif /* __INVERT_H__ */

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -15,27 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "drawable.h"
#include "desaturate.h"
#include "interface.h"
#include "paint_funcs.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
void
image_desaturate (gimage_ptr)
void *gimage_ptr;
image_desaturate (GimpImage *gimage)
{
GImage *gimage;
GimpDrawable *drawable;
gimage = (GImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (! drawable_color (drawable))

View File

@ -18,10 +18,11 @@
#ifndef __DESATURATE_H__
#define __DESATURATE_H__
#include "gimpimageF.h"
#include "gimpdrawableF.h"
/* desaturate functions */
void image_desaturate (void *);
void desaturate (GimpDrawable *);
void image_desaturate (GimpImage *gimage);
void desaturate (GimpDrawable *drawable);
#endif /* __DESATURATE_H__ */

View File

@ -15,10 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "drawable.h"
#include "equalize.h"
#include "gimage.h"
@ -28,14 +24,11 @@
#include "libgimp/gimpintl.h"
void
image_equalize (void *gimage_ptr)
image_equalize (GimpImage *gimage)
{
GimpImage *gimage;
GimpDrawable *drawable;
gimage = (GimpImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (gimp_drawable_indexed (drawable))
@ -43,6 +36,7 @@ image_equalize (void *gimage_ptr)
g_message (_("Equalize does not operate on indexed drawables."));
return;
}
equalize (gimage, drawable, TRUE);
}

View File

@ -22,7 +22,9 @@
#include "gimpdrawableF.h"
/* equalize functions */
void image_equalize (void *);
void equalize (GimpImage *, GimpDrawable *, gboolean);
void image_equalize (GimpImage *gimage);
void equalize (GimpImage *gimage,
GimpDrawable *drawable,
gboolean mask_only);
#endif /* __INVERT_H__ */

View File

@ -74,6 +74,7 @@ void gimage_foreach (GFunc func, gpointer user_data);
#define gimage_lower_layer gimp_image_lower_layer
#define gimage_raise_layer_to_top gimp_image_raise_layer_to_top
#define gimage_lower_layer_to_bottom gimp_image_lower_layer_to_bottom
#define gimage_position_layer gimp_image_position_layer
#define gimage_merge_visible_layers gimp_image_merge_visible_layers
#define gimage_flatten gimp_image_flatten
#define gimage_merge_layers gimp_image_merge_layers

View File

@ -15,27 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "drawable.h"
#include "desaturate.h"
#include "interface.h"
#include "paint_funcs.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
void
image_desaturate (gimage_ptr)
void *gimage_ptr;
image_desaturate (GimpImage *gimage)
{
GImage *gimage;
GimpDrawable *drawable;
gimage = (GImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (! drawable_color (drawable))

View File

@ -18,10 +18,11 @@
#ifndef __DESATURATE_H__
#define __DESATURATE_H__
#include "gimpimageF.h"
#include "gimpdrawableF.h"
/* desaturate functions */
void image_desaturate (void *);
void desaturate (GimpDrawable *);
void image_desaturate (GimpImage *gimage);
void desaturate (GimpDrawable *drawable);
#endif /* __DESATURATE_H__ */

View File

@ -15,10 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "drawable.h"
#include "equalize.h"
#include "gimage.h"
@ -28,14 +24,11 @@
#include "libgimp/gimpintl.h"
void
image_equalize (void *gimage_ptr)
image_equalize (GimpImage *gimage)
{
GimpImage *gimage;
GimpDrawable *drawable;
gimage = (GimpImage *) gimage_ptr;
drawable = gimage_active_drawable (gimage);
if (gimp_drawable_indexed (drawable))
@ -43,6 +36,7 @@ image_equalize (void *gimage_ptr)
g_message (_("Equalize does not operate on indexed drawables."));
return;
}
equalize (gimage, drawable, TRUE);
}

View File

@ -22,7 +22,9 @@
#include "gimpdrawableF.h"
/* equalize functions */
void image_equalize (void *);
void equalize (GimpImage *, GimpDrawable *, gboolean);
void image_equalize (GimpImage *gimage);
void equalize (GimpImage *gimage,
GimpDrawable *drawable,
gboolean mask_only);
#endif /* __INVERT_H__ */

View File

@ -2192,6 +2192,7 @@ gimp_image_lower_layer (GimpImage *gimage,
return NULL;
}
Layer *
gimp_image_raise_layer_to_top (GimpImage *gimage,
Layer *layer_arg)
@ -2359,6 +2360,85 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage,
}
Layer *
gimp_image_position_layer (GimpImage *gimage,
Layer *layer_arg,
gint new_index)
{
Layer *layer;
GSList *list;
GSList *next;
gint x_min, y_min, x_max, y_max;
gint off_x, off_y;
gint index;
gint list_length;
list = gimage->layers;
list_length = g_slist_length (list);
next = NULL;
layer = NULL;
index = 0;
/* find layer_arg */
while (list)
{
layer = (Layer *) list->data;
if (layer == layer_arg)
{
break;
}
list = g_slist_next (list);
index++;
}
if (layer != layer_arg)
{
/* The requested layer was not found in the layerstack
* Return without changing anything
*/
return NULL;
}
if (new_index < 0)
new_index = 0;
if (new_index >= list_length)
new_index = list_length - 1;
if (new_index == index)
return NULL;
/* check if we want to move it below a bottom layer without alpha */
layer = (Layer *) g_slist_last (list)->data;
if (new_index == list_length - 1 &&
!layer_has_alpha (layer))
{
g_message (_("BG has no alpha, layer was placed above"));
new_index--;
}
list = g_slist_remove (gimage->layers, layer_arg);
gimage->layers = g_slist_insert (list, layer_arg, new_index);
/* update the affected area (== area of layer_arg) */
drawable_offsets (GIMP_DRAWABLE(layer_arg), &off_x, &off_y);
x_min = off_x;
y_min = off_y;
x_max = off_x + drawable_width (GIMP_DRAWABLE (layer_arg));
y_max = off_y + drawable_height (GIMP_DRAWABLE (layer_arg));
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
x_min, y_min, x_max, y_max);
/* invalidate the composite preview */
gimp_image_invalidate_preview (gimage);
gimp_image_dirty (gimage);
return layer_arg;
}
Layer *
gimp_image_merge_visible_layers (GimpImage *gimage,
MergeType merge_type)

View File

@ -196,6 +196,7 @@ Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_raise_layer_to_top (GimpImage *, Layer *);
Layer * gimp_image_lower_layer_to_bottom (GimpImage *, Layer *);
Layer * gimp_image_position_layer (GimpImage *, Layer *, gint);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);

View File

@ -15,22 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "appenv.h"
#include "about_dialog.h"
#include "app_procs.h"
#include "brightness_contrast.h"
#include "gimpbrushlist.h"
#include "by_color_select.h"
#include "colormaps.h"
#include "colormap_dialog.i.h"
#include "color_area.h"
#include "color_balance.h"
#include "commands.h"
#include "convert.h"
#include "curves.h"
#include "desaturate.h"
#include "devices.h"
#include "channel_ops.h"
@ -44,23 +37,18 @@
#include "gimprc.h"
#include "global_edit.h"
#include "gradient.h"
#include "histogram_tool.h"
#include "hue_saturation.h"
#include "image_render.h"
#include "info_window.h"
#include "interface.h"
#include "invert.h"
#include "lc_dialog.h"
#include "layer_select.h"
#include "levels.h"
#include "module_db.h"
#include "palette.h"
#include "patterns.h"
#include "plug_in.h"
#include "posterize.h"
#include "resize.h"
#include "scale.h"
#include "threshold.h"
#include "tips_dialog.h"
#include "tools.h"
#include "undo.h"
@ -78,7 +66,7 @@ typedef struct
} ImageResize;
/* external functions */
extern void layers_dialog_layer_merge_query (GImage *, int);
extern void layers_dialog_layer_merge_query (GImage *, gboolean);
/* local functions */
static void image_resize_callback (GtkWidget *, gpointer);
@ -686,7 +674,7 @@ image_equalize_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_equalize ((void *) gdisp->gimage);
image_equalize (gdisp->gimage);
gdisplays_flush ();
}
@ -697,7 +685,7 @@ image_invert_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_invert ((void *) gdisp->gimage);
image_invert (gdisp->gimage);
gdisplays_flush ();
}
@ -708,7 +696,7 @@ image_desaturate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_desaturate ((void *) gdisp->gimage);
image_desaturate (gdisp->gimage);
gdisplays_flush ();
}
@ -719,7 +707,7 @@ channel_ops_duplicate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_duplicate ((void *) gdisp->gimage);
channel_ops_duplicate (gdisp->gimage);
}
void
@ -729,7 +717,7 @@ channel_ops_offset_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_offset ((void *) gdisp->gimage);
channel_ops_offset (gdisp->gimage);
}
void
@ -739,7 +727,7 @@ image_convert_rgb_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_rgb ((void *) gdisp->gimage);
convert_to_rgb (gdisp->gimage);
}
void
@ -749,7 +737,7 @@ image_convert_grayscale_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_grayscale ((void *) gdisp->gimage);
convert_to_grayscale (gdisp->gimage);
}
void
@ -759,7 +747,7 @@ image_convert_indexed_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_indexed ((void *) gdisp->gimage);
convert_to_indexed (gdisp->gimage);
}
void
@ -775,7 +763,7 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize = g_new (ImageResize, 1);
image_resize->gimage = gimage;
image_resize->resize = resize_widget_new (ResizeWidget,
ResizeImage,
@ -807,7 +795,7 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale = g_new (ImageResize, 1);
image_scale->gimage = gimage;
image_scale->resize = resize_widget_new (ScaleWidget,
ResizeImage,
@ -1102,7 +1090,7 @@ dialogs_indexed_palette_cmd_callback (GtkWidget *widget,
{
static ColormapDialog * cmap_dlg;
if(!cmap_dlg)
if (!cmap_dlg)
{
cmap_dlg = colormap_dialog_create (image_context);
colormap_dialog_connect_selected (cmap_dlg_sel_cb, NULL, cmap_dlg);
@ -1169,7 +1157,7 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
/*********************/
static void
image_resize_callback (GtkWidget *w,
image_resize_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_resize;
@ -1191,7 +1179,8 @@ image_resize_callback (GtkWidget *w,
}
else
{
g_message (_("Resize Error: Both width and height must be greater than zero."));
g_message (_("Resize Error: Both width and height must be "
"greater than zero."));
return;
}
}
@ -1201,7 +1190,7 @@ image_resize_callback (GtkWidget *w,
}
static void
image_scale_callback (GtkWidget *w,
image_scale_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_scale;
@ -1255,18 +1244,18 @@ image_scale_callback (GtkWidget *w,
}
static gint
image_delete_callback (GtkWidget *w,
GdkEvent *e,
image_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
image_cancel_callback (w, client_data);
image_cancel_callback (widget, client_data);
return TRUE;
}
static void
image_cancel_callback (GtkWidget *w,
image_cancel_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize *image_resize;

View File

@ -15,22 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "appenv.h"
#include "about_dialog.h"
#include "app_procs.h"
#include "brightness_contrast.h"
#include "gimpbrushlist.h"
#include "by_color_select.h"
#include "colormaps.h"
#include "colormap_dialog.i.h"
#include "color_area.h"
#include "color_balance.h"
#include "commands.h"
#include "convert.h"
#include "curves.h"
#include "desaturate.h"
#include "devices.h"
#include "channel_ops.h"
@ -44,23 +37,18 @@
#include "gimprc.h"
#include "global_edit.h"
#include "gradient.h"
#include "histogram_tool.h"
#include "hue_saturation.h"
#include "image_render.h"
#include "info_window.h"
#include "interface.h"
#include "invert.h"
#include "lc_dialog.h"
#include "layer_select.h"
#include "levels.h"
#include "module_db.h"
#include "palette.h"
#include "patterns.h"
#include "plug_in.h"
#include "posterize.h"
#include "resize.h"
#include "scale.h"
#include "threshold.h"
#include "tips_dialog.h"
#include "tools.h"
#include "undo.h"
@ -78,7 +66,7 @@ typedef struct
} ImageResize;
/* external functions */
extern void layers_dialog_layer_merge_query (GImage *, int);
extern void layers_dialog_layer_merge_query (GImage *, gboolean);
/* local functions */
static void image_resize_callback (GtkWidget *, gpointer);
@ -686,7 +674,7 @@ image_equalize_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_equalize ((void *) gdisp->gimage);
image_equalize (gdisp->gimage);
gdisplays_flush ();
}
@ -697,7 +685,7 @@ image_invert_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_invert ((void *) gdisp->gimage);
image_invert (gdisp->gimage);
gdisplays_flush ();
}
@ -708,7 +696,7 @@ image_desaturate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
image_desaturate ((void *) gdisp->gimage);
image_desaturate (gdisp->gimage);
gdisplays_flush ();
}
@ -719,7 +707,7 @@ channel_ops_duplicate_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_duplicate ((void *) gdisp->gimage);
channel_ops_duplicate (gdisp->gimage);
}
void
@ -729,7 +717,7 @@ channel_ops_offset_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
channel_ops_offset ((void *) gdisp->gimage);
channel_ops_offset (gdisp->gimage);
}
void
@ -739,7 +727,7 @@ image_convert_rgb_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_rgb ((void *) gdisp->gimage);
convert_to_rgb (gdisp->gimage);
}
void
@ -749,7 +737,7 @@ image_convert_grayscale_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_grayscale ((void *) gdisp->gimage);
convert_to_grayscale (gdisp->gimage);
}
void
@ -759,7 +747,7 @@ image_convert_indexed_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
convert_to_indexed ((void *) gdisp->gimage);
convert_to_indexed (gdisp->gimage);
}
void
@ -775,7 +763,7 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize = g_new (ImageResize, 1);
image_resize->gimage = gimage;
image_resize->resize = resize_widget_new (ResizeWidget,
ResizeImage,
@ -807,7 +795,7 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage = gdisp->gimage;
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale = g_new (ImageResize, 1);
image_scale->gimage = gimage;
image_scale->resize = resize_widget_new (ScaleWidget,
ResizeImage,
@ -1102,7 +1090,7 @@ dialogs_indexed_palette_cmd_callback (GtkWidget *widget,
{
static ColormapDialog * cmap_dlg;
if(!cmap_dlg)
if (!cmap_dlg)
{
cmap_dlg = colormap_dialog_create (image_context);
colormap_dialog_connect_selected (cmap_dlg_sel_cb, NULL, cmap_dlg);
@ -1169,7 +1157,7 @@ dialogs_module_browser_cmd_callback (GtkWidget *widget,
/*********************/
static void
image_resize_callback (GtkWidget *w,
image_resize_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_resize;
@ -1191,7 +1179,8 @@ image_resize_callback (GtkWidget *w,
}
else
{
g_message (_("Resize Error: Both width and height must be greater than zero."));
g_message (_("Resize Error: Both width and height must be "
"greater than zero."));
return;
}
}
@ -1201,7 +1190,7 @@ image_resize_callback (GtkWidget *w,
}
static void
image_scale_callback (GtkWidget *w,
image_scale_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize * image_scale;
@ -1255,18 +1244,18 @@ image_scale_callback (GtkWidget *w,
}
static gint
image_delete_callback (GtkWidget *w,
GdkEvent *e,
image_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
image_cancel_callback (w, client_data);
image_cancel_callback (widget, client_data);
return TRUE;
}
static void
image_cancel_callback (GtkWidget *w,
image_cancel_callback (GtkWidget *widget,
gpointer client_data)
{
ImageResize *image_resize;

View File

@ -75,7 +75,6 @@
#define INSENSITIVE 2
typedef struct _LayersDialog LayersDialog;
struct _LayersDialog
@ -105,6 +104,13 @@ struct _LayersDialog
GSList *layer_widgets;
};
typedef enum
{
LAYER_DROP_NONE,
LAYER_DROP_ABOVE,
LAYER_DROP_BELOW
} LayerDropType;
typedef struct _LayerWidget LayerWidget;
struct _LayerWidget
@ -130,6 +136,8 @@ struct _LayerWidget
gboolean edit_mask;
gboolean show_mask;
gboolean visited;
LayerDropType drop_type;
};
/* layers dialog widget routines */
@ -153,6 +161,18 @@ static void layers_dialog_map_callback (GtkWidget *, gpointer);
static void layers_dialog_unmap_callback (GtkWidget *, gpointer);
/* layer widget function prototypes */
static void layer_widget_draw_drop_indicator (LayerWidget *, LayerDropType);
static void layer_widget_drag_indicator_callback (GtkWidget *, gpointer);
static void layer_widget_drag_leave_callback (GtkWidget *,
GdkDragContext *,
guint);
static gboolean layer_widget_drag_motion_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layer_widget_drag_drop_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *layer_widget_create (GImage *, Layer *);
@ -176,7 +196,7 @@ static void layers_dialog_add_mask_query (Layer *);
static void layers_dialog_apply_mask_query (Layer *);
static void layers_dialog_scale_layer_query (GImage *, Layer *);
static void layers_dialog_resize_layer_query (GImage *, Layer *);
void layers_dialog_layer_merge_query (GImage *, int);
void layers_dialog_layer_merge_query (GImage *, gboolean);
/*
* Local data
@ -271,8 +291,9 @@ layers_dialog_create ()
GtkWidget *slider;
GtkWidget *listbox;
if (! layersD)
{
if (layersD)
return layersD->vbox;
layersD = g_new (LayersDialog, 1);
layersD->layer_preview = NULL;
layersD->gimage = NULL;
@ -311,8 +332,7 @@ layers_dialog_create ()
gtk_widget_show (label);
gtk_widget_show (layersD->mode_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (layersD->mode_option_menu),
menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (layersD->mode_option_menu), menu);
layersD->preserve_trans =
gtk_check_button_new_with_label (_("Keep Trans."));
@ -335,8 +355,7 @@ layers_dialog_create ()
layersD->opacity_data =
GTK_ADJUSTMENT (gtk_adjustment_new (100.0, 0.0, 100.0, 1.0, 1.0, 0.0));
slider = gtk_hscale_new (layersD->opacity_data);
gtk_range_set_update_policy (GTK_RANGE (slider),
GTK_UPDATE_CONTINUOUS);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_RIGHT);
gtk_box_pack_start (GTK_BOX (util_box), slider, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (layersD->opacity_data), "value_changed",
@ -382,7 +401,6 @@ layers_dialog_create ()
NULL);
gtk_widget_show (vbox);
}
return layersD->vbox;
}
@ -1177,7 +1195,7 @@ paint_mode_menu_get_position (gint mode)
static void
paint_mode_menu_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1189,7 +1207,7 @@ paint_mode_menu_callback (GtkWidget *widget,
/* If the layer has an alpha channel, set the transparency and redraw */
if (layer_has_alpha (layer))
{
mode = (long) client_data;
mode = (long) data;
if (layer->mode != mode)
{
layer->mode = mode;
@ -1308,7 +1326,7 @@ layer_list_events (GtkWidget *widget,
static void
layers_dialog_map_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
if (! layersD)
return;
@ -1319,7 +1337,7 @@ layers_dialog_map_callback (GtkWidget *widget,
static void
layers_dialog_unmap_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
if (! layersD)
return;
@ -1330,7 +1348,7 @@ layers_dialog_unmap_callback (GtkWidget *widget,
void
layers_dialog_previous_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *new_layer;
@ -1357,7 +1375,7 @@ layers_dialog_previous_layer_callback (GtkWidget *widget,
void
layers_dialog_next_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *new_layer;
@ -1384,7 +1402,7 @@ layers_dialog_next_layer_callback (GtkWidget *widget,
void
layers_dialog_raise_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1397,7 +1415,7 @@ layers_dialog_raise_layer_callback (GtkWidget *widget,
void
layers_dialog_lower_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1410,7 +1428,7 @@ layers_dialog_lower_layer_callback (GtkWidget *widget,
void
layers_dialog_raise_layer_to_top_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1427,7 +1445,7 @@ layers_dialog_raise_layer_to_top_callback (GtkWidget *widget,
void
layers_dialog_lower_layer_to_bottom_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1443,7 +1461,7 @@ layers_dialog_lower_layer_to_bottom_callback (GtkWidget *widget,
void
layers_dialog_new_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1466,7 +1484,7 @@ layers_dialog_new_layer_callback (GtkWidget *widget,
void
layers_dialog_duplicate_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *active_layer;
@ -1490,7 +1508,7 @@ layers_dialog_duplicate_layer_callback (GtkWidget *widget,
void
layers_dialog_delete_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1511,7 +1529,7 @@ layers_dialog_delete_layer_callback (GtkWidget *widget,
void
layers_dialog_scale_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1523,7 +1541,7 @@ layers_dialog_scale_layer_callback (GtkWidget *widget,
void
layers_dialog_resize_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1535,7 +1553,7 @@ layers_dialog_resize_layer_callback (GtkWidget *widget,
void
layers_dialog_add_layer_mask_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1547,7 +1565,7 @@ layers_dialog_add_layer_mask_callback (GtkWidget *widget,
void
layers_dialog_apply_layer_mask_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1565,7 +1583,7 @@ layers_dialog_apply_layer_mask_callback (GtkWidget *widget,
void
layers_dialog_anchor_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1578,7 +1596,7 @@ layers_dialog_anchor_layer_callback (GtkWidget *widget,
void
layers_dialog_merge_layers_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1590,7 +1608,7 @@ layers_dialog_merge_layers_callback (GtkWidget *widget,
void
layers_dialog_merge_down_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1603,7 +1621,7 @@ layers_dialog_merge_down_callback (GtkWidget *widget,
void
layers_dialog_flatten_image_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1617,7 +1635,7 @@ layers_dialog_flatten_image_callback (GtkWidget *widget,
void
layers_dialog_alpha_select_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1631,7 +1649,7 @@ layers_dialog_alpha_select_callback (GtkWidget *widget,
void
layers_dialog_mask_select_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1645,7 +1663,7 @@ layers_dialog_mask_select_callback (GtkWidget *widget,
void
layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1655,7 +1673,6 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
!(layer = gimage_get_active_layer (gimage)))
return;
/* Add an alpha channel */
layer_add_alpha (layer);
gdisplays_flush ();
}
@ -1665,6 +1682,206 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
/* layer widget functions */
/****************************/
enum
{
GIMP_TARGET_LAYER
};
static GtkTargetEntry layer_target_table[] =
{
{ "GIMP_LAYER", 0, GIMP_TARGET_LAYER }
};
static guint n_targets = (sizeof (layer_target_table) /
sizeof (layer_target_table[0]));
static void
layer_widget_draw_drop_indicator (LayerWidget *lw,
LayerDropType drop_type)
{
static GdkGC *gc = NULL;
gint y = 0;
if (!gc)
{
GdkColor fg, bg;
gc = gdk_gc_new (lw->list_item->window);
fg.pixel = 0xFFFFFFFF;
bg.pixel = 0x00000000;
gdk_gc_set_function (gc, GDK_INVERT);
gdk_gc_set_foreground (gc, &fg);
gdk_gc_set_background (gc, &bg);
gdk_gc_set_line_attributes (gc, 5, GDK_LINE_SOLID,
GDK_CAP_BUTT, GDK_JOIN_MITER);
}
if (drop_type != LAYER_DROP_NONE)
{
y = ((drop_type == LAYER_DROP_ABOVE) ?
3 : lw->list_item->allocation.height - 4);
gdk_draw_line (lw->list_item->window, gc,
2, y, lw->list_item->allocation.width - 3, y);
}
}
static void
layer_widget_drag_indicator_callback (GtkWidget *widget,
gpointer data)
{
LayerWidget *lw;
lw = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
layer_widget_draw_drop_indicator (lw, lw->drop_type);
}
static void
layer_widget_drag_leave_callback (GtkWidget *widget,
GdkDragContext *context,
guint time)
{
LayerWidget *lw;
lw = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
lw->drop_type = LAYER_DROP_NONE;
}
static gboolean
layer_widget_drag_motion_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
LayerWidget *dest;
gint dest_index;
GtkWidget *src_widget;
LayerWidget *src;
gint src_index;
gint difference;
LayerDropType drop_type = LAYER_DROP_NONE;
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
gboolean return_val = FALSE;
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
if (layer_has_alpha (dest->layer) &&
(src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (layer_has_alpha (src->layer))
{
src_index = gimage_get_layer_index (layersD->gimage, src->layer);
dest_index = gimage_get_layer_index (layersD->gimage, dest->layer);
difference = dest_index - src_index;
drop_type = ((y < widget->allocation.height / 2) ?
LAYER_DROP_ABOVE : LAYER_DROP_BELOW);
if (difference < 0 &&
drop_type == LAYER_DROP_BELOW)
{
dest_index++;
}
else if (difference > 0 &&
drop_type == LAYER_DROP_ABOVE)
{
dest_index--;
}
if (src_index != dest_index)
{
drag_action = context->suggested_action;
return_val = TRUE;
}
else
{
drop_type = LAYER_DROP_NONE;
}
}
}
gdk_drag_status (context, drag_action, time);
if (drop_type != dest->drop_type)
{
layer_widget_draw_drop_indicator (dest, dest->drop_type);
layer_widget_draw_drop_indicator (dest, drop_type);
dest->drop_type = drop_type;
}
return return_val;
}
static gboolean
layer_widget_drag_drop_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
LayerWidget *dest;
gint dest_index;
GtkWidget *src_widget;
LayerWidget *src;
gint src_index;
gint difference;
LayerDropType drop_type = LAYER_DROP_NONE;
gboolean return_val = FALSE;
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
src_index = gimage_get_layer_index (layersD->gimage, src->layer);
dest_index = gimage_get_layer_index (layersD->gimage, dest->layer);
difference = dest_index - src_index;
drop_type = ((y < widget->allocation.height / 2) ?
LAYER_DROP_ABOVE : LAYER_DROP_BELOW);
if (difference < 0 &&
drop_type == LAYER_DROP_BELOW)
{
dest_index++;
}
else if (difference > 0 &&
drop_type == LAYER_DROP_ABOVE)
{
dest_index--;
}
if (src_index != dest_index)
{
gimage_position_layer (layersD->gimage, src->layer, dest_index);
gdisplays_flush ();
return_val = TRUE;
}
}
layer_widget_draw_drop_indicator (dest, dest->drop_type);
dest->drop_type = LAYER_DROP_NONE;
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static LayerWidget *
layer_widget_get_ID (Layer *ID)
{
@ -1716,6 +1933,7 @@ layer_widget_create (GImage *gimage,
layer_widget->edit_mask = layer->edit_mask;
layer_widget->show_mask = layer->show_mask;
layer_widget->visited = TRUE;
layer_widget->drop_type = LAYER_DROP_NONE;
if (layer->mask)
layer_widget->active_preview = (layer->edit_mask) ? MASK_PREVIEW : LAYER_PREVIEW;
@ -1819,6 +2037,33 @@ layer_widget_create (GImage *gimage,
FALSE, FALSE, 0);
/* gtk_widget_show (layer_widget->clip_widget); */
/* dnd destination */
gtk_drag_dest_set (list_item,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_leave",
GTK_SIGNAL_FUNC (layer_widget_drag_leave_callback),
NULL);
gtk_signal_connect_after (GTK_OBJECT (list_item), "drag_motion",
GTK_SIGNAL_FUNC (layer_widget_drag_motion_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_drop",
GTK_SIGNAL_FUNC (layer_widget_drag_drop_callback),
NULL);
/* re-paint the drop indicator after drawing the widget */
gtk_signal_connect_after (GTK_OBJECT (list_item), "draw",
(GtkSignalFunc) layer_widget_drag_indicator_callback,
layer_widget);
/* dnd source */
gtk_drag_source_set (list_item,
GDK_BUTTON1_MASK,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
gtk_widget_show (list_item);
@ -1912,7 +2157,7 @@ layer_widget_button_events (GtkWidget *widget,
if (widget == layer_widget->eye_widget)
{
old_state = GIMP_DRAWABLE(layer_widget->layer)->visible;
old_state = GIMP_DRAWABLE (layer_widget->layer)->visible;
/* If this was a shift-click, make all/none visible */
if (event->button.state & GDK_SHIFT_MASK)
@ -1923,7 +2168,8 @@ layer_widget_button_events (GtkWidget *widget,
else
{
exclusive = FALSE;
GIMP_DRAWABLE(layer_widget->layer)->visible = !GIMP_DRAWABLE(layer_widget->layer)->visible;
GIMP_DRAWABLE (layer_widget->layer)->visible =
!GIMP_DRAWABLE (layer_widget->layer)->visible;
layer_widget_eye_redraw (layer_widget);
}
}
@ -1951,13 +2197,13 @@ layer_widget_button_events (GtkWidget *widget,
layer_widget->gimage->height);
gdisplays_flush ();
}
else if (old_state != GIMP_DRAWABLE(layer_widget->layer)->visible)
else if (old_state != GIMP_DRAWABLE (layer_widget->layer)->visible)
{
/* Invalidate the gimage preview */
gimage_invalidate_preview (layer_widget->gimage);
drawable_update (GIMP_DRAWABLE(layer_widget->layer), 0, 0,
GIMP_DRAWABLE(layer_widget->layer)->width,
GIMP_DRAWABLE(layer_widget->layer)->height);
drawable_update (GIMP_DRAWABLE (layer_widget->layer), 0, 0,
GIMP_DRAWABLE (layer_widget->layer)->width,
GIMP_DRAWABLE (layer_widget->layer)->height);
gdisplays_flush ();
}
}
@ -1981,7 +2227,8 @@ layer_widget_button_events (GtkWidget *widget,
}
else
{
GIMP_DRAWABLE(layer_widget->layer)->visible = !GIMP_DRAWABLE(layer_widget->layer)->visible;
GIMP_DRAWABLE (layer_widget->layer)->visible =
!GIMP_DRAWABLE (layer_widget->layer)->visible;
layer_widget_eye_redraw (layer_widget);
}
}
@ -2546,7 +2793,7 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
{
lw = (LayerWidget *) list->data;
if (lw != layer_widget)
visible |= GIMP_DRAWABLE(lw->layer)->visible;
visible |= GIMP_DRAWABLE (lw->layer)->visible;
list = g_slist_next (list);
}
@ -2557,9 +2804,9 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
{
lw = (LayerWidget *) list->data;
if (lw != layer_widget)
GIMP_DRAWABLE(lw->layer)->visible = !visible;
GIMP_DRAWABLE (lw->layer)->visible = !visible;
else
GIMP_DRAWABLE(lw->layer)->visible = TRUE;
GIMP_DRAWABLE (lw->layer)->visible = TRUE;
layer_widget_eye_redraw (lw);
@ -2569,7 +2816,7 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
static void
layer_widget_layer_flush (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
LayerWidget *layer_widget;
Layer *layer;
@ -2709,13 +2956,13 @@ static gchar *layer_name = NULL;
static void
new_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
Layer *layer;
GImage *gimage;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
if (layer_name)
g_free (layer_name);
@ -2759,11 +3006,11 @@ new_layer_query_ok_callback (GtkWidget *widget,
static void
new_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
@ -2772,9 +3019,9 @@ new_layer_query_cancel_callback (GtkWidget *widget,
static gint
new_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
new_layer_query_cancel_callback (widget, client_data);
new_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -2782,11 +3029,11 @@ new_layer_query_delete_callback (GtkWidget *widget,
static void
new_layer_query_fill_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
options->fill_type =
(GimpFillType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type");
@ -2978,12 +3225,12 @@ struct _EditLayerOptions
static void
edit_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
EditLayerOptions *options;
Layer *layer;
options = (EditLayerOptions *) client_data;
options = (EditLayerOptions *) data;
if ((layer = options->layer))
{
@ -3010,11 +3257,11 @@ edit_layer_query_ok_callback (GtkWidget *widget,
static void
edit_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
EditLayerOptions *options;
options = (EditLayerOptions *) client_data;
options = (EditLayerOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3022,9 +3269,9 @@ edit_layer_query_cancel_callback (GtkWidget *widget,
static gint
edit_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
edit_layer_query_cancel_callback (widget, client_data);
edit_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3109,14 +3356,14 @@ struct _AddMaskOptions
static void
add_mask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
GImage *gimage;
LayerMask *mask;
Layer *layer;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
if ((layer = (options->layer)) &&
(gimage = GIMP_DRAWABLE (layer)->gimage))
{
@ -3131,11 +3378,11 @@ add_mask_query_ok_callback (GtkWidget *widget,
static void
add_mask_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3143,20 +3390,20 @@ add_mask_query_cancel_callback (GtkWidget *widget,
static gint
add_mask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
add_mask_query_cancel_callback (widget, client_data);
add_mask_query_cancel_callback (widget, data);
return TRUE;
}
static void
add_mask_query_fill_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
options->add_mask_type =
(AddMaskType) gtk_object_get_data (GTK_OBJECT (widget), "add_mask_type");
@ -3256,11 +3503,11 @@ struct _ApplyMaskOptions
static void
apply_mask_query_apply_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gimage_remove_layer_mask (drawable_gimage (GIMP_DRAWABLE (options->layer)),
options->layer, APPLY);
@ -3270,11 +3517,11 @@ apply_mask_query_apply_callback (GtkWidget *widget,
static void
apply_mask_query_discard_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gimage_remove_layer_mask (drawable_gimage (GIMP_DRAWABLE (options->layer)),
options->layer, DISCARD);
@ -3284,11 +3531,11 @@ apply_mask_query_discard_callback (GtkWidget *widget,
static void
apply_mask_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3296,9 +3543,9 @@ apply_mask_query_cancel_callback (GtkWidget *widget,
static gint
apply_mask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
apply_mask_query_cancel_callback (widget, client_data);
apply_mask_query_cancel_callback (widget, data);
return TRUE;
}
@ -3367,13 +3614,13 @@ struct _ScaleLayerOptions
static void
scale_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ScaleLayerOptions *options;
GImage *gimage;
Layer *layer;
options = (ScaleLayerOptions *) client_data;
options = (ScaleLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
@ -3405,10 +3652,10 @@ scale_layer_query_ok_callback (GtkWidget *widget,
static void
scale_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ScaleLayerOptions *options;
options = (ScaleLayerOptions *) client_data;
options = (ScaleLayerOptions *) data;
resize_widget_free (options->resize);
g_free (options);
@ -3417,9 +3664,9 @@ scale_layer_query_cancel_callback (GtkWidget *widget,
static gint
scale_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
scale_layer_query_cancel_callback (widget, client_data);
scale_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3465,13 +3712,13 @@ struct _ResizeLayerOptions
static void
resize_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ResizeLayerOptions *options;
GImage *gimage;
Layer *layer;
options = (ResizeLayerOptions *) client_data;
options = (ResizeLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
@ -3505,10 +3752,10 @@ resize_layer_query_ok_callback (GtkWidget *widget,
static void
resize_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ResizeLayerOptions *options;
options = (ResizeLayerOptions *) client_data;
options = (ResizeLayerOptions *) data;
resize_widget_free (options->resize);
g_free (options);
@ -3517,9 +3764,9 @@ resize_layer_query_cancel_callback (GtkWidget *widget,
static gint
resize_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
resize_layer_query_cancel_callback (widget, client_data);
resize_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3561,18 +3808,18 @@ struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
int merge_visible;
gboolean merge_visible;
MergeType merge_type;
};
static void
layer_merge_query_ok_callback (GtkWidget *w,
gpointer client_data)
layer_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GImage *gimage;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
@ -3585,33 +3832,33 @@ layer_merge_query_ok_callback (GtkWidget *w,
}
static void
layer_merge_query_cancel_callback (GtkWidget *w,
gpointer client_data)
layer_merge_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static gint
layer_merge_query_delete_callback (GtkWidget *w,
GdkEvent *e,
gpointer client_data)
layer_merge_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
layer_merge_query_cancel_callback (w, client_data);
layer_merge_query_cancel_callback (widget, data);
return TRUE;
}
static void
layer_merge_query_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
LayerMergeOptions *options;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
options->merge_type =
(MergeType) gtk_object_get_data (GTK_OBJECT (widget), "merge_type");
@ -3619,8 +3866,8 @@ layer_merge_query_type_callback (GtkWidget *widget,
void
layers_dialog_layer_merge_query (GImage *gimage,
/* if 0, anchor active layer */
gint merge_visible)
/* if FALSE, anchor active layer */
gboolean merge_visible)
{
LayerMergeOptions *options;
GtkWidget *vbox;

View File

@ -75,7 +75,6 @@
#define INSENSITIVE 2
typedef struct _LayersDialog LayersDialog;
struct _LayersDialog
@ -105,6 +104,13 @@ struct _LayersDialog
GSList *layer_widgets;
};
typedef enum
{
LAYER_DROP_NONE,
LAYER_DROP_ABOVE,
LAYER_DROP_BELOW
} LayerDropType;
typedef struct _LayerWidget LayerWidget;
struct _LayerWidget
@ -130,6 +136,8 @@ struct _LayerWidget
gboolean edit_mask;
gboolean show_mask;
gboolean visited;
LayerDropType drop_type;
};
/* layers dialog widget routines */
@ -153,6 +161,18 @@ static void layers_dialog_map_callback (GtkWidget *, gpointer);
static void layers_dialog_unmap_callback (GtkWidget *, gpointer);
/* layer widget function prototypes */
static void layer_widget_draw_drop_indicator (LayerWidget *, LayerDropType);
static void layer_widget_drag_indicator_callback (GtkWidget *, gpointer);
static void layer_widget_drag_leave_callback (GtkWidget *,
GdkDragContext *,
guint);
static gboolean layer_widget_drag_motion_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layer_widget_drag_drop_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *layer_widget_create (GImage *, Layer *);
@ -176,7 +196,7 @@ static void layers_dialog_add_mask_query (Layer *);
static void layers_dialog_apply_mask_query (Layer *);
static void layers_dialog_scale_layer_query (GImage *, Layer *);
static void layers_dialog_resize_layer_query (GImage *, Layer *);
void layers_dialog_layer_merge_query (GImage *, int);
void layers_dialog_layer_merge_query (GImage *, gboolean);
/*
* Local data
@ -271,8 +291,9 @@ layers_dialog_create ()
GtkWidget *slider;
GtkWidget *listbox;
if (! layersD)
{
if (layersD)
return layersD->vbox;
layersD = g_new (LayersDialog, 1);
layersD->layer_preview = NULL;
layersD->gimage = NULL;
@ -311,8 +332,7 @@ layers_dialog_create ()
gtk_widget_show (label);
gtk_widget_show (layersD->mode_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (layersD->mode_option_menu),
menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (layersD->mode_option_menu), menu);
layersD->preserve_trans =
gtk_check_button_new_with_label (_("Keep Trans."));
@ -335,8 +355,7 @@ layers_dialog_create ()
layersD->opacity_data =
GTK_ADJUSTMENT (gtk_adjustment_new (100.0, 0.0, 100.0, 1.0, 1.0, 0.0));
slider = gtk_hscale_new (layersD->opacity_data);
gtk_range_set_update_policy (GTK_RANGE (slider),
GTK_UPDATE_CONTINUOUS);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_RIGHT);
gtk_box_pack_start (GTK_BOX (util_box), slider, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (layersD->opacity_data), "value_changed",
@ -382,7 +401,6 @@ layers_dialog_create ()
NULL);
gtk_widget_show (vbox);
}
return layersD->vbox;
}
@ -1177,7 +1195,7 @@ paint_mode_menu_get_position (gint mode)
static void
paint_mode_menu_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1189,7 +1207,7 @@ paint_mode_menu_callback (GtkWidget *widget,
/* If the layer has an alpha channel, set the transparency and redraw */
if (layer_has_alpha (layer))
{
mode = (long) client_data;
mode = (long) data;
if (layer->mode != mode)
{
layer->mode = mode;
@ -1308,7 +1326,7 @@ layer_list_events (GtkWidget *widget,
static void
layers_dialog_map_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
if (! layersD)
return;
@ -1319,7 +1337,7 @@ layers_dialog_map_callback (GtkWidget *widget,
static void
layers_dialog_unmap_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
if (! layersD)
return;
@ -1330,7 +1348,7 @@ layers_dialog_unmap_callback (GtkWidget *widget,
void
layers_dialog_previous_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *new_layer;
@ -1357,7 +1375,7 @@ layers_dialog_previous_layer_callback (GtkWidget *widget,
void
layers_dialog_next_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *new_layer;
@ -1384,7 +1402,7 @@ layers_dialog_next_layer_callback (GtkWidget *widget,
void
layers_dialog_raise_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1397,7 +1415,7 @@ layers_dialog_raise_layer_callback (GtkWidget *widget,
void
layers_dialog_lower_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1410,7 +1428,7 @@ layers_dialog_lower_layer_callback (GtkWidget *widget,
void
layers_dialog_raise_layer_to_top_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1427,7 +1445,7 @@ layers_dialog_raise_layer_to_top_callback (GtkWidget *widget,
void
layers_dialog_lower_layer_to_bottom_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1443,7 +1461,7 @@ layers_dialog_lower_layer_to_bottom_callback (GtkWidget *widget,
void
layers_dialog_new_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1466,7 +1484,7 @@ layers_dialog_new_layer_callback (GtkWidget *widget,
void
layers_dialog_duplicate_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *active_layer;
@ -1490,7 +1508,7 @@ layers_dialog_duplicate_layer_callback (GtkWidget *widget,
void
layers_dialog_delete_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1511,7 +1529,7 @@ layers_dialog_delete_layer_callback (GtkWidget *widget,
void
layers_dialog_scale_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1523,7 +1541,7 @@ layers_dialog_scale_layer_callback (GtkWidget *widget,
void
layers_dialog_resize_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1535,7 +1553,7 @@ layers_dialog_resize_layer_callback (GtkWidget *widget,
void
layers_dialog_add_layer_mask_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1547,7 +1565,7 @@ layers_dialog_add_layer_mask_callback (GtkWidget *widget,
void
layers_dialog_apply_layer_mask_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1565,7 +1583,7 @@ layers_dialog_apply_layer_mask_callback (GtkWidget *widget,
void
layers_dialog_anchor_layer_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1578,7 +1596,7 @@ layers_dialog_anchor_layer_callback (GtkWidget *widget,
void
layers_dialog_merge_layers_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1590,7 +1608,7 @@ layers_dialog_merge_layers_callback (GtkWidget *widget,
void
layers_dialog_merge_down_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1603,7 +1621,7 @@ layers_dialog_merge_down_callback (GtkWidget *widget,
void
layers_dialog_flatten_image_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1617,7 +1635,7 @@ layers_dialog_flatten_image_callback (GtkWidget *widget,
void
layers_dialog_alpha_select_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1631,7 +1649,7 @@ layers_dialog_alpha_select_callback (GtkWidget *widget,
void
layers_dialog_mask_select_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
@ -1645,7 +1663,7 @@ layers_dialog_mask_select_callback (GtkWidget *widget,
void
layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
GImage *gimage;
Layer *layer;
@ -1655,7 +1673,6 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
!(layer = gimage_get_active_layer (gimage)))
return;
/* Add an alpha channel */
layer_add_alpha (layer);
gdisplays_flush ();
}
@ -1665,6 +1682,206 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
/* layer widget functions */
/****************************/
enum
{
GIMP_TARGET_LAYER
};
static GtkTargetEntry layer_target_table[] =
{
{ "GIMP_LAYER", 0, GIMP_TARGET_LAYER }
};
static guint n_targets = (sizeof (layer_target_table) /
sizeof (layer_target_table[0]));
static void
layer_widget_draw_drop_indicator (LayerWidget *lw,
LayerDropType drop_type)
{
static GdkGC *gc = NULL;
gint y = 0;
if (!gc)
{
GdkColor fg, bg;
gc = gdk_gc_new (lw->list_item->window);
fg.pixel = 0xFFFFFFFF;
bg.pixel = 0x00000000;
gdk_gc_set_function (gc, GDK_INVERT);
gdk_gc_set_foreground (gc, &fg);
gdk_gc_set_background (gc, &bg);
gdk_gc_set_line_attributes (gc, 5, GDK_LINE_SOLID,
GDK_CAP_BUTT, GDK_JOIN_MITER);
}
if (drop_type != LAYER_DROP_NONE)
{
y = ((drop_type == LAYER_DROP_ABOVE) ?
3 : lw->list_item->allocation.height - 4);
gdk_draw_line (lw->list_item->window, gc,
2, y, lw->list_item->allocation.width - 3, y);
}
}
static void
layer_widget_drag_indicator_callback (GtkWidget *widget,
gpointer data)
{
LayerWidget *lw;
lw = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
layer_widget_draw_drop_indicator (lw, lw->drop_type);
}
static void
layer_widget_drag_leave_callback (GtkWidget *widget,
GdkDragContext *context,
guint time)
{
LayerWidget *lw;
lw = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
lw->drop_type = LAYER_DROP_NONE;
}
static gboolean
layer_widget_drag_motion_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
LayerWidget *dest;
gint dest_index;
GtkWidget *src_widget;
LayerWidget *src;
gint src_index;
gint difference;
LayerDropType drop_type = LAYER_DROP_NONE;
GdkDragAction drag_action = GDK_ACTION_DEFAULT;
gboolean return_val = FALSE;
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
if (layer_has_alpha (dest->layer) &&
(src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (layer_has_alpha (src->layer))
{
src_index = gimage_get_layer_index (layersD->gimage, src->layer);
dest_index = gimage_get_layer_index (layersD->gimage, dest->layer);
difference = dest_index - src_index;
drop_type = ((y < widget->allocation.height / 2) ?
LAYER_DROP_ABOVE : LAYER_DROP_BELOW);
if (difference < 0 &&
drop_type == LAYER_DROP_BELOW)
{
dest_index++;
}
else if (difference > 0 &&
drop_type == LAYER_DROP_ABOVE)
{
dest_index--;
}
if (src_index != dest_index)
{
drag_action = context->suggested_action;
return_val = TRUE;
}
else
{
drop_type = LAYER_DROP_NONE;
}
}
}
gdk_drag_status (context, drag_action, time);
if (drop_type != dest->drop_type)
{
layer_widget_draw_drop_indicator (dest, dest->drop_type);
layer_widget_draw_drop_indicator (dest, drop_type);
dest->drop_type = drop_type;
}
return return_val;
}
static gboolean
layer_widget_drag_drop_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
LayerWidget *dest;
gint dest_index;
GtkWidget *src_widget;
LayerWidget *src;
gint src_index;
gint difference;
LayerDropType drop_type = LAYER_DROP_NONE;
gboolean return_val = FALSE;
dest = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
src_index = gimage_get_layer_index (layersD->gimage, src->layer);
dest_index = gimage_get_layer_index (layersD->gimage, dest->layer);
difference = dest_index - src_index;
drop_type = ((y < widget->allocation.height / 2) ?
LAYER_DROP_ABOVE : LAYER_DROP_BELOW);
if (difference < 0 &&
drop_type == LAYER_DROP_BELOW)
{
dest_index++;
}
else if (difference > 0 &&
drop_type == LAYER_DROP_ABOVE)
{
dest_index--;
}
if (src_index != dest_index)
{
gimage_position_layer (layersD->gimage, src->layer, dest_index);
gdisplays_flush ();
return_val = TRUE;
}
}
layer_widget_draw_drop_indicator (dest, dest->drop_type);
dest->drop_type = LAYER_DROP_NONE;
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static LayerWidget *
layer_widget_get_ID (Layer *ID)
{
@ -1716,6 +1933,7 @@ layer_widget_create (GImage *gimage,
layer_widget->edit_mask = layer->edit_mask;
layer_widget->show_mask = layer->show_mask;
layer_widget->visited = TRUE;
layer_widget->drop_type = LAYER_DROP_NONE;
if (layer->mask)
layer_widget->active_preview = (layer->edit_mask) ? MASK_PREVIEW : LAYER_PREVIEW;
@ -1819,6 +2037,33 @@ layer_widget_create (GImage *gimage,
FALSE, FALSE, 0);
/* gtk_widget_show (layer_widget->clip_widget); */
/* dnd destination */
gtk_drag_dest_set (list_item,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_leave",
GTK_SIGNAL_FUNC (layer_widget_drag_leave_callback),
NULL);
gtk_signal_connect_after (GTK_OBJECT (list_item), "drag_motion",
GTK_SIGNAL_FUNC (layer_widget_drag_motion_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_drop",
GTK_SIGNAL_FUNC (layer_widget_drag_drop_callback),
NULL);
/* re-paint the drop indicator after drawing the widget */
gtk_signal_connect_after (GTK_OBJECT (list_item), "draw",
(GtkSignalFunc) layer_widget_drag_indicator_callback,
layer_widget);
/* dnd source */
gtk_drag_source_set (list_item,
GDK_BUTTON1_MASK,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
gtk_widget_show (list_item);
@ -1912,7 +2157,7 @@ layer_widget_button_events (GtkWidget *widget,
if (widget == layer_widget->eye_widget)
{
old_state = GIMP_DRAWABLE(layer_widget->layer)->visible;
old_state = GIMP_DRAWABLE (layer_widget->layer)->visible;
/* If this was a shift-click, make all/none visible */
if (event->button.state & GDK_SHIFT_MASK)
@ -1923,7 +2168,8 @@ layer_widget_button_events (GtkWidget *widget,
else
{
exclusive = FALSE;
GIMP_DRAWABLE(layer_widget->layer)->visible = !GIMP_DRAWABLE(layer_widget->layer)->visible;
GIMP_DRAWABLE (layer_widget->layer)->visible =
!GIMP_DRAWABLE (layer_widget->layer)->visible;
layer_widget_eye_redraw (layer_widget);
}
}
@ -1951,13 +2197,13 @@ layer_widget_button_events (GtkWidget *widget,
layer_widget->gimage->height);
gdisplays_flush ();
}
else if (old_state != GIMP_DRAWABLE(layer_widget->layer)->visible)
else if (old_state != GIMP_DRAWABLE (layer_widget->layer)->visible)
{
/* Invalidate the gimage preview */
gimage_invalidate_preview (layer_widget->gimage);
drawable_update (GIMP_DRAWABLE(layer_widget->layer), 0, 0,
GIMP_DRAWABLE(layer_widget->layer)->width,
GIMP_DRAWABLE(layer_widget->layer)->height);
drawable_update (GIMP_DRAWABLE (layer_widget->layer), 0, 0,
GIMP_DRAWABLE (layer_widget->layer)->width,
GIMP_DRAWABLE (layer_widget->layer)->height);
gdisplays_flush ();
}
}
@ -1981,7 +2227,8 @@ layer_widget_button_events (GtkWidget *widget,
}
else
{
GIMP_DRAWABLE(layer_widget->layer)->visible = !GIMP_DRAWABLE(layer_widget->layer)->visible;
GIMP_DRAWABLE (layer_widget->layer)->visible =
!GIMP_DRAWABLE (layer_widget->layer)->visible;
layer_widget_eye_redraw (layer_widget);
}
}
@ -2546,7 +2793,7 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
{
lw = (LayerWidget *) list->data;
if (lw != layer_widget)
visible |= GIMP_DRAWABLE(lw->layer)->visible;
visible |= GIMP_DRAWABLE (lw->layer)->visible;
list = g_slist_next (list);
}
@ -2557,9 +2804,9 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
{
lw = (LayerWidget *) list->data;
if (lw != layer_widget)
GIMP_DRAWABLE(lw->layer)->visible = !visible;
GIMP_DRAWABLE (lw->layer)->visible = !visible;
else
GIMP_DRAWABLE(lw->layer)->visible = TRUE;
GIMP_DRAWABLE (lw->layer)->visible = TRUE;
layer_widget_eye_redraw (lw);
@ -2569,7 +2816,7 @@ layer_widget_exclusive_visible (LayerWidget *layer_widget)
static void
layer_widget_layer_flush (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
LayerWidget *layer_widget;
Layer *layer;
@ -2709,13 +2956,13 @@ static gchar *layer_name = NULL;
static void
new_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
Layer *layer;
GImage *gimage;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
if (layer_name)
g_free (layer_name);
@ -2759,11 +3006,11 @@ new_layer_query_ok_callback (GtkWidget *widget,
static void
new_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
@ -2772,9 +3019,9 @@ new_layer_query_cancel_callback (GtkWidget *widget,
static gint
new_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
new_layer_query_cancel_callback (widget, client_data);
new_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -2782,11 +3029,11 @@ new_layer_query_delete_callback (GtkWidget *widget,
static void
new_layer_query_fill_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
NewLayerOptions *options;
options = (NewLayerOptions *) client_data;
options = (NewLayerOptions *) data;
options->fill_type =
(GimpFillType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type");
@ -2978,12 +3225,12 @@ struct _EditLayerOptions
static void
edit_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
EditLayerOptions *options;
Layer *layer;
options = (EditLayerOptions *) client_data;
options = (EditLayerOptions *) data;
if ((layer = options->layer))
{
@ -3010,11 +3257,11 @@ edit_layer_query_ok_callback (GtkWidget *widget,
static void
edit_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
EditLayerOptions *options;
options = (EditLayerOptions *) client_data;
options = (EditLayerOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3022,9 +3269,9 @@ edit_layer_query_cancel_callback (GtkWidget *widget,
static gint
edit_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
edit_layer_query_cancel_callback (widget, client_data);
edit_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3109,14 +3356,14 @@ struct _AddMaskOptions
static void
add_mask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
GImage *gimage;
LayerMask *mask;
Layer *layer;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
if ((layer = (options->layer)) &&
(gimage = GIMP_DRAWABLE (layer)->gimage))
{
@ -3131,11 +3378,11 @@ add_mask_query_ok_callback (GtkWidget *widget,
static void
add_mask_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3143,20 +3390,20 @@ add_mask_query_cancel_callback (GtkWidget *widget,
static gint
add_mask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
add_mask_query_cancel_callback (widget, client_data);
add_mask_query_cancel_callback (widget, data);
return TRUE;
}
static void
add_mask_query_fill_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
AddMaskOptions *options;
options = (AddMaskOptions *) client_data;
options = (AddMaskOptions *) data;
options->add_mask_type =
(AddMaskType) gtk_object_get_data (GTK_OBJECT (widget), "add_mask_type");
@ -3256,11 +3503,11 @@ struct _ApplyMaskOptions
static void
apply_mask_query_apply_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gimage_remove_layer_mask (drawable_gimage (GIMP_DRAWABLE (options->layer)),
options->layer, APPLY);
@ -3270,11 +3517,11 @@ apply_mask_query_apply_callback (GtkWidget *widget,
static void
apply_mask_query_discard_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gimage_remove_layer_mask (drawable_gimage (GIMP_DRAWABLE (options->layer)),
options->layer, DISCARD);
@ -3284,11 +3531,11 @@ apply_mask_query_discard_callback (GtkWidget *widget,
static void
apply_mask_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ApplyMaskOptions *options;
options = (ApplyMaskOptions *) client_data;
options = (ApplyMaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
@ -3296,9 +3543,9 @@ apply_mask_query_cancel_callback (GtkWidget *widget,
static gint
apply_mask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
apply_mask_query_cancel_callback (widget, client_data);
apply_mask_query_cancel_callback (widget, data);
return TRUE;
}
@ -3367,13 +3614,13 @@ struct _ScaleLayerOptions
static void
scale_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ScaleLayerOptions *options;
GImage *gimage;
Layer *layer;
options = (ScaleLayerOptions *) client_data;
options = (ScaleLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
@ -3405,10 +3652,10 @@ scale_layer_query_ok_callback (GtkWidget *widget,
static void
scale_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ScaleLayerOptions *options;
options = (ScaleLayerOptions *) client_data;
options = (ScaleLayerOptions *) data;
resize_widget_free (options->resize);
g_free (options);
@ -3417,9 +3664,9 @@ scale_layer_query_cancel_callback (GtkWidget *widget,
static gint
scale_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
scale_layer_query_cancel_callback (widget, client_data);
scale_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3465,13 +3712,13 @@ struct _ResizeLayerOptions
static void
resize_layer_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ResizeLayerOptions *options;
GImage *gimage;
Layer *layer;
options = (ResizeLayerOptions *) client_data;
options = (ResizeLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
@ -3505,10 +3752,10 @@ resize_layer_query_ok_callback (GtkWidget *widget,
static void
resize_layer_query_cancel_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
ResizeLayerOptions *options;
options = (ResizeLayerOptions *) client_data;
options = (ResizeLayerOptions *) data;
resize_widget_free (options->resize);
g_free (options);
@ -3517,9 +3764,9 @@ resize_layer_query_cancel_callback (GtkWidget *widget,
static gint
resize_layer_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
gpointer data)
{
resize_layer_query_cancel_callback (widget, client_data);
resize_layer_query_cancel_callback (widget, data);
return TRUE;
}
@ -3561,18 +3808,18 @@ struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
int merge_visible;
gboolean merge_visible;
MergeType merge_type;
};
static void
layer_merge_query_ok_callback (GtkWidget *w,
gpointer client_data)
layer_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GImage *gimage;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
@ -3585,33 +3832,33 @@ layer_merge_query_ok_callback (GtkWidget *w,
}
static void
layer_merge_query_cancel_callback (GtkWidget *w,
gpointer client_data)
layer_merge_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static gint
layer_merge_query_delete_callback (GtkWidget *w,
GdkEvent *e,
gpointer client_data)
layer_merge_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
layer_merge_query_cancel_callback (w, client_data);
layer_merge_query_cancel_callback (widget, data);
return TRUE;
}
static void
layer_merge_query_type_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
LayerMergeOptions *options;
options = (LayerMergeOptions *) client_data;
options = (LayerMergeOptions *) data;
options->merge_type =
(MergeType) gtk_object_get_data (GTK_OBJECT (widget), "merge_type");
@ -3619,8 +3866,8 @@ layer_merge_query_type_callback (GtkWidget *widget,
void
layers_dialog_layer_merge_query (GImage *gimage,
/* if 0, anchor active layer */
gint merge_visible)
/* if FALSE, anchor active layer */
gboolean merge_visible)
{
LayerMergeOptions *options;
GtkWidget *vbox;