Commit 1fd0eb07 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

update the BrushSelect "object" when the brush opacity is changed.

2003-06-17  Sven Neumann  <sven@gimp.org>

	* app/gui/brush-select.c (opacity_scale_update): update the
	BrushSelect "object" when the brush opacity is changed.

	* libgimp/gimpmenu.[ch]
	* libgimp/gimpbrushmenu.c
	* libgimp/gimpfontmenu.c
	* libgimp/gimpgradientmenu.c
	* libgimp/gimppatternmenu.c: raise selection dialogs when being
	called again, marked strings for translation, added lots of const
	qualifiers, cleaned up code.

	* tools/pdbgen/pdb/brushes.pdb
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/patterns.pdb: use g_memdup() instead of
	g_memmove().

	* app/pdb/brushes_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/patterns_cmds.c: regenerated.

2003-06-17  Sven Neumann  <sven@gimp.org>

	* POTFILES.in: added files with newly marked strings.

	* de.po: updated.
parent e4d27fc7
2003-06-17 Sven Neumann <sven@gimp.org>
* app/gui/brush-select.c (opacity_scale_update): update the
BrushSelect "object" when the brush opacity is changed.
* libgimp/gimpmenu.[ch]
* libgimp/gimpbrushmenu.c
* libgimp/gimpfontmenu.c
* libgimp/gimpgradientmenu.c
* libgimp/gimppatternmenu.c: raise selection dialogs when being
called again, marked strings for translation, added lots of const
qualifiers, cleaned up code.
* tools/pdbgen/pdb/brushes.pdb
* tools/pdbgen/pdb/drawable.pdb
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/patterns.pdb: use g_memdup() instead of
g_memmove().
* app/pdb/brushes_cmds.c
* app/pdb/drawable_cmds.c
* app/pdb/image_cmds.c
* app/pdb/patterns_cmds.c: regenerated.
2003-06-16 Adam D. Moss <adam@gimp.org>
 
