--Sven
This commit is contained in:
Sven Neumann
1999-09-04 14:56:50 +00:00
parent 0f1da4281d
commit 3c01cfd5c0
15 changed files with 408 additions and 198 deletions

View File

@ -1,3 +1,11 @@
Sat Sep 4 16:58:36 MEST 1999 Sven Neumann <sven@gimp.org>
* app/devices.c
* app/gimpcontextpreview.[ch]
* app/gimpdnd.[ch]
* app/inidicatorarea.c: dnd for brushes and patterns. Does not work
yet...
Sat Sep 4 16:31:50 CEST 1999 Olof S Kylander <olof@frozenriver.com> Sat Sep 4 16:31:50 CEST 1999 Olof S Kylander <olof@frozenriver.com>
* patch_xinput_airbrush (newfile) * patch_xinput_airbrush (newfile)

View File

@ -125,6 +125,18 @@ static GtkTargetEntry color_area_target_table[] =
}; };
static guint n_color_area_targets = (sizeof (color_area_target_table) / static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0])); sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
void void
@ -769,7 +781,7 @@ create_device_status (void)
gtk_drag_source_set (deviceD->colors[i], gtk_drag_source_set (deviceD->colors[i],
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets, color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY);
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color, gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
GUINT_TO_POINTER (device_info->device)); GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->colors[i], gtk_drag_dest_set (deviceD->colors[i],
@ -786,15 +798,26 @@ create_device_status (void)
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH, deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1, 3, 4, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN, deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1, 4, 5, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);

View File

