app/Makefile.am new file containing the dnd data definitions.

1999-08-19  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/Makefile.am
	* app/gimpdnd.h: new file containing the dnd data definitions.

	* app/disp_callbacks.[ch]
	* app/interface.c: drop layers on the toolbox to create a new
	image and on the display to copy it to the image's layer stack.

	* app/layers_dialog.c: drop layer on the "New" button to create an
	empty layer with the dropped layer's properties, to "Duplicate" to
	duplicate it and on the trashcan to delete it.
	Thanks to Andy for the ultra-cool dnd preview pixmap patch.

	* app/layer.[ch]
	* app/undo.c: renamed layer_mask() to layer_get_mask(). Prototyped
	some function headers.

	* app/disp_callbacks.c: Wheelmouse stuff: Shift+wheel scales the
	display.

	* app/airbrush.c
	* app/eraser.c
	* app/paint_options.h
	* app/paintbrush.c
	* app/pencil.c
	* app/tool_options.c: moved the "Incremental" toggle to the
	PaintOptions structure because it is used more often now.
This commit is contained in:
Michael Natterer 1999-08-19 19:53:30 +00:00 committed by Michael Natterer
parent e7c1e75606
commit 311c83b0a4
43 changed files with 2636 additions and 1006 deletions

View File

@ -1,3 +1,32 @@
1999-08-19 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/Makefile.am
* app/gimpdnd.h: new file containing the dnd data definitions.
* app/disp_callbacks.[ch]
* app/interface.c: drop layers on the toolbox to create a new
image and on the display to copy it to the image's layer stack.
* app/layers_dialog.c: drop layer on the "New" button to create an
empty layer with the dropped layer's properties, to "Duplicate" to
duplicate it and on the trashcan to delete it.
Thanks to Andy for the ultra-cool dnd preview pixmap patch.
* app/layer.[ch]
* app/undo.c: renamed layer_mask() to layer_get_mask(). Prototyped
some function headers.
* app/disp_callbacks.c: Wheelmouse stuff: Shift+wheel scales the
display.
* app/airbrush.c
* app/eraser.c
* app/paint_options.h
* app/paintbrush.c
* app/pencil.c
* app/tool_options.c: moved the "Incremental" toggle to the
PaintOptions structure because it is used more often now.
Thu Aug 19 18:27:42 MEST 1999 Sven Neumann <sven@gimp.org>
* app/measure.c: use <Ctrl> and/or <Alt> to add horizontal

View File

@ -197,6 +197,7 @@ gimp_SOURCES = \
gimpbrushlistP.h \
gimpcontext.c \
gimpcontext.h \
gimpdnd.h \
gimphistogram.c \
gimphistogram.h \
gimphistogramP.h \

View File

@ -40,7 +40,7 @@
#define MAX_PRESSURE 0.075
/* Default pressure setting */
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_INCREMENTAL_DEFAULT FALSE
#define OFF 0
@ -51,7 +51,7 @@
typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
PaintCore *paint_core;
PaintCore *paint_core;
GimpDrawable *drawable;
};
@ -67,10 +67,6 @@ struct _AirbrushOptions
double pressure;
double pressure_d;
GtkObject *pressure_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
@ -103,9 +99,6 @@ airbrush_options_reset (void)
options->rate_d);
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->pressure_w),
options->pressure_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static AirbrushOptions *
@ -125,8 +118,6 @@ airbrush_options_new (void)
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
options->incremental =
options->incremental_d = AIRBRUSH_INCREMENTAL_DEFAULT;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
@ -172,14 +163,6 @@ airbrush_options_new (void)
&options->pressure);
gtk_widget_show (scale);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
gtk_widget_show (table);
return options;
@ -208,9 +191,9 @@ tools_new_airbrush ()
}
void *
airbrush_paint_func (PaintCore *paint_core,
airbrush_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
int state)
{
GimpBrushP brush;
@ -236,16 +219,17 @@ airbrush_paint_func (PaintCore *paint_core,
timer_state = OFF;
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
if (airbrush_options->rate != 0.0)
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
break;
case FINISH_PAINT :
@ -280,7 +264,8 @@ airbrush_time_out (gpointer client_data)
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable,
airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
gdisplays_flush ();
/* restart the timer */

View File

@ -121,8 +121,8 @@ layer_size (Layer *layer)
GIMP_DRAWABLE(layer)->width * GIMP_DRAWABLE(layer)->height * GIMP_DRAWABLE(layer)->bytes +
strlen (GIMP_DRAWABLE(layer)->name);
if (layer_mask (layer))
size += channel_size (GIMP_CHANNEL (layer_mask (layer)));
if (layer_get_mask (layer))
size += channel_size (GIMP_CHANNEL (layer_get_mask (layer)));
return size;
}

View File

@ -196,11 +196,11 @@ layer_invalidate_preview (GtkObject *object)
}
static void
transform_color (GImage * gimage,
PixelRegion * layerPR,
PixelRegion * bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
transform_color (GImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
{
int i, h;
unsigned char * s, * d;
@ -234,13 +234,13 @@ transform_color (GImage * gimage,
Layer *
layer_new (GimpImage* gimage,
int width,
int height,
GimpImageType type,
char * name,
int opacity,
LayerModeEffects mode)
layer_new (GimpImage *gimage,
gint width,
gint height,
GimpImageType type,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * layer;
@ -297,9 +297,8 @@ layer_unref (Layer *layer)
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
int add_alpha;
layer_copy (Layer *layer,
gint add_alpha)
{
char * layer_name;
Layer * new_layer;
@ -397,12 +396,12 @@ layer_copy (layer, add_alpha)
Layer *
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
char *name,
int opacity,
LayerModeEffects mode)
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
GImage * gimage;
Layer * new_layer;
@ -449,9 +448,8 @@ layer_from_tiles (void *gimage_ptr,
LayerMask *
layer_add_mask (layer, mask)
Layer * layer;
LayerMask * mask;
layer_add_mask (Layer *layer,
LayerMask *mask)
{
if (layer->mask)
return NULL;
@ -471,9 +469,8 @@ layer_add_mask (layer, mask)
LayerMask *
layer_create_mask (layer, add_mask_type)
Layer * layer;
AddMaskType add_mask_type;
layer_create_mask (Layer *layer,
AddMaskType add_mask_type)
{
PixelRegion maskPR, layerPR;
LayerMask *mask;
@ -516,8 +513,7 @@ layer_create_mask (layer, add_mask_type)
Layer *
layer_get_ID (ID)
int ID;
layer_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -529,7 +525,7 @@ layer_get_ID (ID)
void
layer_delete (Layer * layer)
layer_delete (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
@ -569,7 +565,8 @@ gimp_layer_destroy (GtkObject *object)
* to the removed signal to update bits of UI that are tied to a
* particular layer. */
void
layer_removed (Layer *layer, gpointer image)
layer_removed (Layer *layer,
gpointer image)
{
g_return_if_fail (layer != NULL);
g_return_if_fail (GIMP_IS_LAYER (layer));
@ -578,9 +575,8 @@ layer_removed (Layer *layer, gpointer image)
}
void
layer_apply_mask (layer, mode)
Layer * layer;
int mode;
layer_apply_mask (Layer *layer,
gint mode)
{
PixelRegion srcPR, maskPR;
@ -620,13 +616,11 @@ layer_apply_mask (layer, mode)
}
}
static void
layer_translate_lowlevel (layer, off_x, off_y, temporary)
Layer * layer;
int off_x, off_y;
gboolean temporary;
layer_translate_lowlevel (Layer *layer,
gint off_x,
gint off_y,
gboolean temporary)
{
if (!temporary)
{
@ -666,28 +660,23 @@ layer_translate_lowlevel (layer, off_x, off_y, temporary)
void
layer_temporarily_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_temporarily_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, TRUE);
}
void
layer_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, FALSE);
}
void
layer_add_alpha (layer)
Layer *layer;
layer_add_alpha (Layer *layer)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -739,10 +728,10 @@ layer_add_alpha (layer)
void
layer_scale (layer, new_width, new_height, local_origin)
Layer *layer;
int new_width, new_height;
int local_origin;
layer_scale (Layer *layer,
gint new_width,
gint new_height,
gint local_origin)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -813,10 +802,11 @@ layer_scale (layer, new_width, new_height, local_origin)
void
layer_resize (layer, new_width, new_height, offx, offy)
Layer *layer;
int new_width, new_height;
int offx, offy;
layer_resize (Layer *layer,
gint new_width,
gint new_height,
gint offx,
gint offy)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -907,9 +897,8 @@ layer_resize (layer, new_width, new_height, offx, offy)
BoundSeg *
layer_boundary (layer, num_segs)
Layer *layer;
int *num_segs;
layer_boundary (Layer *layer,
gint *num_segs)
{
BoundSeg *new_segs;
@ -962,8 +951,7 @@ layer_boundary (layer, num_segs)
void
layer_invalidate_boundary (layer)
Layer *layer;
layer_invalidate_boundary (Layer *layer)
{
GImage *gimage;
Channel *mask;
@ -993,9 +981,9 @@ layer_invalidate_boundary (layer)
int
layer_pick_correlate (layer, x, y)
Layer *layer;
int x, y;
layer_pick_correlate (Layer *layer,
gint x,
gint y)
{
Tile *tile;
Tile *mask_tile;
@ -1048,34 +1036,33 @@ layer_pick_correlate (layer, x, y)
/* access functions */
void
layer_set_name (Layer *layer, char *name)
layer_set_name (Layer *layer,
gchar *name)
{
gimp_drawable_set_name(GIMP_DRAWABLE(layer), name);
gimp_drawable_set_name (GIMP_DRAWABLE (layer), name);
}
char *
gchar *
layer_get_name (Layer *layer)
{
return gimp_drawable_get_name(GIMP_DRAWABLE(layer));
return gimp_drawable_get_name (GIMP_DRAWABLE (layer));
}
unsigned char *
layer_data (Layer * layer)
guchar *
layer_data (Layer *layer)
{
return NULL;
}
LayerMask *
layer_mask (Layer * layer)
layer_get_mask (Layer *layer)
{
return layer->mask;
}
int
layer_has_alpha (Layer * layer)
layer_has_alpha (Layer *layer)
{
if (GIMP_DRAWABLE(layer)->type == RGBA_GIMAGE ||
GIMP_DRAWABLE(layer)->type == GRAYA_GIMAGE ||
@ -1085,7 +1072,6 @@ layer_has_alpha (Layer * layer)
return 0;
}
int
layer_is_floating_sel (Layer *layer)
{
@ -1103,8 +1089,8 @@ layer_linked (Layer *layer)
TempBuf *
layer_preview (Layer *layer,
int w,
int h)
gint w,
gint h)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1174,9 +1160,9 @@ layer_preview (Layer *layer,
TempBuf *
layer_mask_preview (layer, w, h)
Layer *layer;
int w, h;
layer_mask_preview (Layer *layer,
gint w,
gint h)
{
TempBuf *preview_buf;
LayerMask *mask;
@ -1226,9 +1212,9 @@ layer_mask_preview (layer, w, h)
}
Tattoo
layer_get_tattoo(const Layer *layer)
layer_get_tattoo (const Layer *layer)
{
return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer)));
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
}
void
@ -1251,12 +1237,11 @@ layer_invalidate_previews (GimpImage* gimage)
static void
layer_preview_scale (type, cmap, srcPR, destPR, subsample)
int type;
unsigned char *cmap;
PixelRegion *srcPR;
PixelRegion *destPR;
int subsample;
layer_preview_scale (gint type,
guchar *cmap,
PixelRegion *srcPR,
PixelRegion *destPR,
gint subsample)
{
#define EPSILON 0.000001
unsigned char * src, * s;
@ -1438,8 +1423,12 @@ gimp_layer_mask_destroy (GtkObject *object)
}
LayerMask *
layer_mask_new (GimpImage* gimage, int width, int height, char *name, int opacity,
unsigned char *col)
layer_mask_new (GimpImage *gimage,
gint width,
gint height,
gchar *name,
gint opacity,
guchar *col)
{
LayerMask * layer_mask;
int i;
@ -1507,7 +1496,7 @@ layer_mask_copy (LayerMask *layer_mask)
LayerMask *
layer_mask_get_ID (int ID)
layer_mask_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -1518,7 +1507,7 @@ layer_mask_get_ID (int ID)
}
void
layer_mask_delete (LayerMask * layermask)
layer_mask_delete (LayerMask *layermask)
{
gtk_object_unref (GTK_OBJECT (layermask));
}
@ -1539,7 +1528,8 @@ layer_mask_unref (LayerMask *mask)
}
void
channel_layer_mask (Channel *mask, Layer * layer)
channel_layer_mask (Channel *mask,
Layer *layer)
{
PixelRegion srcPR, destPR;
unsigned char empty = 0;

View File

@ -115,7 +115,7 @@ void layer_mask_unref (LayerMask *);
void layer_set_name (Layer *, char *);
char * layer_get_name (Layer *);
unsigned char * layer_data (Layer *);
LayerMask * layer_mask (Layer *);
LayerMask * layer_get_mask (Layer *);
int layer_has_alpha (Layer *);
int layer_is_floating_sel (Layer *);
int layer_linked (Layer *);

View File

@ -38,9 +38,9 @@ tool_options_toggle_update (GtkWidget *widget,
gpointer data)
{
GtkWidget *set_sensitive;
int *toggle_val;
gboolean *toggle_val;
toggle_val = (int *) data;
toggle_val = (gboolean *) data;
*toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE;
/* a tool options toggle button can set the sensitive state of
@ -70,9 +70,9 @@ void
tool_options_int_adjustment_update (GtkWidget *widget,
gpointer data)
{
int *val;
gint *val;
val = (int *) data;
val = (gint *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -80,9 +80,9 @@ void
tool_options_double_adjustment_update (GtkWidget *widget,
gpointer data)
{
double *val;
gdouble *val;
val = (double *) data;
val = (gdouble *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -112,7 +112,7 @@ tool_options_unitmenu_update (GtkWidget *widget,
{
GUnit *val;
GtkWidget *spinbutton;
int digits;
gint digits;
val = (GUnit *) data;
*val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
@ -134,14 +134,15 @@ static void
tool_options_radio_buttons_update (GtkWidget *widget,
gpointer data)
{
int *toggle_val;
gint *toggle_val;
toggle_val = (int *) data;
toggle_val = (gint *) data;
if (GTK_TOGGLE_BUTTON (widget)->active)
*toggle_val = (int) gtk_object_get_data (GTK_OBJECT (widget), "toggle_value");
*toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget),
"toggle_value");
}
GtkWidget*
GtkWidget *
tool_options_radio_buttons_new (gchar* label,
gpointer toggle_val,
GtkWidget* button_widget[],
@ -154,7 +155,7 @@ tool_options_radio_buttons_new (gchar* label,
GSList *group = NULL;
gint i;
frame = gtk_frame_new (_(label));
frame = gtk_frame_new (label);
g_return_val_if_fail (toggle_val != NULL, frame);
@ -164,8 +165,8 @@ tool_options_radio_buttons_new (gchar* label,
for (i=0; i<num; i++)
{
button_widget[i] = gtk_radio_button_new_with_label (group,
gettext (button_label[i]));
button_widget[i] =
gtk_radio_button_new_with_label (group, gettext (button_label[i]));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button_widget[i]));
gtk_box_pack_start (GTK_BOX (vbox), button_widget[i], FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button_widget[i]), "toggled",
@ -189,7 +190,7 @@ tool_options_init (ToolOptions *options,
ToolOptionsResetFunc reset_func)
{
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->title = _(title);
options->title = title;
options->reset_func = reset_func;
}
@ -576,9 +577,12 @@ paint_options_init (PaintOptions *options,
reset_func);
/* initialize the paint options structure */
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental = options->incremental_d = FALSE;
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental_w = NULL;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 2);
@ -659,17 +663,72 @@ paint_options_init (PaintOptions *options,
/* show the main table */
gtk_widget_show (table);
/* a separator after the common paint options */
if (tool_type != PENCIL)
/* a separator after the common paint options which can be global */
switch (tool_type)
{
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
break;
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
break;
default:
break;
}
if (! global_paint_options)
gtk_widget_show (vbox);
/* the "incremental" toggle */
switch (tool_type)
{
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
options->incremental_w =
gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* a separator after the common paint options which can't be global */
if (tool_type != PENCIL)
{
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
}
break;
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;
}
/* register this Paintoptions structure */
paint_options_list = g_slist_prepend (paint_options_list, options);
}
@ -679,19 +738,10 @@ paint_options_new (ToolType tool_type,
ToolOptionsResetFunc reset_func)
{
PaintOptions *options;
GtkWidget *label;
options = g_new (PaintOptions, 1);
paint_options_init (options, tool_type, reset_func);
options->global = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->global, FALSE, FALSE, 0);
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options->global), label, FALSE, FALSE, 6);
gtk_widget_show (label);
if (global_paint_options && options->global)
gtk_widget_show (options->global);
@ -721,6 +771,11 @@ paint_options_reset (PaintOptions *options)
gtk_option_menu_set_history (GTK_OPTION_MENU (options->paint_mode_w),
gimp_context_get_paint_mode (default_context));
}
if (options->incremental_w)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(options->incremental_w),
options->incremental_d);
}
}

View File

@ -33,9 +33,12 @@
#include "scale.h"
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "gimage.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
/* Function declarations */
static void gdisplay_check_device_cursor (GDisplay *gdisp);
@ -104,7 +107,7 @@ key_to_state (int key)
}
gint
gdisplay_shell_events (GtkWidget *w,
gdisplay_shell_events (GtkWidget *widget,
GdkEvent *event,
GDisplay *gdisp)
{
@ -289,27 +292,37 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* wheelmouse support */
case 4:
state |= GDK_BUTTON4_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMIN);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
case 5:
state |= GDK_BUTTON5_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMOUT);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
@ -588,3 +601,144 @@ gdisplay_origin_button_press (GtkWidget *widget,
return FALSE;
}
gboolean
gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
{
GDisplay *gdisp;
GtkWidget *src_widget;
gboolean return_val = FALSE;
gdisp = (GDisplay *) data;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
/* FIXME: implement special treatment of channel etc.
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
{
case RGB_GIMAGE: case RGBA_GIMAGE:
bytes = 4; type = RGB;
break;
case GRAY_GIMAGE: case GRAYA_GIMAGE:
bytes = 2; type = GRAY;
break;
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
bytes = 4; type = INDEXED;
break;
default:
bytes = 3; type = RGB;
break;
}
gimage_get_background (gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
extract_from_region (&srcPR, &destPR, NULL,
drawable_cmap (drawable), bg, type,
drawable_has_alpha (drawable), FALSE);
else if (bytes > srcPR.bytes)
/* If the layer doesn't have an alpha channel, add one */
add_alpha_region (&srcPR, &destPR);
else
/* Otherwise, do a straight copy */
copy_region (&srcPR, &destPR);
dest_gimage = gdisp->gimage;
dest_width = dest_gimage->width;
dest_height = dest_gimage->height;
new_layer =
layer_from_tiles (dest_gimage,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)),
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
if (new_layer)
{
undo_push_group_start (dest_gimage, EDIT_PASTE_UNDO);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
layer_translate (new_layer, off_x, off_y);
gimage_add_layer (dest_gimage, new_layer, -1);
gdisplays_flush ();
return_val = TRUE;
undo_push_group_end (dest_gimage);
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
if (return_val)
gimp_context_set_display (gimp_context_get_user (), gdisp);
return return_val;
}

View File

@ -25,10 +25,18 @@
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | \
GDK_PROXIMITY_OUT_MASK
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_canvas_events (GtkWidget *, GdkEvent *);
gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
#endif /* __DISP_CALLBACKS_H__ */
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -33,9 +33,12 @@
#include "scale.h"
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "gimage.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
/* Function declarations */
static void gdisplay_check_device_cursor (GDisplay *gdisp);
@ -104,7 +107,7 @@ key_to_state (int key)
}
gint
gdisplay_shell_events (GtkWidget *w,
gdisplay_shell_events (GtkWidget *widget,
GdkEvent *event,
GDisplay *gdisp)
{
@ -289,27 +292,37 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* wheelmouse support */
case 4:
state |= GDK_BUTTON4_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMIN);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
case 5:
state |= GDK_BUTTON5_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMOUT);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
@ -588,3 +601,144 @@ gdisplay_origin_button_press (GtkWidget *widget,
return FALSE;
}
gboolean
gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
{
GDisplay *gdisp;
GtkWidget *src_widget;
gboolean return_val = FALSE;
gdisp = (GDisplay *) data;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
/* FIXME: implement special treatment of channel etc.
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
{
case RGB_GIMAGE: case RGBA_GIMAGE:
bytes = 4; type = RGB;
break;
case GRAY_GIMAGE: case GRAYA_GIMAGE:
bytes = 2; type = GRAY;
break;
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
bytes = 4; type = INDEXED;
break;
default:
bytes = 3; type = RGB;
break;
}
gimage_get_background (gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
extract_from_region (&srcPR, &destPR, NULL,
drawable_cmap (drawable), bg, type,
drawable_has_alpha (drawable), FALSE);
else if (bytes > srcPR.bytes)
/* If the layer doesn't have an alpha channel, add one */
add_alpha_region (&srcPR, &destPR);
else
/* Otherwise, do a straight copy */
copy_region (&srcPR, &destPR);
dest_gimage = gdisp->gimage;
dest_width = dest_gimage->width;
dest_height = dest_gimage->height;
new_layer =
layer_from_tiles (dest_gimage,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)),
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
if (new_layer)
{
undo_push_group_start (dest_gimage, EDIT_PASTE_UNDO);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
layer_translate (new_layer, off_x, off_y);
gimage_add_layer (dest_gimage, new_layer, -1);
gdisplays_flush ();
return_val = TRUE;
undo_push_group_end (dest_gimage);
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
if (return_val)
gimp_context_set_display (gimp_context_get_user (), gdisp);
return return_val;
}

