export bucket_fill_region().

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

	* app/bucket_fill.[ch]: export bucket_fill_region().

	* app/channels_dialog.c: enabled dropping a color to a channel.

	* app/color_area.c
	* app/color_panel.c
	* app/gimpdnd.[ch]: the whole color dnd is now done in a generic
	function in gimpdnd.c (dnd of other types is still hacked in at
	various places but will go to generic functions and callbacks as
	well).

	* app/disp_callbacks.[ch]
	* app/interface.c: drop a color to the display to bucket fill the
	selected region.
This commit is contained in:
Michael Natterer 1999-08-23 14:19:26 +00:00 committed by Michael Natterer
parent 5f2d497b40
commit ef4cb06bb7
28 changed files with 1225 additions and 1003 deletions

View File

@ -1,3 +1,20 @@
1999-08-23 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/bucket_fill.[ch]: export bucket_fill_region().
* app/channels_dialog.c: enabled dropping a color to a channel.
* app/color_area.c
* app/color_panel.c
* app/gimpdnd.[ch]: the whole color dnd is now done in a generic
function in gimpdnd.c (dnd of other types is still hacked in at
various places but will go to generic functions and callbacks as
well).
* app/disp_callbacks.[ch]
* app/interface.c: drop a color to the display to bucket fill the
selected region.
Mon Aug 23 02:19:12 1999 Jay Cox (jaycox@earthlink.net)
* app/paint_funcs.c: fixed a couple of bugs in the scale_region code.

View File

