Commit 8fca3091 authored by jaycox's avatar jaycox
Browse files

Modified Files: ChangeLog app/brush_select.c app/brush_select.h


 Modified Files:
 	ChangeLog app/brush_select.c app/brush_select.h
 	app/gimpbrushgenerated.c app/gimpbrushlist.c
 	app/gimpbrushlist.h app/paint_core.c app/paint_core.h
       Signalified the brushes and cleaned up a few things.

 	app/paint_funcs.c: Minor speed tweak
 ----------------------------------------------------------------------
parent 83963c36
Thu Jul 9 21:23:46 1998 Scott Goehring <scott@poverty.bloomington.in.us>
Fri Jul 10 01:44:29 PDT 1998 Jay Cox <jaycox@earthlink.net>
* paint_core.c paint_core.h gimpbrushlist.h gimpbrushlist.c
gimpbrushgenerated.c brush_select.h brush_select.c
Signalified brushes. got rid of some warnings.
Fixed a bug that showed up when run --no-data
* paint_funcs.c
Minor speed tweak to border_region
Thu Jul 9 21:23:46 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* paint_core.c tile.c undo.c: tile tweaks.
......
......@@ -65,6 +65,18 @@ static gint edit_brush_callback (GtkWidget *w, GdkEvent *e,
gpointer data);
static gint new_brush_callback (GtkWidget *w, GdkEvent *e,
gpointer data);
static gint brush_select_brush_dirty_callback(GimpBrushP brush,
BrushSelectP bsp);
static void connect_signals_to_brush (GimpBrushP brush,
BrushSelectP bsp);
static void disconnect_signals_from_brush(GimpBrushP brush,
BrushSelectP bsp);
static void brush_added_callback (GimpBrushList *list,
GimpBrushP brush,
BrushSelectP bsp);
static void brush_removed_callback (GimpBrushList *list,
GimpBrushP brush,
BrushSelectP bsp);
static void brush_select_close_callback (GtkWidget *, gpointer);
static void brush_select_refresh_callback(GtkWidget *, gpointer);
static void paint_mode_menu_callback (GtkWidget *, gpointer);
......@@ -312,6 +324,14 @@ brush_select_new ()
/* render the brushes into the newly created image structure */
display_brushes (bsp);
gimp_set_foreach(GIMP_SET(brush_list), (GFunc)connect_signals_to_brush, bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
(GtkSignalFunc) brush_added_callback,
bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
(GtkSignalFunc) brush_removed_callback,
bsp);
/* update the active selection */
active = get_active_brush ();
if (active)
......@@ -352,7 +372,7 @@ brush_select_free (BrushSelectP bsp)
}
}
void
static void
brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
{
/* TODO: be smarter here and only update the part of the preview
......@@ -364,10 +384,41 @@ brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
}
}
void
static gint
brush_select_brush_dirty_callback(GimpBrushP brush, BrushSelectP bsp)
{
brush_select_brush_changed(bsp, brush);
return TRUE;
}
static void
connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
{
gtk_signal_connect(GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC(brush_select_brush_dirty_callback),
bsp);
}
static void
disconnect_signals_from_brush(GimpBrushP brush, BrushSelectP bsp)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(brush), bsp);
}
static void
brush_added_callback(GimpBrushList *list, GimpBrushP brush,
BrushSelectP bsp)
{
connect_signals_to_brush(brush, bsp);
brush_select_brush_changed(bsp, brush);
}
static void
brush_removed_callback(GimpBrushList *list, GimpBrushP brush,
BrushSelectP bsp)
{
disconnect_signals_from_brush(brush, bsp);
/* brush_select_brush_changed(bsp, brush); */
}
......@@ -833,7 +884,8 @@ edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
static gint
new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
{
brush_changed_notify(GIMP_BRUSH(gimp_brush_generated_new(10, .5, 0.0, 1.0)));
gimp_brush_list_add(brush_list,
GIMP_BRUSH(gimp_brush_generated_new(10, .5, 0.0, 1.0)));
return TRUE;
}
......
......@@ -45,8 +45,6 @@ struct _BrushSelect {
BrushSelectP brush_select_new (void);
void brush_select_select (BrushSelectP, int);
void brush_select_free (BrushSelectP);
void brush_select_brush_changed(BrushSelectP bsp,
GimpBrushP brush);
/* An interface to other dialogs which need to create a paint mode menu */
GtkWidget * create_paint_mode_menu (MenuItemCallback);
......
......@@ -29,7 +29,7 @@
static GimpObjectClass* parent_class;
static void
gimp_brush_generated_destroy(GimpBrushGenerated *object)
gimp_brush_generated_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
......@@ -195,17 +195,11 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
a = 0;
centerp[ y*gbrush->mask->width + x] = a;
centerp[-1*y*gbrush->mask->width - x] = a;
/* centerp[-1*y*brush->mask->width + x] = a;
centerp[-1*y*brush->mask->width - x] = a;
centerp[ x*brush->mask->width + y] = a;
centerp[ x*brush->mask->width - y] = a;
centerp[-1*x*brush->mask->width + y] = a;
centerp[-1*x*brush->mask->width - y] = a;*/
}
}
g_free (lookup);
/* gtk_signal_emit_by_name(brush, "dirty"); */
brush_changed_notify(GIMP_BRUSH(brush));
gtk_signal_emit_by_name(GTK_OBJECT(brush), "dirty");
/* brush_changed_notify(GIMP_BRUSH(brush)); */
}
float
......
......@@ -29,7 +29,7 @@
static GimpObjectClass* parent_class;
static void
gimp_brush_generated_destroy(GimpBrushGenerated *object)
gimp_brush_generated_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
......@@ -195,17 +195,11 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
a = 0;
centerp[ y*gbrush->mask->width + x] = a;
centerp[-1*y*gbrush->mask->width - x] = a;
/* centerp[-1*y*brush->mask->width + x] = a;
centerp[-1*y*brush->mask->width - x] = a;
centerp[ x*brush->mask->width + y] = a;
centerp[ x*brush->mask->width - y] = a;
centerp[-1*x*brush->mask->width + y] = a;
centerp[-1*x*brush->mask->width - y] = a;*/
}
}
g_free (lookup);
/* gtk_signal_emit_by_name(brush, "dirty"); */
brush_changed_notify(GIMP_BRUSH(brush));
gtk_signal_emit_by_name(GTK_OBJECT(brush), "dirty");
/* brush_changed_notify(GIMP_BRUSH(brush)); */
}
float
......
......@@ -29,7 +29,7 @@
static GimpObjectClass* parent_class;
static void
gimp_brush_generated_destroy(GimpBrushGenerated *object)
gimp_brush_generated_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
......@@ -195,17 +195,11 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
a = 0;
centerp[ y*gbrush->mask->width + x] = a;
centerp[-1*y*gbrush->mask->width - x] = a;
/* centerp[-1*y*brush->mask->width + x] = a;
centerp[-1*y*brush->mask->width - x] = a;
centerp[ x*brush->mask->width + y] = a;
centerp[ x*brush->mask->width - y] = a;
centerp[-1*x*brush->mask->width + y] = a;
centerp[-1*x*brush->mask->width - y] = a;*/
}
}
g_free (lookup);
/* gtk_signal_emit_by_name(brush, "dirty"); */
brush_changed_notify(GIMP_BRUSH(brush));
gtk_signal_emit_by_name(GTK_OBJECT(brush), "dirty");
/* brush_changed_notify(GIMP_BRUSH(brush)); */
}
float
......
......@@ -29,7 +29,7 @@
static GimpObjectClass* parent_class;
static void
gimp_brush_generated_destroy(GimpBrushGenerated *object)
gimp_brush_generated_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
......@@ -195,17 +195,11 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
a = 0;
centerp[ y*gbrush->mask->width + x] = a;
centerp[-1*y*gbrush->mask->width - x] = a;
/* centerp[-1*y*brush->mask->width + x] = a;
centerp[-1*y*brush->mask->width - x] = a;
centerp[ x*brush->mask->width + y] = a;
centerp[ x*brush->mask->width - y] = a;
centerp[-1*x*brush->mask->width + y] = a;
centerp[-1*x*brush->mask->width - y] = a;*/
}
}
g_free (lookup);
/* gtk_signal_emit_by_name(brush, "dirty"); */
brush_changed_notify(GIMP_BRUSH(brush));
gtk_signal_emit_by_name(GTK_OBJECT(brush), "dirty");
/* brush_changed_notify(GIMP_BRUSH(brush)); */
}
float
......
......@@ -166,10 +166,11 @@ brushes_init (int no_data)
brush_list = gimp_brush_list_new();
if (!brush_path)
if (brush_path == NULL || (no_data))
create_default_brush ();
if(!no_data)
datafiles_read_directories (brush_path, gimp_brush_new, 0);
else
datafiles_read_directories (brush_path,
(datafile_loader_t)gimp_brush_new, 0);
gimp_brush_list_recalc_indexes(brush_list);
gimp_brush_list_uniquefy_names(brush_list);
......@@ -194,7 +195,7 @@ void
brushes_free ()
{
if (brush_list) {
gimp_set_foreach (brush_list, brushes_free_one, NULL);
/* gimp_set_foreach (brush_list, brushes_free_one, NULL); */
gimp_object_destroy(GIMP_OBJECT(brush_list));
}
......@@ -278,7 +279,8 @@ static void
gimp_brush_list_recalc_indexes(GimpBrushList *brush_list)
{
int index = 0;
gimp_set_foreach (GIMP_SET(brush_list), gimp_brush_do_indexes, &index);
gimp_set_foreach (GIMP_SET(brush_list), (GFunc)gimp_brush_do_indexes,
&index);
}
void
......@@ -330,16 +332,6 @@ create_brush_dialog ()
}
void
brush_changed_notify (GimpBrushP brush)
{
if (brush)
{
paint_core_invalidate_cache(brush->mask);
if (brush_select_dialog)
brush_select_brush_changed(brush_select_dialog, brush);
}
}
/***********************/
......@@ -785,8 +777,10 @@ gimp_brush_list_get_brush(GimpBrushListP blist, char *name)
{
GimpBrushP brushp;
GSList *list;
if (blist == NULL)
return NULL;
list = GIMP_SET(brush_list)->list;
success = FALSE;
while (list)
{
......
......@@ -66,9 +66,8 @@ void select_brush (GimpBrushP);
GimpBrushP get_brush_by_index (int);
GimpBrushP get_active_brush (void);
/* TODO: {re}move these functions */
/* TODO: {re}move this function */
void create_brush_dialog (void);
void brush_changed_notify (GimpBrushP);
......
......@@ -65,6 +65,18 @@ static gint edit_brush_callback (GtkWidget *w, GdkEvent *e,
gpointer data);
static gint new_brush_callback (GtkWidget *w, GdkEvent *e,
gpointer data);
static gint brush_select_brush_dirty_callback(GimpBrushP brush,
BrushSelectP bsp);
static void connect_signals_to_brush (GimpBrushP brush,
BrushSelectP bsp);
static void disconnect_signals_from_brush(GimpBrushP brush,
BrushSelectP bsp);
static void brush_added_callback (GimpBrushList *list,
GimpBrushP brush,
BrushSelectP bsp);
static void brush_removed_callback (GimpBrushList *list,
GimpBrushP brush,
BrushSelectP bsp);
static void brush_select_close_callback (GtkWidget *, gpointer);
static void brush_select_refresh_callback(GtkWidget *, gpointer);
static void paint_mode_menu_callback (GtkWidget *, gpointer);
......@@ -312,6 +324,14 @@ brush_select_new ()
/* render the brushes into the newly created image structure */
display_brushes (bsp);
gimp_set_foreach(GIMP_SET(brush_list), (GFunc)connect_signals_to_brush, bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
(GtkSignalFunc) brush_added_callback,
bsp);
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
(GtkSignalFunc) brush_removed_callback,
bsp);
/* update the active selection */
active = get_active_brush ();
if (active)
......@@ -352,7 +372,7 @@ brush_select_free (BrushSelectP bsp)
}
}
void
static void
brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
{
/* TODO: be smarter here and only update the part of the preview
......@@ -364,10 +384,41 @@ brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
}
}
void
static gint
brush_select_brush_dirty_callback(GimpBrushP brush, BrushSelectP bsp)
{
brush_select_brush_changed(bsp, brush);
return TRUE;
}
static void
connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
{
gtk_signal_connect(GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC(brush_select_brush_dirty_callback),
bsp);
}
static void
disconnect_signals_from_brush(GimpBrushP brush, BrushSelectP bsp)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(brush), bsp);
}
static void
brush_added_callback(GimpBrushList *list, GimpBrushP brush,
BrushSelectP bsp)
{
connect_signals_to_brush(brush, bsp);
brush_select_brush_changed(bsp, brush);
}
static void
brush_removed_callback(GimpBrushList *list, GimpBrushP brush,
BrushSelectP bsp)
{
disconnect_signals_from_brush(brush, bsp);
/* brush_select_brush_changed(bsp, brush); */
}
......@@ -833,7 +884,8 @@ edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
static gint
new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
{
brush_changed_notify(GIMP_BRUSH(gimp_brush_generated_new(10, .5, 0.0, 1.0)));
gimp_brush_list_add(brush_list,
GIMP_BRUSH(gimp_brush_generated_new(10, .5, 0.0, 1.0)));
return TRUE;
}
......
......@@ -45,8 +45,6 @@ struct _BrushSelect {
BrushSelectP brush_select_new (void);
void brush_select_select (BrushSelectP, int);
void brush_select_free (BrushSelectP);
void brush_select_brush_changed(BrushSelectP bsp,
GimpBrushP brush);
/* An interface to other dialogs which need to create a paint mode menu */
GtkWidget * create_paint_mode_menu (MenuItemCallback);
......
......@@ -3963,12 +3963,17 @@ border_region(PixelRegion *src, gint16 radius)
out = (guchar *)g_malloc ((src->w)*sizeof(guchar));
density = (guchar **)g_malloc (diameter*sizeof(void *));
density += radius;
for (x = -(radius); x < (radius+1); x++) /* compute density[][] */
for (x = -(radius); x < (radius+1); x++) /* allocate density[][] */
{
register double tmpx, tmpy;
density[x] = (guchar *)g_malloc (diameter);
density[x] += radius;
for (y = -radius; y < (radius+1); y++)
}
for (x = -(radius); x < (radius+1); x++) /* compute density[][] */
{
register double tmpx, tmpy;
guchar a;
for (y = 0; y < (radius+1); y++)
{
if (x > 0)
tmpx = x - 0.5;
......@@ -3983,9 +3988,17 @@ border_region(PixelRegion *src, gint16 radius)
else
tmpy = 0.0;
if (tmpy*tmpy + tmpx*tmpx < (radius)*(radius))
density[x][y] = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
a = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
else
density[x][y] = 0;
a = 0;
density[ x][ y] = a;
density[-x][ y] = a;
density[ x][-y] = a;
density[-x][-y] = a;
density[ y][ x] = a;
density[-y][ x] = a;
density[ y][-x] = a;
density[-y][-x] = a;
}
}
pixel_region_get_row (src, src->x, src->y + 0, src->w, buf[0], 1);
......
......@@ -51,7 +51,7 @@ static void paint_to_canvas_tiles (PaintCore *, MaskBuf *, int);
static void paint_to_canvas_buf (PaintCore *, MaskBuf *, int);
static void set_undo_tiles (GimpDrawable *, int, int, int, int);
static void set_canvas_tiles (int, int, int, int);
static int paint_core_invalidate_cache(GimpBrush *brush, gpointer *blah);
/***********************************************************************/
......@@ -399,8 +399,8 @@ paint_core_init (paint_core, drawable, x, y)
GimpDrawable *drawable;
double x, y;
{
GimpBrushP brush;
static GimpBrushP brush = 0;
paint_core->curx = x;
paint_core->cury = y;
......@@ -410,11 +410,22 @@ paint_core_init (paint_core, drawable, x, y)
paint_core->startytilt = paint_core->lastytilt = paint_core->curytilt = 0;
/* Each buffer is the same size as the maximum bounds of the active brush... */
if (brush && brush != get_active_brush ())
{
gtk_signal_disconnect_by_func(GTK_OBJECT(brush),
GTK_SIGNAL_FUNC(paint_core_invalidate_cache),
NULL);
gtk_object_unref(GTK_OBJECT(brush));
}
if (!(brush = get_active_brush ()))
{
g_message ("No brushes available for use with this tool.");
return FALSE;
}
gtk_object_ref(GTK_OBJECT(brush));
gtk_signal_connect(GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC(paint_core_invalidate_cache),
NULL);
paint_core->spacing =
(double) MAXIMUM (brush->mask->width, brush->mask->height) *
......@@ -714,15 +725,13 @@ paint_core_replace_canvas (paint_core, drawable, brush_opacity, image_opacity,
brush_opacity, image_opacity, mode);
}
/* This is a hack to make sure we don't cache data for a brush that
* has changed. Do it the right way when signals get put in.
*/
static MaskBuf *last_brush = NULL;
static MaskBuf *last_brush_mask = NULL;
static int cache_invalid = 0;
int paint_core_invalidate_cache(MaskBuf *buf)
static int paint_core_invalidate_cache(GimpBrush *brush, gpointer *blah)
{
if (last_brush == buf)
/* Make sure we don't cache data for a brush that has changed */
if (last_brush_mask == brush->mask)
{
cache_invalid = 1;
return 1;
......@@ -739,7 +748,6 @@ paint_core_subsample_mask (mask, x, y)
MaskBuf * mask;
double x, y;
{
/* static MaskBuf *last_brush = NULL; */
MaskBuf * dest;
double left;
unsigned char * m, * d;
......@@ -760,9 +768,10 @@ paint_core_subsample_mask (mask, x, y)
kernel = subsample[index2][index1];
if ((mask == last_brush) && kernel_brushes[index2][index1] && !cache_invalid)
if ((mask == last_brush_mask) && kernel_brushes[index2][index1] &&
!cache_invalid)
return kernel_brushes[index2][index1];
else if (mask != last_brush || cache_invalid)
else if (mask != last_brush_mask || cache_invalid)
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
{
......@@ -771,7 +780,7 @@ paint_core_subsample_mask (mask, x, y)
kernel_brushes[i][j] = NULL;
}
last_brush = mask;
last_brush_mask = mask;
cache_invalid = 0;
kernel_brushes[index2][index1] = mask_buf_new (mask->width + 2, mask->height + 2);
dest = kernel_brushes[index2][index1];
......
......@@ -111,7 +111,4 @@ TempBuf * paint_core_get_orig_image (PaintCore *, GimpDrawable *, int, in
void paint_core_paste_canvas (PaintCore *, GimpDrawable *, int, int, int, int, int);
void paint_core_replace_canvas (PaintCore *, GimpDrawable *, int, int, int, int);
/* ugly hacks */
int paint_core_invalidate_cache(MaskBuf *);
#endif /* __PAINT_CORE_H__ */
......@@ -3963,12 +3963,17 @@ border_region(PixelRegion *src, gint16 radius)
out = (guchar *)g_malloc ((src->w)*sizeof(guchar));
density = (guchar **)g_malloc (diameter*sizeof(void *));
density += radius;
for (x = -(radius); x < (radius+1); x++) /* compute density[][] */
for (x = -(radius); x < (radius+1); x++) /* allocate density[][] */
{
register double tmpx, tmpy;
density[x] = (guchar *)g_malloc (diameter);
density[x] += radius;
for (y = -radius; y < (radius+1); y++)
}
for (x = -(radius); x < (radius+1); x++) /* compute density[][] */
{
register double tmpx, tmpy;
guchar a;
for (y = 0; y < (radius+1); y++)
{
if (x > 0)
tmpx = x - 0.5;
......@@ -3983,9 +3988,17 @@ border_region(PixelRegion *src, gint16 radius)
else
tmpy = 0.0;
if (tmpy*tmpy + tmpx*tmpx < (radius)*(radius))
density[x][y] = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
a = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
else
density[x][y] = 0;
a = 0;
density[ x][ y] = a;
density[-x][ y] = a;
density[ x][-y] = a;
density[-x][-y] = a;
density[ y][ x] = a;
density[-y][ x] = a;
density[ y][-x] = a;
density[-y][-x] = a;
}
}
pixel_region_get_row (src, src->x, src->y + 0, src->w, buf[0], 1);
......
......@@ -51,7 +51,7 @@ static void paint_to_canvas_tiles (PaintCore *, MaskBuf *, int);
static void paint_to_canvas_buf (PaintCore *, MaskBuf *, int);
static void set_undo_tiles (GimpDrawable *, int, int, int, int);
static void set_canvas_tiles (int, int, int, int);
static int paint_core_invalidate_cache(GimpBrush *brush, gpointer *blah);
/***********************************************************************/
......@@ -399,8 +399,8 @@ paint_core_init (paint_core, drawable, x, y)
GimpDrawable *drawable;
double x, y;
{
GimpBrushP brush;
static GimpBrushP brush = 0;
paint_core->curx = x;
paint_core->cury = y;
......@@ -410,11 +410,22 @@ paint_core_init (paint_core, drawable, x, y)
paint_core->startytilt = paint_core->lastytilt = paint_core->curytilt = 0;
/* Each buffer is the same size as the maximum boun