@ -24,6 +24,7 @@
#include "gimpbrushpipe.h" #include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h" #include "gimpbrushpipeP.h"
#include "gimpcontextpreview.h" #include "gimpcontextpreview.h"
#include "gimpdnd.h"
#include "gradient.h" #include "gradient.h"
#include "gradient_header.h" #include "gradient_header.h"
#include "interface.h" /* for tool_tips */ #include "interface.h" /* for tool_tips */
@ -37,7 +38,7 @@
#define WHT {255,255,255} #define WHT {255,255,255}
#define BLK { 0, 0, 0} #define BLK { 0, 0, 0}
static unsigned char scale_indicator_bits[7][7][3] = static guchar scale_indicator_bits[7][7][3] =
{ {
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }, { WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT }, { WHT, WHT, WHT, BLK, WHT, WHT, WHT },
@ -52,6 +53,8 @@ static unsigned char scale_indicator_bits[7][7][3] =
#define GRADIENT_POPUP_WIDTH 128 #define GRADIENT_POPUP_WIDTH 128
#define GRADIENT_POPUP_HEIGHT 32 #define GRADIENT_POPUP_HEIGHT 32
#define DRAG_PREVIEW_SIZE 32
/* event mask for the context_preview */ /* event mask for the context_preview */
#define CONTEXT_PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \ #define CONTEXT_PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \ GDK_BUTTON_RELEASE_MASK | \
@ -62,6 +65,19 @@ static unsigned char scale_indicator_bits[7][7][3] =
static GtkWidget *gcp_popup = NULL; static GtkWidget *gcp_popup = NULL;
static GtkWidget *gcp_popup_preview = NULL; static GtkWidget *gcp_popup_preview = NULL;
/* dnd stuff */
static GtkWidget *gcp_drag_window = NULL;
static GtkWidget *gcp_drag_preview = NULL;
static GtkTargetEntry context_preview_target_table[3][1] =
{
{ GIMP_TARGET_BRUSH },
{ GIMP_TARGET_PATTERN },
{ GIMP_TARGET_GRADIENT }
};
static guint n_targets = 1;
/* signals */ /* signals */
enum { enum {
@ -81,15 +97,24 @@ static void gimp_context_preview_popup_open (GimpContextPreview *,
static void gimp_context_preview_popup_close (); static void gimp_context_preview_popup_close ();
static gboolean gimp_context_preview_data_matches_type (GimpContextPreview *, static gboolean gimp_context_preview_data_matches_type (GimpContextPreview *,
gpointer); gpointer);
static void gimp_context_preview_drag_begin (GtkWidget *,
GdkDragContext *);
static void gimp_context_preview_draw_brush (GimpContextPreview *); static void gimp_context_preview_draw_brush (GimpContextPreview *);
static void gimp_context_preview_draw_brush_popup (GimpContextPreview *); static void gimp_context_preview_draw_brush_popup (GimpContextPreview *);
static void gimp_context_preview_draw_brush_drag (GimpContextPreview *);
static void gimp_context_preview_draw_pattern (GimpContextPreview *); static void gimp_context_preview_draw_pattern (GimpContextPreview *);
static void gimp_context_preview_draw_pattern_popup (GimpContextPreview *); static void gimp_context_preview_draw_pattern_popup (GimpContextPreview *);
static void gimp_context_preview_draw_pattern_drag (GimpContextPreview *);
static void gimp_context_preview_draw_gradient (GimpContextPreview *); static void gimp_context_preview_draw_gradient (GimpContextPreview *);
static void gimp_context_preview_draw_gradient_popup (GimpContextPreview *); static void gimp_context_preview_draw_gradient_popup (GimpContextPreview *);
static void gimp_context_preview_draw_gradient_drag (GimpContextPreview *);
static gint brush_dirty_callback (GimpBrush *, GimpContextPreview *); static gint brush_dirty_callback (GimpBrush *, GimpContextPreview *);
static gint brush_rename_callback (GimpBrush *, GimpContextPreview *); static gint brush_rename_callback (GimpBrush *, GimpContextPreview *);
static void draw_brush (GtkPreview *, GimpBrush*, int, int);
static void draw_pattern (GtkPreview *, GPattern*, int, int);
static void draw_gradient (GtkPreview *, gradient_t*, int, int);
static void static void
@ -125,6 +150,7 @@ gimp_context_preview_class_init (GimpContextPreviewClass *class)
widget_class->button_press_event = gimp_context_preview_button_press_event; widget_class->button_press_event = gimp_context_preview_button_press_event;
widget_class->button_release_event = gimp_context_preview_button_release_event; widget_class->button_release_event = gimp_context_preview_button_release_event;
widget_class->drag_begin = gimp_context_preview_drag_begin;
object_class->destroy = gimp_context_preview_destroy; object_class->destroy = gimp_context_preview_destroy;
} }
@ -136,7 +162,9 @@ gimp_context_preview_init (GimpContextPreview *gcp)
gcp->type = GCP_LAST; gcp->type = GCP_LAST;
gcp->width = 0; gcp->width = 0;
gcp->height = 0; gcp->height = 0;
gcp->show_popup = FALSE;
gcp->show_tooltips = FALSE; gcp->show_tooltips = FALSE;
gcp->drag_source = FALSE;
GTK_PREVIEW (gcp)->type = GTK_PREVIEW_COLOR; GTK_PREVIEW (gcp)->type = GTK_PREVIEW_COLOR;
GTK_PREVIEW (gcp)->bpp = 3; GTK_PREVIEW (gcp)->bpp = 3;
GTK_PREVIEW (gcp)->dither = GDK_RGB_DITHER_NORMAL; GTK_PREVIEW (gcp)->dither = GDK_RGB_DITHER_NORMAL;
@ -173,7 +201,9 @@ GtkWidget*
gimp_context_preview_new (GimpContextPreviewType type, gimp_context_preview_new (GimpContextPreviewType type,
gint width, gint width,
gint height, gint height,
gboolean show_tooltips) gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source)
{ {
GimpContextPreview *gcp; GimpContextPreview *gcp;
@ -185,7 +215,9 @@ gimp_context_preview_new (GimpContextPreviewType type,
gcp->type = type; gcp->type = type;
gcp->width = width; gcp->width = width;
gcp->height = height; gcp->height = height;
gcp->show_popup = !drag_source && show_popup;
gcp->show_tooltips = show_tooltips; gcp->show_tooltips = show_tooltips;
gcp->drag_source = drag_source;
gtk_preview_size (GTK_PREVIEW (gcp), width, height); gtk_preview_size (GTK_PREVIEW (gcp), width, height);
@ -199,6 +231,14 @@ gimp_context_preview_update (GimpContextPreview *gcp,
g_return_if_fail (GIMP_IS_CONTEXT_PREVIEW (gcp)); g_return_if_fail (GIMP_IS_CONTEXT_PREVIEW (gcp));
g_return_if_fail (gimp_context_preview_data_matches_type (gcp, data)); g_return_if_fail (gimp_context_preview_data_matches_type (gcp, data));
if (!gcp->data && gcp->drag_source) /* first call */
{
gtk_drag_source_set (GTK_WIDGET (gcp),
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
context_preview_target_table[gcp->type], n_targets,
GDK_ACTION_COPY);
}
if (gcp->data && gcp->type == GCP_BRUSH) if (gcp->data && gcp->type == GCP_BRUSH)
gtk_signal_disconnect_by_data (GTK_OBJECT (gcp->data), gcp); gtk_signal_disconnect_by_data (GTK_OBJECT (gcp->data), gcp);
@ -262,11 +302,14 @@ gimp_context_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
if (bevent->button == 1) if (bevent->button == 1)
{
if (GIMP_CONTEXT_PREVIEW (widget)->show_popup)
{ {
gdk_pointer_grab (widget->window, FALSE, GDK_BUTTON_RELEASE_MASK, gdk_pointer_grab (widget->window, FALSE, GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time); NULL, NULL, bevent->time);
gimp_context_preview_popup_open (GIMP_CONTEXT_PREVIEW (widget), gimp_context_preview_popup_open (GIMP_CONTEXT_PREVIEW (widget),
bevent->x, bevent->y); bevent->x, bevent->y);
}
gtk_signal_emit_by_name (GTK_OBJECT (widget), "clicked"); gtk_signal_emit_by_name (GTK_OBJECT (widget), "clicked");
} }
return TRUE; return TRUE;
@ -276,7 +319,7 @@ static gint
gimp_context_preview_button_release_event (GtkWidget *widget, gimp_context_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
if (bevent->button == 1) if (bevent->button == 1 && GIMP_CONTEXT_PREVIEW (widget)->show_popup)
{ {
gdk_pointer_ungrab (bevent->time); gdk_pointer_ungrab (bevent->time);
gimp_context_preview_popup_close (); gimp_context_preview_popup_close ();
@ -408,67 +451,55 @@ gimp_context_preview_data_matches_type (GimpContextPreview *gcp,
return (match); return (match);
} }
static void
gimp_context_preview_drag_begin (GtkWidget *widget,
GdkDragContext *context)
{
GimpContextPreview *gcp;
gcp = GIMP_CONTEXT_PREVIEW (widget);
if (!gcp_drag_window)
{
gcp_drag_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_policy (GTK_WINDOW (gcp_drag_window), FALSE, FALSE, TRUE);
gtk_widget_realize (gcp_drag_window);
gtk_signal_connect (GTK_OBJECT (gcp_drag_window), "destroy",
gtk_widget_destroyed, &gcp_drag_window);
gcp_drag_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_signal_connect (GTK_OBJECT (gcp_drag_preview), "destroy",
gtk_widget_destroyed, &gcp_drag_preview);
gtk_container_add (GTK_CONTAINER (gcp_drag_window), gcp_drag_preview);
gtk_widget_show (gcp_drag_preview);
}
switch (gcp->type)
{
case GCP_BRUSH:
gimp_context_preview_draw_brush_drag (gcp);
break;
case GCP_PATTERN:
gimp_context_preview_draw_pattern_drag (gcp);
break;
case GCP_GRADIENT:
gimp_context_preview_draw_gradient_drag (gcp);
break;
default:
break;
}
gtk_widget_queue_draw (gcp_drag_preview);
gtk_drag_set_icon_widget (context, gcp_drag_window, 0, 0);
}
/* brush draw functions */ /* brush draw functions */
static void static void draw_brush (GtkPreview *preview,
gimp_context_preview_draw_brush_popup (GimpContextPreview *gcp) GimpBrush *brush,
gint width,
gint height)
{ {
GimpBrush *brush;
guchar *mask, *buf, *b;
guchar bg;
gint width, height;
gint x, y;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
width = brush->mask->width;
height = brush->mask->height;
buf = g_new (guchar, 3 * width);
mask = temp_buf_data (brush->mask);
if (GIMP_IS_BRUSH_PIXMAP (brush))
{
guchar *pixmap = temp_buf_data (GIMP_BRUSH_PIXMAP (brush)->pixmap_mask);
for (y = 0; y < height; y++)
{
b = buf;
for (x = 0; x < width ; x++)
{
bg = (255 - *mask);
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
*b++ = bg + (*mask * *pixmap++) / 255;
mask++;
}
gtk_preview_draw_row (GTK_PREVIEW (gcp_popup_preview), buf, 0, y, width);
}
}
else
{
for (y = 0; y < height; y++)
{
b = buf;
/* Invert the mask for display. */
for (x = 0; x < width; x++)
{
bg = 255 - *mask++;
memset (b, bg, 3);
b += 3;
}
gtk_preview_draw_row (GTK_PREVIEW (gcp_popup_preview), buf, 0, y, width);
}
}
g_free(buf);
}
static void
gimp_context_preview_draw_brush (GimpContextPreview *gcp)
{
GimpBrush *brush;
gboolean scale = FALSE; gboolean scale = FALSE;
gint brush_width, brush_height; gint brush_width, brush_height;
gint offset_x, offset_y; gint offset_x, offset_y;
@ -477,19 +508,16 @@ gimp_context_preview_draw_brush (GimpContextPreview *gcp)
guchar bg; guchar bg;
gint x, y; gint x, y;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
mask_buf = brush->mask; mask_buf = brush->mask;
if (GIMP_IS_BRUSH_PIXMAP (brush)) if (GIMP_IS_BRUSH_PIXMAP (brush))
pixmap_buf = GIMP_BRUSH_PIXMAP(brush)->pixmap_mask; pixmap_buf = GIMP_BRUSH_PIXMAP(brush)->pixmap_mask;
brush_width = mask_buf->width; brush_width = mask_buf->width;
brush_height = mask_buf->height; brush_height = mask_buf->height;
if (brush_width > gcp->width || brush_height > gcp->height) if (brush_width > width || brush_height > height)
{ {
gdouble ratio_x = (gdouble)brush_width / gcp->width; gdouble ratio_x = (gdouble)brush_width / width;
gdouble ratio_y = (gdouble)brush_height / gcp->height; gdouble ratio_y = (gdouble)brush_height / height;
brush_width = (gdouble)brush_width / MAX (ratio_x, ratio_y); brush_width = (gdouble)brush_width / MAX (ratio_x, ratio_y);
brush_height = (gdouble)brush_height / MAX (ratio_x, ratio_y); brush_height = (gdouble)brush_height / MAX (ratio_x, ratio_y);
@ -504,19 +532,19 @@ gimp_context_preview_draw_brush (GimpContextPreview *gcp)
scale = TRUE; scale = TRUE;
} }
offset_x = (gcp->width - brush_width) >> 1; offset_x = (width - brush_width) / 2;
offset_y = (gcp->height - brush_height) >> 1; offset_y = (height - brush_height) / 2;
mask = temp_buf_data (mask_buf); mask = temp_buf_data (mask_buf);
buf = g_new (guchar, 3 * gcp->width); buf = g_new (guchar, 3 * width);
memset (buf, 255, 3 * gcp->width); memset (buf, 255, 3 * width);
if (GIMP_IS_BRUSH_PIXMAP (brush)) if (GIMP_IS_BRUSH_PIXMAP (brush))
{ {
guchar *pixmap = temp_buf_data (pixmap_buf); guchar *pixmap = temp_buf_data (pixmap_buf);
for (y = 0; y < offset_y; y++) for (y = 0; y < offset_y; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
for (y = offset_y; y < brush_height + offset_y; y++) for (y = offset_y; y < brush_height + offset_y; y++)
{ {
b = buf + 3 * offset_x; b = buf + 3 * offset_x;
@ -528,16 +556,16 @@ gimp_context_preview_draw_brush (GimpContextPreview *gcp)
*b++ = bg + (*mask * *pixmap++) / 255; *b++ = bg + (*mask * *pixmap++) / 255;
mask++; mask++;
} }
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
} }
memset (buf, 255, 3 * gcp->width); memset (buf, 255, 3 * width);
for (y = brush_height + offset_y; y < gcp->height; y++) for (y = brush_height + offset_y; y < height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
} }
else else
{ {
for (y = 0; y < offset_y; y++) for (y = 0; y < offset_y; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
for (y = offset_y; y < brush_height + offset_y; y++) for (y = offset_y; y < brush_height + offset_y; y++)
{ {
b = buf + 3 * offset_x; b = buf + 3 * offset_x;
@ -547,19 +575,19 @@ gimp_context_preview_draw_brush (GimpContextPreview *gcp)
memset (b, bg, 3); memset (b, bg, 3);
b += 3; b += 3;
} }
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
} }
memset (buf, 255, 3 * gcp->width); memset (buf, 255, 3 * width);
for (y = brush_height + offset_y; y < gcp->height; y++) for (y = brush_height + offset_y; y < height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width); gtk_preview_draw_row (preview, buf, 0, y, width);
} }
if (scale) if (scale)
{ {
offset_x = gcp->width - scale_indicator_width - 1; offset_x = width - scale_indicator_width - 1;
offset_y = gcp->height - scale_indicator_height - 1; offset_y = height - scale_indicator_height - 1;
for (y = 0; y < scale_indicator_height; y++) for (y = 0; y < scale_indicator_height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), scale_indicator_bits[y][0], gtk_preview_draw_row (preview, scale_indicator_bits[y][0],
offset_x, offset_y + y, scale_indicator_width); offset_x, offset_y + y, scale_indicator_width);
temp_buf_free (mask_buf); temp_buf_free (mask_buf);
if (GIMP_IS_BRUSH_PIXMAP (brush)) if (GIMP_IS_BRUSH_PIXMAP (brush))
@ -569,6 +597,43 @@ gimp_context_preview_draw_brush (GimpContextPreview *gcp)
g_free (buf); g_free (buf);
} }
static void
gimp_context_preview_draw_brush_popup (GimpContextPreview *gcp)
{
GimpBrush *brush;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
draw_brush (GTK_PREVIEW (gcp_popup_preview), brush,
brush->mask->width, brush->mask->height);
}
static void
gimp_context_preview_draw_brush_drag (GimpContextPreview *gcp)
{
GimpBrush *brush;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
draw_brush (GTK_PREVIEW (gcp_drag_preview), brush,
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
}
static void
gimp_context_preview_draw_brush (GimpContextPreview *gcp)
{
GimpBrush *brush;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
draw_brush (GTK_PREVIEW (gcp), brush, gcp->width, gcp->height);
}
/* brush callbacks */ /* brush callbacks */
static gint static gint
brush_dirty_callback (GimpBrush *brush, brush_dirty_callback (GimpBrush *brush,
@ -594,106 +659,86 @@ brush_rename_callback (GimpBrush *brush,
/* pattern draw functions */ /* pattern draw functions */
static void static void
gimp_context_preview_draw_pattern_popup (GimpContextPreview *gcp) draw_pattern (GtkPreview *preview,
GPattern *pattern,
gint width,
gint height)
{ {
GPattern *pattern; gint pattern_width, pattern_height;
guchar *mask; guchar *mask, *src, *buf, *b;
gint width, height;
gint x, y; gint x, y;
g_return_if_fail (gcp != NULL && gcp->data != NULL); pattern_width = pattern->mask->width;
pattern_height = pattern->mask->height;
pattern = (GPattern*)(gcp->data);
width = pattern->mask->width;
height = pattern->mask->height;
mask = temp_buf_data (pattern->mask); mask = temp_buf_data (pattern->mask);
buf = g_new (guchar, 3 * width);
if (pattern->mask->bytes == 1) if (pattern->mask->bytes == 1)
{ {
guchar *buf = g_new (guchar, 3 * width);
guchar *b;
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
b = buf; b = buf;
src = mask + (pattern_width * (y % pattern_height));
for (x = 0; x < width ; x++) for (x = 0; x < width ; x++)
{ {
memset (b, *mask++, 3); memset (b, src[x % pattern_width], 3);
b += 3; b += 3;
} }
gtk_preview_draw_row (GTK_PREVIEW (gcp_popup_preview), buf, 0, y, width); gtk_preview_draw_row (preview, buf, 0, y, width);
} }
g_free(buf);
} }
else else
{ {
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
gtk_preview_draw_row (GTK_PREVIEW (gcp_popup_preview), mask, 0, y, width); b = buf;
mask += 3 * width; src = mask + 3 * (pattern_width * (y % pattern_height));
for (x = 0; x < width ; x++)
{
memcpy (b, src + 3 * (x % pattern_width), 3);
b += 3;
}
gtk_preview_draw_row (preview, buf, 0, y, width);
} }
} }
g_free(buf);
}
static void
gimp_context_preview_draw_pattern_popup (GimpContextPreview *gcp)
{
GPattern *pattern;
g_return_if_fail (gcp != NULL && gcp->data != NULL);
pattern = (GPattern*)(gcp->data);
draw_pattern (GTK_PREVIEW (gcp_popup_preview), pattern,
pattern->mask->width, pattern->mask->height);
}
static void
gimp_context_preview_draw_pattern_drag (GimpContextPreview *gcp)
{
GPattern *pattern;
g_return_if_fail (gcp != NULL && gcp->data != NULL);
pattern = (GPattern*)(gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
draw_pattern (GTK_PREVIEW (gcp_drag_preview), pattern,
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
} }
static void static void
gimp_context_preview_draw_pattern (GimpContextPreview *gcp) gimp_context_preview_draw_pattern (GimpContextPreview *gcp)
{ {
GPattern *pattern; GPattern *pattern;
gint pattern_width, pattern_height;
gint width, height;
gint offset_x, offset_y;
guchar *mask, *buf, *b;
gint x, y;
g_return_if_fail (gcp != NULL && gcp->data != NULL); g_return_if_fail (gcp != NULL && gcp->data != NULL);
pattern = (GPattern*)(gcp->data); pattern = (GPattern*)(gcp->data);
pattern_width = pattern->mask->width; draw_pattern (GTK_PREVIEW (gcp), pattern, gcp->width, gcp->height);
pattern_height = pattern->mask->height;
width = (pattern_width > gcp->width) ? gcp->width : pattern_width;
height = (pattern_height > gcp->height) ? gcp->height : pattern_height;
offset_x = (gcp->width - width) >> 1;
offset_y = (gcp->height - height) >> 1;
mask = temp_buf_data (pattern->mask);
buf = g_new (guchar, 3 * gcp->width);
memset (buf, 255, 3 * gcp->width);
for (y = 0; y < offset_y; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width);
if (pattern->mask->bytes == 1)
{
for (y = offset_y; y < height + offset_y; y++)
{
b = buf + 3 * offset_x;
for (x = 0; x < width ; x++)
{
memset (b, mask[x], 3);
b += 3;
}
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width);
mask += pattern_width;
}
}
else
{
for (y = offset_y; y < height + offset_y; y++)
{
b = buf + 3 * offset_x;
memcpy (b, mask, 3 * width);
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width);
mask += 3 * pattern_width;
}
}
memset (buf, 255, 3 * gcp->width);
for (y = height + offset_y; y < gcp->height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcp), buf, 0, y, gcp->width);
g_free(buf);
} }
@ -770,6 +815,20 @@ gimp_context_preview_draw_gradient_popup (GimpContextPreview *gcp)
GRADIENT_POPUP_WIDTH, GRADIENT_POPUP_HEIGHT); GRADIENT_POPUP_WIDTH, GRADIENT_POPUP_HEIGHT);
} }
static void
gimp_context_preview_draw_gradient_drag (GimpContextPreview *gcp)
{
gradient_t *gradient;
g_return_if_fail (gcp != NULL && gcp->data != NULL);
gradient = (gradient_t*)(gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
GRADIENT_POPUP_WIDTH / 4, GRADIENT_POPUP_HEIGHT / 4);
draw_gradient (GTK_PREVIEW (gcp_drag_preview), gradient,
GRADIENT_POPUP_WIDTH / 4, GRADIENT_POPUP_HEIGHT / 4);
}
static void static void
gimp_context_preview_draw_gradient (GimpContextPreview *gcp) gimp_context_preview_draw_gradient (GimpContextPreview *gcp)
{ {

View File

@ -47,13 +47,15 @@ typedef enum
struct _GimpContextPreview struct _GimpContextPreview
{ {
GtkPreview preview; GtkPreview preview; /* parent */
gpointer data; gpointer data; /* brush|pattern|gradient */
GimpContextPreviewType type; GimpContextPreviewType type; /* GCP_BRUSH|GCP_PATTERN|GCP_GRADIENT */
gint width; gint width; /* preview width */
gint height; gint height; /* preview_height */
gboolean show_tooltips; gboolean show_popup; /* popup a larger preview on press */
gboolean show_tooltips; /* install tooltips showing the name */
gboolean drag_source; /* make the preview a drag_source */
}; };
struct _GimpContextPreviewClass struct _GimpContextPreviewClass
@ -67,7 +69,9 @@ GtkType gimp_context_preview_get_type (void);
GtkWidget* gimp_context_preview_new (GimpContextPreviewType type, GtkWidget* gimp_context_preview_new (GimpContextPreviewType type,
gint width, gint width,
gint height, gint height,
gboolean show_tooltips); gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source);
void gimp_context_preview_update (GimpContextPreview *gcp, void gimp_context_preview_update (GimpContextPreview *gcp,
gpointer data); gpointer data);

View File

@ -242,7 +242,7 @@ gimp_dnd_color_drag_begin (GtkWidget *widget,
window = gtk_window_new (GTK_WINDOW_POPUP); window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32); gtk_widget_set_usize (window, 32, 32);
gtk_widget_realize (window); gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget), gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-drag-window", "gimp-color-drag-window",

View File

@ -33,7 +33,10 @@ enum
GIMP_DND_TYPE_LAYER_MASK, GIMP_DND_TYPE_LAYER_MASK,
GIMP_DND_TYPE_COMPONENT, GIMP_DND_TYPE_COMPONENT,
GIMP_DND_TYPE_PATH, GIMP_DND_TYPE_PATH,
GIMP_DND_TYPE_COLOR GIMP_DND_TYPE_COLOR,
GIMP_DND_TYPE_BRUSH,
GIMP_DND_TYPE_PATTERN,
GIMP_DND_TYPE_GRADIENT
}; };
#define GIMP_TARGET_URI_LIST \ #define GIMP_TARGET_URI_LIST \
@ -66,6 +69,15 @@ enum
#define GIMP_TARGET_COLOR \ #define GIMP_TARGET_COLOR \
{ "application/x-color", 0, GIMP_DND_TYPE_COLOR } { "application/x-color", 0, GIMP_DND_TYPE_COLOR }
#define GIMP_TARGET_BRUSH \
{ "GIMP_BRUSH", 0, GIMP_DND_TYPE_BRUSH }
#define GIMP_TARGET_PATTERN \
{ "GIMP_PATTERN", 0, GIMP_DND_TYPE_PATTERN }
#define GIMP_TARGET_GRADIENT \
{ "GIMP_GRADIENT", 0, GIMP_DND_TYPE_GRADIENT }
typedef enum typedef enum
{ {
GIMP_DROP_NONE, GIMP_DROP_NONE,

View File

@ -125,6 +125,18 @@ static GtkTargetEntry color_area_target_table[] =
}; };
static guint n_color_area_targets = (sizeof (color_area_target_table) / static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0])); sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
void void
@ -769,7 +781,7 @@ create_device_status (void)
gtk_drag_source_set (deviceD->colors[i], gtk_drag_source_set (deviceD->colors[i],
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets, color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY);
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color, gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
GUINT_TO_POINTER (device_info->device)); GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->colors[i], gtk_drag_dest_set (deviceD->colors[i],
@ -786,15 +798,26 @@ create_device_status (void)
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH, deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1, 3, 4, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN, deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1, 4, 5, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);