@ -42,8 +42,8 @@
typedef struct _BucketTool BucketTool;
struct _BucketTool
{
int target_x; /* starting x coord */
int target_y; /* starting y coord */
gint target_x; /* starting x coord */
gint target_y; /* starting y coord */
};
typedef struct _BucketOptions BucketOptions;
@ -51,12 +51,12 @@ struct _BucketOptions
{
PaintOptions paint_options;
double threshold;
double threshold_d;
gdouble threshold;
gdouble threshold_d;
GtkObject *threshold_w;
int sample_merged;
int sample_merged_d;
gboolean sample_merged;
gboolean sample_merged_d;
GtkWidget *sample_merged_w;
BucketFillMode fill_mode;
@ -75,13 +75,10 @@ static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void bucket_fill_region (BucketFillMode, PixelRegion *,
PixelRegion *, unsigned char *,
TempBuf *, int, int, int);
static void bucket_fill_line_color (unsigned char *, unsigned char *,
unsigned char *, int, int, int);
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
TempBuf *, int, int, int, int, int);
static void bucket_fill_line_color (guchar *, guchar *, guchar *,
gboolean, gint, gint);
static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *,
gboolean, gint, gint, gint, gint);
/* functions */
@ -183,7 +180,7 @@ bucket_fill_button_press (Tool *tool,
{
GDisplay * gdisp;
BucketTool * bucket_tool;
int use_offsets;
gboolean use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -196,7 +193,9 @@ bucket_fill_button_press (Tool *tool,
/* Make the tool active and set the gdisplay which owns it */
gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
/* Make the tool active and set the gdisplay which owns it */
@ -212,7 +211,7 @@ bucket_fill_button_release (Tool *tool,
GDisplay * gdisp;
BucketTool * bucket_tool;
Argument *return_vals;
int nreturn_vals;
gint nreturn_vals;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -255,8 +254,8 @@ bucket_fill_cursor_update (Tool *tool,
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
int off_x, off_y;
gint x, y;
gint off_x, off_y;
gdisp = (GDisplay *) gdisp_ptr;
@ -311,23 +310,24 @@ void
bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
int paint_mode,
double opacity,
double threshold,
int sample_merged,
double x,
double y)
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y)
{
TileManager *buf_tiles;
PixelRegion bufPR, maskPR;
Channel *mask = NULL;
int bytes, has_alpha;
int x1, y1, x2, y2;
unsigned char col [MAX_CHANNELS];
unsigned char *d1, *d2;
gint bytes;
gboolean has_alpha;
gint x1, y1, x2, y2;
guchar col [MAX_CHANNELS];
guchar *d1, *d2;
GPatternP pattern;
TempBuf *pat_buf;
int new_buf = 0;
gboolean new_buf = FALSE;
pat_buf = NULL;
@ -370,7 +370,7 @@ bucket_fill (GimpImage *gimage,
d2 += pat_buf->bytes;
}
new_buf = 1;
new_buf = TRUE;
}
else
pat_buf = pattern->mask;
@ -423,7 +423,7 @@ bucket_fill (GimpImage *gimage,
if (! has_alpha)
{
bytes ++;
has_alpha = 1;
has_alpha = TRUE;
}
}
@ -455,16 +455,15 @@ bucket_fill (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
static void
bucket_fill_line_color (unsigned char *buf,
unsigned char *mask,
unsigned char *col,
int has_alpha,
int bytes,
int width)
bucket_fill_line_color (guchar *buf,
guchar *mask,
guchar *col,
gboolean has_alpha,
gint bytes,
gint width)
{
int alpha, b;
gint alpha, b;
alpha = (has_alpha) ? bytes - 1 : bytes;
while (width--)
@ -484,20 +483,19 @@ bucket_fill_line_color (unsigned char *buf,
}
}
static void
bucket_fill_line_pattern (unsigned char *buf,
unsigned char *mask,
bucket_fill_line_pattern (guchar *buf,
guchar *mask,
TempBuf *pattern,
int has_alpha,
int bytes,
int x,
int y,
int width)
gboolean has_alpha,
gint bytes,
gint x,
gint y,
gint width)
{
unsigned char *pat, *p;
int alpha, b;
int i;
guchar *pat, *p;
gint alpha, b;
gint i;
/* Get a pointer to the appropriate scanline of the pattern buffer */
pat = temp_buf_data (pattern) +
@ -523,22 +521,23 @@ bucket_fill_line_pattern (unsigned char *buf,
}
}
static void
void
bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
unsigned char *col,
guchar *col,
TempBuf *pattern,
int off_x,
int off_y,
int has_alpha)
gint off_x,
gint off_y,
gboolean has_alpha)
{
unsigned char *s, *m;
int y;
guchar *s, *m;
gint y;
void *pr;
for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (2, bufPR, maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
s = bufPR->data;
if (maskPR)

View File

@ -29,10 +29,26 @@ typedef enum
PATTERN_BUCKET_FILL
} BucketFillMode;
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
double, double, int, double, double);
void bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
void bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
guchar *col,
TempBuf *pattern,
gint off_x,
gint off_y,
gboolean has_alpha);
Tool * tools_new_bucket_fill (void);
void tools_free_bucket_fill (Tool *);
void tools_free_bucket_fill (Tool *tool);
#endif /* __BUCKET_FILL_H__ */

View File

@ -156,6 +156,8 @@ static void channel_widget_drag_leave_callback (GtkWidget *,
guint);
static void channel_widget_drag_indicator_callback (GtkWidget *, gpointer);
static void channel_widget_set_color (gpointer,
guchar, guchar, guchar);
static void channel_widget_draw_drop_indicator (ChannelWidget *, GimpDropType);
static void channel_widget_delete (ChannelWidget *);
static void channel_widget_select_update (GtkWidget *, gpointer);
@ -214,6 +216,14 @@ static OpsButton channels_ops_buttons[] =
/* dnd structures */
static GtkTargetEntry channel_color_target_table[] =
{
GIMP_TARGET_CHANNEL,
GIMP_TARGET_COLOR
};
static guint n_channel_color_targets = (sizeof (channel_color_target_table) /
sizeof (channel_color_target_table[0]));
static GtkTargetEntry channel_target_table[] =
{
GIMP_TARGET_CHANNEL
@ -829,10 +839,10 @@ static gint
channel_list_events (GtkWidget *widget,
GdkEvent *event)
{
ChannelWidget *channel_widget;
GdkEventKey *kevent;
GdkEventButton *bevent;
GtkWidget *event_widget;
ChannelWidget *channel_widget;
event_widget = gtk_get_event_widget (event);
@ -843,9 +853,13 @@ channel_list_events (GtkWidget *widget,
switch (event->type)
{
case GDK_2BUTTON_PRESS:
if (channel_widget->type == AUXILLARY_CHANNEL)
channels_dialog_edit_channel_query (channel_widget);
return TRUE;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
if (bevent->button == 3 || bevent->button == 2)
{
gtk_menu_popup (GTK_MENU (channelsD->ops_menu),
@ -855,11 +869,6 @@ channel_list_events (GtkWidget *widget,
}
break;
case GDK_2BUTTON_PRESS:
if (channel_widget->type == AUXILLARY_CHANNEL)
channels_dialog_edit_channel_query (channel_widget);
return TRUE;
case GDK_KEY_PRESS:
kevent = (GdkEventKey *) event;
switch (kevent->keyval)
@ -1375,8 +1384,11 @@ channel_widget_create (GImage *gimage,
/* dnd destination */
gtk_drag_dest_set (list_item,
GTK_DEST_DEFAULT_ALL,
channel_target_table, n_channel_targets,
GDK_ACTION_MOVE);
channel_color_target_table, n_channel_color_targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gimp_dnd_color_dest_set (list_item,
channel_widget_set_color,
(gpointer) channel_widget);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_leave",
GTK_SIGNAL_FUNC (channel_widget_drag_leave_callback),
@ -1489,6 +1501,13 @@ channel_widget_drag_motion_callback (GtkWidget *widget,
drop_type = GIMP_DROP_NONE;
}
}
else if (gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_dnd_get_color_func"))
{
drag_action = GDK_ACTION_COPY;
return_val = TRUE;
drop_type = GIMP_DROP_NONE;
}
}
gdk_drag_status (context, drag_action, time);
@ -1610,6 +1629,30 @@ channel_widget_drag_indicator_callback (GtkWidget *widget,
channel_widget_draw_drop_indicator (channel_widget, channel_widget->drop_type);
}
static void
channel_widget_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
ChannelWidget *channel_widget = (ChannelWidget *) data;
Channel *channel = channel_widget->channel;
if (r != channel->col[0] ||
g != channel->col[1] ||
b != channel->col[2])
{
channel->col[0] = r;
channel->col[1] = g;
channel->col[2] = b;
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
gdisplays_flush ();
}
}
static void
channel_widget_draw_drop_indicator (ChannelWidget *channel_widget,
GimpDropType drop_type)
@ -1696,16 +1739,17 @@ static gint
channel_widget_button_events (GtkWidget *widget,
GdkEvent *event)
{
static int button_down = 0;
static GtkWidget *click_widget = NULL;
static int old_state;
static int exclusive;
ChannelWidget *channel_widget;
GtkWidget *event_widget;
GdkEventButton *bevent;
gint return_val;
int visible;
int width, height;
gint visible;
gint width, height;
static gboolean button_down = FALSE;
static GtkWidget *click_widget = NULL;
static gint old_state;
static gint exclusive;
channel_widget = (ChannelWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1745,7 +1789,7 @@ channel_widget_button_events (GtkWidget *widget,
return TRUE;
}
button_down = 1;
button_down = TRUE;
click_widget = widget;
gtk_grab_add (click_widget);
@ -1775,7 +1819,7 @@ channel_widget_button_events (GtkWidget *widget,
case GDK_BUTTON_RELEASE:
return_val = TRUE;
button_down = 0;
button_down = FALSE;
gtk_grab_remove (click_widget);
if (widget == channel_widget->eye_widget)
@ -1829,10 +1873,10 @@ static gint
channel_widget_preview_events (GtkWidget *widget,
GdkEvent *event)
{
ChannelWidget *channel_widget;
GdkEventExpose *eevent;
GdkEventButton *bevent;
ChannelWidget *channel_widget;
int valid;
gboolean valid;
channel_widget = (ChannelWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1902,8 +1946,8 @@ static void
channel_widget_preview_redraw (ChannelWidget *channel_widget)
{
TempBuf * preview_buf;
int width, height;
int channel;
gint width, height;
gint channel;
/* allocate the channel widget pixmap */
if (! channel_widget->channel_pixmap)
@ -2040,7 +2084,7 @@ channel_widget_eye_redraw (ChannelWidget *channel_widget)
GdkPixmap *pixmap;
GdkColor *color;
GtkStateType state;
int visible;
gboolean visible;
state = channel_widget->list_item->state;
@ -2062,7 +2106,8 @@ channel_widget_eye_redraw (ChannelWidget *channel_widget)
visible = GIMP_DRAWABLE (channel_widget->channel)->visible;
break;
default:
visible = gimage_get_component_visible (channel_widget->gimage, channel_widget->type);
visible = gimage_get_component_visible (channel_widget->gimage,
channel_widget->type);
break;
}
@ -2112,7 +2157,7 @@ channel_widget_exclusive_visible (ChannelWidget *channel_widget)
{
GSList *list;
ChannelWidget *cw;
int visible = FALSE;
gboolean visible = FALSE;
if (!channelsD)
return;
@ -2286,7 +2331,8 @@ new_channel_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage))
{
new_channel = channel_new (gimage, gimage->width, gimage->height,
channel_name, (int) (255 * options->opacity) / 100,
channel_name,
(gint) (255 * options->opacity) / 100,
options->color_panel->color);
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);

View File

@ -35,25 +35,11 @@ typedef enum
} ColorAreaTarget;
/* local function prototypes */
static void color_area_drag_begin (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drag_end (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_set_color (gpointer, guchar, guchar, guchar);
static void color_area_get_color (gpointer, guchar *, guchar *, guchar *);
/* Global variables */
gint active_color = 0;
gint active_color = FOREGROUND;
/* Static variables */
static GdkGC *color_area_gc = NULL;
@ -67,7 +53,7 @@ static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b;
static guchar revert_bg_r, revert_bg_g, revert_bg_b;
/* dnd structures */
/* dnd stuff */
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -268,16 +254,13 @@ color_area_edit (void)
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
}
if (active_color == FOREGROUND)
{
palette_get_foreground (&r, &g, &b);
edit_color = FOREGROUND;
}
else
{
palette_get_background (&r, &g, &b);
edit_color = BACKGROUND;
}
edit_color = active_color;
if (! color_notebook)
{
@ -333,7 +316,36 @@ color_area_events (GtkWidget *widget,
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
press_target = color_area_target (bevent->x, bevent->y);
{
target = color_area_target (bevent->x, bevent->y);
press_target = INVALID_AREA;
switch (target)
{
case FORE_AREA:
case BACK_AREA:
if (target != active_color)
{
active_color = target;
color_area_draw ();
}
else
{
press_target = target;
}
break;
case SWAP_AREA:
palette_swap_colors ();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors ();
color_area_draw ();
break;
default:
break;
}
}
break;
case GDK_BUTTON_RELEASE:
@ -349,23 +361,7 @@ color_area_events (GtkWidget *widget,
{
case FORE_AREA:
case BACK_AREA:
if (target == active_color)
{
color_area_edit ();
}
else
{
active_color = target;
color_area_draw ();
}
break;
case SWAP_AREA:
palette_swap_colors();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors();
color_area_draw ();
break;
default:
break;
@ -405,34 +401,19 @@ color_area_create (gint width,
swap_pixmap = swap_pmap;
/* dnd stuff */
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (color_area, color_area_get_color, NULL);
gtk_drag_dest_set (color_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY);
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_begin",
GTK_SIGNAL_FUNC (color_area_drag_begin),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_end",
GTK_SIGNAL_FUNC (color_area_drag_end),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_get",
GTK_SIGNAL_FUNC (color_area_drag_handle),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_received",
GTK_SIGNAL_FUNC (color_area_drop_handle),
color_area);
gimp_dnd_color_dest_set (color_area, color_area_set_color, NULL);
return color_area;
}
@ -444,76 +425,23 @@ color_area_update ()
}
static void
color_area_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_get_color (gpointer data,
guchar *r,
guchar *g,
guchar *b)
{
GtkWidget *window;
GdkColor bg;
guchar r, g, b;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-area-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
palette_get_foreground (r, g, b);
else
palette_get_background (&r, &g, &b);
bg.red = 0xff * r;
bg.green = 0xff * g;
bg.blue = 0xff * b;
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
palette_get_background (r, g, b);
}
static void
color_area_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-area-drag-window", NULL);
}
static void
color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 *vals;
guchar r, g, b;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
r = vals[0] / 0xff;
g = vals[1] / 0xff;
b = vals[2] / 0xff;
if (color_notebook_active &&
active_color == edit_color)
{
@ -527,29 +455,3 @@ color_area_drop_handle (GtkWidget *widget,
palette_set_background (r, g, b);
}
}
static void
color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 vals[4];
guchar r, g, b;
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
else
palette_get_background (&r, &g, &b);
vals[0] = r * 0xff;
vals[1] = g * 0xff;
vals[2] = b * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}

View File

@ -46,24 +46,10 @@ static gint color_panel_events (GtkWidget *, GdkEvent *);
static void color_panel_select_callback (gint, gint, gint,
ColorNotebookState, void *);
static void color_panel_drag_begin (GtkWidget *, GdkDragContext *, gpointer);
static void color_panel_drag_end (GtkWidget *, GdkDragContext *, gpointer);
static void color_panel_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_panel_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_panel_get_color (gpointer, guchar *, guchar *, guchar *);
static void color_panel_set_color (gpointer, guchar, guchar, guchar);
/* dnd structures */
/* dnd stuff */
static GtkTargetEntry color_panel_target_table[] =
{
GIMP_TARGET_COLOR
@ -71,6 +57,8 @@ static GtkTargetEntry color_panel_target_table[] =
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
sizeof (color_panel_target_table[0]));
/* public functions */
ColorPanel *
color_panel_new (guchar *initial,
gint width,
@ -111,34 +99,21 @@ color_panel_new (guchar *initial,
gtk_widget_show (private->drawing_area);
/* dnd stuff */
gtk_drag_source_set (private->drawing_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (private->drawing_area,
color_panel_get_color, color_panel);
gtk_drag_dest_set (private->drawing_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY);
gtk_drag_source_set (private->drawing_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_begin",
GTK_SIGNAL_FUNC (color_panel_drag_begin),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_end",
GTK_SIGNAL_FUNC (color_panel_drag_end),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_data_get",
GTK_SIGNAL_FUNC (color_panel_drag_handle),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_data_received",
GTK_SIGNAL_FUNC (color_panel_drop_handle),
color_panel);
gimp_dnd_color_dest_set (private->drawing_area,
color_panel_set_color, color_panel);
return color_panel;
}
@ -163,6 +138,8 @@ color_panel_free (ColorPanel *color_panel)
g_free (color_panel);
}
/* private functions */
static void
color_panel_draw (ColorPanel *color_panel)
{
@ -289,99 +266,33 @@ color_panel_select_callback (gint r,
}
static void
color_panel_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_panel_get_color (gpointer data,
guchar *r,
guchar *g,
guchar *b)
{
ColorPanel *color_panel = data;
GtkWidget *window;
GdkColor bg;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-panel-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
bg.red = 0xff * color_panel->color[0];
bg.green = 0xff * color_panel->color[1];
bg.blue = 0xff * color_panel->color[2];
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
*r = color_panel->color[0];
*g = color_panel->color[1];
*b = color_panel->color[2];
}
static void
color_panel_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-panel-drag-window", NULL);
}
static void
color_panel_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
color_panel_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
ColorPanel *color_panel = data;
ColorPanelPrivate *private = (ColorPanelPrivate *) color_panel->private_part;
guint16 *vals;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
color_panel->color[0] = vals[0] / 0xff;
color_panel->color[1] = vals[1] / 0xff;
color_panel->color[2] = vals[2] / 0xff;
color_panel->color[0] = r;
color_panel->color[1] = g;
color_panel->color[2] = b;
if (private->color_notebook_active)
color_notebook_set_color (private->color_notebook,
color_panel->color[0],
color_panel->color[1],
color_panel->color[2],
TRUE);
color_notebook_set_color (private->color_notebook, r, g, b, TRUE);
color_panel_draw (color_panel);
}
static void
color_panel_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
ColorPanel *color_panel = data;
guint16 vals[4];
vals[0] = color_panel->color[0] * 0xff;
vals[1] = color_panel->color[1] * 0xff;
vals[2] = color_panel->color[2] * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "bucket_fill.h"
#include "colormaps.h"
#include "cursorutil.h"
#include "devices.h"
@ -751,3 +752,61 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
GimpImage *gimage;
GimpDrawable *drawable;
TileManager *buf_tiles;
PixelRegion bufPR;
GimpContext *context;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (context) * 255,
gimp_context_get_paint_mode (context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
}

View File

@ -38,5 +38,9 @@ gboolean gdisplay_drag_drop (GtkWidget *widget,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "bucket_fill.h"
#include "colormaps.h"
#include "cursorutil.h"
#include "devices.h"
@ -751,3 +752,61 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
GimpImage *gimage;
GimpDrawable *drawable;
TileManager *buf_tiles;
PixelRegion bufPR;
GimpContext *context;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (context) * 255,
gimp_context_get_paint_mode (context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
}

View File

@ -38,5 +38,9 @@ gboolean gdisplay_drag_drop (GtkWidget *widget,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "bucket_fill.h"
#include "colormaps.h"
#include "cursorutil.h"
#include "devices.h"
@ -751,3 +752,61 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
GimpImage *gimage;
GimpDrawable *drawable;
TileManager *buf_tiles;
PixelRegion bufPR;
GimpContext *context;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (context) * 255,
gimp_context_get_paint_mode (context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
}

View File

@ -38,5 +38,9 @@ gboolean gdisplay_drag_drop (GtkWidget *widget,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (gpointer data,
guchar r,
guchar g,
guchar b);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -132,7 +132,8 @@ static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_COLOR
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
@ -711,6 +712,7 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);

View File

@ -132,7 +132,8 @@ static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_COLOR
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
@ -711,6 +712,7 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);

View File

@ -19,6 +19,10 @@
#include "gimpdnd.h"
#include "gimprc.h"
/****************************/
/* drawable dnd functions */
/****************************/
#define GRAD_CHECK_SIZE_SM 4
#define GRAD_CHECK_DARK (1.0 / 3.0)
@ -214,3 +218,156 @@ gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
gdk_pixmap_unref (drag_pixmap);
}
/*************************/
/* color dnd functions */
/*************************/
static void
gimp_dnd_color_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
GtkWidget *window;
GdkColor bg;
guchar r, g, b;
GimpDndGetColorFunc get_color_func;
get_color_func =
(GimpDndGetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_color_func");
if (! get_color_func)
return;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
(* get_color_func) (data, &r, &g, &b);
bg.red = 0xff * r;
bg.green = 0xff * g;
bg.blue = 0xff * b;
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
}
static void
gimp_dnd_color_drag_end (GtkWidget *widget,
GdkDragContext *context)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-drag-window", NULL);
}
static void
gimp_dnd_color_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 vals[4];
guchar r, g, b;
GimpDndGetColorFunc get_color_func;
get_color_func =
(GimpDndGetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_color_func");
if (! get_color_func)
return;
(* get_color_func) (data, &r, &g, &b);
vals[0] = r * 0xff;
vals[1] = g * 0xff;
vals[2] = b * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}
static void
gimp_dnd_color_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 *vals;
guchar r, g, b;
GimpDndSetColorFunc set_color_func;
set_color_func =
(GimpDndSetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_set_color_func");
if (! set_color_func)
return;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
r = vals[0] / 0xff;
g = vals[1] / 0xff;
b = vals[2] / 0xff;
(* set_color_func) (data, r, g, b);
}
void
gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndGetColorFunc get_color_func,
gpointer data)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_begin",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_begin),
data);
gtk_signal_connect (GTK_OBJECT (widget), "drag_end",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_end),
data);
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_handle),
data);
gtk_object_set_data (GTK_OBJECT (widget), "gimp_dnd_get_color_func",
(gpointer) get_color_func);
}
void
gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndSetColorFunc set_color_func,
gpointer data)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_color_drop_handle),
data);
gtk_object_set_data (GTK_OBJECT (widget), "gimp_dnd_set_color_func",
(gpointer) set_color_func);
}

