2000-05-08 09:23:30 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2000-05-31 14:15:06 +08:00
|
|
|
*
|
|
|
|
* gimpbrushmenu.c
|
1998-10-21 06:36:52 +08:00
|
|
|
* Copyright (C) 1998 Andy Thomas
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-10-21 06:36:52 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2000-05-08 09:23:30 +08:00
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1998-10-21 06:36:52 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-10-21 06:36:52 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2000-05-08 09:23:30 +08:00
|
|
|
*/
|
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimpui.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Idea is to have a function to call that returns a widget that
|
|
|
|
* completely controls the selection of a brush.
|
|
|
|
* you get a widget returned that you can use in a table say.
|
|
|
|
* In:- Initial brush name. Null means use current selection.
|
2000-05-31 14:15:06 +08:00
|
|
|
* pointer to func to call when brush changes (GimpRunBrushCallback).
|
1998-10-21 06:36:52 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
#define BSEL_DATA_KEY "__bsel_data"
|
|
|
|
#define CELL_SIZE 20
|
|
|
|
#define BRUSH_EVENT_MASK GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
1998-10-21 06:36:52 +08:00
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_BUTTON1_MOTION_MASK
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
struct __brushes_sel
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
gchar *dname;
|
|
|
|
GimpRunBrushCallback cback;
|
|
|
|
GtkWidget *brush_preview;
|
|
|
|
GtkWidget *device_brushpopup;
|
|
|
|
GtkWidget *device_brushpreview;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *top_hbox;
|
|
|
|
gchar *brush_name; /* Local copy */
|
|
|
|
gdouble opacity;
|
|
|
|
gint spacing;
|
|
|
|
gint paint_mode;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gchar *mask_data; /* local copy */
|
|
|
|
void *brush_popup_pnt; /* Pointer use to control the popup */
|
|
|
|
gpointer data;
|
1998-10-21 06:36:52 +08:00
|
|
|
};
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
typedef struct __brushes_sel BSelect;
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
static void
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_popup_open (gint x,
|
|
|
|
gint y,
|
|
|
|
BSelect *bsel)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gint x_org;
|
|
|
|
gint y_org;
|
|
|
|
gint scr_w;
|
|
|
|
gint scr_h;
|
|
|
|
gchar *src;
|
|
|
|
gchar *buf;
|
|
|
|
guchar *b;
|
|
|
|
guchar *s;
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
/* make sure the popup exists and is not visible */
|
|
|
|
if (bsel->device_brushpopup == NULL)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_hide (bsel->device_brushpopup);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* decide where to put the popup */
|
|
|
|
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 < 0) ? 0 : x;
|
|
|
|
y = (y < 0) ? 0 : y;
|
|
|
|
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);
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gtk_widget_set_uposition (bsel->device_brushpopup, x, y);
|
|
|
|
gtk_widget_show (bsel->device_brushpopup);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
/* Draw the brush */
|
|
|
|
buf = g_new (gchar, bsel->width);
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
memset (buf, 255, sizeof(bsel->width));
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
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++;
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsel->device_brushpreview),
|
|
|
|
(guchar *)buf, 0, y, bsel->width);
|
1998-10-21 06:36:52 +08:00
|
|
|
src += bsel->width;
|
|
|
|
}
|
2000-05-31 14:15:06 +08:00
|
|
|
g_free (buf);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
/* Draw the brush preview */
|
|
|
|
gtk_widget_draw (bsel->device_brushpreview, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_popup_close (BSelect *bsel)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
|
|
|
if (bsel->device_brushpopup != NULL)
|
|
|
|
gtk_widget_hide (bsel->device_brushpopup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
brush_preview_events (GtkWidget *widget,
|
2000-05-08 09:23:30 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
2000-05-08 09:23:30 +08:00
|
|
|
BSelect *bsel = (BSelect*)data;
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
if (bsel->mask_data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_grab_add (widget);
|
1998-10-21 06:36:52 +08:00
|
|
|
brush_popup_open (bevent->x, bevent->y, bsel);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_grab_remove (widget);
|
1998-10-21 06:36:52 +08:00
|
|
|
brush_popup_close (bsel);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_DELETE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-01 05:16:11 +08:00
|
|
|
brush_pre_update (GtkWidget *brush_preview,
|
|
|
|
gint brush_width,
|
|
|
|
gint brush_height,
|
|
|
|
gchar *mask_data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
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;
|
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Set buffer to white */
|
2000-05-08 09:23:30 +08:00
|
|
|
memset (buf, 255, CELL_SIZE);
|
1998-10-21 06:36:52 +08:00
|
|
|
for (i = 0; i < CELL_SIZE; i++)
|
2000-05-31 14:15:06 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brush_preview),
|
|
|
|
(guchar *)buf, 0, i, CELL_SIZE);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
offset_x = ((CELL_SIZE - width) >> 1);
|
|
|
|
offset_y = ((CELL_SIZE - height) >> 1);
|
|
|
|
|
|
|
|
ystart = CLAMP (offset_y, 0, CELL_SIZE);
|
2000-05-31 14:15:06 +08:00
|
|
|
yend = CLAMP (offset_y + height, 0, CELL_SIZE);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
src = mask_data;
|
|
|
|
|
|
|
|
for (y = ystart; y < yend; y++)
|
|
|
|
{
|
2000-05-31 14:15:06 +08:00
|
|
|
gint j;
|
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
s = src;
|
|
|
|
b = buf;
|
|
|
|
for (j = 0; j < width ; j++)
|
|
|
|
*b++ = 255 - *s++;
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brush_preview),
|
|
|
|
(guchar *)buf, offset_x, y, width);
|
1998-10-21 06:36:52 +08:00
|
|
|
src += brush_width;
|
|
|
|
}
|
2000-05-08 09:23:30 +08:00
|
|
|
g_free (buf);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
/* Draw the brush preview */
|
|
|
|
gtk_widget_draw (brush_preview, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_select_invoker (gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
gint spacing,
|
|
|
|
gint paint_mode,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gchar *mask_data,
|
|
|
|
gint closing,
|
|
|
|
gpointer data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gint mask_d_sz;
|
2000-05-31 14:15:06 +08:00
|
|
|
BSelect *bsel = (BSelect *) data;
|
2000-05-08 09:23:30 +08:00
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
if(bsel->mask_data != NULL)
|
|
|
|
g_free(bsel->mask_data);
|
2000-05-08 09:23:30 +08:00
|
|
|
|
|
|
|
bsel->width = width;
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->height = height;
|
2000-05-08 09:23:30 +08:00
|
|
|
mask_d_sz = width * height;
|
|
|
|
bsel->mask_data = g_malloc (mask_d_sz);
|
2000-06-02 05:18:04 +08:00
|
|
|
g_memmove (bsel->mask_data, mask_data, mask_d_sz);
|
2000-05-08 09:23:30 +08:00
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
brush_pre_update (bsel->brush_preview,
|
|
|
|
bsel->width, bsel->height, bsel->mask_data);
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->opacity = opacity;
|
|
|
|
bsel->spacing = spacing;
|
|
|
|
bsel->paint_mode = paint_mode;
|
2000-05-08 09:23:30 +08:00
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
if (bsel->cback != NULL)
|
|
|
|
(bsel->cback) (name, opacity, spacing, paint_mode,
|
|
|
|
width, height, mask_data, closing, bsel->data);
|
2000-05-08 09:23:30 +08:00
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
if (closing)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_widget_set_sensitive (bsel->button, TRUE);
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->brush_popup_pnt = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
brush_select_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
BSelect *bsel = (BSelect*)data;
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (bsel->button,FALSE);
|
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->brush_popup_pnt =
|
2000-05-08 09:23:30 +08:00
|
|
|
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);
|
1998-10-21 06:36:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2000-05-31 14:15:06 +08:00
|
|
|
gimp_brush_select_widget (gchar *dname,
|
|
|
|
gchar *ibrush,
|
|
|
|
gdouble opacity,
|
|
|
|
gint spacing,
|
|
|
|
gint paint_mode,
|
|
|
|
GimpRunBrushCallback cback,
|
|
|
|
gpointer data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *brush;
|
|
|
|
GtkWidget *button;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint init_spacing;
|
2000-06-01 05:16:11 +08:00
|
|
|
GimpLayerModeEffects init_paint_mode;
|
2000-05-08 09:23:30 +08:00
|
|
|
gdouble init_opacity;
|
2000-06-02 05:18:04 +08:00
|
|
|
gint mask_data_size;
|
2000-06-01 05:16:11 +08:00
|
|
|
guint8 *mask_data;
|
2000-05-08 09:23:30 +08:00
|
|
|
gchar *brush_name;
|
|
|
|
BSelect *bsel;
|
|
|
|
|
|
|
|
bsel = g_new (BSelect, 1);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 3);
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_widget_show (hbox);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_OUT);
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_widget_show (frame);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
brush = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (brush), CELL_SIZE, CELL_SIZE);
|
2000-05-08 09:23:30 +08:00
|
|
|
gtk_widget_show (brush);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), brush);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
gtk_widget_set_events (brush, BRUSH_EVENT_MASK);
|
|
|
|
|
2001-07-31 20:10:14 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush), "event",
|
|
|
|
G_CALLBACK (brush_preview_events),
|
|
|
|
bsel);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
bsel->cback = cback;
|
|
|
|
bsel->data = data;
|
|
|
|
bsel->mask_data = NULL;
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->device_brushpopup = bsel->device_brushpreview = NULL;
|
2000-05-08 09:23:30 +08:00
|
|
|
bsel->brush_preview = brush;
|
|
|
|
bsel->brush_name = ibrush;
|
|
|
|
bsel->dname = dname;
|
|
|
|
bsel->brush_popup_pnt = NULL;
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
/* Do initial brush setup */
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_name = gimp_brushes_get_brush_data (ibrush,
|
|
|
|
&init_opacity,
|
|
|
|
&init_spacing,
|
|
|
|
&init_paint_mode,
|
|
|
|
&width,
|
|
|
|
&height,
|
2000-06-02 05:18:04 +08:00
|
|
|
&mask_data_size,
|
2000-05-08 09:23:30 +08:00
|
|
|
&mask_data);
|
|
|
|
if (brush_name)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_pre_update (bsel->brush_preview, width, height, mask_data);
|
|
|
|
bsel->mask_data = mask_data;
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->brush_name = brush_name;
|
2000-05-08 09:23:30 +08:00
|
|
|
bsel->width = width;
|
|
|
|
bsel->height = height;
|
2000-05-31 14:15:06 +08:00
|
|
|
if (opacity != -1)
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->opacity = opacity;
|
|
|
|
else
|
|
|
|
bsel->opacity = init_opacity;
|
2000-05-31 14:15:06 +08:00
|
|
|
if (spacing != -1)
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->spacing = spacing;
|
|
|
|
else
|
|
|
|
bsel->spacing = init_spacing;
|
2000-05-31 14:15:06 +08:00
|
|
|
if (paint_mode != -1)
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->paint_mode = paint_mode;
|
|
|
|
else
|
|
|
|
bsel->paint_mode = init_paint_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label ("... ");
|
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), button);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
bsel->button = button;
|
2001-07-31 20:10:14 +08:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (brush_select_callback),
|
|
|
|
bsel);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2001-07-31 20:10:14 +08:00
|
|
|
g_object_set_data (G_OBJECT (hbox), BSEL_DATA_KEY, bsel);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
void
|
2000-05-08 09:23:30 +08:00
|
|
|
gimp_brush_select_widget_close_popup (GtkWidget *widget)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
BSelect *bsel;
|
2000-05-31 14:15:06 +08:00
|
|
|
|
2001-07-31 20:10:14 +08:00
|
|
|
bsel = (BSelect *) g_object_get_data (G_OBJECT (widget), BSEL_DATA_KEY);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
if (bsel && bsel->brush_popup_pnt)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-06-01 05:16:11 +08:00
|
|
|
gimp_brushes_close_popup (bsel->brush_popup_pnt);
|
1998-10-21 06:36:52 +08:00
|
|
|
bsel->brush_popup_pnt = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
void
|
2000-05-08 09:23:30 +08:00
|
|
|
gimp_brush_select_widget_set_popup (GtkWidget *widget,
|
|
|
|
gchar *bname,
|
|
|
|
gdouble opacity,
|
|
|
|
gint spacing,
|
|
|
|
gint paint_mode)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint init_spacing;
|
2000-06-01 05:16:11 +08:00
|
|
|
GimpLayerModeEffects init_paint_mode;
|
2000-05-08 09:23:30 +08:00
|
|
|
gdouble init_opacity;
|
2000-08-03 08:48:55 +08:00
|
|
|
gint mask_data_size;
|
2000-06-01 05:16:11 +08:00
|
|
|
guint8 *mask_data;
|
2000-05-08 09:23:30 +08:00
|
|
|
gchar *brush_name;
|
|
|
|
BSelect *bsel;
|
|
|
|
|
2001-07-31 20:10:14 +08:00
|
|
|
bsel = (BSelect *) g_object_get_data (G_OBJECT (widget), BSEL_DATA_KEY);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
if (bsel)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_name = gimp_brushes_get_brush_data (bname,
|
|
|
|
&init_opacity,
|
|
|
|
&init_spacing,
|
|
|
|
&init_paint_mode,
|
|
|
|
&width,
|
|
|
|
&height,
|
2000-06-02 05:18:04 +08:00
|
|
|
&mask_data_size,
|
2000-05-08 09:23:30 +08:00
|
|
|
&mask_data);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
if (opacity == -1.0)
|
1998-10-21 06:36:52 +08:00
|
|
|
opacity = init_opacity;
|
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
if (spacing == -1)
|
1998-10-21 06:36:52 +08:00
|
|
|
spacing = init_spacing;
|
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
if (paint_mode == -1)
|
1998-10-21 06:36:52 +08:00
|
|
|
paint_mode = init_paint_mode;
|
|
|
|
|
2000-05-08 09:23:30 +08:00
|
|
|
brush_select_invoker (bname, opacity, spacing, paint_mode,
|
|
|
|
width, height, mask_data, 0, bsel);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-06-01 05:16:11 +08:00
|
|
|
if (bsel->brush_popup_pnt)
|
|
|
|
gimp_brushes_set_popup (bsel->brush_popup_pnt,
|
|
|
|
bname, opacity, spacing, paint_mode);
|
1998-10-21 06:36:52 +08:00
|
|
|
}
|
|
|
|
}
|