mirror of https://github.com/GNOME/gimp.git
applied gimp-alt-980729-0 and gimp-alt-980730-0, brush and pattern popups in
the devices dialog -Yosh
This commit is contained in:
parent
5b6e6cd6f0
commit
81a6cba140
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 31 15:41:30 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* applied gimp-alt-980729-0 and gimp-alt-980730-0, adds brush
|
||||
popup and pattern popup to the devices dialog
|
||||
|
||||
Fri Jul 31 19:17:15 BST 1998 Adam D. Moss <adam@gimp.org>
|
||||
|
||||
* app/[lots of files].c: On all gimp-core fopen()s
|
||||
|
|
464
app/devices.c
464
app/devices.c
|
@ -24,10 +24,22 @@
|
|||
#include "devices.h"
|
||||
#include "interface.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "palette.h"
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define CELL_SIZE 20 /* The size of the preview cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
#define BRUSH_PREVIEW 1
|
||||
#define PATTERN_PREVIEW 2
|
||||
|
||||
typedef struct _DeviceInfo DeviceInfo;
|
||||
|
||||
struct _DeviceInfo {
|
||||
|
@ -46,6 +58,7 @@ struct _DeviceInfo {
|
|||
GdkDeviceKey *keys;
|
||||
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
ToolType tool;
|
||||
unsigned char foreground[3];
|
||||
};
|
||||
|
@ -64,6 +77,7 @@ struct _DeviceInfoDialog {
|
|||
GtkWidget **tools;
|
||||
GtkWidget **colors;
|
||||
GtkWidget **brushes;
|
||||
GtkWidget **patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,7 +85,10 @@ struct _DeviceInfoDialog {
|
|||
|
||||
GList *devices_info = NULL;
|
||||
DeviceInfoDialog *deviceD = NULL;
|
||||
|
||||
GtkWidget *device_bpopup = NULL; /* Can't share since differnt depths */
|
||||
GtkWidget *device_bpreview = NULL;
|
||||
GtkWidget *device_patpopup = NULL;
|
||||
GtkWidget *device_patpreview = NULL;
|
||||
/* If true, don't update device information dialog */
|
||||
int suppress_update = FALSE;
|
||||
|
||||
|
@ -85,6 +102,8 @@ static void devices_write_rc (void);
|
|||
static void device_status_destroy_callback (void);
|
||||
static void devices_close_callback (GtkWidget *, gpointer);
|
||||
static void device_status_update_current ();
|
||||
static gint brush_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
static gint pattern_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
|
||||
/* Global data */
|
||||
int current_device = GDK_CORE_POINTER;
|
||||
|
@ -172,6 +191,7 @@ devices_init (void)
|
|||
device_info->axes = NULL;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -198,7 +218,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[])
|
||||
guchar foreground[],gchar *pattern_name)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
|
@ -248,6 +268,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
device_info->mode = GDK_MODE_DISABLED;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -296,14 +317,20 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
}
|
||||
}
|
||||
|
||||
if (values & (DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
device_info->is_init = TRUE;
|
||||
|
||||
|
||||
if (values & DEVICE_BRUSH)
|
||||
{
|
||||
device_info->brush = gimp_brush_list_get_brush(brush_list, brush_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
device_info->pattern = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_TOOL)
|
||||
device_info->tool = tool;
|
||||
|
||||
|
@ -351,6 +378,8 @@ select_device (guint32 new_device)
|
|||
palette_set_foreground (device_info->foreground[0],
|
||||
device_info->foreground[1],
|
||||
device_info->foreground[2]);
|
||||
if (device_info->pattern)
|
||||
select_pattern(device_info->pattern);
|
||||
}
|
||||
|
||||
suppress_update = FALSE;
|
||||
|
@ -409,6 +438,7 @@ devices_save_current_info (void)
|
|||
device_info->is_init = TRUE;
|
||||
device_info->device = current_device;
|
||||
device_info->brush = get_active_brush ();
|
||||
device_info->pattern = get_active_pattern();
|
||||
if (active_tool_type >= 0)
|
||||
device_info->tool = active_tool_type;
|
||||
else
|
||||
|
@ -529,6 +559,7 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
|
@ -590,7 +621,7 @@ create_device_status (void)
|
|||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 4, FALSE);
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
deviceD->table);
|
||||
|
@ -602,6 +633,7 @@ create_device_status (void)
|
|||
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
||||
|
||||
tmp_list = devices_info;
|
||||
i=0;
|
||||
|
@ -638,16 +670,35 @@ create_device_status (void)
|
|||
0, 0, 2, 2);
|
||||
|
||||
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), 20, 20);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
||||
2, 3, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
deviceD->brushes[i] = gtk_label_new ("");
|
||||
deviceD->brushes[i] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->brushes[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->brushes[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "event",
|
||||
(GtkSignalFunc) brush_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
||||
3, 4, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
deviceD->patterns[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->patterns[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->patterns[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
||||
4, 5, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
if (device_info->is_present)
|
||||
device_status_update (device_info->device);
|
||||
|
||||
|
@ -685,6 +736,7 @@ device_status_destroy_callback (void)
|
|||
g_free(deviceD->tools);
|
||||
g_free(deviceD->colors);
|
||||
g_free(deviceD->brushes);
|
||||
g_free(deviceD->patterns);
|
||||
|
||||
g_free(deviceD);
|
||||
deviceD = NULL;
|
||||
|
@ -727,11 +779,392 @@ device_status_update_current ()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_bpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_bpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_bpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_bpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_bpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_bpreview);
|
||||
gtk_widget_show (device_bpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->brushes[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (brush->mask->width >> 1);
|
||||
y = y_org + y - (brush->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_bpreview), brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (device_bpopup, x, y);
|
||||
|
||||
/* Draw the brush */
|
||||
buf = g_new (gchar, brush->mask->width);
|
||||
src = (gchar *)temp_buf_data (brush->mask);
|
||||
for (y = 0; y < brush->mask->height; y++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_bpreview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_bpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GPatternP pattern)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_patpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_patpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_patpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_patpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_patpreview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_patpreview);
|
||||
gtk_widget_show (device_patpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->patterns[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (pattern->mask->width >> 1);
|
||||
y = y_org + y - (pattern->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + pattern->mask->width > scr_w) ? scr_w - pattern->mask->width : x;
|
||||
y = (y + pattern->mask->height > scr_h) ? scr_h - pattern->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_patpreview), pattern->mask->width, pattern->mask->height);
|
||||
|
||||
gtk_widget_popup (device_patpopup, x, y);
|
||||
|
||||
/* Draw the pattern */
|
||||
buf = g_new (gchar, pattern->mask->width * 3);
|
||||
src = (gchar *)temp_buf_data (pattern->mask);
|
||||
for (y = 0; y < pattern->mask->height; y++)
|
||||
{
|
||||
if (pattern->mask->bytes == 1)
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x];
|
||||
buf[x*3+1] = src[x];
|
||||
buf[x*3+2] = src[x];
|
||||
}
|
||||
else
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x*3+0];
|
||||
buf[x*3+1] = src[x*3+1];
|
||||
buf[x*3+2] = src[x*3+2];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_patpreview), (guchar *)buf, 0, y, pattern->mask->width);
|
||||
src += pattern->mask->width * pattern->mask->bytes;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_patpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
device_popup_close (int type)
|
||||
{
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
if (device_bpopup != NULL)
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
else if (type == PATTERN_PREVIEW)
|
||||
{
|
||||
if (device_patpopup != NULL)
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
device_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid,
|
||||
int type)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkEventButton *bevent;
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
tmp_list = devices_info;
|
||||
while (tmp_list)
|
||||
{
|
||||
device_info = (DeviceInfo *)tmp_list->data;
|
||||
|
||||
if (device_info->device == deviceD->ids[deviceid])
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if(tmp_list == NULL)
|
||||
{
|
||||
g_message("Failed to find device_info\n");
|
||||
break; /* Error no device info */
|
||||
}
|
||||
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
brush = device_info->brush;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (brush->mask->width > CELL_SIZE ||
|
||||
brush->mask->height > CELL_SIZE)
|
||||
brush_popup_open (deviceid, bevent->x, bevent->y, brush);
|
||||
}
|
||||
else if(type == PATTERN_PREVIEW)
|
||||
{
|
||||
pattern = device_info->pattern;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (pattern->mask->width > CELL_SIZE ||
|
||||
pattern->mask->height > CELL_SIZE)
|
||||
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* Ungrab the pointer */
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
|
||||
/* Close the device preview popup window */
|
||||
device_popup_close (type);
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,BRUSH_PREVIEW));
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,PATTERN_PREVIEW));
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_brush(GimpBrushP brush,int preview_id)
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->brushes[preview_id],brush->name,NULL);
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += brush_buf->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_pattern(GPatternP pattern,int preview_id)
|
||||
{
|
||||
gchar *buffer = NULL;
|
||||
TempBuf * pattern_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int rowstride;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->patterns[preview_id],pattern->name,NULL);
|
||||
|
||||
buffer = g_new (gchar, pattern->mask->width * 3);
|
||||
pattern_buf = pattern->mask;
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (pattern_buf->width > CELL_SIZE) ? CELL_SIZE: pattern_buf->width;
|
||||
height = (pattern_buf->height > CELL_SIZE) ? CELL_SIZE: pattern_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
src = mask_buf_data (pattern_buf) + (ystart - offset_y) * rowstride;
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
|
||||
if (pattern_buf->bytes == 1)
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s;
|
||||
*b++ = *s;
|
||||
*b++ = *s++;
|
||||
}
|
||||
else
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += rowstride;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
device_status_update (guint32 deviceid)
|
||||
{
|
||||
int i, j;
|
||||
guchar buffer[20*3];
|
||||
guchar buffer[CELL_SIZE*3];
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkDeviceInfo *gdk_info;
|
||||
|
@ -783,6 +1216,7 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_hide (deviceD->tools[i]);
|
||||
gtk_widget_hide (deviceD->colors[i]);
|
||||
gtk_widget_hide (deviceD->brushes[i]);
|
||||
gtk_widget_hide (deviceD->patterns[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -795,24 +1229,26 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_draw (deviceD->tools[i], NULL);
|
||||
gtk_widget_show (deviceD->tools[i]);
|
||||
|
||||
for (j=0;j<20*3;j+=3)
|
||||
for (j=0;j<CELL_SIZE*3;j+=3)
|
||||
{
|
||||
buffer[j] = device_info->foreground[0];
|
||||
buffer[j+1] = device_info->foreground[1];
|
||||
buffer[j+2] = device_info->foreground[2];
|
||||
}
|
||||
|
||||
for (j=0;j<20;j++)
|
||||
for (j=0;j<CELL_SIZE;j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
||||
0, j, 20);
|
||||
0, j, CELL_SIZE);
|
||||
gtk_widget_draw (deviceD->colors[i], NULL);
|
||||
gtk_widget_show (deviceD->colors[i]);
|
||||
|
||||
if (device_info->brush)
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), device_info->brush->name);
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), "");
|
||||
device_update_brush(device_info->brush,i);
|
||||
gtk_widget_draw (deviceD->brushes[i],NULL);
|
||||
gtk_widget_show (deviceD->brushes[i]);
|
||||
|
||||
device_update_pattern(device_info->pattern,i);
|
||||
gtk_widget_draw (deviceD->patterns[i],NULL);
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef enum {
|
|||
DEVICE_BRUSH = 1 << 3,
|
||||
DEVICE_TOOL = 1 << 4,
|
||||
DEVICE_FOREGROUND = 1 << 5,
|
||||
DEVICE_PATTERN = 1 << 6,
|
||||
} DeviceValues;
|
||||
|
||||
/* Create device info dialog */
|
||||
|
@ -53,7 +54,7 @@ void devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[]);
|
||||
guchar foreground[],gchar *pattern_name);
|
||||
|
||||
/* Free device status (only for session-managment) */
|
||||
void device_status_free (void);
|
||||
|
|
16
app/gimprc.c
16
app/gimprc.c
|
@ -1590,6 +1590,7 @@ parse_device (gpointer val1p,
|
|||
gint num_keys = 0;
|
||||
GdkDeviceKey *keys = NULL;
|
||||
gchar *brush_name = NULL;
|
||||
gchar *pattern_name = NULL;
|
||||
ToolType tool = RECT_SELECT;
|
||||
guchar foreground[3] = { 0, 0, 0 };
|
||||
|
||||
|
@ -1697,6 +1698,17 @@ parse_device (gpointer val1p,
|
|||
|
||||
brush_name = g_strdup (token_str);
|
||||
}
|
||||
else if (!strcmp ("pattern", token_sym))
|
||||
{
|
||||
values |= DEVICE_PATTERN;
|
||||
|
||||
token = peek_next_token ();
|
||||
if (!token || (token != TOKEN_STRING))
|
||||
goto error;
|
||||
token = get_next_token ();
|
||||
|
||||
pattern_name = g_strdup (token_str);
|
||||
}
|
||||
else if (!strcmp ("tool", token_sym))
|
||||
{
|
||||
values |= DEVICE_TOOL;
|
||||
|
@ -1744,9 +1756,10 @@ parse_device (gpointer val1p,
|
|||
token = get_next_token ();
|
||||
|
||||
devices_rc_update (name, values, mode, num_axes, axes, num_keys, keys,
|
||||
brush_name, tool, foreground);
|
||||
brush_name, tool, foreground,pattern_name);
|
||||
|
||||
g_free (brush_name);
|
||||
g_free (pattern_name);
|
||||
g_free (name);
|
||||
g_free (axes);
|
||||
g_free (keys);
|
||||
|
@ -1754,6 +1767,7 @@ parse_device (gpointer val1p,
|
|||
return OK;
|
||||
|
||||
error:
|
||||
g_free (pattern_name);
|
||||
g_free (brush_name);
|
||||
g_free (name);
|
||||
g_free (axes);
|
||||
|
|
|
@ -24,10 +24,22 @@
|
|||
#include "devices.h"
|
||||
#include "interface.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "palette.h"
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define CELL_SIZE 20 /* The size of the preview cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
#define BRUSH_PREVIEW 1
|
||||
#define PATTERN_PREVIEW 2
|
||||
|
||||
typedef struct _DeviceInfo DeviceInfo;
|
||||
|
||||
struct _DeviceInfo {
|
||||
|
@ -46,6 +58,7 @@ struct _DeviceInfo {
|
|||
GdkDeviceKey *keys;
|
||||
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
ToolType tool;
|
||||
unsigned char foreground[3];
|
||||
};
|
||||
|
@ -64,6 +77,7 @@ struct _DeviceInfoDialog {
|
|||
GtkWidget **tools;
|
||||
GtkWidget **colors;
|
||||
GtkWidget **brushes;
|
||||
GtkWidget **patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,7 +85,10 @@ struct _DeviceInfoDialog {
|
|||
|
||||
GList *devices_info = NULL;
|
||||
DeviceInfoDialog *deviceD = NULL;
|
||||
|
||||
GtkWidget *device_bpopup = NULL; /* Can't share since differnt depths */
|
||||
GtkWidget *device_bpreview = NULL;
|
||||
GtkWidget *device_patpopup = NULL;
|
||||
GtkWidget *device_patpreview = NULL;
|
||||
/* If true, don't update device information dialog */
|
||||
int suppress_update = FALSE;
|
||||
|
||||
|
@ -85,6 +102,8 @@ static void devices_write_rc (void);
|
|||
static void device_status_destroy_callback (void);
|
||||
static void devices_close_callback (GtkWidget *, gpointer);
|
||||
static void device_status_update_current ();
|
||||
static gint brush_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
static gint pattern_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
|
||||
/* Global data */
|
||||
int current_device = GDK_CORE_POINTER;
|
||||
|
@ -172,6 +191,7 @@ devices_init (void)
|
|||
device_info->axes = NULL;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -198,7 +218,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[])
|
||||
guchar foreground[],gchar *pattern_name)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
|
@ -248,6 +268,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
device_info->mode = GDK_MODE_DISABLED;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -296,14 +317,20 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
}
|
||||
}
|
||||
|
||||
if (values & (DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
device_info->is_init = TRUE;
|
||||
|
||||
|
||||
if (values & DEVICE_BRUSH)
|
||||
{
|
||||
device_info->brush = gimp_brush_list_get_brush(brush_list, brush_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
device_info->pattern = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_TOOL)
|
||||
device_info->tool = tool;
|
||||
|
||||
|
@ -351,6 +378,8 @@ select_device (guint32 new_device)
|
|||
palette_set_foreground (device_info->foreground[0],
|
||||
device_info->foreground[1],
|
||||
device_info->foreground[2]);
|
||||
if (device_info->pattern)
|
||||
select_pattern(device_info->pattern);
|
||||
}
|
||||
|
||||
suppress_update = FALSE;
|
||||
|
@ -409,6 +438,7 @@ devices_save_current_info (void)
|
|||
device_info->is_init = TRUE;
|
||||
device_info->device = current_device;
|
||||
device_info->brush = get_active_brush ();
|
||||
device_info->pattern = get_active_pattern();
|
||||
if (active_tool_type >= 0)
|
||||
device_info->tool = active_tool_type;
|
||||
else
|
||||
|
@ -529,6 +559,7 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
|
@ -590,7 +621,7 @@ create_device_status (void)
|
|||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 4, FALSE);
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
deviceD->table);
|
||||
|
@ -602,6 +633,7 @@ create_device_status (void)
|
|||
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
||||
|
||||
tmp_list = devices_info;
|
||||
i=0;
|
||||
|
@ -638,16 +670,35 @@ create_device_status (void)
|
|||
0, 0, 2, 2);
|
||||
|
||||
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), 20, 20);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
||||
2, 3, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
deviceD->brushes[i] = gtk_label_new ("");
|
||||
deviceD->brushes[i] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->brushes[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->brushes[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "event",
|
||||
(GtkSignalFunc) brush_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
||||
3, 4, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
deviceD->patterns[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->patterns[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->patterns[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
||||
4, 5, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
if (device_info->is_present)
|
||||
device_status_update (device_info->device);
|
||||
|
||||
|
@ -685,6 +736,7 @@ device_status_destroy_callback (void)
|
|||
g_free(deviceD->tools);
|
||||
g_free(deviceD->colors);
|
||||
g_free(deviceD->brushes);
|
||||
g_free(deviceD->patterns);
|
||||
|
||||
g_free(deviceD);
|
||||
deviceD = NULL;
|
||||
|
@ -727,11 +779,392 @@ device_status_update_current ()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_bpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_bpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_bpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_bpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_bpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_bpreview);
|
||||
gtk_widget_show (device_bpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->brushes[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (brush->mask->width >> 1);
|
||||
y = y_org + y - (brush->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_bpreview), brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (device_bpopup, x, y);
|
||||
|
||||
/* Draw the brush */
|
||||
buf = g_new (gchar, brush->mask->width);
|
||||
src = (gchar *)temp_buf_data (brush->mask);
|
||||
for (y = 0; y < brush->mask->height; y++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_bpreview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_bpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GPatternP pattern)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_patpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_patpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_patpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_patpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_patpreview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_patpreview);
|
||||
gtk_widget_show (device_patpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->patterns[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (pattern->mask->width >> 1);
|
||||
y = y_org + y - (pattern->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + pattern->mask->width > scr_w) ? scr_w - pattern->mask->width : x;
|
||||
y = (y + pattern->mask->height > scr_h) ? scr_h - pattern->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_patpreview), pattern->mask->width, pattern->mask->height);
|
||||
|
||||
gtk_widget_popup (device_patpopup, x, y);
|
||||
|
||||
/* Draw the pattern */
|
||||
buf = g_new (gchar, pattern->mask->width * 3);
|
||||
src = (gchar *)temp_buf_data (pattern->mask);
|
||||
for (y = 0; y < pattern->mask->height; y++)
|
||||
{
|
||||
if (pattern->mask->bytes == 1)
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x];
|
||||
buf[x*3+1] = src[x];
|
||||
buf[x*3+2] = src[x];
|
||||
}
|
||||
else
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x*3+0];
|
||||
buf[x*3+1] = src[x*3+1];
|
||||
buf[x*3+2] = src[x*3+2];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_patpreview), (guchar *)buf, 0, y, pattern->mask->width);
|
||||
src += pattern->mask->width * pattern->mask->bytes;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_patpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
device_popup_close (int type)
|
||||
{
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
if (device_bpopup != NULL)
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
else if (type == PATTERN_PREVIEW)
|
||||
{
|
||||
if (device_patpopup != NULL)
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
device_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid,
|
||||
int type)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkEventButton *bevent;
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
tmp_list = devices_info;
|
||||
while (tmp_list)
|
||||
{
|
||||
device_info = (DeviceInfo *)tmp_list->data;
|
||||
|
||||
if (device_info->device == deviceD->ids[deviceid])
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if(tmp_list == NULL)
|
||||
{
|
||||
g_message("Failed to find device_info\n");
|
||||
break; /* Error no device info */
|
||||
}
|
||||
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
brush = device_info->brush;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (brush->mask->width > CELL_SIZE ||
|
||||
brush->mask->height > CELL_SIZE)
|
||||
brush_popup_open (deviceid, bevent->x, bevent->y, brush);
|
||||
}
|
||||
else if(type == PATTERN_PREVIEW)
|
||||
{
|
||||
pattern = device_info->pattern;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (pattern->mask->width > CELL_SIZE ||
|
||||
pattern->mask->height > CELL_SIZE)
|
||||
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* Ungrab the pointer */
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
|
||||
/* Close the device preview popup window */
|
||||
device_popup_close (type);
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,BRUSH_PREVIEW));
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,PATTERN_PREVIEW));
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_brush(GimpBrushP brush,int preview_id)
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->brushes[preview_id],brush->name,NULL);
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += brush_buf->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_pattern(GPatternP pattern,int preview_id)
|
||||
{
|
||||
gchar *buffer = NULL;
|
||||
TempBuf * pattern_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int rowstride;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->patterns[preview_id],pattern->name,NULL);
|
||||
|
||||
buffer = g_new (gchar, pattern->mask->width * 3);
|
||||
pattern_buf = pattern->mask;
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (pattern_buf->width > CELL_SIZE) ? CELL_SIZE: pattern_buf->width;
|
||||
height = (pattern_buf->height > CELL_SIZE) ? CELL_SIZE: pattern_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
src = mask_buf_data (pattern_buf) + (ystart - offset_y) * rowstride;
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
|
||||
if (pattern_buf->bytes == 1)
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s;
|
||||
*b++ = *s;
|
||||
*b++ = *s++;
|
||||
}
|
||||
else
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += rowstride;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
device_status_update (guint32 deviceid)
|
||||
{
|
||||
int i, j;
|
||||
guchar buffer[20*3];
|
||||
guchar buffer[CELL_SIZE*3];
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkDeviceInfo *gdk_info;
|
||||
|
@ -783,6 +1216,7 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_hide (deviceD->tools[i]);
|
||||
gtk_widget_hide (deviceD->colors[i]);
|
||||
gtk_widget_hide (deviceD->brushes[i]);
|
||||
gtk_widget_hide (deviceD->patterns[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -795,24 +1229,26 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_draw (deviceD->tools[i], NULL);
|
||||
gtk_widget_show (deviceD->tools[i]);
|
||||
|
||||
for (j=0;j<20*3;j+=3)
|
||||
for (j=0;j<CELL_SIZE*3;j+=3)
|
||||
{
|
||||
buffer[j] = device_info->foreground[0];
|
||||
buffer[j+1] = device_info->foreground[1];
|
||||
buffer[j+2] = device_info->foreground[2];
|
||||
}
|
||||
|
||||
for (j=0;j<20;j++)
|
||||
for (j=0;j<CELL_SIZE;j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
||||
0, j, 20);
|
||||
0, j, CELL_SIZE);
|
||||
gtk_widget_draw (deviceD->colors[i], NULL);
|
||||
gtk_widget_show (deviceD->colors[i]);
|
||||
|
||||
if (device_info->brush)
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), device_info->brush->name);
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), "");
|
||||
device_update_brush(device_info->brush,i);
|
||||
gtk_widget_draw (deviceD->brushes[i],NULL);
|
||||
gtk_widget_show (deviceD->brushes[i]);
|
||||
|
||||
device_update_pattern(device_info->pattern,i);
|
||||
gtk_widget_draw (deviceD->patterns[i],NULL);
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,22 @@
|
|||
#include "devices.h"
|
||||
#include "interface.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "palette.h"
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define CELL_SIZE 20 /* The size of the preview cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
#define BRUSH_PREVIEW 1
|
||||
#define PATTERN_PREVIEW 2
|
||||
|
||||
typedef struct _DeviceInfo DeviceInfo;
|
||||
|
||||
struct _DeviceInfo {
|
||||
|
@ -46,6 +58,7 @@ struct _DeviceInfo {
|
|||
GdkDeviceKey *keys;
|
||||
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
ToolType tool;
|
||||
unsigned char foreground[3];
|
||||
};
|
||||
|
@ -64,6 +77,7 @@ struct _DeviceInfoDialog {
|
|||
GtkWidget **tools;
|
||||
GtkWidget **colors;
|
||||
GtkWidget **brushes;
|
||||
GtkWidget **patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,7 +85,10 @@ struct _DeviceInfoDialog {
|
|||
|
||||
GList *devices_info = NULL;
|
||||
DeviceInfoDialog *deviceD = NULL;
|
||||
|
||||
GtkWidget *device_bpopup = NULL; /* Can't share since differnt depths */
|
||||
GtkWidget *device_bpreview = NULL;
|
||||
GtkWidget *device_patpopup = NULL;
|
||||
GtkWidget *device_patpreview = NULL;
|
||||
/* If true, don't update device information dialog */
|
||||
int suppress_update = FALSE;
|
||||
|
||||
|
@ -85,6 +102,8 @@ static void devices_write_rc (void);
|
|||
static void device_status_destroy_callback (void);
|
||||
static void devices_close_callback (GtkWidget *, gpointer);
|
||||
static void device_status_update_current ();
|
||||
static gint brush_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
static gint pattern_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
|
||||
/* Global data */
|
||||
int current_device = GDK_CORE_POINTER;
|
||||
|
@ -172,6 +191,7 @@ devices_init (void)
|
|||
device_info->axes = NULL;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -198,7 +218,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[])
|
||||
guchar foreground[],gchar *pattern_name)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
|
@ -248,6 +268,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
device_info->mode = GDK_MODE_DISABLED;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -296,14 +317,20 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
}
|
||||
}
|
||||
|
||||
if (values & (DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
device_info->is_init = TRUE;
|
||||
|
||||
|
||||
if (values & DEVICE_BRUSH)
|
||||
{
|
||||
device_info->brush = gimp_brush_list_get_brush(brush_list, brush_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
device_info->pattern = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_TOOL)
|
||||
device_info->tool = tool;
|
||||
|
||||
|
@ -351,6 +378,8 @@ select_device (guint32 new_device)
|
|||
palette_set_foreground (device_info->foreground[0],
|
||||
device_info->foreground[1],
|
||||
device_info->foreground[2]);
|
||||
if (device_info->pattern)
|
||||
select_pattern(device_info->pattern);
|
||||
}
|
||||
|
||||
suppress_update = FALSE;
|
||||
|
@ -409,6 +438,7 @@ devices_save_current_info (void)
|
|||
device_info->is_init = TRUE;
|
||||
device_info->device = current_device;
|
||||
device_info->brush = get_active_brush ();
|
||||
device_info->pattern = get_active_pattern();
|
||||
if (active_tool_type >= 0)
|
||||
device_info->tool = active_tool_type;
|
||||
else
|
||||
|
@ -529,6 +559,7 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
|
@ -590,7 +621,7 @@ create_device_status (void)
|
|||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 4, FALSE);
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
deviceD->table);
|
||||
|
@ -602,6 +633,7 @@ create_device_status (void)
|
|||
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
||||
|
||||
tmp_list = devices_info;
|
||||
i=0;
|
||||
|
@ -638,16 +670,35 @@ create_device_status (void)
|
|||
0, 0, 2, 2);
|
||||
|
||||
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), 20, 20);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
||||
2, 3, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
deviceD->brushes[i] = gtk_label_new ("");
|
||||
deviceD->brushes[i] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->brushes[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->brushes[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "event",
|
||||
(GtkSignalFunc) brush_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
||||
3, 4, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
deviceD->patterns[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->patterns[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->patterns[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
||||
4, 5, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
if (device_info->is_present)
|
||||
device_status_update (device_info->device);
|
||||
|
||||
|
@ -685,6 +736,7 @@ device_status_destroy_callback (void)
|
|||
g_free(deviceD->tools);
|
||||
g_free(deviceD->colors);
|
||||
g_free(deviceD->brushes);
|
||||
g_free(deviceD->patterns);
|
||||
|
||||
g_free(deviceD);
|
||||
deviceD = NULL;
|
||||
|
@ -727,11 +779,392 @@ device_status_update_current ()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_bpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_bpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_bpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_bpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_bpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_bpreview);
|
||||
gtk_widget_show (device_bpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->brushes[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (brush->mask->width >> 1);
|
||||
y = y_org + y - (brush->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_bpreview), brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (device_bpopup, x, y);
|
||||
|
||||
/* Draw the brush */
|
||||
buf = g_new (gchar, brush->mask->width);
|
||||
src = (gchar *)temp_buf_data (brush->mask);
|
||||
for (y = 0; y < brush->mask->height; y++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_bpreview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_bpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GPatternP pattern)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_patpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_patpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_patpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_patpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_patpreview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_patpreview);
|
||||
gtk_widget_show (device_patpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->patterns[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (pattern->mask->width >> 1);
|
||||
y = y_org + y - (pattern->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + pattern->mask->width > scr_w) ? scr_w - pattern->mask->width : x;
|
||||
y = (y + pattern->mask->height > scr_h) ? scr_h - pattern->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_patpreview), pattern->mask->width, pattern->mask->height);
|
||||
|
||||
gtk_widget_popup (device_patpopup, x, y);
|
||||
|
||||
/* Draw the pattern */
|
||||
buf = g_new (gchar, pattern->mask->width * 3);
|
||||
src = (gchar *)temp_buf_data (pattern->mask);
|
||||
for (y = 0; y < pattern->mask->height; y++)
|
||||
{
|
||||
if (pattern->mask->bytes == 1)
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x];
|
||||
buf[x*3+1] = src[x];
|
||||
buf[x*3+2] = src[x];
|
||||
}
|
||||
else
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x*3+0];
|
||||
buf[x*3+1] = src[x*3+1];
|
||||
buf[x*3+2] = src[x*3+2];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_patpreview), (guchar *)buf, 0, y, pattern->mask->width);
|
||||
src += pattern->mask->width * pattern->mask->bytes;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_patpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
device_popup_close (int type)
|
||||
{
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
if (device_bpopup != NULL)
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
else if (type == PATTERN_PREVIEW)
|
||||
{
|
||||
if (device_patpopup != NULL)
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
device_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid,
|
||||
int type)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkEventButton *bevent;
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
tmp_list = devices_info;
|
||||
while (tmp_list)
|
||||
{
|
||||
device_info = (DeviceInfo *)tmp_list->data;
|
||||
|
||||
if (device_info->device == deviceD->ids[deviceid])
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if(tmp_list == NULL)
|
||||
{
|
||||
g_message("Failed to find device_info\n");
|
||||
break; /* Error no device info */
|
||||
}
|
||||
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
brush = device_info->brush;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (brush->mask->width > CELL_SIZE ||
|
||||
brush->mask->height > CELL_SIZE)
|
||||
brush_popup_open (deviceid, bevent->x, bevent->y, brush);
|
||||
}
|
||||
else if(type == PATTERN_PREVIEW)
|
||||
{
|
||||
pattern = device_info->pattern;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (pattern->mask->width > CELL_SIZE ||
|
||||
pattern->mask->height > CELL_SIZE)
|
||||
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* Ungrab the pointer */
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
|
||||
/* Close the device preview popup window */
|
||||
device_popup_close (type);
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,BRUSH_PREVIEW));
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,PATTERN_PREVIEW));
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_brush(GimpBrushP brush,int preview_id)
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->brushes[preview_id],brush->name,NULL);
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += brush_buf->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_pattern(GPatternP pattern,int preview_id)
|
||||
{
|
||||
gchar *buffer = NULL;
|
||||
TempBuf * pattern_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int rowstride;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->patterns[preview_id],pattern->name,NULL);
|
||||
|
||||
buffer = g_new (gchar, pattern->mask->width * 3);
|
||||
pattern_buf = pattern->mask;
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (pattern_buf->width > CELL_SIZE) ? CELL_SIZE: pattern_buf->width;
|
||||
height = (pattern_buf->height > CELL_SIZE) ? CELL_SIZE: pattern_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
src = mask_buf_data (pattern_buf) + (ystart - offset_y) * rowstride;
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
|
||||
if (pattern_buf->bytes == 1)
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s;
|
||||
*b++ = *s;
|
||||
*b++ = *s++;
|
||||
}
|
||||
else
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += rowstride;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
device_status_update (guint32 deviceid)
|
||||
{
|
||||
int i, j;
|
||||
guchar buffer[20*3];
|
||||
guchar buffer[CELL_SIZE*3];
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkDeviceInfo *gdk_info;
|
||||
|
@ -783,6 +1216,7 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_hide (deviceD->tools[i]);
|
||||
gtk_widget_hide (deviceD->colors[i]);
|
||||
gtk_widget_hide (deviceD->brushes[i]);
|
||||
gtk_widget_hide (deviceD->patterns[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -795,24 +1229,26 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_draw (deviceD->tools[i], NULL);
|
||||
gtk_widget_show (deviceD->tools[i]);
|
||||
|
||||
for (j=0;j<20*3;j+=3)
|
||||
for (j=0;j<CELL_SIZE*3;j+=3)
|
||||
{
|
||||
buffer[j] = device_info->foreground[0];
|
||||
buffer[j+1] = device_info->foreground[1];
|
||||
buffer[j+2] = device_info->foreground[2];
|
||||
}
|
||||
|
||||
for (j=0;j<20;j++)
|
||||
for (j=0;j<CELL_SIZE;j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
||||
0, j, 20);
|
||||
0, j, CELL_SIZE);
|
||||
gtk_widget_draw (deviceD->colors[i], NULL);
|
||||
gtk_widget_show (deviceD->colors[i]);
|
||||
|
||||
if (device_info->brush)
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), device_info->brush->name);
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), "");
|
||||
device_update_brush(device_info->brush,i);
|
||||
gtk_widget_draw (deviceD->brushes[i],NULL);
|
||||
gtk_widget_show (deviceD->brushes[i]);
|
||||
|
||||
device_update_pattern(device_info->pattern,i);
|
||||
gtk_widget_draw (deviceD->patterns[i],NULL);
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "appenv.h"
|
||||
#include "colormaps.h"
|
||||
#include "datafiles.h"
|
||||
#include "devices.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "pattern_select.h"
|
||||
|
@ -248,6 +249,23 @@ load_pattern (char *filename)
|
|||
} /* if */
|
||||
}
|
||||
|
||||
GPatternP
|
||||
pattern_list_get_pattern (GSList *list, char *name)
|
||||
{
|
||||
GPatternP patternp;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
if (!strcmp (patternp->name, name))
|
||||
{
|
||||
return patternp;
|
||||
}
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GPatternP
|
||||
get_pattern_by_index (int index)
|
||||
|
@ -276,6 +294,8 @@ select_pattern (pattern)
|
|||
/* Keep up appearances in the pattern dialog */
|
||||
if (pattern_select_dialog)
|
||||
pattern_select_select (pattern_select_dialog, pattern->index);
|
||||
|
||||
device_status_update (current_device);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ void pattern_select_dialog_free (void);
|
|||
void select_pattern (GPatternP);
|
||||
GPatternP get_pattern_by_index (int);
|
||||
GPatternP get_active_pattern (void);
|
||||
GPatternP pattern_list_get_pattern (GSList *list, char *name);
|
||||
void create_pattern_dialog (void);
|
||||
|
||||
/* global variables */
|
||||
|
|
|
@ -24,10 +24,22 @@
|
|||
#include "devices.h"
|
||||
#include "interface.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "palette.h"
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define CELL_SIZE 20 /* The size of the preview cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
#define BRUSH_PREVIEW 1
|
||||
#define PATTERN_PREVIEW 2
|
||||
|
||||
typedef struct _DeviceInfo DeviceInfo;
|
||||
|
||||
struct _DeviceInfo {
|
||||
|
@ -46,6 +58,7 @@ struct _DeviceInfo {
|
|||
GdkDeviceKey *keys;
|
||||
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
ToolType tool;
|
||||
unsigned char foreground[3];
|
||||
};
|
||||
|
@ -64,6 +77,7 @@ struct _DeviceInfoDialog {
|
|||
GtkWidget **tools;
|
||||
GtkWidget **colors;
|
||||
GtkWidget **brushes;
|
||||
GtkWidget **patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,7 +85,10 @@ struct _DeviceInfoDialog {
|
|||
|
||||
GList *devices_info = NULL;
|
||||
DeviceInfoDialog *deviceD = NULL;
|
||||
|
||||
GtkWidget *device_bpopup = NULL; /* Can't share since differnt depths */
|
||||
GtkWidget *device_bpreview = NULL;
|
||||
GtkWidget *device_patpopup = NULL;
|
||||
GtkWidget *device_patpreview = NULL;
|
||||
/* If true, don't update device information dialog */
|
||||
int suppress_update = FALSE;
|
||||
|
||||
|
@ -85,6 +102,8 @@ static void devices_write_rc (void);
|
|||
static void device_status_destroy_callback (void);
|
||||
static void devices_close_callback (GtkWidget *, gpointer);
|
||||
static void device_status_update_current ();
|
||||
static gint brush_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
static gint pattern_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
|
||||
/* Global data */
|
||||
int current_device = GDK_CORE_POINTER;
|
||||
|
@ -172,6 +191,7 @@ devices_init (void)
|
|||
device_info->axes = NULL;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -198,7 +218,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[])
|
||||
guchar foreground[],gchar *pattern_name)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
|
@ -248,6 +268,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
device_info->mode = GDK_MODE_DISABLED;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -296,14 +317,20 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
}
|
||||
}
|
||||
|
||||
if (values & (DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
device_info->is_init = TRUE;
|
||||
|
||||
|
||||
if (values & DEVICE_BRUSH)
|
||||
{
|
||||
device_info->brush = gimp_brush_list_get_brush(brush_list, brush_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
device_info->pattern = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_TOOL)
|
||||
device_info->tool = tool;
|
||||
|
||||
|
@ -351,6 +378,8 @@ select_device (guint32 new_device)
|
|||
palette_set_foreground (device_info->foreground[0],
|
||||
device_info->foreground[1],
|
||||
device_info->foreground[2]);
|
||||
if (device_info->pattern)
|
||||
select_pattern(device_info->pattern);
|
||||
}
|
||||
|
||||
suppress_update = FALSE;
|
||||
|
@ -409,6 +438,7 @@ devices_save_current_info (void)
|
|||
device_info->is_init = TRUE;
|
||||
device_info->device = current_device;
|
||||
device_info->brush = get_active_brush ();
|
||||
device_info->pattern = get_active_pattern();
|
||||
if (active_tool_type >= 0)
|
||||
device_info->tool = active_tool_type;
|
||||
else
|
||||
|
@ -529,6 +559,7 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
|
@ -590,7 +621,7 @@ create_device_status (void)
|
|||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 4, FALSE);
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
deviceD->table);
|
||||
|
@ -602,6 +633,7 @@ create_device_status (void)
|
|||
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
||||
|
||||
tmp_list = devices_info;
|
||||
i=0;
|
||||
|
@ -638,16 +670,35 @@ create_device_status (void)
|
|||
0, 0, 2, 2);
|
||||
|
||||
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), 20, 20);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
||||
2, 3, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
deviceD->brushes[i] = gtk_label_new ("");
|
||||
deviceD->brushes[i] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->brushes[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->brushes[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "event",
|
||||
(GtkSignalFunc) brush_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
||||
3, 4, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
deviceD->patterns[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->patterns[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->patterns[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
||||
4, 5, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
if (device_info->is_present)
|
||||
device_status_update (device_info->device);
|
||||
|
||||
|
@ -685,6 +736,7 @@ device_status_destroy_callback (void)
|
|||
g_free(deviceD->tools);
|
||||
g_free(deviceD->colors);
|
||||
g_free(deviceD->brushes);
|
||||
g_free(deviceD->patterns);
|
||||
|
||||
g_free(deviceD);
|
||||
deviceD = NULL;
|
||||
|
@ -727,11 +779,392 @@ device_status_update_current ()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_bpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_bpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_bpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_bpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_bpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_bpreview);
|
||||
gtk_widget_show (device_bpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->brushes[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (brush->mask->width >> 1);
|
||||
y = y_org + y - (brush->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_bpreview), brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (device_bpopup, x, y);
|
||||
|
||||
/* Draw the brush */
|
||||
buf = g_new (gchar, brush->mask->width);
|
||||
src = (gchar *)temp_buf_data (brush->mask);
|
||||
for (y = 0; y < brush->mask->height; y++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_bpreview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_bpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GPatternP pattern)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_patpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_patpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_patpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_patpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_patpreview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_patpreview);
|
||||
gtk_widget_show (device_patpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->patterns[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (pattern->mask->width >> 1);
|
||||
y = y_org + y - (pattern->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + pattern->mask->width > scr_w) ? scr_w - pattern->mask->width : x;
|
||||
y = (y + pattern->mask->height > scr_h) ? scr_h - pattern->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_patpreview), pattern->mask->width, pattern->mask->height);
|
||||
|
||||
gtk_widget_popup (device_patpopup, x, y);
|
||||
|
||||
/* Draw the pattern */
|
||||
buf = g_new (gchar, pattern->mask->width * 3);
|
||||
src = (gchar *)temp_buf_data (pattern->mask);
|
||||
for (y = 0; y < pattern->mask->height; y++)
|
||||
{
|
||||
if (pattern->mask->bytes == 1)
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x];
|
||||
buf[x*3+1] = src[x];
|
||||
buf[x*3+2] = src[x];
|
||||
}
|
||||
else
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x*3+0];
|
||||
buf[x*3+1] = src[x*3+1];
|
||||
buf[x*3+2] = src[x*3+2];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_patpreview), (guchar *)buf, 0, y, pattern->mask->width);
|
||||
src += pattern->mask->width * pattern->mask->bytes;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_patpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
device_popup_close (int type)
|
||||
{
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
if (device_bpopup != NULL)
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
else if (type == PATTERN_PREVIEW)
|
||||
{
|
||||
if (device_patpopup != NULL)
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
device_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid,
|
||||
int type)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkEventButton *bevent;
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
tmp_list = devices_info;
|
||||
while (tmp_list)
|
||||
{
|
||||
device_info = (DeviceInfo *)tmp_list->data;
|
||||
|
||||
if (device_info->device == deviceD->ids[deviceid])
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if(tmp_list == NULL)
|
||||
{
|
||||
g_message("Failed to find device_info\n");
|
||||
break; /* Error no device info */
|
||||
}
|
||||
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
brush = device_info->brush;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (brush->mask->width > CELL_SIZE ||
|
||||
brush->mask->height > CELL_SIZE)
|
||||
brush_popup_open (deviceid, bevent->x, bevent->y, brush);
|
||||
}
|
||||
else if(type == PATTERN_PREVIEW)
|
||||
{
|
||||
pattern = device_info->pattern;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (pattern->mask->width > CELL_SIZE ||
|
||||
pattern->mask->height > CELL_SIZE)
|
||||
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* Ungrab the pointer */
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
|
||||
/* Close the device preview popup window */
|
||||
device_popup_close (type);
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,BRUSH_PREVIEW));
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,PATTERN_PREVIEW));
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_brush(GimpBrushP brush,int preview_id)
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->brushes[preview_id],brush->name,NULL);
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += brush_buf->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_pattern(GPatternP pattern,int preview_id)
|
||||
{
|
||||
gchar *buffer = NULL;
|
||||
TempBuf * pattern_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int rowstride;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->patterns[preview_id],pattern->name,NULL);
|
||||
|
||||
buffer = g_new (gchar, pattern->mask->width * 3);
|
||||
pattern_buf = pattern->mask;
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (pattern_buf->width > CELL_SIZE) ? CELL_SIZE: pattern_buf->width;
|
||||
height = (pattern_buf->height > CELL_SIZE) ? CELL_SIZE: pattern_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
src = mask_buf_data (pattern_buf) + (ystart - offset_y) * rowstride;
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
|
||||
if (pattern_buf->bytes == 1)
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s;
|
||||
*b++ = *s;
|
||||
*b++ = *s++;
|
||||
}
|
||||
else
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += rowstride;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
device_status_update (guint32 deviceid)
|
||||
{
|
||||
int i, j;
|
||||
guchar buffer[20*3];
|
||||
guchar buffer[CELL_SIZE*3];
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkDeviceInfo *gdk_info;
|
||||
|
@ -783,6 +1216,7 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_hide (deviceD->tools[i]);
|
||||
gtk_widget_hide (deviceD->colors[i]);
|
||||
gtk_widget_hide (deviceD->brushes[i]);
|
||||
gtk_widget_hide (deviceD->patterns[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -795,24 +1229,26 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_draw (deviceD->tools[i], NULL);
|
||||
gtk_widget_show (deviceD->tools[i]);
|
||||
|
||||
for (j=0;j<20*3;j+=3)
|
||||
for (j=0;j<CELL_SIZE*3;j+=3)
|
||||
{
|
||||
buffer[j] = device_info->foreground[0];
|
||||
buffer[j+1] = device_info->foreground[1];
|
||||
buffer[j+2] = device_info->foreground[2];
|
||||
}
|
||||
|
||||
for (j=0;j<20;j++)
|
||||
for (j=0;j<CELL_SIZE;j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
||||
0, j, 20);
|
||||
0, j, CELL_SIZE);
|
||||
gtk_widget_draw (deviceD->colors[i], NULL);
|
||||
gtk_widget_show (deviceD->colors[i]);
|
||||
|
||||
if (device_info->brush)
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), device_info->brush->name);
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), "");
|
||||
device_update_brush(device_info->brush,i);
|
||||
gtk_widget_draw (deviceD->brushes[i],NULL);
|
||||
gtk_widget_show (deviceD->brushes[i]);
|
||||
|
||||
device_update_pattern(device_info->pattern,i);
|
||||
gtk_widget_draw (deviceD->patterns[i],NULL);
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,22 @@
|
|||
#include "devices.h"
|
||||
#include "interface.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "palette.h"
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define CELL_SIZE 20 /* The size of the preview cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
#define BRUSH_PREVIEW 1
|
||||
#define PATTERN_PREVIEW 2
|
||||
|
||||
typedef struct _DeviceInfo DeviceInfo;
|
||||
|
||||
struct _DeviceInfo {
|
||||
|
@ -46,6 +58,7 @@ struct _DeviceInfo {
|
|||
GdkDeviceKey *keys;
|
||||
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
ToolType tool;
|
||||
unsigned char foreground[3];
|
||||
};
|
||||
|
@ -64,6 +77,7 @@ struct _DeviceInfoDialog {
|
|||
GtkWidget **tools;
|
||||
GtkWidget **colors;
|
||||
GtkWidget **brushes;
|
||||
GtkWidget **patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,7 +85,10 @@ struct _DeviceInfoDialog {
|
|||
|
||||
GList *devices_info = NULL;
|
||||
DeviceInfoDialog *deviceD = NULL;
|
||||
|
||||
GtkWidget *device_bpopup = NULL; /* Can't share since differnt depths */
|
||||
GtkWidget *device_bpreview = NULL;
|
||||
GtkWidget *device_patpopup = NULL;
|
||||
GtkWidget *device_patpreview = NULL;
|
||||
/* If true, don't update device information dialog */
|
||||
int suppress_update = FALSE;
|
||||
|
||||
|
@ -85,6 +102,8 @@ static void devices_write_rc (void);
|
|||
static void device_status_destroy_callback (void);
|
||||
static void devices_close_callback (GtkWidget *, gpointer);
|
||||
static void device_status_update_current ();
|
||||
static gint brush_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
static gint pattern_preview_events (GtkWidget *, GdkEvent *, int);
|
||||
|
||||
/* Global data */
|
||||
int current_device = GDK_CORE_POINTER;
|
||||
|
@ -172,6 +191,7 @@ devices_init (void)
|
|||
device_info->axes = NULL;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -198,7 +218,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[])
|
||||
guchar foreground[],gchar *pattern_name)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
|
@ -248,6 +268,7 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
device_info->mode = GDK_MODE_DISABLED;
|
||||
|
||||
device_info->brush = NULL;
|
||||
device_info->pattern = NULL;
|
||||
device_info->tool = RECT_SELECT;
|
||||
device_info->foreground[0] = 0;
|
||||
device_info->foreground[1] = 0;
|
||||
|
@ -296,14 +317,20 @@ devices_rc_update (gchar *name, DeviceValues values,
|
|||
}
|
||||
}
|
||||
|
||||
if (values & (DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
||||
device_info->is_init = TRUE;
|
||||
|
||||
|
||||
if (values & DEVICE_BRUSH)
|
||||
{
|
||||
device_info->brush = gimp_brush_list_get_brush(brush_list, brush_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
device_info->pattern = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
}
|
||||
|
||||
if (values & DEVICE_TOOL)
|
||||
device_info->tool = tool;
|
||||
|
||||
|
@ -351,6 +378,8 @@ select_device (guint32 new_device)
|
|||
palette_set_foreground (device_info->foreground[0],
|
||||
device_info->foreground[1],
|
||||
device_info->foreground[2]);
|
||||
if (device_info->pattern)
|
||||
select_pattern(device_info->pattern);
|
||||
}
|
||||
|
||||
suppress_update = FALSE;
|
||||
|
@ -409,6 +438,7 @@ devices_save_current_info (void)
|
|||
device_info->is_init = TRUE;
|
||||
device_info->device = current_device;
|
||||
device_info->brush = get_active_brush ();
|
||||
device_info->pattern = get_active_pattern();
|
||||
if (active_tool_type >= 0)
|
||||
device_info->tool = active_tool_type;
|
||||
else
|
||||
|
@ -529,6 +559,7 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
|
@ -590,7 +621,7 @@ create_device_status (void)
|
|||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 4, FALSE);
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
deviceD->table);
|
||||
|
@ -602,6 +633,7 @@ create_device_status (void)
|
|||
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
||||
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
||||
|
||||
tmp_list = devices_info;
|
||||
i=0;
|
||||
|
@ -638,16 +670,35 @@ create_device_status (void)
|
|||
0, 0, 2, 2);
|
||||
|
||||
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), 20, 20);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
||||
2, 3, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
deviceD->brushes[i] = gtk_label_new ("");
|
||||
deviceD->brushes[i] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->brushes[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->brushes[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "event",
|
||||
(GtkSignalFunc) brush_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
||||
3, 4, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
deviceD->patterns[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (deviceD->patterns[i]), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (deviceD->patterns[i], PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
(gpointer)i);
|
||||
|
||||
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
||||
4, 5, i, i+1,
|
||||
0, 0, 2, 2);
|
||||
|
||||
|
||||
if (device_info->is_present)
|
||||
device_status_update (device_info->device);
|
||||
|
||||
|
@ -685,6 +736,7 @@ device_status_destroy_callback (void)
|
|||
g_free(deviceD->tools);
|
||||
g_free(deviceD->colors);
|
||||
g_free(deviceD->brushes);
|
||||
g_free(deviceD->patterns);
|
||||
|
||||
g_free(deviceD);
|
||||
deviceD = NULL;
|
||||
|
@ -727,11 +779,392 @@ device_status_update_current ()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_bpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_bpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_bpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_bpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_bpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_bpreview);
|
||||
gtk_widget_show (device_bpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->brushes[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (brush->mask->width >> 1);
|
||||
y = y_org + y - (brush->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_bpreview), brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (device_bpopup, x, y);
|
||||
|
||||
/* Draw the brush */
|
||||
buf = g_new (gchar, brush->mask->width);
|
||||
src = (gchar *)temp_buf_data (brush->mask);
|
||||
for (y = 0; y < brush->mask->height; y++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_bpreview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_bpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_popup_open (int preview_id,
|
||||
int x,
|
||||
int y,
|
||||
GPatternP pattern)
|
||||
{
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* make sure the popup exists and is not visible */
|
||||
if (device_patpopup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
device_patpopup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (device_patpopup), FALSE, FALSE, TRUE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (device_patpopup), frame);
|
||||
gtk_widget_show (frame);
|
||||
device_patpreview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_container_add (GTK_CONTAINER (frame), device_patpreview);
|
||||
gtk_widget_show (device_patpreview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
|
||||
/* decide where to put the popup */
|
||||
gdk_window_get_origin (deviceD->patterns[preview_id]->window, &x_org, &y_org);
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
x = x_org + x - (pattern->mask->width >> 1);
|
||||
y = y_org + y - (pattern->mask->height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + pattern->mask->width > scr_w) ? scr_w - pattern->mask->width : x;
|
||||
y = (y + pattern->mask->height > scr_h) ? scr_h - pattern->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (device_patpreview), pattern->mask->width, pattern->mask->height);
|
||||
|
||||
gtk_widget_popup (device_patpopup, x, y);
|
||||
|
||||
/* Draw the pattern */
|
||||
buf = g_new (gchar, pattern->mask->width * 3);
|
||||
src = (gchar *)temp_buf_data (pattern->mask);
|
||||
for (y = 0; y < pattern->mask->height; y++)
|
||||
{
|
||||
if (pattern->mask->bytes == 1)
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x];
|
||||
buf[x*3+1] = src[x];
|
||||
buf[x*3+2] = src[x];
|
||||
}
|
||||
else
|
||||
for (x = 0; x < pattern->mask->width; x++)
|
||||
{
|
||||
buf[x*3+0] = src[x*3+0];
|
||||
buf[x*3+1] = src[x*3+1];
|
||||
buf[x*3+2] = src[x*3+2];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (device_patpreview), (guchar *)buf, 0, y, pattern->mask->width);
|
||||
src += pattern->mask->width * pattern->mask->bytes;
|
||||
}
|
||||
g_free(buf);
|
||||
|
||||
/* Draw the brush preview */
|
||||
gtk_widget_draw (device_patpreview, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
device_popup_close (int type)
|
||||
{
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
if (device_bpopup != NULL)
|
||||
gtk_widget_hide (device_bpopup);
|
||||
}
|
||||
else if (type == PATTERN_PREVIEW)
|
||||
{
|
||||
if (device_patpopup != NULL)
|
||||
gtk_widget_hide (device_patpopup);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
device_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid,
|
||||
int type)
|
||||
{
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkEventButton *bevent;
|
||||
GimpBrushP brush;
|
||||
GPatternP pattern;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
tmp_list = devices_info;
|
||||
while (tmp_list)
|
||||
{
|
||||
device_info = (DeviceInfo *)tmp_list->data;
|
||||
|
||||
if (device_info->device == deviceD->ids[deviceid])
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if(tmp_list == NULL)
|
||||
{
|
||||
g_message("Failed to find device_info\n");
|
||||
break; /* Error no device info */
|
||||
}
|
||||
|
||||
if(type == BRUSH_PREVIEW)
|
||||
{
|
||||
brush = device_info->brush;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (brush->mask->width > CELL_SIZE ||
|
||||
brush->mask->height > CELL_SIZE)
|
||||
brush_popup_open (deviceid, bevent->x, bevent->y, brush);
|
||||
}
|
||||
else if(type == PATTERN_PREVIEW)
|
||||
{
|
||||
pattern = device_info->pattern;
|
||||
|
||||
/* Show the brush popup window if the brush is too large */
|
||||
if (pattern->mask->width > CELL_SIZE ||
|
||||
pattern->mask->height > CELL_SIZE)
|
||||
pattern_popup_open (deviceid, bevent->x, bevent->y, pattern);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* Ungrab the pointer */
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
|
||||
/* Close the device preview popup window */
|
||||
device_popup_close (type);
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,BRUSH_PREVIEW));
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_preview_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
int deviceid)
|
||||
{
|
||||
return(device_preview_events(widget,event,deviceid,PATTERN_PREVIEW));
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_brush(GimpBrushP brush,int preview_id)
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->brushes[preview_id],brush->name,NULL);
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->brushes[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += brush_buf->width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_update_pattern(GPatternP pattern,int preview_id)
|
||||
{
|
||||
gchar *buffer = NULL;
|
||||
TempBuf * pattern_buf;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int rowstride;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
/* Set the tip to be the name of the brush */
|
||||
gtk_tooltips_set_tip(tool_tips,deviceD->patterns[preview_id],pattern->name,NULL);
|
||||
|
||||
buffer = g_new (gchar, pattern->mask->width * 3);
|
||||
pattern_buf = pattern->mask;
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (pattern_buf->width > CELL_SIZE) ? CELL_SIZE: pattern_buf->width;
|
||||
height = (pattern_buf->height > CELL_SIZE) ? CELL_SIZE: pattern_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
src = mask_buf_data (pattern_buf) + (ystart - offset_y) * rowstride;
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
|
||||
if (pattern_buf->bytes == 1)
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s;
|
||||
*b++ = *s;
|
||||
*b++ = *s++;
|
||||
}
|
||||
else
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
*b++ = *s++;
|
||||
}
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->patterns[preview_id]),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
|
||||
src += rowstride;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void
|
||||
device_status_update (guint32 deviceid)
|
||||
{
|
||||
int i, j;
|
||||
guchar buffer[20*3];
|
||||
guchar buffer[CELL_SIZE*3];
|
||||
GList *tmp_list;
|
||||
DeviceInfo *device_info;
|
||||
GdkDeviceInfo *gdk_info;
|
||||
|
@ -783,6 +1216,7 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_hide (deviceD->tools[i]);
|
||||
gtk_widget_hide (deviceD->colors[i]);
|
||||
gtk_widget_hide (deviceD->brushes[i]);
|
||||
gtk_widget_hide (deviceD->patterns[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -795,24 +1229,26 @@ device_status_update (guint32 deviceid)
|
|||
gtk_widget_draw (deviceD->tools[i], NULL);
|
||||
gtk_widget_show (deviceD->tools[i]);
|
||||
|
||||
for (j=0;j<20*3;j+=3)
|
||||
for (j=0;j<CELL_SIZE*3;j+=3)
|
||||
{
|
||||
buffer[j] = device_info->foreground[0];
|
||||
buffer[j+1] = device_info->foreground[1];
|
||||
buffer[j+2] = device_info->foreground[2];
|
||||
}
|
||||
|
||||
for (j=0;j<20;j++)
|
||||
for (j=0;j<CELL_SIZE;j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
||||
0, j, 20);
|
||||
0, j, CELL_SIZE);
|
||||
gtk_widget_draw (deviceD->colors[i], NULL);
|
||||
gtk_widget_show (deviceD->colors[i]);
|
||||
|
||||
if (device_info->brush)
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), device_info->brush->name);
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (deviceD->brushes[i]), "");
|
||||
device_update_brush(device_info->brush,i);
|
||||
gtk_widget_draw (deviceD->brushes[i],NULL);
|
||||
gtk_widget_show (deviceD->brushes[i]);
|
||||
|
||||
device_update_pattern(device_info->pattern,i);
|
||||
gtk_widget_draw (deviceD->patterns[i],NULL);
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef enum {
|
|||
DEVICE_BRUSH = 1 << 3,
|
||||
DEVICE_TOOL = 1 << 4,
|
||||
DEVICE_FOREGROUND = 1 << 5,
|
||||
DEVICE_PATTERN = 1 << 6,
|
||||
} DeviceValues;
|
||||
|
||||
/* Create device info dialog */
|
||||
|
@ -53,7 +54,7 @@ void devices_rc_update (gchar *name, DeviceValues values,
|
|||
GdkInputMode mode, gint num_axes,
|
||||
GdkAxisUse *axes, gint num_keys, GdkDeviceKey *keys,
|
||||
gchar *brush_name, ToolType tool,
|
||||
guchar foreground[]);
|
||||
guchar foreground[],gchar *pattern_name);
|
||||
|
||||
/* Free device status (only for session-managment) */
|
||||
void device_status_free (void);
|
||||
|
|
Loading…
Reference in New Issue