View File

@ -25,10 +25,18 @@
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | \
GDK_PROXIMITY_OUT_MASK
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_canvas_events (GtkWidget *, GdkEvent *);
gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
#endif /* __DISP_CALLBACKS_H__ */
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -33,9 +33,12 @@
#include "scale.h"
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "gimage.h"
#include "dialog_handler.h"
#include "libgimp/gimpintl.h"
/* Function declarations */
static void gdisplay_check_device_cursor (GDisplay *gdisp);
@ -104,7 +107,7 @@ key_to_state (int key)
}
gint
gdisplay_shell_events (GtkWidget *w,
gdisplay_shell_events (GtkWidget *widget,
GdkEvent *event,
GDisplay *gdisp)
{
@ -289,27 +292,37 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* wheelmouse support */
case 4:
state |= GDK_BUTTON4_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMIN);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
case 5:
state |= GDK_BUTTON5_MASK;
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
if (state & GDK_SHIFT_MASK)
{
change_scale (gdisp, ZOOMOUT);
}
else
{
GtkAdjustment *adj =
(state & GDK_CONTROL_MASK) ? gdisp->hsbdata : gdisp->vsbdata;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value,
adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return_val = TRUE;
break;
@ -588,3 +601,144 @@ gdisplay_origin_button_press (GtkWidget *widget,
return FALSE;
}
gboolean
gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
{
GDisplay *gdisp;
GtkWidget *src_widget;
gboolean return_val = FALSE;
gdisp = (GDisplay *) data;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
/* FIXME: implement special treatment of channel etc.
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
{
case RGB_GIMAGE: case RGBA_GIMAGE:
bytes = 4; type = RGB;
break;
case GRAY_GIMAGE: case GRAYA_GIMAGE:
bytes = 2; type = GRAY;
break;
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
bytes = 4; type = INDEXED;
break;
default:
bytes = 3; type = RGB;
break;
}
gimage_get_background (gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
extract_from_region (&srcPR, &destPR, NULL,
drawable_cmap (drawable), bg, type,
drawable_has_alpha (drawable), FALSE);
else if (bytes > srcPR.bytes)
/* If the layer doesn't have an alpha channel, add one */
add_alpha_region (&srcPR, &destPR);
else
/* Otherwise, do a straight copy */
copy_region (&srcPR, &destPR);
dest_gimage = gdisp->gimage;
dest_width = dest_gimage->width;
dest_height = dest_gimage->height;
new_layer =
layer_from_tiles (dest_gimage,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)),
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
if (new_layer)
{
undo_push_group_start (dest_gimage, EDIT_PASTE_UNDO);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
layer_translate (new_layer, off_x, off_y);
gimage_add_layer (dest_gimage, new_layer, -1);
gdisplays_flush ();
return_val = TRUE;
undo_push_group_end (dest_gimage);
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
if (return_val)
gimp_context_set_display (gimp_context_get_user (), gdisp);
return return_val;
}

View File

@ -25,10 +25,18 @@
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | \
GDK_PROXIMITY_OUT_MASK
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_shell_events (GtkWidget *, GdkEvent *, GDisplay *);
gint gdisplay_canvas_events (GtkWidget *, GdkEvent *);
gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
#endif /* __DISP_CALLBACKS_H__ */
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -33,6 +33,7 @@
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimage.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "indicator_area.h"
#include "interface.h"
@ -74,15 +75,21 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
char **data,
int width,
int height);
static void gimp_set_drop_open (GtkWidget *);
static void gimp_dnd_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
{
@ -109,22 +116,26 @@ GtkTooltips * tool_tips;
static GdkColor colors[12];
static GtkWidget * toolbox_shell = NULL;
enum {
TARGET_URI_LIST,
TARGET_TEXT_PLAIN,
TARGET_URL
} TargetType;
static
GtkTargetEntry dnd_target_table[] =
static GtkTargetEntry toolbox_target_table[] =
{
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "text/plain", 0, TARGET_TEXT_PLAIN },
{ "_NETSCAPE_URL",0, TARGET_URL }
GIMP_TARGET_URI_LIST,
GIMP_TARGET_TEXT_PLAIN,
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
static guint
dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]);
static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
static void
tools_select_update (GtkWidget *widget,
@ -583,8 +594,7 @@ create_toolbox ()
if (show_indicators && (!no_data) )
create_indicator_area (vbox);
gtk_widget_show (window);
gimp_set_drop_open (window);
toolbox_set_drag_dest (window);
toolbox_shell = window;
}
@ -685,14 +695,23 @@ create_display_shell (GDisplay* gdisp,
(GtkSignalFunc) gdisplay_destroy,
gdisp);
/* active display callback */
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "button_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "key_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
/* dnd stuff */
gtk_drag_dest_set (gdisp->shell,
GTK_DEST_DEFAULT_ALL,
display_target_table, display_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
@ -1420,26 +1439,29 @@ message_box_close_callback (GtkWidget *widget,
/* DnD functions */
static void
gimp_set_drop_open (GtkWidget *object)
toolbox_set_drag_dest (GtkWidget *object)
{
gtk_drag_dest_set (object,
GTK_DEST_DEFAULT_ALL,
dnd_target_table, dnd_n_targets,
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object),
"drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_data_received),
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
}
static void
gimp_dnd_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
@ -1456,6 +1478,99 @@ gimp_dnd_data_received (GtkWidget *widget,
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
if (layer)
{
GImage *gimage;
LayerMask *mask;
Layer *new_layer;
GImage *new_gimage;
LayerMask *new_mask;
gint width, height;
gint off_x, off_y;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
new_gimage = gimage_new (width, height, gimage->base_type);
gimage_disable_undo (new_gimage);
gimage_set_resolution (new_gimage,
gimage->xresolution, gimage->yresolution);
gimage_set_unit (new_gimage, gimage->unit);
new_layer = layer_copy (layer, FALSE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), new_gimage);
layer_set_name (GIMP_LAYER (new_layer),
layer_get_name (GIMP_LAYER (layer)));
mask = layer_get_mask (layer);
new_mask = layer_get_mask (new_layer);
if (new_mask)
{
gimp_drawable_set_name (GIMP_DRAWABLE (new_mask),
gimp_drawable_get_name (GIMP_DRAWABLE (mask)));
}
gimp_drawable_offsets (GIMP_DRAWABLE (new_layer), &off_x, &off_y);
layer_translate (new_layer, -off_x, -off_y);
gimage_add_layer (new_gimage, new_layer, 0);
gdisplay_new (new_gimage, 0x0101);
gimage_enable_undo (new_gimage);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -33,6 +33,7 @@
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimage.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "indicator_area.h"
#include "interface.h"
@ -74,15 +75,21 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
char **data,
int width,
int height);
static void gimp_set_drop_open (GtkWidget *);
static void gimp_dnd_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
{
@ -109,22 +116,26 @@ GtkTooltips * tool_tips;
static GdkColor colors[12];
static GtkWidget * toolbox_shell = NULL;
enum {
TARGET_URI_LIST,
TARGET_TEXT_PLAIN,
TARGET_URL
} TargetType;
static
GtkTargetEntry dnd_target_table[] =
static GtkTargetEntry toolbox_target_table[] =
{
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "text/plain", 0, TARGET_TEXT_PLAIN },
{ "_NETSCAPE_URL",0, TARGET_URL }
GIMP_TARGET_URI_LIST,
GIMP_TARGET_TEXT_PLAIN,
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
static guint
dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]);
static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
static void
tools_select_update (GtkWidget *widget,
@ -583,8 +594,7 @@ create_toolbox ()
if (show_indicators && (!no_data) )
create_indicator_area (vbox);
gtk_widget_show (window);
gimp_set_drop_open (window);
toolbox_set_drag_dest (window);
toolbox_shell = window;
}
@ -685,14 +695,23 @@ create_display_shell (GDisplay* gdisp,
(GtkSignalFunc) gdisplay_destroy,
gdisp);
/* active display callback */
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "button_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "key_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
/* dnd stuff */
gtk_drag_dest_set (gdisp->shell,
GTK_DEST_DEFAULT_ALL,
display_target_table, display_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
@ -1420,26 +1439,29 @@ message_box_close_callback (GtkWidget *widget,
/* DnD functions */
static void
gimp_set_drop_open (GtkWidget *object)
toolbox_set_drag_dest (GtkWidget *object)
{
gtk_drag_dest_set (object,
GTK_DEST_DEFAULT_ALL,
dnd_target_table, dnd_n_targets,
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object),
"drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_data_received),
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
}
static void
gimp_dnd_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
@ -1456,6 +1478,99 @@ gimp_dnd_data_received (GtkWidget *widget,
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
if (layer)
{
GImage *gimage;
LayerMask *mask;
Layer *new_layer;
GImage *new_gimage;
LayerMask *new_mask;
gint width, height;
gint off_x, off_y;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
new_gimage = gimage_new (width, height, gimage->base_type);
gimage_disable_undo (new_gimage);
gimage_set_resolution (new_gimage,
gimage->xresolution, gimage->yresolution);
gimage_set_unit (new_gimage, gimage->unit);
new_layer = layer_copy (layer, FALSE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), new_gimage);
layer_set_name (GIMP_LAYER (new_layer),
layer_get_name (GIMP_LAYER (layer)));
mask = layer_get_mask (layer);
new_mask = layer_get_mask (new_layer);
if (new_mask)
{
gimp_drawable_set_name (GIMP_DRAWABLE (new_mask),
gimp_drawable_get_name (GIMP_DRAWABLE (mask)));
}
gimp_drawable_offsets (GIMP_DRAWABLE (new_layer), &off_x, &off_y);
layer_translate (new_layer, -off_x, -off_y);
gimage_add_layer (new_gimage, new_layer, 0);
gdisplay_new (new_gimage, 0x0101);
gimage_enable_undo (new_gimage);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -50,10 +50,6 @@ struct _EraserOptions
gboolean hard_d;
GtkWidget *hard_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
gboolean anti_erase;
gboolean anti_erase_d;
GtkWidget *anti_erase_w;
@ -84,8 +80,8 @@ eraser_options_reset (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
}
static EraserOptions *
@ -101,7 +97,6 @@ eraser_options_new (void)
ERASER,
eraser_options_reset);
options->hard = options->hard_d = ERASER_DEFAULT_HARD;
options->incremental = options->incremental_d = ERASER_DEFAULT_INCREMENTAL;
options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE;
/* the main vbox */
@ -116,17 +111,7 @@ eraser_options_new (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_widget_show (options->hard_w);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* the anti_erase toggle */
options->anti_erase_w = gtk_check_button_new_with_label (_("Anti erase"));
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
@ -140,7 +125,6 @@ eraser_options_new (void)
return options;
}
static void
eraser_modifier_key_func (Tool *tool,
GdkEventKey *kevent,
@ -170,7 +154,11 @@ eraser_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental, eraser_options->anti_erase);
eraser_motion (paint_core,
drawable,
eraser_options->hard,
eraser_options->paint_options.incremental,
eraser_options->anti_erase);
break;
case FINISH_PAINT :
@ -305,20 +293,21 @@ eraser_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
gint hardness = ERASER_DEFAULT_HARD;
gint method = ERASER_DEFAULT_INCREMENTAL;
gint anti_erase = ERASER_DEFAULT_ANTI_ERASE;
gboolean hardness = ERASER_DEFAULT_HARD;
gboolean method = ERASER_DEFAULT_INCREMENTAL;
gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE;
EraserOptions *options = eraser_options;
if(options)
if (options)
{
hardness = options->hard;
method = options->incremental;
hardness = options->hard;
method = options->paint_options.incremental;
anti_erase = options->anti_erase;
}
return eraser_non_gui(drawable,num_strokes,stroke_array,hardness,method,anti_erase);
return eraser_non_gui (drawable, num_strokes, stroke_array,
hardness, method, anti_erase);
}
gboolean
@ -334,9 +323,9 @@ eraser_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_hard = hardness;
non_gui_hard = hardness;
non_gui_incremental = method;
non_gui_anti_erase = anti_erase;
non_gui_anti_erase = anti_erase;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;

49
app/gimpdnd.h Normal file
View File

@ -0,0 +1,49 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DND_H__
#define __GIMP_DND_H__
enum
{
GIMP_DND_TYPE_URI_LIST,
GIMP_DND_TYPE_TEXT_PLAIN,
GIMP_DND_TYPE_NETSCAPE_URL,
GIMP_DND_TYPE_LAYER,
GIMP_DND_TYPE_CHANNEL,
GIMP_DND_TYPE_LAYER_MASK
};
#define GIMP_TARGET_URI_LIST \
{ "text/uri-list", 0, GIMP_DND_TYPE_URI_LIST }
#define GIMP_TARGET_TEXT_PLAIN \
{ "text/plain", 0, GIMP_DND_TYPE_TEXT_PLAIN }
#define GIMP_TARGET_NETSCAPE_URL \
{ "_NETSCAPE_URL", 0, GIMP_DND_TYPE_NETSCAPE_URL }
#define GIMP_TARGET_LAYER \
{ "GIMP_LAYER", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER }
#define GIMP_TARGET_CHANNEL \
{ "GIMP_CHANNEL", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_CHANNEL }
#define GIMP_TARGET_LAYER_MASK \
{ "GIMP_LAYER_MASK", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER_MASK }
#endif /* __GIMP_DND_H__ */

View File

@ -196,11 +196,11 @@ layer_invalidate_preview (GtkObject *object)
}
static void
transform_color (GImage * gimage,
PixelRegion * layerPR,
PixelRegion * bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
transform_color (GImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
{
int i, h;
unsigned char * s, * d;
@ -234,13 +234,13 @@ transform_color (GImage * gimage,
Layer *
layer_new (GimpImage* gimage,
int width,
int height,
GimpImageType type,
char * name,
int opacity,
LayerModeEffects mode)
layer_new (GimpImage *gimage,
gint width,
gint height,
GimpImageType type,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * layer;
@ -297,9 +297,8 @@ layer_unref (Layer *layer)
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
int add_alpha;
layer_copy (Layer *layer,
gint add_alpha)
{
char * layer_name;
Layer * new_layer;
@ -397,12 +396,12 @@ layer_copy (layer, add_alpha)
Layer *
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
char *name,
int opacity,
LayerModeEffects mode)
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
GImage * gimage;
Layer * new_layer;
@ -449,9 +448,8 @@ layer_from_tiles (void *gimage_ptr,
LayerMask *
layer_add_mask (layer, mask)
Layer * layer;
LayerMask * mask;
layer_add_mask (Layer *layer,
LayerMask *mask)
{
if (layer->mask)
return NULL;
@ -471,9 +469,8 @@ layer_add_mask (layer, mask)
LayerMask *
layer_create_mask (layer, add_mask_type)
Layer * layer;
AddMaskType add_mask_type;
layer_create_mask (Layer *layer,
AddMaskType add_mask_type)
{
PixelRegion maskPR, layerPR;
LayerMask *mask;
@ -516,8 +513,7 @@ layer_create_mask (layer, add_mask_type)
Layer *
layer_get_ID (ID)
int ID;
layer_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -529,7 +525,7 @@ layer_get_ID (ID)
void
layer_delete (Layer * layer)
layer_delete (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
@ -569,7 +565,8 @@ gimp_layer_destroy (GtkObject *object)
* to the removed signal to update bits of UI that are tied to a
* particular layer. */
void
layer_removed (Layer *layer, gpointer image)
layer_removed (Layer *layer,
gpointer image)
{
g_return_if_fail (layer != NULL);
g_return_if_fail (GIMP_IS_LAYER (layer));
@ -578,9 +575,8 @@ layer_removed (Layer *layer, gpointer image)
}
void
layer_apply_mask (layer, mode)
Layer * layer;
int mode;
layer_apply_mask (Layer *layer,
gint mode)
{
PixelRegion srcPR, maskPR;
@ -620,13 +616,11 @@ layer_apply_mask (layer, mode)
}
}
static void
layer_translate_lowlevel (layer, off_x, off_y, temporary)
Layer * layer;
int off_x, off_y;
gboolean temporary;
layer_translate_lowlevel (Layer *layer,
gint off_x,
gint off_y,
gboolean temporary)
{
if (!temporary)
{
@ -666,28 +660,23 @@ layer_translate_lowlevel (layer, off_x, off_y, temporary)
void
layer_temporarily_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_temporarily_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, TRUE);
}
void
layer_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, FALSE);
}
void
layer_add_alpha (layer)
Layer *layer;
layer_add_alpha (Layer *layer)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -739,10 +728,10 @@ layer_add_alpha (layer)
void
layer_scale (layer, new_width, new_height, local_origin)
Layer *layer;
int new_width, new_height;
int local_origin;
layer_scale (Layer *layer,
gint new_width,
gint new_height,
gint local_origin)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -813,10 +802,11 @@ layer_scale (layer, new_width, new_height, local_origin)
void
layer_resize (layer, new_width, new_height, offx, offy)
Layer *layer;
int new_width, new_height;
int offx, offy;
layer_resize (Layer *layer,
gint new_width,
gint new_height,
gint offx,
gint offy)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -907,9 +897,8 @@ layer_resize (layer, new_width, new_height, offx, offy)
BoundSeg *
layer_boundary (layer, num_segs)
Layer *layer;
int *num_segs;
layer_boundary (Layer *layer,
gint *num_segs)
{
BoundSeg *new_segs;
@ -962,8 +951,7 @@ layer_boundary (layer, num_segs)
void
layer_invalidate_boundary (layer)
Layer *layer;
layer_invalidate_boundary (Layer *layer)
{
GImage *gimage;
Channel *mask;
@ -993,9 +981,9 @@ layer_invalidate_boundary (layer)
int
layer_pick_correlate (layer, x, y)
Layer *layer;
int x, y;
layer_pick_correlate (Layer *layer,
gint x,
gint y)
{
Tile *tile;
Tile *mask_tile;
@ -1048,34 +1036,33 @@ layer_pick_correlate (layer, x, y)
/* access functions */
void
layer_set_name (Layer *layer, char *name)
layer_set_name (Layer *layer,
gchar *name)
{
gimp_drawable_set_name(GIMP_DRAWABLE(layer), name);
gimp_drawable_set_name (GIMP_DRAWABLE (layer), name);
}
char *
gchar *
layer_get_name (Layer *layer)
{
return gimp_drawable_get_name(GIMP_DRAWABLE(layer));
return gimp_drawable_get_name (GIMP_DRAWABLE (layer));
}
unsigned char *
layer_data (Layer * layer)
guchar *
layer_data (Layer *layer)
{
return NULL;
}
LayerMask *
layer_mask (Layer * layer)
layer_get_mask (Layer *layer)
{
return layer->mask;
}
int
layer_has_alpha (Layer * layer)
layer_has_alpha (Layer *layer)
{
if (GIMP_DRAWABLE(layer)->type == RGBA_GIMAGE ||
GIMP_DRAWABLE(layer)->type == GRAYA_GIMAGE ||
@ -1085,7 +1072,6 @@ layer_has_alpha (Layer * layer)
return 0;
}
int
layer_is_floating_sel (Layer *layer)
{
@ -1103,8 +1089,8 @@ layer_linked (Layer *layer)
TempBuf *
layer_preview (Layer *layer,
int w,
int h)
gint w,
gint h)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1174,9 +1160,9 @@ layer_preview (Layer *layer,
TempBuf *
layer_mask_preview (layer, w, h)
Layer *layer;
int w, h;
layer_mask_preview (Layer *layer,
gint w,
gint h)
{
TempBuf *preview_buf;
LayerMask *mask;
@ -1226,9 +1212,9 @@ layer_mask_preview (layer, w, h)
}
Tattoo
layer_get_tattoo(const Layer *layer)
layer_get_tattoo (const Layer *layer)
{
return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer)));
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
}
void
@ -1251,12 +1237,11 @@ layer_invalidate_previews (GimpImage* gimage)
static void
layer_preview_scale (type, cmap, srcPR, destPR, subsample)
int type;
unsigned char *cmap;
PixelRegion *srcPR;
PixelRegion *destPR;
int subsample;
layer_preview_scale (gint type,
guchar *cmap,
PixelRegion *srcPR,
PixelRegion *destPR,
gint subsample)
{
#define EPSILON 0.000001
unsigned char * src, * s;
@ -1438,8 +1423,12 @@ gimp_layer_mask_destroy (GtkObject *object)
}
LayerMask *
layer_mask_new (GimpImage* gimage, int width, int height, char *name, int opacity,
unsigned char *col)
layer_mask_new (GimpImage *gimage,
gint width,
gint height,
gchar *name,
gint opacity,
guchar *col)
{
LayerMask * layer_mask;
int i;
@ -1507,7 +1496,7 @@ layer_mask_copy (LayerMask *layer_mask)
LayerMask *
layer_mask_get_ID (int ID)
layer_mask_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -1518,7 +1507,7 @@ layer_mask_get_ID (int ID)
}
void
layer_mask_delete (LayerMask * layermask)
layer_mask_delete (LayerMask *layermask)
{
gtk_object_unref (GTK_OBJECT (layermask));
}
@ -1539,7 +1528,8 @@ layer_mask_unref (LayerMask *mask)
}
void
channel_layer_mask (Channel *mask, Layer * layer)
channel_layer_mask (Channel *mask,
Layer *layer)
{
PixelRegion srcPR, destPR;
unsigned char empty = 0;

View File

@ -115,7 +115,7 @@ void layer_mask_unref (LayerMask *);
void layer_set_name (Layer *, char *);
char * layer_get_name (Layer *);
unsigned char * layer_data (Layer *);
LayerMask * layer_mask (Layer *);
LayerMask * layer_get_mask (Layer *);
int layer_has_alpha (Layer *);
int layer_is_floating_sel (Layer *);
int layer_linked (Layer *);

View File

@ -28,6 +28,7 @@
#include "gdisplay.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "image_render.h"
#include "interface.h"
@ -162,6 +163,17 @@ static gint layer_list_events (GtkWidget *, GdkEvent *);
static void layers_dialog_map_callback (GtkWidget *, gpointer);
static void layers_dialog_unmap_callback (GtkWidget *, gpointer);
/* ops buttons dnd callbacks */
static gboolean layers_dialog_drag_new_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layers_dialog_drag_duplicate_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layers_dialog_drag_delete_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
/* layer widget function prototypes */
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *layer_widget_create (GImage *, Layer *);
@ -172,6 +184,8 @@ static gboolean layer_widget_drag_motion_callback (GtkWidget *,
static gboolean layer_widget_drag_drop_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static void layer_widget_drag_begin_callback (GtkWidget *,
GdkDragContext *);
static void layer_widget_drag_leave_callback (GtkWidget *,
GdkDragContext *,
guint);
@ -281,14 +295,9 @@ static OpsButton layers_ops_buttons[] =
/* dnd structures */
enum
{
GIMP_TARGET_LAYER
};
static GtkTargetEntry layer_target_table[] =
{
{ "GIMP_LAYER", 0, GIMP_TARGET_LAYER }
GIMP_TARGET_LAYER
};
static guint n_targets = (sizeof (layer_target_table) /
@ -411,6 +420,33 @@ layers_dialog_create ()
gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 2);
gtk_widget_show (button_box);
/* drop to new */
gtk_drag_dest_set (layers_ops_buttons[0].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[0].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_new_layer_callback),
NULL);
/* drop to duplicate */
gtk_drag_dest_set (layers_ops_buttons[3].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[3].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_duplicate_layer_callback),
NULL);
/* drop to trahcan */
gtk_drag_dest_set (layers_ops_buttons[5].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[5].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_delete_layer_callback),
NULL);
/* Set up signals for map/unmap for the accelerators */
gtk_signal_connect (GTK_OBJECT (layersD->vbox), "map",
(GtkSignalFunc) layers_dialog_map_callback,
@ -1674,6 +1710,138 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
gdisplays_flush ();
}
/*******************************/
/* ops buttons dnd callbacks */
/*******************************/
static gboolean
layers_dialog_drag_new_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
src->layer == layersD->active_layer)
{
Layer *layer;
GImage *gimage;
gint width, height;
gint off_x, off_y;
gimage = layersD->gimage;
width = gimp_drawable_width (GIMP_DRAWABLE (src->layer));
height = gimp_drawable_height (GIMP_DRAWABLE (src->layer));
gimp_drawable_offsets (GIMP_DRAWABLE (src->layer), &off_x, &off_y);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
layer = layer_new (gimage, width, height,
gimage_base_type_with_alpha (gimage),
_("Empty Layer Copy"),
src->layer->opacity,
src->layer->mode);
if (layer)
{
drawable_fill (GIMP_DRAWABLE (layer), TRANSPARENT_FILL);
layer_translate (layer, off_x, off_y);
gimage_add_layer (gimage, layer, -1);
/* End the group undo */
undo_push_group_end (gimage);
gdisplays_flush ();
}
else
{
g_message (_("layers_dialog_drop_new_layer_callback():\n"
"could not allocate new layer"));
}
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static gboolean
layers_dialog_drag_duplicate_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
! layer_is_floating_sel (src->layer) &&
src->layer == layersD->active_layer)
{
layers_dialog_duplicate_layer_callback (widget, NULL);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static gboolean
layers_dialog_drag_delete_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
src->layer == layersD->active_layer)
{
layers_dialog_delete_layer_callback (widget, NULL);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
/****************************/
/* layer widget functions */
/****************************/
@ -1848,6 +2016,9 @@ layer_widget_create (GImage *gimage,
gtk_signal_connect (GTK_OBJECT (list_item), "drag_drop",
GTK_SIGNAL_FUNC (layer_widget_drag_drop_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_begin",
GTK_SIGNAL_FUNC (layer_widget_drag_begin_callback),
NULL);
/* re-paint the drop indicator after drawing the widget */
gtk_signal_connect_after (GTK_OBJECT (list_item), "draw",
@ -1858,7 +2029,9 @@ layer_widget_create (GImage *gimage,
gtk_drag_source_set (list_item,
GDK_BUTTON1_MASK,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gtk_object_set_data (GTK_OBJECT (list_item), "gimp_layer", (gpointer) layer);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
@ -1922,7 +2095,7 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
if (src_index != dest_index)
{
drag_action = context->suggested_action;
drag_action = GDK_ACTION_MOVE;
return_val = TRUE;
}
else
@ -1944,6 +2117,182 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
return return_val;
}
#define GRAD_CHECK_SIZE_SM 4
#define GRAD_CHECK_DARK (1.0 / 3.0)
#define GRAD_CHECK_LIGHT (2.0 / 3.0)
/* Good idea for size to be <= small preview size in LCP dialog.
* that way we get good cache hits.
*/
#define DRAG_IMAGE_SZ 32
static void
layer_widget_drag_begin_callback (GtkWidget *widget,
GdkDragContext *context)
{
GdkPixmap *drag_pixmap;
LayerWidget *layer_widget;
Layer *layer;
TempBuf *tmpbuf;
gint bpp;
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
gint width;
gint height;
GdkGC *gc = NULL;
gdouble ratio;
int offx, offy;
if(!preview_size)
return;
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
layer = layer_widget->layer;
if (layer_widget->gimage->width > layer_widget->gimage->height)
ratio = (double) DRAG_IMAGE_SZ / (double) layer_widget->gimage->width;
else
ratio = (double) DRAG_IMAGE_SZ / (double) layer_widget->gimage->height;
width = (int) (ratio * layer_widget->gimage->width);
height = (int) (ratio * layer_widget->gimage->height);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
offx = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->offset_x);
offy = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->offset_y);
drag_pixmap = gdk_pixmap_new (widget->window,
width+2, height+2, -1);
/* Is this always valid??? */
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
gdk_draw_rectangle (drag_pixmap,
gc,
TRUE,
0,0,
width+2,
height+2);
gc = layer_widget->layer_preview->style->black_gc;
gdk_draw_rectangle (drag_pixmap,
gc,
FALSE,
0,0,
width+1,
height+1);
/* readjust for actual layer size */
width = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->width);
height = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->height);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
tmpbuf = layer_preview (layer, width, height);
bpp = tmpbuf->bytes;
/* Draw the thumbnail with checks */
src = temp_buf_data (tmpbuf);
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
p0 = even;
p1 = odd;
for (x = 0; x < width; x++) {
if(bpp == 4)
{
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
}
else if(bpp == 3)
{
r = ((gdouble)src[x*3+0])/255.0;
g = ((gdouble)src[x*3+1])/255.0;
b = ((gdouble)src[x*3+2])/255.0;
a = 1.0;
}
else
{
r = ((gdouble)src[x*bpp+0])/255.0;
g = b = r;
if(bpp == 2)
a = ((gdouble)src[x*bpp+1])/255.0;
else
a = 1.0;
}
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gdk_draw_rgb_image(drag_pixmap,gc,
1+offx,y+1+offy,
width,
1,
GDK_RGB_DITHER_NORMAL,
(guchar *)odd,
3);
}
else
{
gdk_draw_rgb_image(drag_pixmap,gc,
1+offx,y+1+offy,
width,
1,
GDK_RGB_DITHER_NORMAL,
(guchar *)even,
3);
}
src += width * bpp;
}
g_free(even);
g_free(odd);
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
drag_pixmap,
NULL,
-8,-8);
gdk_pixmap_unref (drag_pixmap);
}
static gboolean
layer_widget_drag_drop_callback (GtkWidget *widget,
GdkDragContext *context,

View File

@ -33,6 +33,7 @@
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimage.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "indicator_area.h"
#include "interface.h"
@ -74,15 +75,21 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
char **data,
int width,
int height);
static void gimp_set_drop_open (GtkWidget *);
static void gimp_dnd_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
{
@ -109,22 +116,26 @@ GtkTooltips * tool_tips;
static GdkColor colors[12];
static GtkWidget * toolbox_shell = NULL;
enum {
TARGET_URI_LIST,
TARGET_TEXT_PLAIN,
TARGET_URL
} TargetType;
static
GtkTargetEntry dnd_target_table[] =
static GtkTargetEntry toolbox_target_table[] =
{
{ "text/uri-list", 0, TARGET_URI_LIST },
{ "text/plain", 0, TARGET_TEXT_PLAIN },
{ "_NETSCAPE_URL",0, TARGET_URL }
GIMP_TARGET_URI_LIST,
GIMP_TARGET_TEXT_PLAIN,
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
static guint
dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]);
static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
static void
tools_select_update (GtkWidget *widget,
@ -583,8 +594,7 @@ create_toolbox ()
if (show_indicators && (!no_data) )
create_indicator_area (vbox);
gtk_widget_show (window);
gimp_set_drop_open (window);
toolbox_set_drag_dest (window);
toolbox_shell = window;
}
@ -685,14 +695,23 @@ create_display_shell (GDisplay* gdisp,
(GtkSignalFunc) gdisplay_destroy,
gdisp);
/* active display callback */
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "button_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "key_press_event",
(GtkSignalFunc) gdisplay_shell_events,
gdisp);
/* dnd stuff */
gtk_drag_dest_set (gdisp->shell,
GTK_DEST_DEFAULT_ALL,
display_target_table, display_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
@ -1420,26 +1439,29 @@ message_box_close_callback (GtkWidget *widget,
/* DnD functions */
static void
gimp_set_drop_open (GtkWidget *object)
toolbox_set_drag_dest (GtkWidget *object)
{
gtk_drag_dest_set (object,
GTK_DEST_DEFAULT_ALL,
dnd_target_table, dnd_n_targets,
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object),
"drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_data_received),
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
}
static void
gimp_dnd_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
@ -1456,6 +1478,99 @@ gimp_dnd_data_received (GtkWidget *widget,
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
GimpDrawable *drawable = NULL;
Layer *layer = NULL;
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer");
channel = (Channel *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_channel");
layer_mask = (LayerMask *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_layer_mask");
if (layer)
{
drawable = GIMP_DRAWABLE (layer);
}
else if (channel)
{
drawable = GIMP_DRAWABLE (channel);
}
else if (layer_mask)
{
drawable = GIMP_DRAWABLE (layer_mask);
channel = GIMP_CHANNEL (layer_mask);
}
if (layer)
{
GImage *gimage;
LayerMask *mask;
Layer *new_layer;
GImage *new_gimage;
LayerMask *new_mask;
gint width, height;
gint off_x, off_y;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
new_gimage = gimage_new (width, height, gimage->base_type);
gimage_disable_undo (new_gimage);
gimage_set_resolution (new_gimage,
gimage->xresolution, gimage->yresolution);
gimage_set_unit (new_gimage, gimage->unit);
new_layer = layer_copy (layer, FALSE);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), new_gimage);
layer_set_name (GIMP_LAYER (new_layer),
layer_get_name (GIMP_LAYER (layer)));
mask = layer_get_mask (layer);
new_mask = layer_get_mask (new_layer);
if (new_mask)
{
gimp_drawable_set_name (GIMP_DRAWABLE (new_mask),
gimp_drawable_get_name (GIMP_DRAWABLE (mask)));
}
gimp_drawable_offsets (GIMP_DRAWABLE (new_layer), &off_x, &off_y);
layer_translate (new_layer, -off_x, -off_y);
gimage_add_layer (new_gimage, new_layer, 0);
gdisplay_new (new_gimage, 0x0101);
gimage_enable_undo (new_gimage);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -196,11 +196,11 @@ layer_invalidate_preview (GtkObject *object)
}
static void
transform_color (GImage * gimage,
PixelRegion * layerPR,
PixelRegion * bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
transform_color (GImage *gimage,
PixelRegion *layerPR,
PixelRegion *bufPR,
GimpDrawable *drawable,
GimpImageBaseType type)
{
int i, h;
unsigned char * s, * d;
@ -234,13 +234,13 @@ transform_color (GImage * gimage,
Layer *
layer_new (GimpImage* gimage,
int width,
int height,
GimpImageType type,
char * name,
int opacity,
LayerModeEffects mode)
layer_new (GimpImage *gimage,
gint width,
gint height,
GimpImageType type,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * layer;
@ -297,9 +297,8 @@ layer_unref (Layer *layer)
Layer *
layer_copy (layer, add_alpha)
Layer * layer;
int add_alpha;
layer_copy (Layer *layer,
gint add_alpha)
{
char * layer_name;
Layer * new_layer;
@ -397,12 +396,12 @@ layer_copy (layer, add_alpha)
Layer *
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
char *name,
int opacity,
LayerModeEffects mode)
layer_from_tiles (void *gimage_ptr,
GimpDrawable *drawable,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
GImage * gimage;
Layer * new_layer;
@ -449,9 +448,8 @@ layer_from_tiles (void *gimage_ptr,
LayerMask *
layer_add_mask (layer, mask)
Layer * layer;
LayerMask * mask;
layer_add_mask (Layer *layer,
LayerMask *mask)
{
if (layer->mask)
return NULL;
@ -471,9 +469,8 @@ layer_add_mask (layer, mask)
LayerMask *
layer_create_mask (layer, add_mask_type)
Layer * layer;
AddMaskType add_mask_type;
layer_create_mask (Layer *layer,
AddMaskType add_mask_type)
{
PixelRegion maskPR, layerPR;
LayerMask *mask;
@ -516,8 +513,7 @@ layer_create_mask (layer, add_mask_type)
Layer *
layer_get_ID (ID)
int ID;
layer_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -529,7 +525,7 @@ layer_get_ID (ID)
void
layer_delete (Layer * layer)
layer_delete (Layer *layer)
{
gtk_object_unref (GTK_OBJECT (layer));
}
@ -569,7 +565,8 @@ gimp_layer_destroy (GtkObject *object)
* to the removed signal to update bits of UI that are tied to a
* particular layer. */
void
layer_removed (Layer *layer, gpointer image)
layer_removed (Layer *layer,
gpointer image)
{
g_return_if_fail (layer != NULL);
g_return_if_fail (GIMP_IS_LAYER (layer));
@ -578,9 +575,8 @@ layer_removed (Layer *layer, gpointer image)
}
void
layer_apply_mask (layer, mode)
Layer * layer;
int mode;
layer_apply_mask (Layer *layer,
gint mode)
{
PixelRegion srcPR, maskPR;
@ -620,13 +616,11 @@ layer_apply_mask (layer, mode)
}
}
static void
layer_translate_lowlevel (layer, off_x, off_y, temporary)
Layer * layer;
int off_x, off_y;
gboolean temporary;
layer_translate_lowlevel (Layer *layer,
gint off_x,
gint off_y,
gboolean temporary)
{
if (!temporary)
{
@ -666,28 +660,23 @@ layer_translate_lowlevel (layer, off_x, off_y, temporary)
void
layer_temporarily_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_temporarily_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, TRUE);
}
void
layer_translate (layer, off_x, off_y)
Layer * layer;
int off_x, off_y;
layer_translate (Layer *layer,
gint off_x,
gint off_y)
{
layer_translate_lowlevel (layer, off_x, off_y, FALSE);
}
void
layer_add_alpha (layer)
Layer *layer;
layer_add_alpha (Layer *layer)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -739,10 +728,10 @@ layer_add_alpha (layer)
void
layer_scale (layer, new_width, new_height, local_origin)
Layer *layer;
int new_width, new_height;
int local_origin;
layer_scale (Layer *layer,
gint new_width,
gint new_height,
gint local_origin)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -813,10 +802,11 @@ layer_scale (layer, new_width, new_height, local_origin)
void
layer_resize (layer, new_width, new_height, offx, offy)
Layer *layer;
int new_width, new_height;
int offx, offy;
layer_resize (Layer *layer,
gint new_width,
gint new_height,
gint offx,
gint offy)
{
PixelRegion srcPR, destPR;
TileManager *new_tiles;
@ -907,9 +897,8 @@ layer_resize (layer, new_width, new_height, offx, offy)
BoundSeg *
layer_boundary (layer, num_segs)
Layer *layer;
int *num_segs;
layer_boundary (Layer *layer,
gint *num_segs)
{
BoundSeg *new_segs;
@ -962,8 +951,7 @@ layer_boundary (layer, num_segs)
void
layer_invalidate_boundary (layer)
Layer *layer;
layer_invalidate_boundary (Layer *layer)
{
GImage *gimage;
Channel *mask;
@ -993,9 +981,9 @@ layer_invalidate_boundary (layer)
int
layer_pick_correlate (layer, x, y)
Layer *layer;
int x, y;
layer_pick_correlate (Layer *layer,
gint x,
gint y)
{
Tile *tile;
Tile *mask_tile;
@ -1048,34 +1036,33 @@ layer_pick_correlate (layer, x, y)
/* access functions */
void
layer_set_name (Layer *layer, char *name)
layer_set_name (Layer *layer,
gchar *name)
{
gimp_drawable_set_name(GIMP_DRAWABLE(layer), name);
gimp_drawable_set_name (GIMP_DRAWABLE (layer), name);
}
char *
gchar *
layer_get_name (Layer *layer)
{
return gimp_drawable_get_name(GIMP_DRAWABLE(layer));
return gimp_drawable_get_name (GIMP_DRAWABLE (layer));
}
unsigned char *
layer_data (Layer * layer)
guchar *
layer_data (Layer *layer)
{
return NULL;
}
LayerMask *
layer_mask (Layer * layer)
layer_get_mask (Layer *layer)
{
return layer->mask;
}
int
layer_has_alpha (Layer * layer)
layer_has_alpha (Layer *layer)
{
if (GIMP_DRAWABLE(layer)->type == RGBA_GIMAGE ||
GIMP_DRAWABLE(layer)->type == GRAYA_GIMAGE ||
@ -1085,7 +1072,6 @@ layer_has_alpha (Layer * layer)
return 0;
}
int
layer_is_floating_sel (Layer *layer)
{
@ -1103,8 +1089,8 @@ layer_linked (Layer *layer)
TempBuf *
layer_preview (Layer *layer,
int w,
int h)
gint w,
gint h)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1174,9 +1160,9 @@ layer_preview (Layer *layer,
TempBuf *
layer_mask_preview (layer, w, h)
Layer *layer;
int w, h;
layer_mask_preview (Layer *layer,
gint w,
gint h)
{
TempBuf *preview_buf;
LayerMask *mask;
@ -1226,9 +1212,9 @@ layer_mask_preview (layer, w, h)
}
Tattoo
layer_get_tattoo(const Layer *layer)
layer_get_tattoo (const Layer *layer)
{
return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer)));
return (gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
}
void
@ -1251,12 +1237,11 @@ layer_invalidate_previews (GimpImage* gimage)
static void
layer_preview_scale (type, cmap, srcPR, destPR, subsample)
int type;
unsigned char *cmap;
PixelRegion *srcPR;
PixelRegion *destPR;
int subsample;
layer_preview_scale (gint type,
guchar *cmap,
PixelRegion *srcPR,
PixelRegion *destPR,
gint subsample)
{
#define EPSILON 0.000001
unsigned char * src, * s;
@ -1438,8 +1423,12 @@ gimp_layer_mask_destroy (GtkObject *object)
}
LayerMask *
layer_mask_new (GimpImage* gimage, int width, int height, char *name, int opacity,
unsigned char *col)
layer_mask_new (GimpImage *gimage,
gint width,
gint height,
gchar *name,
gint opacity,
guchar *col)
{
LayerMask * layer_mask;
int i;
@ -1507,7 +1496,7 @@ layer_mask_copy (LayerMask *layer_mask)
LayerMask *
layer_mask_get_ID (int ID)
layer_mask_get_ID (gint ID)
{
GimpDrawable *drawable;
drawable = drawable_get_ID (ID);
@ -1518,7 +1507,7 @@ layer_mask_get_ID (int ID)
}
void
layer_mask_delete (LayerMask * layermask)
layer_mask_delete (LayerMask *layermask)
{
gtk_object_unref (GTK_OBJECT (layermask));
}
@ -1539,7 +1528,8 @@ layer_mask_unref (LayerMask *mask)
}
void
channel_layer_mask (Channel *mask, Layer * layer)
channel_layer_mask (Channel *mask,
Layer *layer)
{
PixelRegion srcPR, destPR;
unsigned char empty = 0;

View File

@ -115,7 +115,7 @@ void layer_mask_unref (LayerMask *);
void layer_set_name (Layer *, char *);
char * layer_get_name (Layer *);
unsigned char * layer_data (Layer *);
LayerMask * layer_mask (Layer *);
LayerMask * layer_get_mask (Layer *);
int layer_has_alpha (Layer *);
int layer_is_floating_sel (Layer *);
int layer_linked (Layer *);

View File

@ -28,6 +28,7 @@
#include "gdisplay.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "gimpdnd.h"
#include "gimprc.h"
#include "image_render.h"
#include "interface.h"
@ -162,6 +163,17 @@ static gint layer_list_events (GtkWidget *, GdkEvent *);
static void layers_dialog_map_callback (GtkWidget *, gpointer);
static void layers_dialog_unmap_callback (GtkWidget *, gpointer);
/* ops buttons dnd callbacks */
static gboolean layers_dialog_drag_new_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layers_dialog_drag_duplicate_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static gboolean layers_dialog_drag_delete_layer_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
/* layer widget function prototypes */
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *layer_widget_create (GImage *, Layer *);
@ -172,6 +184,8 @@ static gboolean layer_widget_drag_motion_callback (GtkWidget *,
static gboolean layer_widget_drag_drop_callback (GtkWidget *,
GdkDragContext *,
gint, gint, guint);
static void layer_widget_drag_begin_callback (GtkWidget *,
GdkDragContext *);
static void layer_widget_drag_leave_callback (GtkWidget *,
GdkDragContext *,
guint);
@ -281,14 +295,9 @@ static OpsButton layers_ops_buttons[] =
/* dnd structures */
enum
{
GIMP_TARGET_LAYER
};
static GtkTargetEntry layer_target_table[] =
{
{ "GIMP_LAYER", 0, GIMP_TARGET_LAYER }
GIMP_TARGET_LAYER
};
static guint n_targets = (sizeof (layer_target_table) /
@ -411,6 +420,33 @@ layers_dialog_create ()
gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 2);
gtk_widget_show (button_box);
/* drop to new */
gtk_drag_dest_set (layers_ops_buttons[0].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[0].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_new_layer_callback),
NULL);
/* drop to duplicate */
gtk_drag_dest_set (layers_ops_buttons[3].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[3].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_duplicate_layer_callback),
NULL);
/* drop to trahcan */
gtk_drag_dest_set (layers_ops_buttons[5].widget,
GTK_DEST_DEFAULT_ALL,
layer_target_table, n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (layers_ops_buttons[5].widget), "drag_drop",
GTK_SIGNAL_FUNC (layers_dialog_drag_delete_layer_callback),
NULL);
/* Set up signals for map/unmap for the accelerators */
gtk_signal_connect (GTK_OBJECT (layersD->vbox), "map",
(GtkSignalFunc) layers_dialog_map_callback,
@ -1674,6 +1710,138 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *widget,
gdisplays_flush ();
}
/*******************************/
/* ops buttons dnd callbacks */
/*******************************/
static gboolean
layers_dialog_drag_new_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
src->layer == layersD->active_layer)
{
Layer *layer;
GImage *gimage;
gint width, height;
gint off_x, off_y;
gimage = layersD->gimage;
width = gimp_drawable_width (GIMP_DRAWABLE (src->layer));
height = gimp_drawable_height (GIMP_DRAWABLE (src->layer));
gimp_drawable_offsets (GIMP_DRAWABLE (src->layer), &off_x, &off_y);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
layer = layer_new (gimage, width, height,
gimage_base_type_with_alpha (gimage),
_("Empty Layer Copy"),
src->layer->opacity,
src->layer->mode);
if (layer)
{
drawable_fill (GIMP_DRAWABLE (layer), TRANSPARENT_FILL);
layer_translate (layer, off_x, off_y);
gimage_add_layer (gimage, layer, -1);
/* End the group undo */
undo_push_group_end (gimage);
gdisplays_flush ();
}
else
{
g_message (_("layers_dialog_drop_new_layer_callback():\n"
"could not allocate new layer"));
}
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static gboolean
layers_dialog_drag_duplicate_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
! layer_is_floating_sel (src->layer) &&
src->layer == layersD->active_layer)
{
layers_dialog_duplicate_layer_callback (widget, NULL);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
static gboolean
layers_dialog_drag_delete_layer_callback (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GtkWidget *src_widget;
LayerWidget *src;
gboolean return_val = FALSE;
if ((src_widget = gtk_drag_get_source_widget (context)))
{
src
= (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (src_widget));
if (src &&
src->layer == layersD->active_layer)
{
layers_dialog_delete_layer_callback (widget, NULL);
return_val = TRUE;
}
}
gtk_drag_finish (context, return_val, FALSE, time);
return return_val;
}
/****************************/
/* layer widget functions */
/****************************/
@ -1848,6 +2016,9 @@ layer_widget_create (GImage *gimage,
gtk_signal_connect (GTK_OBJECT (list_item), "drag_drop",
GTK_SIGNAL_FUNC (layer_widget_drag_drop_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_begin",
GTK_SIGNAL_FUNC (layer_widget_drag_begin_callback),
NULL);
/* re-paint the drop indicator after drawing the widget */
gtk_signal_connect_after (GTK_OBJECT (list_item), "draw",
@ -1858,7 +2029,9 @@ layer_widget_create (GImage *gimage,
gtk_drag_source_set (list_item,
GDK_BUTTON1_MASK,
layer_target_table, n_targets,
GDK_ACTION_MOVE);
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gtk_object_set_data (GTK_OBJECT (list_item), "gimp_layer", (gpointer) layer);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
@ -1922,7 +2095,7 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
if (src_index != dest_index)
{
drag_action = context->suggested_action;
drag_action = GDK_ACTION_MOVE;
return_val = TRUE;
}
else
@ -1944,6 +2117,182 @@ layer_widget_drag_motion_callback (GtkWidget *widget,
return return_val;
}
#define GRAD_CHECK_SIZE_SM 4
#define GRAD_CHECK_DARK (1.0 / 3.0)
#define GRAD_CHECK_LIGHT (2.0 / 3.0)
/* Good idea for size to be <= small preview size in LCP dialog.
* that way we get good cache hits.
*/
#define DRAG_IMAGE_SZ 32
static void
layer_widget_drag_begin_callback (GtkWidget *widget,
GdkDragContext *context)
{
GdkPixmap *drag_pixmap;
LayerWidget *layer_widget;
Layer *layer;
TempBuf *tmpbuf;
gint bpp;
gint x,y;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1,*even,*odd;
gint width;
gint height;
GdkGC *gc = NULL;
gdouble ratio;
int offx, offy;
if(!preview_size)
return;
layer_widget = (LayerWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
layer = layer_widget->layer;
if (layer_widget->gimage->width > layer_widget->gimage->height)
ratio = (double) DRAG_IMAGE_SZ / (double) layer_widget->gimage->width;
else
ratio = (double) DRAG_IMAGE_SZ / (double) layer_widget->gimage->height;
width = (int) (ratio * layer_widget->gimage->width);
height = (int) (ratio * layer_widget->gimage->height);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
offx = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->offset_x);
offy = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->offset_y);
drag_pixmap = gdk_pixmap_new (widget->window,
width+2, height+2, -1);
/* Is this always valid??? */
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
gdk_draw_rectangle (drag_pixmap,
gc,
TRUE,
0,0,
width+2,
height+2);
gc = layer_widget->layer_preview->style->black_gc;
gdk_draw_rectangle (drag_pixmap,
gc,
FALSE,
0,0,
width+1,
height+1);
/* readjust for actual layer size */
width = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->width);
height = (int) (ratio * GIMP_DRAWABLE (layer_widget->layer)->height);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
tmpbuf = layer_preview (layer, width, height);
bpp = tmpbuf->bytes;
/* Draw the thumbnail with checks */
src = temp_buf_data (tmpbuf);
even = g_malloc(width*3);
odd = g_malloc(width*3);
for (y = 0; y < height; y++)
{
p0 = even;
p1 = odd;
for (x = 0; x < width; x++) {
if(bpp == 4)
{
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
}
else if(bpp == 3)
{
r = ((gdouble)src[x*3+0])/255.0;
g = ((gdouble)src[x*3+1])/255.0;
b = ((gdouble)src[x*3+2])/255.0;
a = 1.0;
}
else
{
r = ((gdouble)src[x*bpp+0])/255.0;
g = b = r;
if(bpp == 2)
a = ((gdouble)src[x*bpp+1])/255.0;
else
a = 1.0;
}
if ((x / GRAD_CHECK_SIZE_SM) & 1) {
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
} else {
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
} /* else */
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
} /* for */
if ((y / GRAD_CHECK_SIZE_SM) & 1)
{
gdk_draw_rgb_image(drag_pixmap,gc,
1+offx,y+1+offy,
width,
1,
GDK_RGB_DITHER_NORMAL,
(guchar *)odd,
3);
}
else
{
gdk_draw_rgb_image(drag_pixmap,gc,
1+offx,y+1+offy,
width,
1,
GDK_RGB_DITHER_NORMAL,
(guchar *)even,
3);
}
src += width * bpp;
}
g_free(even);
g_free(odd);
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
drag_pixmap,
NULL,
-8,-8);
gdk_pixmap_unref (drag_pixmap);
}
static gboolean
layer_widget_drag_drop_callback (GtkWidget *widget,
GdkDragContext *context,

View File

@ -40,7 +40,7 @@
#define MAX_PRESSURE 0.075
/* Default pressure setting */
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_INCREMENTAL_DEFAULT FALSE
#define OFF 0
@ -51,7 +51,7 @@
typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
PaintCore *paint_core;
PaintCore *paint_core;
GimpDrawable *drawable;
};
@ -67,10 +67,6 @@ struct _AirbrushOptions
double pressure;
double pressure_d;
GtkObject *pressure_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
@ -103,9 +99,6 @@ airbrush_options_reset (void)
options->rate_d);
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->pressure_w),
options->pressure_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static AirbrushOptions *
@ -125,8 +118,6 @@ airbrush_options_new (void)
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
options->incremental =
options->incremental_d = AIRBRUSH_INCREMENTAL_DEFAULT;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
@ -172,14 +163,6 @@ airbrush_options_new (void)
&options->pressure);
gtk_widget_show (scale);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
gtk_widget_show (table);
return options;
@ -208,9 +191,9 @@ tools_new_airbrush ()
}
void *
airbrush_paint_func (PaintCore *paint_core,
airbrush_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
int state)
{
GimpBrushP brush;
@ -236,16 +219,17 @@ airbrush_paint_func (PaintCore *paint_core,
timer_state = OFF;
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
if (airbrush_options->rate != 0.0)
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
break;
case FINISH_PAINT :
@ -280,7 +264,8 @@ airbrush_time_out (gpointer client_data)
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable,
airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
gdisplays_flush ();
/* restart the timer */

View File

@ -50,10 +50,6 @@ struct _EraserOptions
gboolean hard_d;
GtkWidget *hard_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
gboolean anti_erase;
gboolean anti_erase_d;
GtkWidget *anti_erase_w;
@ -84,8 +80,8 @@ eraser_options_reset (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
}
static EraserOptions *
@ -101,7 +97,6 @@ eraser_options_new (void)
ERASER,
eraser_options_reset);
options->hard = options->hard_d = ERASER_DEFAULT_HARD;
options->incremental = options->incremental_d = ERASER_DEFAULT_INCREMENTAL;
options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE;
/* the main vbox */
@ -116,17 +111,7 @@ eraser_options_new (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_widget_show (options->hard_w);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* the anti_erase toggle */
options->anti_erase_w = gtk_check_button_new_with_label (_("Anti erase"));
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
@ -140,7 +125,6 @@ eraser_options_new (void)
return options;
}
static void
eraser_modifier_key_func (Tool *tool,
GdkEventKey *kevent,
@ -170,7 +154,11 @@ eraser_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental, eraser_options->anti_erase);
eraser_motion (paint_core,
drawable,
eraser_options->hard,
eraser_options->paint_options.incremental,
eraser_options->anti_erase);
break;
case FINISH_PAINT :
@ -305,20 +293,21 @@ eraser_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
gint hardness = ERASER_DEFAULT_HARD;
gint method = ERASER_DEFAULT_INCREMENTAL;
gint anti_erase = ERASER_DEFAULT_ANTI_ERASE;
gboolean hardness = ERASER_DEFAULT_HARD;
gboolean method = ERASER_DEFAULT_INCREMENTAL;
gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE;
EraserOptions *options = eraser_options;
if(options)
if (options)
{
hardness = options->hard;
method = options->incremental;
hardness = options->hard;
method = options->paint_options.incremental;
anti_erase = options->anti_erase;
}
return eraser_non_gui(drawable,num_strokes,stroke_array,hardness,method,anti_erase);
return eraser_non_gui (drawable, num_strokes, stroke_array,
hardness, method, anti_erase);
}
gboolean
@ -334,9 +323,9 @@ eraser_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_hard = hardness;
non_gui_hard = hardness;
non_gui_incremental = method;
non_gui_anti_erase = anti_erase;
non_gui_anti_erase = anti_erase;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;

View File

@ -37,22 +37,12 @@
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
static PencilOptions *pencil_options = NULL;
static PaintOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_incremental = FALSE;
#define PENCIL_INCREMENTAL_DEFAULT FALSE
@ -85,7 +75,7 @@ pencil_paint_func (PaintCore *paint_core,
void
pencil_options_reset (void)
{
paint_options_reset (&pencil_options->paint_options);
paint_options_reset (pencil_options);
}
Tool *
@ -172,10 +162,10 @@ pencil_motion (PaintCore *paint_core,
static void *
pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental );
pencil_motion (paint_core, drawable, non_gui_incremental);
return NULL;
}
@ -183,8 +173,8 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
gboolean
pencil_non_gui (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
int num_strokes,
double *stroke_array)
{
int i;

View File

@ -37,8 +37,12 @@ struct _PaintOptions
/* options used by all paint tools */
GtkObject *opacity_w;
GtkWidget *paint_mode_w;
/* the incremental toggle */
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};

View File

@ -70,10 +70,6 @@ struct _PaintbrushOptions
int gradient_type;
int gradient_type_d;
GtkWidget *gradient_type_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
/* the paint brush tool options */
@ -105,14 +101,15 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget,
if (paintbrush_options->use_gradient)
{
incremental_save = options->incremental;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
TRUE);
incremental_save = options->paint_options.incremental;
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w), TRUE);
}
else
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
incremental_save);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w),
incremental_save);
}
}
@ -140,8 +137,6 @@ paintbrush_options_reset (void)
options->gradient_length_d);
gtk_option_menu_set_history (GTK_OPTION_MENU (options->gradient_type_w),
options->gradient_type_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static PaintbrushOptions *
@ -178,8 +173,6 @@ paintbrush_options_new (void)
paintbrush_options_reset);
options->fade_out =
options->fade_out_d = PAINTBRUSH_DEFAULT_FADE_OUT;
options->incremental =
options->incremental_d = PAINTBRUSH_DEFAULT_INCREMENTAL;
options->use_gradient =
options->use_gradient_d = PAINTBRUSH_DEFAULT_USE_GRADIENT;
options->gradient_length =
@ -268,20 +261,13 @@ paintbrush_options_new (void)
gtk_option_menu_set_history (GTK_OPTION_MENU (options->gradient_type_w),
options->gradient_type_d);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
/* automatically set the sensitive state of the gradient stuff */
gtk_widget_set_sensitive (scale, options->use_gradient_d);
gtk_widget_set_sensitive (length_label, options->use_gradient_d);
gtk_widget_set_sensitive (options->gradient_type_w, options->use_gradient_d);
gtk_widget_set_sensitive (type_label, options->use_gradient_d);
gtk_widget_set_sensitive (options->incremental_w, ! options->use_gradient_d);
gtk_widget_set_sensitive (options->paint_options.incremental_w,
! options->use_gradient_d);
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "set_sensitive",
scale);
gtk_object_set_data (GTK_OBJECT (scale), "set_sensitive",
@ -291,7 +277,7 @@ paintbrush_options_new (void)
gtk_object_set_data (GTK_OBJECT (options->gradient_type_w), "set_sensitive",
type_label);
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "inverse_sensitive",
options->incremental_w);
options->paint_options.incremental_w);
return options;
}
@ -320,7 +306,7 @@ paintbrush_paint_func (PaintCore *paint_core,
paintbrush_options->fade_out,
paintbrush_options->use_gradient ?
exp(paintbrush_options->gradient_length/10) : 0,
paintbrush_options->incremental,
paintbrush_options->paint_options.incremental,
paintbrush_options->gradient_type);
break;
@ -378,12 +364,12 @@ tools_free_paintbrush (Tool *tool)
static void
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out,
double gradient_length,
PaintApplicationMode incremental,
GradientPaintMode gradient_type)
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out,
double gradient_length,
PaintApplicationMode incremental,
GradientPaintMode gradient_type)
{
GImage *gimage;
TempBuf * area;
@ -404,7 +390,6 @@ paintbrush_motion (PaintCore *paint_core,
/* silly hack to be removed later */
/* paint_core->brush = gimp_brush_list_get_brush_by_index(brush_list,(rand()% gimp_brush_list_length(brush_list))); */
/* Get a region which can be used to paint to */
@ -431,7 +416,7 @@ paintbrush_motion (PaintCore *paint_core,
/* need to make a gui to handle this */
mode = gradient_type;
if(gradient_length)
if (gradient_length)
{
paint_core_get_color_from_gradient (paint_core, gradient_length, &r,&g,&b,&a,mode);
r = r * 255.0;
@ -444,7 +429,7 @@ paintbrush_motion (PaintCore *paint_core,
col[2] = (gint)b;
/* always use incremental mode with gradients */
/* make the gui cool later */
incremental = INCREMENTAL;
paint_appl_mode = INCREMENTAL;
}
/* just leave this because I know as soon as i delete it i'll find a bug */
/* printf("temp_blend: %u grad_len: %f distance: %f \n",temp_blend, gradient_length, distance); */
@ -454,10 +439,10 @@ paintbrush_motion (PaintCore *paint_core,
/* we check to see if this is a pixmap, if so composite the
pixmap image into the are instead of the color */
if(GIMP_IS_BRUSH_PIXMAP(paint_core->brush) && !gradient_length)
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{
color_area_with_pixmap(gimage, drawable, area, paint_core->brush);
incremental = INCREMENTAL;
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
paint_appl_mode = INCREMENTAL;
}
else
{
@ -471,7 +456,7 @@ paintbrush_motion (PaintCore *paint_core,
(int) (gimp_context_get_opacity (NULL) * 255),
gimp_context_get_paint_mode (NULL),
PRESSURE,
incremental ? INCREMENTAL : CONSTANT);
paint_appl_mode);
}
}
@ -481,11 +466,11 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
paintbrush_motion(paint_core,drawable,
non_gui_fade_out,
(non_gui_gradient_length)?exp(non_gui_gradient_length/10):0,
non_gui_incremental,
non_gui_gradient_type);
paintbrush_motion (paint_core,drawable,
non_gui_fade_out,
(non_gui_gradient_length)?exp(non_gui_gradient_length/10):0,
non_gui_incremental,
non_gui_gradient_type);
return NULL;
}
@ -496,35 +481,35 @@ paintbrush_non_gui_default (GimpDrawable *drawable,
double *stroke_array)
{
PaintbrushOptions *options = paintbrush_options;
double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT;
gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
int use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT;
double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT;
gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
int use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT;
double gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH;
int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
int i;
if(options)
if (options)
{
fade_out = options->fade_out;
incremental = options->incremental;
use_gradient = options->use_gradient;
fade_out = options->fade_out;
incremental = options->paint_options.incremental;
use_gradient = options->use_gradient;
gradient_length = options->gradient_length;
gradient_type = options->gradient_type;
gradient_type = options->gradient_type;
}
if(use_gradient == 0)
gradient_length = 0.0;
if (use_gradient == 0)
gradient_length = 0.0;
/* Hmmm... PDB paintbrush should have gradient type added to it!*/
/* thats why the code below is duplicated.
*/
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = gradient_type;
non_gui_incremental = incremental;
non_gui_gradient_type = gradient_type;
non_gui_incremental = incremental;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
@ -570,10 +555,10 @@ paintbrush_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;

View File

@ -37,22 +37,12 @@
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
static PencilOptions *pencil_options = NULL;
static PaintOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_incremental = FALSE;
#define PENCIL_INCREMENTAL_DEFAULT FALSE
@ -85,7 +75,7 @@ pencil_paint_func (PaintCore *paint_core,
void
pencil_options_reset (void)
{
paint_options_reset (&pencil_options->paint_options);
paint_options_reset (pencil_options);
}
Tool *
@ -172,10 +162,10 @@ pencil_motion (PaintCore *paint_core,
static void *
pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental );
pencil_motion (paint_core, drawable, non_gui_incremental);
return NULL;
}
@ -183,8 +173,8 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
gboolean
pencil_non_gui (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
int num_strokes,
double *stroke_array)
{
int i;

View File

@ -38,9 +38,9 @@ tool_options_toggle_update (GtkWidget *widget,
gpointer data)
{
GtkWidget *set_sensitive;
int *toggle_val;
gboolean *toggle_val;
toggle_val = (int *) data;
toggle_val = (gboolean *) data;
*toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE;
/* a tool options toggle button can set the sensitive state of
@ -70,9 +70,9 @@ void
tool_options_int_adjustment_update (GtkWidget *widget,
gpointer data)
{
int *val;
gint *val;
val = (int *) data;
val = (gint *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -80,9 +80,9 @@ void
tool_options_double_adjustment_update (GtkWidget *widget,
gpointer data)
{
double *val;
gdouble *val;
val = (double *) data;
val = (gdouble *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -112,7 +112,7 @@ tool_options_unitmenu_update (GtkWidget *widget,
{
GUnit *val;
GtkWidget *spinbutton;
int digits;
gint digits;
val = (GUnit *) data;
*val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
@ -134,14 +134,15 @@ static void
tool_options_radio_buttons_update (GtkWidget *widget,
gpointer data)
{
int *toggle_val;
gint *toggle_val;
toggle_val = (int *) data;
toggle_val = (gint *) data;
if (GTK_TOGGLE_BUTTON (widget)->active)
*toggle_val = (int) gtk_object_get_data (GTK_OBJECT (widget), "toggle_value");
*toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget),
"toggle_value");
}
GtkWidget*
GtkWidget *
tool_options_radio_buttons_new (gchar* label,
gpointer toggle_val,
GtkWidget* button_widget[],
@ -154,7 +155,7 @@ tool_options_radio_buttons_new (gchar* label,
GSList *group = NULL;
gint i;
frame = gtk_frame_new (_(label));
frame = gtk_frame_new (label);
g_return_val_if_fail (toggle_val != NULL, frame);
@ -164,8 +165,8 @@ tool_options_radio_buttons_new (gchar* label,
for (i=0; i<num; i++)
{
button_widget[i] = gtk_radio_button_new_with_label (group,
gettext (button_label[i]));
button_widget[i] =
gtk_radio_button_new_with_label (group, gettext (button_label[i]));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button_widget[i]));
gtk_box_pack_start (GTK_BOX (vbox), button_widget[i], FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button_widget[i]), "toggled",
@ -189,7 +190,7 @@ tool_options_init (ToolOptions *options,
ToolOptionsResetFunc reset_func)
{
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->title = _(title);
options->title = title;
options->reset_func = reset_func;
}
@ -576,9 +577,12 @@ paint_options_init (PaintOptions *options,
reset_func);
/* initialize the paint options structure */
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental = options->incremental_d = FALSE;
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental_w = NULL;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 2);
@ -659,17 +663,72 @@ paint_options_init (PaintOptions *options,
/* show the main table */
gtk_widget_show (table);
/* a separator after the common paint options */
if (tool_type != PENCIL)
/* a separator after the common paint options which can be global */
switch (tool_type)
{
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
break;
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
break;
default:
break;
}
if (! global_paint_options)
gtk_widget_show (vbox);
/* the "incremental" toggle */
switch (tool_type)
{
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
options->incremental_w =
gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* a separator after the common paint options which can't be global */
if (tool_type != PENCIL)
{
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
}
break;
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;
}
/* register this Paintoptions structure */
paint_options_list = g_slist_prepend (paint_options_list, options);
}
@ -679,19 +738,10 @@ paint_options_new (ToolType tool_type,
ToolOptionsResetFunc reset_func)
{
PaintOptions *options;
GtkWidget *label;
options = g_new (PaintOptions, 1);
paint_options_init (options, tool_type, reset_func);
options->global = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->global, FALSE, FALSE, 0);
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options->global), label, FALSE, FALSE, 6);
gtk_widget_show (label);
if (global_paint_options && options->global)
gtk_widget_show (options->global);
@ -721,6 +771,11 @@ paint_options_reset (PaintOptions *options)
gtk_option_menu_set_history (GTK_OPTION_MENU (options->paint_mode_w),
gimp_context_get_paint_mode (default_context));
}
if (options->incremental_w)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(options->incremental_w),
options->incremental_d);
}
}