* plug-ins/common/gif.c: Attempt to use the palette colour
......@@ -380,6 +380,8 @@ opacity_scale_update (GtkAdjustment *adjustment,
g_signal_handlers_unblock_by_func (bsp->context,
brush_select_opacity_changed,
bsp);
brush_select_change_callbacks (bsp, FALSE);
}
static void
......
......@@ -542,9 +542,8 @@ brushes_get_brush_data_invoker (Gimp *gimp,
if (success)
{
length = brush->mask->height * brush->mask->width;
mask_data = g_new (guint8, length);
g_memmove (mask_data, temp_buf_data (brush->mask), length);
length = brush->mask->height * brush->mask->width;
mask_data = g_memdup (temp_buf_data (brush->mask), length);
}
}
......
......@@ -1417,7 +1417,7 @@ drawable_thumbnail_invoker (Gimp *gimp,
gint32 width = 0;
gint32 height = 0;
gint32 bpp = 0;
gint32 num_pixels = 0;
gint32 num_bytes = 0;
guint8 *thumbnail_data = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
......@@ -1453,12 +1453,11 @@ drawable_thumbnail_invoker (Gimp *gimp,
if (buf)
{
num_pixels = buf->height * buf->width * buf->bytes;
thumbnail_data = g_new (guint8, num_pixels);
g_memmove (thumbnail_data, temp_buf_data (buf), num_pixels);
width = buf->width;
height = buf->height;
bpp = buf->bytes;
num_bytes = buf->height * buf->width * buf->bytes;
thumbnail_data = g_memdup (temp_buf_data (buf), num_bytes);
width = buf->width;
height = buf->height;
bpp = buf->bytes;
}
}
}
......@@ -1470,7 +1469,7 @@ drawable_thumbnail_invoker (Gimp *gimp,
return_args[1].value.pdb_int = width;
return_args[2].value.pdb_int = height;
return_args[3].value.pdb_int = bpp;
return_args[4].value.pdb_int = num_pixels;
return_args[4].value.pdb_int = num_bytes;
return_args[5].value.pdb_pointer = thumbnail_data;
}
......@@ -1516,7 +1515,7 @@ static ProcArg drawable_thumbnail_outargs[] =
{
GIMP_PDB_INT32,
"thumbnail_data_count",
"The number of pixels in thumbnail data"
"The number of bytes in thumbnail data"
},
{
GIMP_PDB_INT8ARRAY,
......
......@@ -2689,8 +2689,7 @@ image_thumbnail_invoker (Gimp *gimp,
if (buf)
{
num_bytes = buf->height * buf->width * buf->bytes;
thumbnail_data = g_new (guint8, num_bytes);
g_memmove (thumbnail_data, temp_buf_data (buf), num_bytes);
thumbnail_data = g_memdup (temp_buf_data (buf), num_bytes);
width = buf->width;
height = buf->height;
bpp = buf->bytes;
......
......@@ -281,8 +281,7 @@ patterns_get_pattern_data_invoker (Gimp *gimp,
{
length = pattern->mask->height * pattern->mask->width *
pattern->mask->bytes;
mask_data = g_new (guint8, length);
g_memmove (mask_data, temp_buf_data (pattern->mask), length);
mask_data = g_memdup (temp_buf_data (pattern->mask), length);
}
}
......
......@@ -87,7 +87,7 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dialogname:
@title:
@brush_name:
@opacity:
@spacing:
......@@ -95,6 +95,8 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@dialogname:
<!-- ##### FUNCTION gimp_brush_select_widget ##### -->
......@@ -102,14 +104,18 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dname:
@ibrush:
@title:
@brush_name:
@opacity:
@spacing:
@paint_mode:
@cback:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@cback:
@dname:
@ibrush:
<!-- ##### USER_FUNCTION GimpRunBrushCallback ##### -->
......@@ -134,10 +140,12 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@widget:
@bname:
@brush_name:
@opacity:
@spacing:
@paint_mode:
<!-- # Unused Parameters # -->
@bname:
<!-- ##### FUNCTION gimp_brush_select_widget_close_popup ##### -->
......@@ -153,11 +161,13 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dialogtitle:
@title:
@font_name:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@dialogtitle:
<!-- ##### FUNCTION gimp_font_select_widget ##### -->
......@@ -165,11 +175,15 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dname:
@ifont:
@cback:
@title:
@font_name:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@cback:
@dname:
@ifont:
<!-- ##### USER_FUNCTION GimpRunFontCallback ##### -->
......@@ -188,6 +202,8 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@widget:
@font_name:
<!-- # Unused Parameters # -->
@fname:
......@@ -204,12 +220,15 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dialogtitle:
@title:
@gradient_name:
@sample_sz:
@sample_size:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@dialogtitle:
@sample_sz:
<!-- ##### FUNCTION gimp_gradient_select_widget ##### -->
......@@ -217,11 +236,16 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@gname:
@igradient:
@cback:
@title:
@gradient_name:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@gradient:
@cback:
@gname:
@igradient:
<!-- ##### USER_FUNCTION GimpRunGradientCallback ##### -->
......@@ -250,6 +274,8 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@widget:
@gradient_name:
<!-- # Unused Parameters # -->
@gname:
......@@ -258,11 +284,13 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dialogtitle:
@title:
@pattern_name:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@dialogtitle:
<!-- ##### FUNCTION gimp_pattern_select_widget ##### -->
......@@ -270,11 +298,15 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@dname:
@ipattern:
@cback:
@title:
@pattern_name:
@callback:
@data:
@Returns:
<!-- # Unused Parameters # -->
@cback:
@dname:
@ipattern:
<!-- ##### USER_FUNCTION GimpRunPatternCallback ##### -->
......@@ -305,6 +337,8 @@ Widgets and functions for selecting images, layers, brushes, patterns etc.
</para>
@widget:
@pattern_name:
<!-- # Unused Parameters # -->
@pname:
......@@ -32,6 +32,8 @@
#include "gimp.h"
#include "gimpui.h"
#include "libgimp-intl.h"
/* Idea is to have a function to call that returns a widget that
* completely controls the selection of a brush.
......@@ -40,8 +42,8 @@
* pointer to func to call when brush changes (GimpRunBrushCallback).
* Returned:- Pointer to a widget that you can use in UI.
*
* Widget simply made up of a preview widget (20x20) containing the brush mask
* and a button that can be clicked on to change the brush.
* Widget simply made up of a preview widget (20x20) containing the brush
* mask and a button that can be clicked on to change the brush.
*/
......@@ -54,8 +56,8 @@
struct __brushes_sel
{
gchar *dname;
GimpRunBrushCallback cback;
gchar *title;
GimpRunBrushCallback callback;
GtkWidget *brush_preview;
GtkWidget *device_brushpopup;
GtkWidget *device_brushpreview;
......@@ -67,37 +69,40 @@ struct __brushes_sel
gint paint_mode;
gint width;
gint height;
gchar *mask_data; /* local copy */
void *brush_popup_pnt; /* Pointer use to control the popup */
guchar *mask_data; /* local copy */
gchar *brush_popup_pnt; /* used to control the popup */
gpointer data;
};
typedef struct __brushes_sel BSelect;
static void
brush_popup_open (gint x,
gint y,
BSelect *bsel)
brush_popup_open (BSelect *bsel,
gint x,
gint y)
{
gint x_org;
gint y_org;
gint scr_w;
gint scr_h;
gchar *src;
gchar *buf;
guchar *b;
guchar *s;
const guchar *src;
const guchar *s;
guchar *buf;
guchar *b;
gint x_org;
gint y_org;
gint scr_w;
gint scr_h;
/* make sure the popup exists and is not visible */
if (bsel->device_brushpopup == NULL)
if (! bsel->device_brushpopup)
{
GtkWidget *frame;
bsel->device_brushpopup = gtk_window_new (GTK_WINDOW_POPUP);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (bsel->device_brushpopup), frame);
gtk_widget_show (frame);
bsel->device_brushpreview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
gtk_container_add (GTK_CONTAINER (frame), bsel->device_brushpreview);
gtk_widget_show (bsel->device_brushpreview);
......@@ -111,12 +116,14 @@ brush_popup_open (gint x,
gdk_window_get_origin (bsel->brush_preview->window, &x_org, &y_org);
scr_w = gdk_screen_width ();
scr_h = gdk_screen_height ();
x = x_org + x - (bsel->width >> 1);
y = y_org + y - (bsel->height >> 1);
x = x_org + x - (bsel->width / 2);
y = y_org + y - (bsel->height / 2);
x = (x < 0) ? 0 : x;
y = (y < 0) ? 0 : y;
x = (x + bsel->width > scr_w) ? scr_w - bsel->width : x;
x = (x + bsel->width > scr_w) ? scr_w - bsel->width : x;
y = (y + bsel->height > scr_h) ? scr_h - bsel->height : y;
gtk_preview_size (GTK_PREVIEW (bsel->device_brushpreview),
bsel->width, bsel->height);
......@@ -124,24 +131,26 @@ brush_popup_open (gint x,
gtk_widget_show (bsel->device_brushpopup);
/* Draw the brush */
buf = g_new (gchar, bsel->width);
memset (buf, 255, sizeof(bsel->width));
buf = g_new (guchar, bsel->width);
memset (buf, 255, bsel->width);
src = bsel->mask_data;
for (y = 0; y < bsel->height; y++)
{
int j;
s = src;
b = buf;
for (j = 0; j < bsel->width ; j++)
*b++ = 255 - *s++;
gtk_preview_draw_row (GTK_PREVIEW (bsel->device_brushpreview),
(guchar *)buf, 0, y, bsel->width);
buf, 0, y, bsel->width);
src += bsel->width;
}
g_free (buf);
gtk_widget_queue_draw (bsel->device_brushpreview);
......@@ -150,7 +159,7 @@ brush_popup_open (gint x,
static void
brush_popup_close (BSelect *bsel)
{
if (bsel->device_brushpopup != NULL)
if (bsel->device_brushpopup)
gtk_widget_hide (bsel->device_brushpopup);
}
......@@ -175,7 +184,7 @@ brush_preview_events (GtkWidget *widget,
if (bevent->button == 1)
{
gtk_grab_add (widget);
brush_popup_open (bevent->x, bevent->y, bsel);
brush_popup_open (bsel, bevent->x, bevent->y);
}
break;
......@@ -200,38 +209,35 @@ brush_preview_events (GtkWidget *widget,
}
static void
brush_pre_update (GtkWidget *brush_preview,
gint brush_width,
gint brush_height,
gchar *mask_data)
brush_preview_update (GtkWidget *brush_preview,
gint brush_width,
gint brush_height,
const gchar *mask_data)
{
gint y;
gint i;
gchar *src;
gchar *buf;
guchar *b;
guchar *s;
gint offset_x;
gint offset_y;
gint yend;
gint ystart;
gint width,height;
guchar *buf;
guchar *b;
const guchar *src;
const guchar *s;
gint i, y;
gint offset_x, offset_y;
gint ystart, yend;
gint width, height;
/* Draw the brush */
buf = g_new (gchar, CELL_SIZE);
/* Limit to cell size */
width = (brush_width > CELL_SIZE) ? CELL_SIZE: brush_width;
height = (brush_height > CELL_SIZE) ? CELL_SIZE: brush_height;
buf = g_new (guchar, CELL_SIZE);
/* Set buffer to white */
memset (buf, 255, CELL_SIZE);
for (i = 0; i < CELL_SIZE; i++)
gtk_preview_draw_row (GTK_PREVIEW (brush_preview),
(guchar *)buf, 0, i, CELL_SIZE);
offset_x = ((CELL_SIZE - width) >> 1);
offset_y = ((CELL_SIZE - height) >> 1);
buf, 0, i, CELL_SIZE);
/* Limit to cell size */
width = (brush_width > CELL_SIZE) ? CELL_SIZE: brush_width;
height = (brush_height > CELL_SIZE) ? CELL_SIZE: brush_height;
offset_x = ((CELL_SIZE - width) / 2);
offset_y = ((CELL_SIZE - height) / 2);
ystart = CLAMP (offset_y, 0, CELL_SIZE);
yend = CLAMP (offset_y + height, 0, CELL_SIZE);
......@@ -247,53 +253,48 @@ brush_pre_update (GtkWidget *brush_preview,
for (j = 0; j < width ; j++)
*b++ = 255 - *s++;
gtk_preview_draw_row (GTK_PREVIEW (brush_preview),
(guchar *)buf, offset_x, y, width);
gtk_preview_draw_row (GTK_PREVIEW (brush_preview),
buf, offset_x, y, width);
src += brush_width;
}
g_free (buf);
gtk_widget_queue_draw (brush_preview);
}
static void
brush_select_invoker (gchar *name,
gdouble opacity,
gint spacing,
gint paint_mode,
gint width,
gint height,
gchar *mask_data,
gint closing,
gpointer data)
brush_select_invoker (const gchar *name,
gdouble opacity,
gint spacing,
gint paint_mode,
gint width,
gint height,
const guchar *mask_data,
gboolean closing,
gpointer data)
{
gint mask_d_sz;
BSelect *bsel = (BSelect *) data;
if(bsel->mask_data != NULL)
g_free(bsel->mask_data);
g_free (bsel->brush_name);
g_free (bsel->mask_data);
bsel->width = width;
bsel->height = height;
mask_d_sz = width * height;
bsel->mask_data = g_malloc (mask_d_sz);
g_memmove (bsel->mask_data, mask_data, mask_d_sz);
brush_pre_update (bsel->brush_preview,
bsel->width, bsel->height, bsel->mask_data);
bsel->opacity = opacity;
bsel->spacing = spacing;
bsel->brush_name = g_strdup (name);
bsel->width = width;
bsel->height = height;
bsel->mask_data = g_memdup (mask_data, width * height);
bsel->opacity = opacity;
bsel->spacing = spacing;
bsel->paint_mode = paint_mode;
if (bsel->cback != NULL)
(bsel->cback) (name, opacity, spacing, paint_mode,
width, height, mask_data, closing, bsel->data);
brush_preview_update (bsel->brush_preview, width, height, mask_data);
if (bsel->callback)
bsel->callback (name, opacity, spacing, paint_mode,
width, height, mask_data, closing, bsel->data);
if (closing)
{
gtk_widget_set_sensitive (bsel->button, TRUE);
bsel->brush_popup_pnt = NULL;
}
bsel->brush_popup_pnt = NULL;
}
static void
......@@ -302,42 +303,53 @@ brush_select_callback (GtkWidget *widget,
{
BSelect *bsel = (BSelect*)data;
gtk_widget_set_sensitive (bsel->button,FALSE);
bsel->brush_popup_pnt =
gimp_interactive_selection_brush ((bsel->dname) ? bsel->dname
: "Brush Plugin Selection",
bsel->brush_name,
bsel->opacity,
bsel->spacing,
bsel->paint_mode,
brush_select_invoker,
bsel);
if (bsel->brush_popup_pnt)
{
/* calling gimp_brushes_set_popup() raises the dialog */
gimp_brushes_set_popup (bsel->brush_popup_pnt,
bsel->brush_name,
bsel->opacity,
bsel->spacing,
bsel->paint_mode);
}
else
{
bsel->brush_popup_pnt =
gimp_interactive_selection_brush (bsel->title ?
bsel->title : _("Brush Selection"),
bsel->brush_name,
bsel->opacity,
bsel->spacing,
bsel->paint_mode,
brush_select_invoker,
bsel);
}
}