View File

@ -73,9 +73,24 @@ typedef enum
GIMP_DROP_BELOW
} GimpDropType;
/* drawable dnd functions */
void gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
GdkDragContext *context,
GimpDrawable *drawable,
GdkGC *gc);
/* color dnd functions */
typedef void (*GimpDndSetColorFunc) (gpointer, guchar, guchar, guchar);
typedef void (*GimpDndGetColorFunc) (gpointer, guchar *, guchar *, guchar *);
void gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndGetColorFunc get_color_func,
gpointer data);
void gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndSetColorFunc set_color_func,
gpointer data);
#endif /* __GIMP_DND_H__ */

View File

@ -156,6 +156,8 @@ static void channel_widget_drag_leave_callback (GtkWidget *,
guint);
static void channel_widget_drag_indicator_callback (GtkWidget *, gpointer);
static void channel_widget_set_color (gpointer,
guchar, guchar, guchar);
static void channel_widget_draw_drop_indicator (ChannelWidget *, GimpDropType);
static void channel_widget_delete (ChannelWidget *);
static void channel_widget_select_update (GtkWidget *, gpointer);
@ -214,6 +216,14 @@ static OpsButton channels_ops_buttons[] =
/* dnd structures */
static GtkTargetEntry channel_color_target_table[] =
{
GIMP_TARGET_CHANNEL,
GIMP_TARGET_COLOR
};
static guint n_channel_color_targets = (sizeof (channel_color_target_table) /
sizeof (channel_color_target_table[0]));
static GtkTargetEntry channel_target_table[] =
{
GIMP_TARGET_CHANNEL
@ -829,10 +839,10 @@ static gint
channel_list_events (GtkWidget *widget,
GdkEvent *event)
{
ChannelWidget *channel_widget;
GdkEventKey *kevent;
GdkEventButton *bevent;
GtkWidget *event_widget;
ChannelWidget *channel_widget;
event_widget = gtk_get_event_widget (event);
@ -843,9 +853,13 @@ channel_list_events (GtkWidget *widget,
switch (event->type)
{
case GDK_2BUTTON_PRESS:
if (channel_widget->type == AUXILLARY_CHANNEL)
channels_dialog_edit_channel_query (channel_widget);
return TRUE;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
if (bevent->button == 3 || bevent->button == 2)
{
gtk_menu_popup (GTK_MENU (channelsD->ops_menu),
@ -855,11 +869,6 @@ channel_list_events (GtkWidget *widget,
}
break;
case GDK_2BUTTON_PRESS:
if (channel_widget->type == AUXILLARY_CHANNEL)
channels_dialog_edit_channel_query (channel_widget);
return TRUE;
case GDK_KEY_PRESS:
kevent = (GdkEventKey *) event;
switch (kevent->keyval)
@ -1375,8 +1384,11 @@ channel_widget_create (GImage *gimage,
/* dnd destination */
gtk_drag_dest_set (list_item,
GTK_DEST_DEFAULT_ALL,
channel_target_table, n_channel_targets,
GDK_ACTION_MOVE);
channel_color_target_table, n_channel_color_targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gimp_dnd_color_dest_set (list_item,
channel_widget_set_color,
(gpointer) channel_widget);
gtk_signal_connect (GTK_OBJECT (list_item), "drag_leave",
GTK_SIGNAL_FUNC (channel_widget_drag_leave_callback),
@ -1489,6 +1501,13 @@ channel_widget_drag_motion_callback (GtkWidget *widget,
drop_type = GIMP_DROP_NONE;
}
}
else if (gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_dnd_get_color_func"))
{
drag_action = GDK_ACTION_COPY;
return_val = TRUE;
drop_type = GIMP_DROP_NONE;
}
}
gdk_drag_status (context, drag_action, time);
@ -1610,6 +1629,30 @@ channel_widget_drag_indicator_callback (GtkWidget *widget,
channel_widget_draw_drop_indicator (channel_widget, channel_widget->drop_type);
}
static void
channel_widget_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
ChannelWidget *channel_widget = (ChannelWidget *) data;
Channel *channel = channel_widget->channel;
if (r != channel->col[0] ||
g != channel->col[1] ||
b != channel->col[2])
{
channel->col[0] = r;
channel->col[1] = g;
channel->col[2] = b;
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
gdisplays_flush ();
}
}
static void
channel_widget_draw_drop_indicator (ChannelWidget *channel_widget,
GimpDropType drop_type)
@ -1696,16 +1739,17 @@ static gint
channel_widget_button_events (GtkWidget *widget,
GdkEvent *event)
{
static int button_down = 0;
static GtkWidget *click_widget = NULL;
static int old_state;
static int exclusive;
ChannelWidget *channel_widget;
GtkWidget *event_widget;
GdkEventButton *bevent;
gint return_val;
int visible;
int width, height;
gint visible;
gint width, height;
static gboolean button_down = FALSE;
static GtkWidget *click_widget = NULL;
static gint old_state;
static gint exclusive;
channel_widget = (ChannelWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1745,7 +1789,7 @@ channel_widget_button_events (GtkWidget *widget,
return TRUE;
}
button_down = 1;
button_down = TRUE;
click_widget = widget;
gtk_grab_add (click_widget);
@ -1775,7 +1819,7 @@ channel_widget_button_events (GtkWidget *widget,
case GDK_BUTTON_RELEASE:
return_val = TRUE;
button_down = 0;
button_down = FALSE;
gtk_grab_remove (click_widget);
if (widget == channel_widget->eye_widget)
@ -1829,10 +1873,10 @@ static gint
channel_widget_preview_events (GtkWidget *widget,
GdkEvent *event)
{
ChannelWidget *channel_widget;
GdkEventExpose *eevent;
GdkEventButton *bevent;
ChannelWidget *channel_widget;
int valid;
gboolean valid;
channel_widget = (ChannelWidget *) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1902,8 +1946,8 @@ static void
channel_widget_preview_redraw (ChannelWidget *channel_widget)
{
TempBuf * preview_buf;
int width, height;
int channel;
gint width, height;
gint channel;
/* allocate the channel widget pixmap */
if (! channel_widget->channel_pixmap)
@ -2040,7 +2084,7 @@ channel_widget_eye_redraw (ChannelWidget *channel_widget)
GdkPixmap *pixmap;
GdkColor *color;
GtkStateType state;
int visible;
gboolean visible;
state = channel_widget->list_item->state;
@ -2062,7 +2106,8 @@ channel_widget_eye_redraw (ChannelWidget *channel_widget)
visible = GIMP_DRAWABLE (channel_widget->channel)->visible;
break;
default:
visible = gimage_get_component_visible (channel_widget->gimage, channel_widget->type);
visible = gimage_get_component_visible (channel_widget->gimage,
channel_widget->type);
break;
}
@ -2112,7 +2157,7 @@ channel_widget_exclusive_visible (ChannelWidget *channel_widget)
{
GSList *list;
ChannelWidget *cw;
int visible = FALSE;
gboolean visible = FALSE;
if (!channelsD)
return;
@ -2286,7 +2331,8 @@ new_channel_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage))
{
new_channel = channel_new (gimage, gimage->width, gimage->height,
channel_name, (int) (255 * options->opacity) / 100,
channel_name,
(gint) (255 * options->opacity) / 100,
options->color_panel->color);
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);

View File

@ -35,25 +35,11 @@ typedef enum
} ColorAreaTarget;
/* local function prototypes */
static void color_area_drag_begin (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drag_end (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_set_color (gpointer, guchar, guchar, guchar);
static void color_area_get_color (gpointer, guchar *, guchar *, guchar *);
/* Global variables */
gint active_color = 0;
gint active_color = FOREGROUND;
/* Static variables */
static GdkGC *color_area_gc = NULL;
@ -67,7 +53,7 @@ static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b;
static guchar revert_bg_r, revert_bg_g, revert_bg_b;
/* dnd structures */
/* dnd stuff */
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -268,16 +254,13 @@ color_area_edit (void)
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
}
if (active_color == FOREGROUND)
{
palette_get_foreground (&r, &g, &b);
edit_color = FOREGROUND;
}
else
{
palette_get_background (&r, &g, &b);
edit_color = BACKGROUND;
}
edit_color = active_color;
if (! color_notebook)
{
@ -333,7 +316,36 @@ color_area_events (GtkWidget *widget,
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
press_target = color_area_target (bevent->x, bevent->y);
{
target = color_area_target (bevent->x, bevent->y);
press_target = INVALID_AREA;
switch (target)
{
case FORE_AREA:
case BACK_AREA:
if (target != active_color)
{
active_color = target;
color_area_draw ();
}
else
{
press_target = target;
}
break;
case SWAP_AREA:
palette_swap_colors ();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors ();
color_area_draw ();
break;
default:
break;
}
}
break;
case GDK_BUTTON_RELEASE:
@ -349,23 +361,7 @@ color_area_events (GtkWidget *widget,
{
case FORE_AREA:
case BACK_AREA:
if (target == active_color)
{
color_area_edit ();
}
else
{
active_color = target;
color_area_draw ();
}
break;
case SWAP_AREA:
palette_swap_colors();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors();
color_area_draw ();
break;
default:
break;
@ -405,34 +401,19 @@ color_area_create (gint width,
swap_pixmap = swap_pmap;
/* dnd stuff */
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (color_area, color_area_get_color, NULL);
gtk_drag_dest_set (color_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY);
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_begin",
GTK_SIGNAL_FUNC (color_area_drag_begin),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_end",
GTK_SIGNAL_FUNC (color_area_drag_end),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_get",
GTK_SIGNAL_FUNC (color_area_drag_handle),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_received",
GTK_SIGNAL_FUNC (color_area_drop_handle),
color_area);
gimp_dnd_color_dest_set (color_area, color_area_set_color, NULL);
return color_area;
}
@ -444,76 +425,23 @@ color_area_update ()
}
static void
color_area_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_get_color (gpointer data,
guchar *r,
guchar *g,
guchar *b)
{
GtkWidget *window;
GdkColor bg;
guchar r, g, b;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-area-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
palette_get_foreground (r, g, b);
else
palette_get_background (&r, &g, &b);
bg.red = 0xff * r;
bg.green = 0xff * g;
bg.blue = 0xff * b;
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
palette_get_background (r, g, b);
}
static void
color_area_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-area-drag-window", NULL);
}
static void
color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 *vals;
guchar r, g, b;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
r = vals[0] / 0xff;
g = vals[1] / 0xff;
b = vals[2] / 0xff;
if (color_notebook_active &&
active_color == edit_color)
{
@ -527,29 +455,3 @@ color_area_drop_handle (GtkWidget *widget,
palette_set_background (r, g, b);
}
}
static void
color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 vals[4];
guchar r, g, b;
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
else
palette_get_background (&r, &g, &b);
vals[0] = r * 0xff;
vals[1] = g * 0xff;
vals[2] = b * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}

View File

@ -132,7 +132,8 @@ static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_COLOR
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
@ -711,6 +712,7 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);

View File

@ -42,8 +42,8 @@
typedef struct _BucketTool BucketTool;
struct _BucketTool
{
int target_x; /* starting x coord */
int target_y; /* starting y coord */
gint target_x; /* starting x coord */
gint target_y; /* starting y coord */
};
typedef struct _BucketOptions BucketOptions;
@ -51,12 +51,12 @@ struct _BucketOptions
{
PaintOptions paint_options;
double threshold;
double threshold_d;
gdouble threshold;
gdouble threshold_d;
GtkObject *threshold_w;
int sample_merged;
int sample_merged_d;
gboolean sample_merged;
gboolean sample_merged_d;
GtkWidget *sample_merged_w;
BucketFillMode fill_mode;
@ -75,13 +75,10 @@ static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void bucket_fill_region (BucketFillMode, PixelRegion *,
PixelRegion *, unsigned char *,
TempBuf *, int, int, int);
static void bucket_fill_line_color (unsigned char *, unsigned char *,
unsigned char *, int, int, int);
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
TempBuf *, int, int, int, int, int);
static void bucket_fill_line_color (guchar *, guchar *, guchar *,
gboolean, gint, gint);
static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *,
gboolean, gint, gint, gint, gint);
/* functions */
@ -183,7 +180,7 @@ bucket_fill_button_press (Tool *tool,
{
GDisplay * gdisp;
BucketTool * bucket_tool;
int use_offsets;
gboolean use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -196,7 +193,9 @@ bucket_fill_button_press (Tool *tool,
/* Make the tool active and set the gdisplay which owns it */
gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
/* Make the tool active and set the gdisplay which owns it */
@ -212,7 +211,7 @@ bucket_fill_button_release (Tool *tool,
GDisplay * gdisp;
BucketTool * bucket_tool;
Argument *return_vals;
int nreturn_vals;
gint nreturn_vals;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -255,8 +254,8 @@ bucket_fill_cursor_update (Tool *tool,
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
int off_x, off_y;
gint x, y;
gint off_x, off_y;
gdisp = (GDisplay *) gdisp_ptr;
@ -311,23 +310,24 @@ void
bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
int paint_mode,
double opacity,
double threshold,
int sample_merged,
double x,
double y)
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y)
{
TileManager *buf_tiles;
PixelRegion bufPR, maskPR;
Channel *mask = NULL;
int bytes, has_alpha;
int x1, y1, x2, y2;
unsigned char col [MAX_CHANNELS];
unsigned char *d1, *d2;
gint bytes;
gboolean has_alpha;
gint x1, y1, x2, y2;
guchar col [MAX_CHANNELS];
guchar *d1, *d2;
GPatternP pattern;
TempBuf *pat_buf;
int new_buf = 0;
gboolean new_buf = FALSE;
pat_buf = NULL;
@ -370,7 +370,7 @@ bucket_fill (GimpImage *gimage,
d2 += pat_buf->bytes;
}
new_buf = 1;
new_buf = TRUE;
}
else
pat_buf = pattern->mask;
@ -423,7 +423,7 @@ bucket_fill (GimpImage *gimage,
if (! has_alpha)
{
bytes ++;
has_alpha = 1;
has_alpha = TRUE;
}
}
@ -455,16 +455,15 @@ bucket_fill (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
static void
bucket_fill_line_color (unsigned char *buf,
unsigned char *mask,
unsigned char *col,
int has_alpha,
int bytes,
int width)
bucket_fill_line_color (guchar *buf,
guchar *mask,
guchar *col,
gboolean has_alpha,
gint bytes,
gint width)
{
int alpha, b;
gint alpha, b;
alpha = (has_alpha) ? bytes - 1 : bytes;
while (width--)
@ -484,20 +483,19 @@ bucket_fill_line_color (unsigned char *buf,
}
}
static void
bucket_fill_line_pattern (unsigned char *buf,
unsigned char *mask,
bucket_fill_line_pattern (guchar *buf,
guchar *mask,
TempBuf *pattern,
int has_alpha,
int bytes,
int x,
int y,
int width)
gboolean has_alpha,
gint bytes,
gint x,
gint y,
gint width)
{
unsigned char *pat, *p;
int alpha, b;
int i;
guchar *pat, *p;
gint alpha, b;
gint i;
/* Get a pointer to the appropriate scanline of the pattern buffer */
pat = temp_buf_data (pattern) +
@ -523,22 +521,23 @@ bucket_fill_line_pattern (unsigned char *buf,
}
}
static void
void
bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
unsigned char *col,
guchar *col,
TempBuf *pattern,
int off_x,
int off_y,
int has_alpha)
gint off_x,
gint off_y,
gboolean has_alpha)
{
unsigned char *s, *m;
int y;
guchar *s, *m;
gint y;
void *pr;
for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (2, bufPR, maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
s = bufPR->data;
if (maskPR)

View File

@ -29,10 +29,26 @@ typedef enum
PATTERN_BUCKET_FILL
} BucketFillMode;
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
double, double, int, double, double);
void bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
void bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
guchar *col,
TempBuf *pattern,
gint off_x,
gint off_y,
gboolean has_alpha);
Tool * tools_new_bucket_fill (void);
void tools_free_bucket_fill (Tool *);
void tools_free_bucket_fill (Tool *tool);
#endif /* __BUCKET_FILL_H__ */

View File

@ -42,8 +42,8 @@
typedef struct _BucketTool BucketTool;
struct _BucketTool
{
int target_x; /* starting x coord */
int target_y; /* starting y coord */
gint target_x; /* starting x coord */
gint target_y; /* starting y coord */
};
typedef struct _BucketOptions BucketOptions;
@ -51,12 +51,12 @@ struct _BucketOptions
{
PaintOptions paint_options;
double threshold;
double threshold_d;
gdouble threshold;
gdouble threshold_d;
GtkObject *threshold_w;
int sample_merged;
int sample_merged_d;
gboolean sample_merged;
gboolean sample_merged_d;
GtkWidget *sample_merged_w;
BucketFillMode fill_mode;
@ -75,13 +75,10 @@ static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer);
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void bucket_fill_region (BucketFillMode, PixelRegion *,
PixelRegion *, unsigned char *,
TempBuf *, int, int, int);
static void bucket_fill_line_color (unsigned char *, unsigned char *,
unsigned char *, int, int, int);
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
TempBuf *, int, int, int, int, int);
static void bucket_fill_line_color (guchar *, guchar *, guchar *,
gboolean, gint, gint);
static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *,
gboolean, gint, gint, gint, gint);
/* functions */
@ -183,7 +180,7 @@ bucket_fill_button_press (Tool *tool,
{
GDisplay * gdisp;
BucketTool * bucket_tool;
int use_offsets;
gboolean use_offsets;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -196,7 +193,9 @@ bucket_fill_button_press (Tool *tool,
/* Make the tool active and set the gdisplay which owns it */
gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time);
/* Make the tool active and set the gdisplay which owns it */
@ -212,7 +211,7 @@ bucket_fill_button_release (Tool *tool,
GDisplay * gdisp;
BucketTool * bucket_tool;
Argument *return_vals;
int nreturn_vals;
gint nreturn_vals;
gdisp = (GDisplay *) gdisp_ptr;
bucket_tool = (BucketTool *) tool->private;
@ -255,8 +254,8 @@ bucket_fill_cursor_update (Tool *tool,
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
int off_x, off_y;
gint x, y;
gint off_x, off_y;
gdisp = (GDisplay *) gdisp_ptr;
@ -311,23 +310,24 @@ void
bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
int paint_mode,
double opacity,
double threshold,
int sample_merged,
double x,
double y)
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y)
{
TileManager *buf_tiles;
PixelRegion bufPR, maskPR;
Channel *mask = NULL;
int bytes, has_alpha;
int x1, y1, x2, y2;
unsigned char col [MAX_CHANNELS];
unsigned char *d1, *d2;
gint bytes;
gboolean has_alpha;
gint x1, y1, x2, y2;
guchar col [MAX_CHANNELS];
guchar *d1, *d2;
GPatternP pattern;
TempBuf *pat_buf;
int new_buf = 0;
gboolean new_buf = FALSE;
pat_buf = NULL;
@ -370,7 +370,7 @@ bucket_fill (GimpImage *gimage,
d2 += pat_buf->bytes;
}
new_buf = 1;
new_buf = TRUE;
}
else
pat_buf = pattern->mask;
@ -423,7 +423,7 @@ bucket_fill (GimpImage *gimage,
if (! has_alpha)
{
bytes ++;
has_alpha = 1;
has_alpha = TRUE;
}
}
@ -455,16 +455,15 @@ bucket_fill (GimpImage *gimage,
gimp_remove_busy_cursors (NULL);
}
static void
bucket_fill_line_color (unsigned char *buf,
unsigned char *mask,
unsigned char *col,
int has_alpha,
int bytes,
int width)
bucket_fill_line_color (guchar *buf,
guchar *mask,
guchar *col,
gboolean has_alpha,
gint bytes,
gint width)
{
int alpha, b;
gint alpha, b;
alpha = (has_alpha) ? bytes - 1 : bytes;
while (width--)
@ -484,20 +483,19 @@ bucket_fill_line_color (unsigned char *buf,
}
}
static void
bucket_fill_line_pattern (unsigned char *buf,
unsigned char *mask,
bucket_fill_line_pattern (guchar *buf,
guchar *mask,
TempBuf *pattern,
int has_alpha,
int bytes,
int x,
int y,
int width)
gboolean has_alpha,
gint bytes,
gint x,
gint y,
gint width)
{
unsigned char *pat, *p;
int alpha, b;
int i;
guchar *pat, *p;
gint alpha, b;
gint i;
/* Get a pointer to the appropriate scanline of the pattern buffer */
pat = temp_buf_data (pattern) +
@ -523,22 +521,23 @@ bucket_fill_line_pattern (unsigned char *buf,
}
}
static void
void
bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
unsigned char *col,
guchar *col,
TempBuf *pattern,
int off_x,
int off_y,
int has_alpha)
gint off_x,
gint off_y,
gboolean has_alpha)
{
unsigned char *s, *m;
int y;
guchar *s, *m;
gint y;
void *pr;
for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (2, bufPR, maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
s = bufPR->data;
if (maskPR)

View File

@ -29,10 +29,26 @@ typedef enum
PATTERN_BUCKET_FILL
} BucketFillMode;
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
double, double, int, double, double);
void bucket_fill (GimpImage *gimage,
GimpDrawable *drawable,
BucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
void bucket_fill_region (BucketFillMode fill_mode,
PixelRegion *bufPR,
PixelRegion *maskPR,
guchar *col,
TempBuf *pattern,
gint off_x,
gint off_y,
gboolean has_alpha);
Tool * tools_new_bucket_fill (void);
void tools_free_bucket_fill (Tool *);
void tools_free_bucket_fill (Tool *tool);
#endif /* __BUCKET_FILL_H__ */

View File

@ -46,24 +46,10 @@ static gint color_panel_events (GtkWidget *, GdkEvent *);
static void color_panel_select_callback (gint, gint, gint,
ColorNotebookState, void *);
static void color_panel_drag_begin (GtkWidget *, GdkDragContext *, gpointer);
static void color_panel_drag_end (GtkWidget *, GdkDragContext *, gpointer);
static void color_panel_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_panel_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_panel_get_color (gpointer, guchar *, guchar *, guchar *);
static void color_panel_set_color (gpointer, guchar, guchar, guchar);
/* dnd structures */
/* dnd stuff */
static GtkTargetEntry color_panel_target_table[] =
{
GIMP_TARGET_COLOR
@ -71,6 +57,8 @@ static GtkTargetEntry color_panel_target_table[] =
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
sizeof (color_panel_target_table[0]));
/* public functions */
ColorPanel *
color_panel_new (guchar *initial,
gint width,
@ -111,34 +99,21 @@ color_panel_new (guchar *initial,
gtk_widget_show (private->drawing_area);
/* dnd stuff */
gtk_drag_source_set (private->drawing_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (private->drawing_area,
color_panel_get_color, color_panel);
gtk_drag_dest_set (private->drawing_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY);
gtk_drag_source_set (private->drawing_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_begin",
GTK_SIGNAL_FUNC (color_panel_drag_begin),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_end",
GTK_SIGNAL_FUNC (color_panel_drag_end),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_data_get",
GTK_SIGNAL_FUNC (color_panel_drag_handle),
color_panel);
gtk_signal_connect (GTK_OBJECT (private->drawing_area),
"drag_data_received",
GTK_SIGNAL_FUNC (color_panel_drop_handle),
color_panel);
gimp_dnd_color_dest_set (private->drawing_area,
color_panel_set_color, color_panel);
return color_panel;
}
@ -163,6 +138,8 @@ color_panel_free (ColorPanel *color_panel)
g_free (color_panel);
}
/* private functions */
static void
color_panel_draw (ColorPanel *color_panel)
{
@ -289,99 +266,33 @@ color_panel_select_callback (gint r,
}
static void
color_panel_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_panel_get_color (gpointer data,
guchar *r,
guchar *g,
guchar *b)
{
ColorPanel *color_panel = data;
GtkWidget *window;
GdkColor bg;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-panel-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
bg.red = 0xff * color_panel->color[0];
bg.green = 0xff * color_panel->color[1];
bg.blue = 0xff * color_panel->color[2];
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
*r = color_panel->color[0];
*g = color_panel->color[1];
*b = color_panel->color[2];
}
static void
color_panel_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-panel-drag-window", NULL);
}
static void
color_panel_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
color_panel_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
ColorPanel *color_panel = data;
ColorPanelPrivate *private = (ColorPanelPrivate *) color_panel->private_part;
guint16 *vals;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
color_panel->color[0] = vals[0] / 0xff;
color_panel->color[1] = vals[1] / 0xff;
color_panel->color[2] = vals[2] / 0xff;
color_panel->color[0] = r;
color_panel->color[1] = g;
color_panel->color[2] = b;
if (private->color_notebook_active)
color_notebook_set_color (private->color_notebook,
color_panel->color[0],
color_panel->color[1],
color_panel->color[2],
TRUE);
color_notebook_set_color (private->color_notebook, r, g, b, TRUE);
color_panel_draw (color_panel);
}
static void
color_panel_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
ColorPanel *color_panel = data;
guint16 vals[4];
vals[0] = color_panel->color[0] * 0xff;
vals[1] = color_panel->color[1] * 0xff;
vals[2] = color_panel->color[2] * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}

View File

@ -19,6 +19,10 @@
#include "gimpdnd.h"
#include "gimprc.h"
/****************************/
/* drawable dnd functions */
/****************************/
#define GRAD_CHECK_SIZE_SM 4
#define GRAD_CHECK_DARK (1.0 / 3.0)
@ -214,3 +218,156 @@ gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
gdk_pixmap_unref (drag_pixmap);
}
/*************************/
/* color dnd functions */
/*************************/
static void
gimp_dnd_color_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
GtkWidget *window;
GdkColor bg;
guchar r, g, b;
GimpDndGetColorFunc get_color_func;
get_color_func =
(GimpDndGetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_color_func");
if (! get_color_func)
return;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
(* get_color_func) (data, &r, &g, &b);
bg.red = 0xff * r;
bg.green = 0xff * g;
bg.blue = 0xff * b;
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
}
static void
gimp_dnd_color_drag_end (GtkWidget *widget,
GdkDragContext *context)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-drag-window", NULL);
}
static void
gimp_dnd_color_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 vals[4];
guchar r, g, b;
GimpDndGetColorFunc get_color_func;
get_color_func =
(GimpDndGetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_color_func");
if (! get_color_func)
return;
(* get_color_func) (data, &r, &g, &b);
vals[0] = r * 0xff;
vals[1] = g * 0xff;
vals[2] = b * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}
static void
gimp_dnd_color_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 *vals;
guchar r, g, b;
GimpDndSetColorFunc set_color_func;
set_color_func =
(GimpDndSetColorFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_set_color_func");
if (! set_color_func)
return;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
r = vals[0] / 0xff;
g = vals[1] / 0xff;
b = vals[2] / 0xff;
(* set_color_func) (data, r, g, b);
}
void
gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndGetColorFunc get_color_func,
gpointer data)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_begin",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_begin),
data);
gtk_signal_connect (GTK_OBJECT (widget), "drag_end",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_end),
data);
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gimp_dnd_color_drag_handle),
data);
gtk_object_set_data (GTK_OBJECT (widget), "gimp_dnd_get_color_func",
(gpointer) get_color_func);
}
void
gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndSetColorFunc set_color_func,
gpointer data)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_color_drop_handle),
data);
gtk_object_set_data (GTK_OBJECT (widget), "gimp_dnd_set_color_func",
(gpointer) set_color_func);
}