View File

@ -40,7 +40,7 @@
#define MAX_PRESSURE 0.075
/* Default pressure setting */
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_INCREMENTAL_DEFAULT FALSE
#define OFF 0
@ -51,7 +51,7 @@
typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
PaintCore *paint_core;
PaintCore *paint_core;
GimpDrawable *drawable;
};
@ -67,10 +67,6 @@ struct _AirbrushOptions
double pressure;
double pressure_d;
GtkObject *pressure_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
@ -103,9 +99,6 @@ airbrush_options_reset (void)
options->rate_d);
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->pressure_w),
options->pressure_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static AirbrushOptions *
@ -125,8 +118,6 @@ airbrush_options_new (void)
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
options->incremental =
options->incremental_d = AIRBRUSH_INCREMENTAL_DEFAULT;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
@ -172,14 +163,6 @@ airbrush_options_new (void)
&options->pressure);
gtk_widget_show (scale);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
gtk_widget_show (table);
return options;
@ -208,9 +191,9 @@ tools_new_airbrush ()
}
void *
airbrush_paint_func (PaintCore *paint_core,
airbrush_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
int state)
{
GimpBrushP brush;
@ -236,16 +219,17 @@ airbrush_paint_func (PaintCore *paint_core,
timer_state = OFF;
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
if (airbrush_options->rate != 0.0)
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
break;
case FINISH_PAINT :
@ -280,7 +264,8 @@ airbrush_time_out (gpointer client_data)
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable,
airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
gdisplays_flush ();
/* restart the timer */

View File

@ -50,10 +50,6 @@ struct _EraserOptions
gboolean hard_d;
GtkWidget *hard_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
gboolean anti_erase;
gboolean anti_erase_d;
GtkWidget *anti_erase_w;
@ -84,8 +80,8 @@ eraser_options_reset (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
}
static EraserOptions *
@ -101,7 +97,6 @@ eraser_options_new (void)
ERASER,
eraser_options_reset);
options->hard = options->hard_d = ERASER_DEFAULT_HARD;
options->incremental = options->incremental_d = ERASER_DEFAULT_INCREMENTAL;
options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE;
/* the main vbox */
@ -116,17 +111,7 @@ eraser_options_new (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_widget_show (options->hard_w);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* the anti_erase toggle */
options->anti_erase_w = gtk_check_button_new_with_label (_("Anti erase"));
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
@ -140,7 +125,6 @@ eraser_options_new (void)
return options;
}
static void
eraser_modifier_key_func (Tool *tool,
GdkEventKey *kevent,
@ -170,7 +154,11 @@ eraser_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental, eraser_options->anti_erase);
eraser_motion (paint_core,
drawable,
eraser_options->hard,
eraser_options->paint_options.incremental,
eraser_options->anti_erase);
break;
case FINISH_PAINT :
@ -305,20 +293,21 @@ eraser_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
gint hardness = ERASER_DEFAULT_HARD;
gint method = ERASER_DEFAULT_INCREMENTAL;
gint anti_erase = ERASER_DEFAULT_ANTI_ERASE;
gboolean hardness = ERASER_DEFAULT_HARD;
gboolean method = ERASER_DEFAULT_INCREMENTAL;
gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE;
EraserOptions *options = eraser_options;
if(options)
if (options)
{
hardness = options->hard;
method = options->incremental;
hardness = options->hard;
method = options->paint_options.incremental;
anti_erase = options->anti_erase;
}
return eraser_non_gui(drawable,num_strokes,stroke_array,hardness,method,anti_erase);
return eraser_non_gui (drawable, num_strokes, stroke_array,
hardness, method, anti_erase);
}
gboolean
@ -334,9 +323,9 @@ eraser_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_hard = hardness;
non_gui_hard = hardness;
non_gui_incremental = method;
non_gui_anti_erase = anti_erase;
non_gui_anti_erase = anti_erase;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;