View File

@ -117,7 +117,7 @@ indicator_area_create ()
brush_preview = gimp_context_preview_new (GCP_BRUSH, brush_preview = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, brush_preview, gtk_tooltips_set_tip (tool_tips, brush_preview,
_("The active brush.\nClick to open the Brushes Dialog."), _("The active brush.\nClick to open the Brushes Dialog."),
NULL); NULL);
@ -128,7 +128,7 @@ indicator_area_create ()
pattern_preview = gimp_context_preview_new (GCP_PATTERN, pattern_preview = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, pattern_preview, gtk_tooltips_set_tip (tool_tips, pattern_preview,
_("The active pattern.\nClick to open the Patterns Dialog."), _("The active pattern.\nClick to open the Patterns Dialog."),
NULL); NULL);
@ -139,7 +139,7 @@ indicator_area_create ()
gradient_preview = gimp_context_preview_new (GCP_GRADIENT, gradient_preview = gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, gradient_preview, gtk_tooltips_set_tip (tool_tips, gradient_preview,
_("The active gradient.\nClick to open the Gradients Dialog."), _("The active gradient.\nClick to open the Gradients Dialog."),
NULL); NULL);

View File

@ -125,6 +125,18 @@ static GtkTargetEntry color_area_target_table[] =
}; };
static guint n_color_area_targets = (sizeof (color_area_target_table) / static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0])); sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
void void
@ -769,7 +781,7 @@ create_device_status (void)
gtk_drag_source_set (deviceD->colors[i], gtk_drag_source_set (deviceD->colors[i],
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets, color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY);
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color, gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
GUINT_TO_POINTER (device_info->device)); GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->colors[i], gtk_drag_dest_set (deviceD->colors[i],
@ -786,15 +798,26 @@ create_device_status (void)
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH, deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1, 3, 4, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN, deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1, 4, 5, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);