View File

@ -73,9 +73,24 @@ typedef enum
GIMP_DROP_BELOW
} GimpDropType;
/* drawable dnd functions */
void gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
GdkDragContext *context,
GimpDrawable *drawable,
GdkGC *gc);
/* color dnd functions */
typedef void (*GimpDndSetColorFunc) (gpointer, guchar, guchar, guchar);
typedef void (*GimpDndGetColorFunc) (gpointer, guchar *, guchar *, guchar *);
void gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndGetColorFunc get_color_func,
gpointer data);
void gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndSetColorFunc set_color_func,
gpointer data);
#endif /* __GIMP_DND_H__ */

View File

@ -35,25 +35,11 @@ typedef enum
} ColorAreaTarget;
/* local function prototypes */
static void color_area_drag_begin (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drag_end (GtkWidget *, GdkDragContext *, gpointer);
static void color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data);
static void color_area_set_color (gpointer, guchar, guchar, guchar);
static void color_area_get_color (gpointer, guchar *, guchar *, guchar *);
/* Global variables */
gint active_color = 0;
gint active_color = FOREGROUND;
/* Static variables */
static GdkGC *color_area_gc = NULL;
@ -67,7 +53,7 @@ static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b;
static guchar revert_bg_r, revert_bg_g, revert_bg_b;
/* dnd structures */
/* dnd stuff */
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -268,16 +254,13 @@ color_area_edit (void)
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
}
if (active_color == FOREGROUND)
{
palette_get_foreground (&r, &g, &b);
edit_color = FOREGROUND;
}
else
{
palette_get_background (&r, &g, &b);
edit_color = BACKGROUND;
}
edit_color = active_color;
if (! color_notebook)
{
@ -333,7 +316,36 @@ color_area_events (GtkWidget *widget,
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
press_target = color_area_target (bevent->x, bevent->y);
{
target = color_area_target (bevent->x, bevent->y);
press_target = INVALID_AREA;
switch (target)
{
case FORE_AREA:
case BACK_AREA:
if (target != active_color)
{
active_color = target;
color_area_draw ();
}
else
{
press_target = target;
}
break;
case SWAP_AREA:
palette_swap_colors ();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors ();
color_area_draw ();
break;
default:
break;
}
}
break;
case GDK_BUTTON_RELEASE:
@ -349,23 +361,7 @@ color_area_events (GtkWidget *widget,
{
case FORE_AREA:
case BACK_AREA:
if (target == active_color)
{
color_area_edit ();
}
else
{
active_color = target;
color_area_draw ();
}
break;
case SWAP_AREA:
palette_swap_colors();
color_area_draw ();
break;
case DEF_AREA:
palette_set_default_colors();
color_area_draw ();
break;
default:
break;
@ -405,34 +401,19 @@ color_area_create (gint width,
swap_pixmap = swap_pmap;
/* dnd stuff */
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (color_area, color_area_get_color, NULL);
gtk_drag_dest_set (color_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY);
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_begin",
GTK_SIGNAL_FUNC (color_area_drag_begin),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_end",
GTK_SIGNAL_FUNC (color_area_drag_end),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_get",
GTK_SIGNAL_FUNC (color_area_drag_handle),
color_area);
gtk_signal_connect (GTK_OBJECT (color_area),
"drag_data_received",
GTK_SIGNAL_FUNC (color_area_drop_handle),
color_area);
gimp_dnd_color_dest_set (color_area, color_area_set_color, NULL);
return color_area;
}
@ -444,76 +425,23 @@ color_area_update ()
}
static void
color_area_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_get_color (gpointer data,
guchar *r,
guchar *g,
guchar *b)
{
GtkWidget *window;
GdkColor bg;
guchar r, g, b;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32);
gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-area-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
palette_get_foreground (r, g, b);
else
palette_get_background (&r, &g, &b);
bg.red = 0xff * r;
bg.green = 0xff * g;
bg.blue = 0xff * b;
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
gtk_drag_set_icon_widget (context, window, -2, -2);
palette_get_background (r, g, b);
}
static void
color_area_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
color_area_set_color (gpointer data,
guchar r,
guchar g,
guchar b)
{
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-area-drag-window", NULL);
}
static void
color_area_drop_handle (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 *vals;
guchar r, g, b;
if (selection_data->length < 0)
return;
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
vals = (guint16 *) selection_data->data;
r = vals[0] / 0xff;
g = vals[1] / 0xff;
b = vals[2] / 0xff;
if (color_notebook_active &&
active_color == edit_color)
{
@ -527,29 +455,3 @@ color_area_drop_handle (GtkWidget *widget,
palette_set_background (r, g, b);
}
}
static void
color_area_drag_handle (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guint16 vals[4];
guchar r, g, b;
if (active_color == FOREGROUND)
palette_get_foreground (&r, &g, &b);
else
palette_get_background (&r, &g, &b);
vals[0] = r * 0xff;
vals[1] = g * 0xff;
vals[2] = b * 0xff;
vals[3] = 0xffff;
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *) vals, 8);
}

View File

@ -85,6 +85,7 @@ pnm
polar
ps
psd
psp
randomize
ripple
rotate