View File

@ -40,7 +40,7 @@
#define MAX_PRESSURE 0.075
/* Default pressure setting */
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define AIRBRUSH_INCREMENTAL_DEFAULT FALSE
#define OFF 0
@ -51,7 +51,7 @@
typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
PaintCore *paint_core;
PaintCore *paint_core;
GimpDrawable *drawable;
};
@ -67,10 +67,6 @@ struct _AirbrushOptions
double pressure;
double pressure_d;
GtkObject *pressure_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
@ -103,9 +99,6 @@ airbrush_options_reset (void)
options->rate_d);
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->pressure_w),
options->pressure_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static AirbrushOptions *
@ -125,8 +118,6 @@ airbrush_options_new (void)
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
options->incremental =
options->incremental_d = AIRBRUSH_INCREMENTAL_DEFAULT;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
@ -172,14 +163,6 @@ airbrush_options_new (void)
&options->pressure);
gtk_widget_show (scale);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
gtk_widget_show (table);
return options;
@ -208,9 +191,9 @@ tools_new_airbrush ()
}
void *
airbrush_paint_func (PaintCore *paint_core,
airbrush_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
int state)
{
GimpBrushP brush;
@ -236,16 +219,17 @@ airbrush_paint_func (PaintCore *paint_core,
timer_state = OFF;
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
if (airbrush_options->rate != 0.0)
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
}
break;
case FINISH_PAINT :
@ -280,7 +264,8 @@ airbrush_time_out (gpointer client_data)
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable,
airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
airbrush_options->paint_options.incremental ?
INCREMENTAL : CONSTANT);
gdisplays_flush ();
/* restart the timer */