View File

@ -117,7 +117,7 @@ indicator_area_create ()
brush_preview = gimp_context_preview_new (GCP_BRUSH, brush_preview = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, brush_preview, gtk_tooltips_set_tip (tool_tips, brush_preview,
_("The active brush.\nClick to open the Brushes Dialog."), _("The active brush.\nClick to open the Brushes Dialog."),
NULL); NULL);
@ -128,7 +128,7 @@ indicator_area_create ()
pattern_preview = gimp_context_preview_new (GCP_PATTERN, pattern_preview = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, pattern_preview, gtk_tooltips_set_tip (tool_tips, pattern_preview,
_("The active pattern.\nClick to open the Patterns Dialog."), _("The active pattern.\nClick to open the Patterns Dialog."),
NULL); NULL);
@ -139,7 +139,7 @@ indicator_area_create ()
gradient_preview = gimp_context_preview_new (GCP_GRADIENT, gradient_preview = gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, gradient_preview, gtk_tooltips_set_tip (tool_tips, gradient_preview,
_("The active gradient.\nClick to open the Gradients Dialog."), _("The active gradient.\nClick to open the Gradients Dialog."),
NULL); NULL);

View File

@ -125,6 +125,18 @@ static GtkTargetEntry color_area_target_table[] =
}; };
static guint n_color_area_targets = (sizeof (color_area_target_table) / static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0])); sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
void void
@ -769,7 +781,7 @@ create_device_status (void)
gtk_drag_source_set (deviceD->colors[i], gtk_drag_source_set (deviceD->colors[i],
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets, color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY);
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color, gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
GUINT_TO_POINTER (device_info->device)); GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->colors[i], gtk_drag_dest_set (deviceD->colors[i],
@ -786,15 +798,26 @@ create_device_status (void)
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH, deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1, 3, 4, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN, deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1, 4, 5, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);