View File

@ -50,10 +50,6 @@ struct _EraserOptions
gboolean hard_d;
GtkWidget *hard_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
gboolean anti_erase;
gboolean anti_erase_d;
GtkWidget *anti_erase_w;
@ -84,8 +80,8 @@ eraser_options_reset (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
options->anti_erase_d);
}
static EraserOptions *
@ -101,7 +97,6 @@ eraser_options_new (void)
ERASER,
eraser_options_reset);
options->hard = options->hard_d = ERASER_DEFAULT_HARD;
options->incremental = options->incremental_d = ERASER_DEFAULT_INCREMENTAL;
options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE;
/* the main vbox */
@ -116,17 +111,7 @@ eraser_options_new (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
options->hard_d);
gtk_widget_show (options->hard_w);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* the anti_erase toggle */
options->anti_erase_w = gtk_check_button_new_with_label (_("Anti erase"));
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
@ -140,7 +125,6 @@ eraser_options_new (void)
return options;
}
static void
eraser_modifier_key_func (Tool *tool,
GdkEventKey *kevent,
@ -170,7 +154,11 @@ eraser_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental, eraser_options->anti_erase);
eraser_motion (paint_core,
drawable,
eraser_options->hard,
eraser_options->paint_options.incremental,
eraser_options->anti_erase);
break;
case FINISH_PAINT :
@ -305,20 +293,21 @@ eraser_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
gint hardness = ERASER_DEFAULT_HARD;
gint method = ERASER_DEFAULT_INCREMENTAL;
gint anti_erase = ERASER_DEFAULT_ANTI_ERASE;
gboolean hardness = ERASER_DEFAULT_HARD;
gboolean method = ERASER_DEFAULT_INCREMENTAL;
gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE;
EraserOptions *options = eraser_options;
if(options)
if (options)
{
hardness = options->hard;
method = options->incremental;
hardness = options->hard;
method = options->paint_options.incremental;
anti_erase = options->anti_erase;
}
return eraser_non_gui(drawable,num_strokes,stroke_array,hardness,method,anti_erase);
return eraser_non_gui (drawable, num_strokes, stroke_array,
hardness, method, anti_erase);
}
gboolean
@ -334,9 +323,9 @@ eraser_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_hard = hardness;
non_gui_hard = hardness;
non_gui_incremental = method;
non_gui_anti_erase = anti_erase;
non_gui_anti_erase = anti_erase;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;