View File

@ -125,6 +125,18 @@ static GtkTargetEntry color_area_target_table[] =
}; };
static guint n_color_area_targets = (sizeof (color_area_target_table) / static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0])); sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
void void
@ -769,7 +781,7 @@ create_device_status (void)
gtk_drag_source_set (deviceD->colors[i], gtk_drag_source_set (deviceD->colors[i],
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
color_area_target_table, n_color_area_targets, color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY);
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color, gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
GUINT_TO_POINTER (device_info->device)); GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->colors[i], gtk_drag_dest_set (deviceD->colors[i],
@ -786,15 +798,26 @@ create_device_status (void)
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH, deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1, 3, 4, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN, deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
TRUE); FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1, 4, 5, i, i+1,
0, 0, 2, 2); 0, 0, 2, 2);

View File

@ -242,7 +242,7 @@ gimp_dnd_color_drag_begin (GtkWidget *widget,
window = gtk_window_new (GTK_WINDOW_POPUP); window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_widget_set_usize (window, 48, 32); gtk_widget_set_usize (window, 32, 32);
gtk_widget_realize (window); gtk_widget_realize (window);
gtk_object_set_data_full (GTK_OBJECT (widget), gtk_object_set_data_full (GTK_OBJECT (widget),
"gimp-color-drag-window", "gimp-color-drag-window",

View File

@ -33,7 +33,10 @@ enum
GIMP_DND_TYPE_LAYER_MASK, GIMP_DND_TYPE_LAYER_MASK,
GIMP_DND_TYPE_COMPONENT, GIMP_DND_TYPE_COMPONENT,
GIMP_DND_TYPE_PATH, GIMP_DND_TYPE_PATH,
GIMP_DND_TYPE_COLOR GIMP_DND_TYPE_COLOR,
GIMP_DND_TYPE_BRUSH,
GIMP_DND_TYPE_PATTERN,
GIMP_DND_TYPE_GRADIENT
}; };
#define GIMP_TARGET_URI_LIST \ #define GIMP_TARGET_URI_LIST \
@ -66,6 +69,15 @@ enum
#define GIMP_TARGET_COLOR \ #define GIMP_TARGET_COLOR \
{ "application/x-color", 0, GIMP_DND_TYPE_COLOR } { "application/x-color", 0, GIMP_DND_TYPE_COLOR }
#define GIMP_TARGET_BRUSH \
{ "GIMP_BRUSH", 0, GIMP_DND_TYPE_BRUSH }
#define GIMP_TARGET_PATTERN \
{ "GIMP_PATTERN", 0, GIMP_DND_TYPE_PATTERN }
#define GIMP_TARGET_GRADIENT \
{ "GIMP_GRADIENT", 0, GIMP_DND_TYPE_GRADIENT }
typedef enum typedef enum
{ {
GIMP_DROP_NONE, GIMP_DROP_NONE,

View File

@ -117,7 +117,7 @@ indicator_area_create ()
brush_preview = gimp_context_preview_new (GCP_BRUSH, brush_preview = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, brush_preview, gtk_tooltips_set_tip (tool_tips, brush_preview,
_("The active brush.\nClick to open the Brushes Dialog."), _("The active brush.\nClick to open the Brushes Dialog."),
NULL); NULL);
@ -128,7 +128,7 @@ indicator_area_create ()
pattern_preview = gimp_context_preview_new (GCP_PATTERN, pattern_preview = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE, CELL_SIZE, CELL_SIZE,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, pattern_preview, gtk_tooltips_set_tip (tool_tips, pattern_preview,
_("The active pattern.\nClick to open the Patterns Dialog."), _("The active pattern.\nClick to open the Patterns Dialog."),
NULL); NULL);
@ -139,7 +139,7 @@ indicator_area_create ()
gradient_preview = gimp_context_preview_new (GCP_GRADIENT, gradient_preview = gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT,
FALSE); TRUE, FALSE, FALSE);
gtk_tooltips_set_tip (tool_tips, gradient_preview, gtk_tooltips_set_tip (tool_tips, gradient_preview,
_("The active gradient.\nClick to open the Gradients Dialog."), _("The active gradient.\nClick to open the Gradients Dialog."),
NULL); NULL);