View File

@ -37,8 +37,12 @@ struct _PaintOptions
/* options used by all paint tools */
GtkObject *opacity_w;
GtkWidget *paint_mode_w;
/* the incremental toggle */
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};

View File

@ -37,22 +37,12 @@
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
static PencilOptions *pencil_options = NULL;
static PaintOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_incremental = FALSE;
#define PENCIL_INCREMENTAL_DEFAULT FALSE
@ -85,7 +75,7 @@ pencil_paint_func (PaintCore *paint_core,
void
pencil_options_reset (void)
{
paint_options_reset (&pencil_options->paint_options);
paint_options_reset (pencil_options);
}
Tool *
@ -172,10 +162,10 @@ pencil_motion (PaintCore *paint_core,
static void *
pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental );
pencil_motion (paint_core, drawable, non_gui_incremental);
return NULL;
}
@ -183,8 +173,8 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
gboolean
pencil_non_gui (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
int num_strokes,
double *stroke_array)
{
int i;

View File

@ -37,8 +37,12 @@ struct _PaintOptions
/* options used by all paint tools */
GtkObject *opacity_w;
GtkWidget *paint_mode_w;
/* the incremental toggle */
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};

View File

@ -70,10 +70,6 @@ struct _PaintbrushOptions
int gradient_type;
int gradient_type_d;
GtkWidget *gradient_type_w;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
/* the paint brush tool options */
@ -105,14 +101,15 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget,
if (paintbrush_options->use_gradient)
{
incremental_save = options->incremental;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
TRUE);
incremental_save = options->paint_options.incremental;
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w), TRUE);
}
else
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
incremental_save);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w),
incremental_save);
}
}
@ -140,8 +137,6 @@ paintbrush_options_reset (void)
options->gradient_length_d);
gtk_option_menu_set_history (GTK_OPTION_MENU (options->gradient_type_w),
options->gradient_type_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
}
static PaintbrushOptions *
@ -178,8 +173,6 @@ paintbrush_options_new (void)
paintbrush_options_reset);
options->fade_out =
options->fade_out_d = PAINTBRUSH_DEFAULT_FADE_OUT;
options->incremental =
options->incremental_d = PAINTBRUSH_DEFAULT_INCREMENTAL;
options->use_gradient =
options->use_gradient_d = PAINTBRUSH_DEFAULT_USE_GRADIENT;
options->gradient_length =
@ -268,20 +261,13 @@ paintbrush_options_new (void)
gtk_option_menu_set_history (GTK_OPTION_MENU (options->gradient_type_w),
options->gradient_type_d);
/* the incremental toggle */
options->incremental_w = gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (vbox), options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_widget_show (options->incremental_w);
/* automatically set the sensitive state of the gradient stuff */
gtk_widget_set_sensitive (scale, options->use_gradient_d);
gtk_widget_set_sensitive (length_label, options->use_gradient_d);
gtk_widget_set_sensitive (options->gradient_type_w, options->use_gradient_d);
gtk_widget_set_sensitive (type_label, options->use_gradient_d);
gtk_widget_set_sensitive (options->incremental_w, ! options->use_gradient_d);
gtk_widget_set_sensitive (options->paint_options.incremental_w,
! options->use_gradient_d);
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "set_sensitive",
scale);
gtk_object_set_data (GTK_OBJECT (scale), "set_sensitive",
@ -291,7 +277,7 @@ paintbrush_options_new (void)
gtk_object_set_data (GTK_OBJECT (options->gradient_type_w), "set_sensitive",
type_label);
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "inverse_sensitive",
options->incremental_w);
options->paint_options.incremental_w);
return options;
}
@ -320,7 +306,7 @@ paintbrush_paint_func (PaintCore *paint_core,
paintbrush_options->fade_out,
paintbrush_options->use_gradient ?
exp(paintbrush_options->gradient_length/10) : 0,
paintbrush_options->incremental,
paintbrush_options->paint_options.incremental,
paintbrush_options->gradient_type);
break;
@ -378,12 +364,12 @@ tools_free_paintbrush (Tool *tool)
static void
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out,
double gradient_length,
PaintApplicationMode incremental,
GradientPaintMode gradient_type)
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out,
double gradient_length,
PaintApplicationMode incremental,
GradientPaintMode gradient_type)
{
GImage *gimage;
TempBuf * area;
@ -404,7 +390,6 @@ paintbrush_motion (PaintCore *paint_core,
/* silly hack to be removed later */
/* paint_core->brush = gimp_brush_list_get_brush_by_index(brush_list,(rand()% gimp_brush_list_length(brush_list))); */
/* Get a region which can be used to paint to */
@ -431,7 +416,7 @@ paintbrush_motion (PaintCore *paint_core,
/* need to make a gui to handle this */
mode = gradient_type;
if(gradient_length)
if (gradient_length)
{
paint_core_get_color_from_gradient (paint_core, gradient_length, &r,&g,&b,&a,mode);
r = r * 255.0;
@ -444,7 +429,7 @@ paintbrush_motion (PaintCore *paint_core,
col[2] = (gint)b;
/* always use incremental mode with gradients */
/* make the gui cool later */
incremental = INCREMENTAL;
paint_appl_mode = INCREMENTAL;
}
/* just leave this because I know as soon as i delete it i'll find a bug */
/* printf("temp_blend: %u grad_len: %f distance: %f \n",temp_blend, gradient_length, distance); */
@ -454,10 +439,10 @@ paintbrush_motion (PaintCore *paint_core,
/* we check to see if this is a pixmap, if so composite the
pixmap image into the are instead of the color */
if(GIMP_IS_BRUSH_PIXMAP(paint_core->brush) && !gradient_length)
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{
color_area_with_pixmap(gimage, drawable, area, paint_core->brush);
incremental = INCREMENTAL;
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
paint_appl_mode = INCREMENTAL;
}
else
{
@ -471,7 +456,7 @@ paintbrush_motion (PaintCore *paint_core,
(int) (gimp_context_get_opacity (NULL) * 255),
gimp_context_get_paint_mode (NULL),
PRESSURE,
incremental ? INCREMENTAL : CONSTANT);
paint_appl_mode);
}
}
@ -481,11 +466,11 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
paintbrush_motion(paint_core,drawable,
non_gui_fade_out,
(non_gui_gradient_length)?exp(non_gui_gradient_length/10):0,
non_gui_incremental,
non_gui_gradient_type);
paintbrush_motion (paint_core,drawable,
non_gui_fade_out,
(non_gui_gradient_length)?exp(non_gui_gradient_length/10):0,
non_gui_incremental,
non_gui_gradient_type);
return NULL;
}
@ -496,35 +481,35 @@ paintbrush_non_gui_default (GimpDrawable *drawable,
double *stroke_array)
{
PaintbrushOptions *options = paintbrush_options;
double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT;
gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
int use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT;
double fade_out = PAINTBRUSH_DEFAULT_FADE_OUT;
gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
int use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT;
double gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH;
int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
int gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
int i;
if(options)
if (options)
{
fade_out = options->fade_out;
incremental = options->incremental;
use_gradient = options->use_gradient;
fade_out = options->fade_out;
incremental = options->paint_options.incremental;
use_gradient = options->use_gradient;
gradient_length = options->gradient_length;
gradient_type = options->gradient_type;
gradient_type = options->gradient_type;
}
if(use_gradient == 0)
gradient_length = 0.0;
if (use_gradient == 0)
gradient_length = 0.0;
/* Hmmm... PDB paintbrush should have gradient type added to it!*/
/* thats why the code below is duplicated.
*/
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = gradient_type;
non_gui_incremental = incremental;
non_gui_gradient_type = gradient_type;
non_gui_incremental = incremental;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
@ -570,10 +555,10 @@ paintbrush_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;

View File

@ -37,22 +37,12 @@
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
gboolean incremental;
gboolean incremental_d;
GtkWidget *incremental_w;
};
static PencilOptions *pencil_options = NULL;
static PaintOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_incremental = FALSE;
#define PENCIL_INCREMENTAL_DEFAULT FALSE
@ -85,7 +75,7 @@ pencil_paint_func (PaintCore *paint_core,
void
pencil_options_reset (void)
{
paint_options_reset (&pencil_options->paint_options);
paint_options_reset (pencil_options);
}
Tool *
@ -172,10 +162,10 @@ pencil_motion (PaintCore *paint_core,
static void *
pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental );
pencil_motion (paint_core, drawable, non_gui_incremental);
return NULL;
}
@ -183,8 +173,8 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
gboolean
pencil_non_gui (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
int num_strokes,
double *stroke_array)
{
int i;

View File

@ -38,9 +38,9 @@ tool_options_toggle_update (GtkWidget *widget,
gpointer data)
{
GtkWidget *set_sensitive;
int *toggle_val;
gboolean *toggle_val;
toggle_val = (int *) data;
toggle_val = (gboolean *) data;
*toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE;
/* a tool options toggle button can set the sensitive state of
@ -70,9 +70,9 @@ void
tool_options_int_adjustment_update (GtkWidget *widget,
gpointer data)
{
int *val;
gint *val;
val = (int *) data;
val = (gint *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -80,9 +80,9 @@ void
tool_options_double_adjustment_update (GtkWidget *widget,
gpointer data)
{
double *val;
gdouble *val;
val = (double *) data;
val = (gdouble *) data;
*val = GTK_ADJUSTMENT (widget)->value;
}
@ -112,7 +112,7 @@ tool_options_unitmenu_update (GtkWidget *widget,
{
GUnit *val;
GtkWidget *spinbutton;
int digits;
gint digits;
val = (GUnit *) data;
*val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
@ -134,14 +134,15 @@ static void
tool_options_radio_buttons_update (GtkWidget *widget,
gpointer data)
{
int *toggle_val;
gint *toggle_val;
toggle_val = (int *) data;
toggle_val = (gint *) data;
if (GTK_TOGGLE_BUTTON (widget)->active)
*toggle_val = (int) gtk_object_get_data (GTK_OBJECT (widget), "toggle_value");
*toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget),
"toggle_value");
}
GtkWidget*
GtkWidget *
tool_options_radio_buttons_new (gchar* label,
gpointer toggle_val,
GtkWidget* button_widget[],
@ -154,7 +155,7 @@ tool_options_radio_buttons_new (gchar* label,
GSList *group = NULL;
gint i;
frame = gtk_frame_new (_(label));
frame = gtk_frame_new (label);
g_return_val_if_fail (toggle_val != NULL, frame);
@ -164,8 +165,8 @@ tool_options_radio_buttons_new (gchar* label,
for (i=0; i<num; i++)
{
button_widget[i] = gtk_radio_button_new_with_label (group,
gettext (button_label[i]));
button_widget[i] =
gtk_radio_button_new_with_label (group, gettext (button_label[i]));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button_widget[i]));
gtk_box_pack_start (GTK_BOX (vbox), button_widget[i], FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button_widget[i]), "toggled",
@ -189,7 +190,7 @@ tool_options_init (ToolOptions *options,
ToolOptionsResetFunc reset_func)
{
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->title = _(title);
options->title = title;
options->reset_func = reset_func;
}
@ -576,9 +577,12 @@ paint_options_init (PaintOptions *options,
reset_func);
/* initialize the paint options structure */
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental = options->incremental_d = FALSE;
options->global = NULL;
options->opacity_w = NULL;
options->paint_mode_w = NULL;
options->incremental_w = NULL;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 2);
@ -659,17 +663,72 @@ paint_options_init (PaintOptions *options,
/* show the main table */
gtk_widget_show (table);
/* a separator after the common paint options */
if (tool_type != PENCIL)
/* a separator after the common paint options which can be global */
switch (tool_type)
{
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
break;
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
break;
default:
break;
}
if (! global_paint_options)
gtk_widget_show (vbox);
/* the "incremental" toggle */
switch (tool_type)
{
case AIRBRUSH:
case ERASER:
case PAINTBRUSH:
case PENCIL:
options->incremental_w =
gtk_check_button_new_with_label (_("Incremental"));
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->incremental_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled",
(GtkSignalFunc) tool_options_toggle_update,
&options->incremental);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w),
options->incremental_d);
gtk_widget_show (options->incremental_w);
/* a separator after the common paint options which can't be global */
if (tool_type != PENCIL)
{
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
}
break;
case BUCKET_FILL:
case BLEND:
case CLONE:
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;
}
/* register this Paintoptions structure */
paint_options_list = g_slist_prepend (paint_options_list, options);
}
@ -679,19 +738,10 @@ paint_options_new (ToolType tool_type,
ToolOptionsResetFunc reset_func)
{
PaintOptions *options;
GtkWidget *label;
options = g_new (PaintOptions, 1);
paint_options_init (options, tool_type, reset_func);
options->global = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox),
options->global, FALSE, FALSE, 0);
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options->global), label, FALSE, FALSE, 6);
gtk_widget_show (label);
if (global_paint_options && options->global)
gtk_widget_show (options->global);
@ -721,6 +771,11 @@ paint_options_reset (PaintOptions *options)
gtk_option_menu_set_history (GTK_OPTION_MENU (options->paint_mode_w),
gimp_context_get_paint_mode (default_context));
}
if (options->incremental_w)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(options->incremental_w),
options->incremental_d);
}
}

View File

@ -121,8 +121,8 @@ layer_size (Layer *layer)
GIMP_DRAWABLE(layer)->width * GIMP_DRAWABLE(layer)->height * GIMP_DRAWABLE(layer)->bytes +
strlen (GIMP_DRAWABLE(layer)->name);
if (layer_mask (layer))
size += channel_size (GIMP_CHANNEL (layer_mask (layer)));
if (layer_get_mask (layer))
size += channel_size (GIMP_CHANNEL (layer_get_mask (layer)));
return size;
}

49
app/widgets/gimpdnd.h Normal file
View File

@ -0,0 +1,49 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DND_H__
#define __GIMP_DND_H__
enum
{
GIMP_DND_TYPE_URI_LIST,
GIMP_DND_TYPE_TEXT_PLAIN,
GIMP_DND_TYPE_NETSCAPE_URL,
GIMP_DND_TYPE_LAYER,
GIMP_DND_TYPE_CHANNEL,
GIMP_DND_TYPE_LAYER_MASK
};
#define GIMP_TARGET_URI_LIST \
{ "text/uri-list", 0, GIMP_DND_TYPE_URI_LIST }
#define GIMP_TARGET_TEXT_PLAIN \
{ "text/plain", 0, GIMP_DND_TYPE_TEXT_PLAIN }
#define GIMP_TARGET_NETSCAPE_URL \
{ "_NETSCAPE_URL", 0, GIMP_DND_TYPE_NETSCAPE_URL }
#define GIMP_TARGET_LAYER \
{ "GIMP_LAYER", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER }
#define GIMP_TARGET_CHANNEL \
{ "GIMP_CHANNEL", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_CHANNEL }
#define GIMP_TARGET_LAYER_MASK \
{ "GIMP_LAYER_MASK", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER_MASK }
#endif /* __GIMP_DND_H__ */