1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <string.h>
|
Include config.h, guard inclusion of <unistd.h>.
1999-09-14 Tor Lillqvist <tml@iki.fi>
* app/brush_select.c: Include config.h, guard inclusion of
<unistd.h>.
* app/gimpcontextpreview.c: Include config.h, <string.h> and
appenv.h.
* app/xinput_airbrush.c: Include config.h, <stdio.h>, appenv.h and
libgimp/gimpmath.h. Use G_PI.
* app/makefile.{cygwin,msc}: Updates.
* plug-ins/makefile.{cygwin,msc}: Add the unofficial sel_gauss
plug-in. Add new object files for FractalExplorer and
gimpressionist.
* plug-ins/common/iwarp.c (iwarp_deform): Combine two loops over
the same xi, yi area into one. Remove the then actually unused
deform_area_vectors array. Only one element of the array was used
for each x,yi loop.
* plug-ins/common/sparkle.c: Don't include <math.h>,
libgimp/gimpmath.h includes it. Use G_PI.
1999-09-15 05:20:04 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
2001-02-12 11:27:28 +08:00
|
|
|
#include "context_manager.h"
|
1999-08-13 01:53:51 +08:00
|
|
|
#include "brush_scale.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "brush_edit.h"
|
|
|
|
#include "brush_select.h"
|
2001-02-04 22:10:03 +08:00
|
|
|
#include "brushes.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "dialog_handler.h"
|
1999-09-03 01:27:28 +08:00
|
|
|
#include "gimpbrushgenerated.h"
|
|
|
|
#include "gimpbrushpipe.h"
|
1999-07-06 23:18:25 +08:00
|
|
|
#include "gimpcontext.h"
|
2001-02-11 09:39:24 +08:00
|
|
|
#include "gimpdata.h"
|
1999-10-28 23:05:49 +08:00
|
|
|
#include "gimpdnd.h"
|
1998-07-12 19:40:43 +08:00
|
|
|
#include "gimplist.h"
|
1999-07-06 23:18:25 +08:00
|
|
|
#include "gimprc.h"
|
1998-06-23 01:30:40 +08:00
|
|
|
#include "session.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "temp_buf.h"
|
|
|
|
|
2001-01-22 09:46:28 +08:00
|
|
|
#include "tools/paint_options.h"
|
|
|
|
|
2001-01-22 05:58:16 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
#define MIN_CELL_SIZE 25
|
|
|
|
#define MAX_CELL_SIZE 25 /* disable variable brush preview size */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#define STD_BRUSH_COLUMNS 5
|
|
|
|
#define STD_BRUSH_ROWS 5
|
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
/* how long to wait after mouse-down before showing brush popup */
|
1999-05-02 05:37:34 +08:00
|
|
|
#define POPUP_DELAY_MS 150
|
|
|
|
|
1999-04-29 16:50:22 +08:00
|
|
|
#define MAX_WIN_WIDTH(bsp) (MIN_CELL_SIZE * ((bsp)->NUM_BRUSH_COLUMNS))
|
|
|
|
#define MAX_WIN_HEIGHT(bsp) (MIN_CELL_SIZE * ((bsp)->NUM_BRUSH_ROWS))
|
1999-09-27 05:16:37 +08:00
|
|
|
#define MARGIN_WIDTH 1
|
|
|
|
#define MARGIN_HEIGHT 1
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#define BRUSH_EVENT_MASK GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_BUTTON1_MOTION_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK
|
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
/* the pixmaps for the [scale|pipe]_indicators */
|
1999-10-27 02:27:27 +08:00
|
|
|
#define indicator_width 7
|
1999-09-27 05:16:37 +08:00
|
|
|
#define indicator_height 7
|
1999-09-03 01:27:28 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
#define WHT {255, 255, 255}
|
|
|
|
#define BLK { 0, 0, 0}
|
|
|
|
#define RED {255, 127, 127}
|
1999-09-03 01:27:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* local function prototypes */
|
1999-10-28 23:05:49 +08:00
|
|
|
static void brush_change_callbacks (BrushSelect *bsp,
|
|
|
|
gboolean closing);
|
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
static GimpBrush * brush_select_drag_brush (GtkWidget *widget,
|
|
|
|
gpointer data);
|
1999-10-28 23:05:49 +08:00
|
|
|
static void brush_select_drop_brush (GtkWidget *widget,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gpointer data);
|
1999-10-27 02:27:27 +08:00
|
|
|
static void brush_select_brush_changed (GimpContext *context,
|
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp);
|
|
|
|
static void brush_select_opacity_changed (GimpContext *context,
|
|
|
|
gdouble opacity,
|
|
|
|
BrushSelect *bsp);
|
|
|
|
static void brush_select_paint_mode_changed (GimpContext *context,
|
|
|
|
LayerModeEffects paint_mode,
|
|
|
|
BrushSelect *bsp);
|
|
|
|
static void brush_select_select (BrushSelect *bsp,
|
|
|
|
GimpBrush *brush);
|
|
|
|
|
|
|
|
static void brush_select_brush_dirty_callback (GimpBrush *brush,
|
|
|
|
BrushSelect *bsp);
|
2001-02-04 22:10:03 +08:00
|
|
|
static void brush_added_callback (GimpContainer *container,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp);
|
2001-02-04 22:10:03 +08:00
|
|
|
static void brush_removed_callback (GimpContainer *container,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp);
|
|
|
|
|
|
|
|
static void draw_brush_popup (GtkPreview *preview,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
static gint brush_popup_anim_timeout (gpointer data);
|
|
|
|
static gboolean brush_popup_timeout (gpointer data);
|
|
|
|
static void brush_popup_open (BrushSelect *,
|
|
|
|
gint, gint, GimpBrush *);
|
|
|
|
static void brush_popup_close (BrushSelect *);
|
|
|
|
|
|
|
|
static void display_setup (BrushSelect *);
|
2000-04-15 00:33:47 +08:00
|
|
|
static void clear_brush (BrushSelect *,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *, gint, gint);
|
2000-04-15 00:33:47 +08:00
|
|
|
static void display_brush (BrushSelect *,
|
|
|
|
GimpBrush *, gint, gint,
|
|
|
|
gboolean);
|
1999-10-27 02:27:27 +08:00
|
|
|
static void do_display_brush (GimpBrush *brush,
|
|
|
|
BrushSelect *bsp);
|
|
|
|
static void display_brushes (BrushSelect *);
|
|
|
|
|
|
|
|
static void brush_select_show_selected (BrushSelect *, gint, gint);
|
|
|
|
static void update_active_brush_field (BrushSelect *);
|
|
|
|
static void preview_calc_scrollbar (BrushSelect *);
|
|
|
|
|
|
|
|
static gint brush_select_resize (GtkWidget *, GdkEvent *,
|
|
|
|
BrushSelect *);
|
|
|
|
static gint brush_select_events (GtkWidget *, GdkEvent *,
|
|
|
|
BrushSelect *);
|
|
|
|
|
|
|
|
/* static void brush_select_map_callback (GtkWidget *,
|
|
|
|
BrushSelect *); */
|
|
|
|
static void brush_select_scroll_update (GtkAdjustment *, gpointer);
|
|
|
|
static void opacity_scale_update (GtkAdjustment *, gpointer);
|
|
|
|
static void paint_mode_menu_callback (GtkWidget *, gpointer);
|
|
|
|
static void spacing_scale_update (GtkAdjustment *, gpointer);
|
|
|
|
|
|
|
|
static void brush_select_close_callback (GtkWidget *, gpointer);
|
|
|
|
static void brush_select_refresh_callback (GtkWidget *, gpointer);
|
|
|
|
static void brush_select_new_brush_callback (GtkWidget *, gpointer);
|
|
|
|
static void brush_select_edit_brush_callback (GtkWidget *, gpointer);
|
|
|
|
static void brush_select_delete_brush_callback (GtkWidget *, gpointer);
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static unsigned char scale_indicator_bits[7][7][3] =
|
|
|
|
{
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
|
|
|
|
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char pipe_indicator_bits[7][7][3] =
|
|
|
|
{
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
|
|
|
|
{ WHT, WHT, WHT, WHT, RED, RED, RED },
|
|
|
|
{ WHT, WHT, WHT, RED, RED, RED, RED },
|
|
|
|
{ WHT, WHT, RED, RED, RED, RED, RED },
|
|
|
|
{ WHT, RED, RED, RED, RED, RED, RED }
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char scale_pipe_indicator_bits[7][7][3] =
|
|
|
|
{
|
|
|
|
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
|
|
|
|
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
|
|
|
|
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
|
|
|
|
{ WHT, WHT, WHT, BLK, RED, RED, RED },
|
|
|
|
{ WHT, WHT, RED, BLK, RED, RED, RED },
|
|
|
|
{ WHT, RED, RED, RED, RED, RED, RED }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
static GtkTargetEntry preview_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_BRUSH
|
|
|
|
};
|
|
|
|
static guint preview_n_targets = (sizeof (preview_target_table) /
|
|
|
|
sizeof (preview_target_table[0]));
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* The main brush selection dialog */
|
|
|
|
BrushSelect *brush_select_dialog = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* local variables */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* List of active dialogs */
|
gave parasite undo a MISC_UNDO class for now so it compiles
* app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now
so it compiles
* app/tools_cmds.c: fix crop invoker to give correct args to
crop_image
* app/color_cmds.c: s/GRAY/GRAY_LUT/g;
* app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs,
brush_select_dialog, s/active_dialogs/brush_active_dialogs/
* app/gimage_cmds.[ch]
* app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate
function from gimage_cmds to channel_ops, export offset and duplicate
* app/gimpbrushlist.[ch]: removed PDB procs
* app/gradient.[ch]: removed PDB procs,
* app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients,
grad_active_dialogs, gradient_select_dialog
* app/gradient_select.c: removed PDB procs,
s/active_dialogs/grad_active_dialogs/
* app/patterns.[ch]: removed PDB procs
* app/pattern_select.[ch]: removed PDB procs,
s/active_dialogs/pattern_active_dialogs/
* app/procedural_db.c: removed PDB procs and supporting functions
* app/procedrual_db.h: fiddled with enums
* app/channel_cmds.[ch]
* app/drawable_cmds.[ch]
* app/parasite_cmds.[ch]: pdbgenned now, removed header files
* app/gimpparasite.c: minor cleanup
* app/internal_procs.c: use pdbgen stuff
* app/tools_cmds.c
* app/text_tool_cmds.c: updated from pdbgen
* app/brushes_cmds.c
* app/brush_select_cmds.c
* app/gradient_cmds.c
* app/gradient_select_cmds.c
* app/patterns_cmds.c
* app/pattern_select_cmds.c
* app/procedural_db_cmds.c: new pdbgen files
* app/Makefile.am: file shuffle (see above)
-Yosh
1999-04-24 04:54:02 +08:00
|
|
|
GSList *brush_active_dialogs = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* Brush editor dialog */
|
1999-04-23 22:47:50 +08:00
|
|
|
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
void
|
|
|
|
brush_dialog_create (void)
|
|
|
|
{
|
|
|
|
if (! brush_select_dialog)
|
|
|
|
{
|
|
|
|
brush_select_dialog = brush_select_new (NULL, NULL, 0.0, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_VISIBLE (brush_select_dialog->shell))
|
|
|
|
gtk_widget_show (brush_select_dialog->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise (brush_select_dialog->shell->window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-04-15 00:33:47 +08:00
|
|
|
brush_dialog_free (void)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
if (brush_select_dialog)
|
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
session_get_window_info (brush_select_dialog->shell,
|
|
|
|
&brush_select_session_info);
|
|
|
|
|
|
|
|
/* save the size of the preview */
|
|
|
|
brush_select_session_info.width =
|
|
|
|
brush_select_dialog->preview->allocation.width;
|
|
|
|
brush_select_session_info.height =
|
|
|
|
brush_select_dialog->preview->allocation.height;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_free (brush_select_dialog);
|
|
|
|
brush_select_dialog = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
/* If title == NULL then it is the main brush dialog */
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *
|
1999-04-22 22:34:00 +08:00
|
|
|
brush_select_new (gchar *title,
|
|
|
|
/* These are the required initial vals
|
|
|
|
* If init_name == NULL then use current brush
|
|
|
|
*/
|
|
|
|
gchar *init_name,
|
|
|
|
gdouble init_opacity,
|
|
|
|
gint init_spacing,
|
|
|
|
gint init_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1999-04-23 22:47:50 +08:00
|
|
|
GtkWidget *frame;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *sbar;
|
1999-04-22 22:34:00 +08:00
|
|
|
GtkWidget *sep;
|
|
|
|
GtkWidget *table;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *util_box;
|
|
|
|
GtkWidget *slider;
|
1999-10-27 02:27:27 +08:00
|
|
|
GtkWidget *button;
|
1999-04-24 07:28:49 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *active = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static gboolean first_call = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp = g_new (BrushSelect, 1);
|
|
|
|
bsp->callback_name = NULL;
|
1999-11-03 17:58:46 +08:00
|
|
|
bsp->dnd_brush = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->brush_popup = NULL;
|
|
|
|
bsp->popup_timeout_tag = 0;
|
|
|
|
bsp->popup_anim_timeout_tag = 0;
|
|
|
|
bsp->scroll_offset = 0;
|
|
|
|
bsp->old_row = 0;
|
|
|
|
bsp->old_col = 0;
|
|
|
|
bsp->NUM_BRUSH_COLUMNS = STD_BRUSH_COLUMNS;
|
|
|
|
bsp->NUM_BRUSH_ROWS = STD_BRUSH_ROWS;
|
|
|
|
bsp->redraw = TRUE;
|
|
|
|
bsp->freeze = FALSE;
|
|
|
|
|
|
|
|
/* The shell */
|
|
|
|
bsp->shell = gimp_dialog_new (title ? title : _("Brush Selection"),
|
|
|
|
"brush_selection",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/brush_selection.html",
|
2000-01-30 07:06:06 +08:00
|
|
|
title ? GTK_WIN_POS_MOUSE : GTK_WIN_POS_NONE,
|
1999-10-27 02:27:27 +08:00
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Refresh"), brush_select_refresh_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
bsp, NULL, NULL, FALSE, FALSE,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Close"), brush_select_close_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
bsp, NULL, NULL, TRUE, TRUE,
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
NULL);
|
1999-09-02 17:20:48 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
if (title)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->context = gimp_context_new (title, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
bsp->context = gimp_context_get_user ();
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
session_set_window_geometry (bsp->shell, &brush_select_session_info,
|
|
|
|
FALSE);
|
1999-10-28 23:05:49 +08:00
|
|
|
dialog_register (bsp->shell);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (no_data && first_call)
|
1999-10-27 02:27:27 +08:00
|
|
|
brushes_init (FALSE);
|
1999-07-06 23:18:25 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
first_call = FALSE;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (title && init_name && strlen (init_name))
|
|
|
|
{
|
2001-02-06 01:48:50 +08:00
|
|
|
active = (GimpBrush *)
|
|
|
|
gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list),
|
|
|
|
init_name);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
active = gimp_context_get_brush (gimp_context_get_user ());
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (!active)
|
|
|
|
{
|
|
|
|
active = gimp_context_get_brush (gimp_context_get_standard ());
|
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (title)
|
|
|
|
{
|
|
|
|
gimp_context_set_brush (bsp->context, active);
|
|
|
|
gimp_context_set_paint_mode (bsp->context, init_mode);
|
|
|
|
gimp_context_set_opacity (bsp->context, init_opacity);
|
|
|
|
bsp->spacing_value = init_spacing;
|
1999-09-28 01:58:10 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-29 16:50:22 +08:00
|
|
|
/* The main vbox */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), vbox);
|
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* The horizontal box containing the brush list & options box */
|
1997-11-25 06:05:25 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
|
|
|
|
|
|
|
/* A place holder for paint mode switching */
|
|
|
|
bsp->left_box = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), bsp->left_box, TRUE, TRUE, 0);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* The horizontal box containing preview & scrollbar */
|
|
|
|
bsp->brush_selection_box = gtk_hbox_new (FALSE, 2);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (bsp->left_box), bsp->brush_selection_box);
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), frame,
|
1999-04-22 22:34:00 +08:00
|
|
|
TRUE, TRUE, 0);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
bsp->sbar_data =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT (bsp),
|
|
|
|
1, 1, MAX_WIN_HEIGHT (bsp)));
|
1997-11-25 06:05:25 +08:00
|
|
|
sbar = gtk_vscrollbar_new (bsp->sbar_data);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->sbar_data), "value_changed",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_scroll_update),
|
|
|
|
bsp);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), sbar, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the brush preview window and the underlying image */
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
/* Get the maximum brush extents */
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->cell_width = MIN_CELL_SIZE;
|
1999-04-29 16:50:22 +08:00
|
|
|
bsp->cell_height = MIN_CELL_SIZE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-13 23:20:35 +08:00
|
|
|
bsp->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (bsp->preview),
|
|
|
|
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
|
1999-04-29 16:50:22 +08:00
|
|
|
gtk_widget_set_usize (bsp->preview,
|
|
|
|
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_set_expand (GTK_PREVIEW (bsp->preview), TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_set_events (bsp->preview, BRUSH_EVENT_MASK);
|
1999-04-23 22:47:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->preview), "event",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_events),
|
1997-11-25 06:05:25 +08:00
|
|
|
bsp);
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT(bsp->preview), "size_allocate",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_resize),
|
1999-04-23 22:47:50 +08:00
|
|
|
bsp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* dnd stuff */
|
1999-11-03 17:58:46 +08:00
|
|
|
gtk_drag_source_set (bsp->preview,
|
|
|
|
GDK_BUTTON2_MASK,
|
|
|
|
preview_target_table, preview_n_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_brush_source_set (bsp->preview, brush_select_drag_brush, bsp);
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_drag_dest_set (bsp->preview,
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
preview_target_table, preview_n_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_brush_dest_set (bsp->preview, brush_select_drop_brush, bsp);
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (bsp->preview);
|
|
|
|
|
|
|
|
gtk_widget_show (sbar);
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_widget_show (frame);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_widget_show (bsp->brush_selection_box);
|
|
|
|
gtk_widget_show (bsp->left_box);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
/* Options box */
|
1999-04-22 22:34:00 +08:00
|
|
|
bsp->options_box = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), bsp->options_box, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the active brush label */
|
1999-04-29 16:50:22 +08:00
|
|
|
util_box = gtk_hbox_new (FALSE, 0);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
bsp->brush_name = gtk_label_new (_("No Brushes available"));
|
1999-04-29 16:50:22 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_name, FALSE, FALSE, 4);
|
1999-11-25 19:35:48 +08:00
|
|
|
bsp->brush_size = gtk_label_new ("(0 x 0)");
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_size, FALSE, FALSE, 2);
|
|
|
|
|
|
|
|
gtk_widget_show (bsp->brush_name);
|
|
|
|
gtk_widget_show (bsp->brush_size);
|
|
|
|
gtk_widget_show (util_box);
|
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* A place holder for paint mode switching */
|
|
|
|
bsp->right_box = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->options_box), bsp->right_box, TRUE, TRUE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* The vbox for the paint options */
|
|
|
|
bsp->paint_options_box = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->right_box), bsp->paint_options_box,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
/* A separator before the paint options */
|
1999-04-22 22:34:00 +08:00
|
|
|
sep = gtk_hseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (sep);
|
|
|
|
|
|
|
|
/* Create the frame and the table for the options */
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), table, FALSE, FALSE, 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the opacity scale widget */
|
1998-09-19 08:40:27 +08:00
|
|
|
bsp->opacity_data =
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new
|
|
|
|
(gimp_context_get_opacity (bsp->context) * 100.0,
|
|
|
|
0.0, 100.0, 1.0, 1.0, 0.0));
|
1997-11-25 06:05:25 +08:00
|
|
|
slider = gtk_hscale_new (bsp->opacity_data);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->opacity_data), "value_changed",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (opacity_scale_update),
|
|
|
|
bsp);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Opacity:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* Create the paint mode option menu */
|
2000-02-13 21:14:34 +08:00
|
|
|
bsp->option_menu =
|
|
|
|
paint_mode_menu_new (paint_mode_menu_callback, (gpointer) bsp,
|
|
|
|
gimp_context_get_paint_mode (bsp->context));
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Mode:"), 1.0, 0.5,
|
2000-02-13 21:14:34 +08:00
|
|
|
bsp->option_menu, 1, TRUE);
|
1999-04-22 22:34:00 +08:00
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
gtk_widget_show (bsp->paint_options_box);
|
|
|
|
gtk_widget_show (bsp->right_box);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
/* Create the edit/new buttons */
|
1999-04-22 22:34:00 +08:00
|
|
|
util_box = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 4);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
button = gtk_button_new_with_label (_("New"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (brush_select_new_brush_callback),
|
|
|
|
bsp);
|
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), button, TRUE, TRUE, 6);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-09-03 01:27:28 +08:00
|
|
|
bsp->edit_button = gtk_button_new_with_label (_("Edit"));
|
1999-09-02 17:20:48 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->edit_button), "clicked",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_edit_brush_callback),
|
|
|
|
bsp);
|
1999-09-02 17:20:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), bsp->edit_button, TRUE, TRUE, 5);
|
|
|
|
|
1999-09-03 01:27:28 +08:00
|
|
|
bsp->delete_button = gtk_button_new_with_label (_("Delete"));
|
1999-09-02 17:20:48 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->delete_button), "clicked",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_delete_brush_callback),
|
1999-09-02 17:20:48 +08:00
|
|
|
bsp);
|
|
|
|
gtk_box_pack_start (GTK_BOX (util_box), bsp->delete_button, TRUE, TRUE, 5);
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
gtk_widget_show (bsp->edit_button);
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_widget_show (button);
|
1999-09-02 17:20:48 +08:00
|
|
|
gtk_widget_show (bsp->delete_button);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_widget_show (util_box);
|
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
/* Create the spacing scale widget */
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_box_pack_end (GTK_BOX (bsp->options_box), table, FALSE, FALSE, 2);
|
|
|
|
|
|
|
|
bsp->spacing_data =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 1000.0, 1.0, 1.0, 0.0));
|
|
|
|
slider = gtk_hscale_new (bsp->spacing_data);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
1999-10-27 02:27:27 +08:00
|
|
|
if (title && init_spacing >= 0)
|
|
|
|
{
|
|
|
|
/* Use passed spacing instead of brushes default */
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->spacing_data),
|
|
|
|
init_spacing);
|
|
|
|
}
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->spacing_data), "value_changed",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (spacing_scale_update),
|
|
|
|
bsp);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Spacing:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1999-04-22 22:34:00 +08:00
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (bsp->options_box);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* add callbacks to keep the display area current */
|
2001-02-04 22:10:03 +08:00
|
|
|
bsp->name_changed_handler_id =
|
|
|
|
gimp_container_add_handler
|
2001-02-05 01:34:30 +08:00
|
|
|
(GIMP_CONTAINER (global_brush_list), "name_changed",
|
2001-02-04 22:10:03 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
|
|
|
bsp);
|
|
|
|
|
|
|
|
bsp->dirty_handler_id =
|
|
|
|
gimp_container_add_handler
|
2001-02-07 11:14:38 +08:00
|
|
|
(GIMP_CONTAINER (global_brush_list), "invalidate_preview",
|
2001-02-04 22:10:03 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
|
|
|
bsp);
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (global_brush_list), "add",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_added_callback),
|
|
|
|
bsp);
|
2001-02-05 01:34:30 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (global_brush_list), "remove",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (brush_removed_callback),
|
|
|
|
bsp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-29 16:50:22 +08:00
|
|
|
/* Only for main dialog */
|
1999-09-28 01:58:10 +08:00
|
|
|
if (!title)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-04-29 16:50:22 +08:00
|
|
|
/* set the preview's size in the callback
|
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->shell), "map",
|
|
|
|
GTK_SIGNAL_FUNC (brush_select_map_callback),
|
|
|
|
bsp);
|
|
|
|
*/
|
1999-04-24 07:28:49 +08:00
|
|
|
|
|
|
|
/* if we are in per-tool paint options mode, hide the paint options */
|
1999-04-22 22:34:00 +08:00
|
|
|
brush_select_show_paint_options (bsp, global_paint_options);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
1999-04-24 07:28:49 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_widget_show (bsp->shell);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
preview_calc_scrollbar (bsp);
|
1999-07-06 23:18:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->context), "brush_changed",
|
|
|
|
GTK_SIGNAL_FUNC (brush_select_brush_changed),
|
|
|
|
bsp);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->context), "opacity_changed",
|
|
|
|
GTK_SIGNAL_FUNC (brush_select_opacity_changed),
|
|
|
|
bsp);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (bsp->context), "paint_mode_changed",
|
|
|
|
GTK_SIGNAL_FUNC (brush_select_paint_mode_changed),
|
|
|
|
bsp);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (active)
|
|
|
|
brush_select_select (bsp, active);
|
1999-04-24 07:28:49 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* Add to active brush dialogs list */
|
|
|
|
brush_active_dialogs = g_slist_append (brush_active_dialogs, bsp);
|
1999-04-24 07:28:49 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return bsp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_free (BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
if (!bsp)
|
1998-07-24 16:56:18 +08:00
|
|
|
return;
|
1999-09-02 17:20:48 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* remove from active list */
|
|
|
|
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (bsp->context), bsp);
|
|
|
|
|
|
|
|
if (bsp->brush_popup != NULL)
|
|
|
|
gtk_widget_destroy (bsp->brush_popup);
|
|
|
|
|
|
|
|
if (bsp->callback_name)
|
1999-09-03 01:27:28 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_free (bsp->callback_name);
|
|
|
|
gtk_object_unref (GTK_OBJECT (bsp->context));
|
1999-09-03 01:27:28 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
2001-02-04 22:10:03 +08:00
|
|
|
bsp->name_changed_handler_id);
|
2001-02-05 01:34:30 +08:00
|
|
|
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
2001-02-04 22:10:03 +08:00
|
|
|
bsp->dirty_handler_id);
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (global_brush_list), bsp);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
g_free (bsp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_freeze_all (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
2001-02-05 01:34:30 +08:00
|
|
|
GSList *list;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
bsp = (BrushSelect *) list->data;
|
1999-09-02 17:20:48 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->freeze = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_thaw_all (void)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
2001-02-05 01:34:30 +08:00
|
|
|
GSList *list;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
bsp = (BrushSelect *) list->data;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->freeze = FALSE;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
preview_calc_scrollbar (bsp);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_show_paint_options (BrushSelect *bsp,
|
|
|
|
gboolean show)
|
1999-04-22 22:34:00 +08:00
|
|
|
{
|
|
|
|
if ((bsp == NULL) && ((bsp = brush_select_dialog) == NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
if (! GTK_WIDGET_VISIBLE (bsp->paint_options_box))
|
|
|
|
gtk_widget_show (bsp->paint_options_box);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
if (bsp->brush_selection_box->parent != bsp->left_box)
|
|
|
|
gtk_widget_reparent (bsp->brush_selection_box, bsp->left_box);
|
|
|
|
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
|
|
|
|
bsp->options_box,
|
|
|
|
FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
|
1999-04-29 16:50:22 +08:00
|
|
|
bsp->left_box,
|
|
|
|
TRUE, TRUE, 0, GTK_PACK_START);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_VISIBLE (bsp->paint_options_box))
|
|
|
|
gtk_widget_hide (bsp->paint_options_box);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
if (bsp->brush_selection_box->parent != bsp->right_box)
|
|
|
|
gtk_widget_reparent (bsp->brush_selection_box, bsp->right_box);
|
1999-04-29 16:50:22 +08:00
|
|
|
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
|
|
|
|
bsp->left_box,
|
|
|
|
FALSE, FALSE, 0, GTK_PACK_START);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
|
|
|
|
bsp->options_box,
|
|
|
|
TRUE, TRUE, 0, GTK_PACK_START);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* call this dialog's PDB callback */
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_change_callbacks (BrushSelect *bsp,
|
1999-10-28 23:05:49 +08:00
|
|
|
gboolean closing)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-01-14 11:55:56 +08:00
|
|
|
gchar *name;
|
1999-10-27 02:27:27 +08:00
|
|
|
ProcRecord *prec = NULL;
|
2001-01-14 11:55:56 +08:00
|
|
|
GimpBrush *brush;
|
|
|
|
gint nreturn_vals;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static gboolean busy = FALSE;
|
|
|
|
|
|
|
|
/* Any procs registered to callback? */
|
|
|
|
Argument *return_vals;
|
|
|
|
|
|
|
|
if (!bsp || !bsp->callback_name || busy)
|
|
|
|
return;
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
busy = TRUE;
|
|
|
|
name = bsp->callback_name;
|
1999-10-27 02:27:27 +08:00
|
|
|
brush = gimp_context_get_brush (bsp->context);
|
|
|
|
|
|
|
|
/* If its still registered run it */
|
|
|
|
prec = procedural_db_lookup (name);
|
|
|
|
|
|
|
|
if (prec && brush)
|
|
|
|
{
|
|
|
|
return_vals =
|
|
|
|
procedural_db_run_proc (name,
|
|
|
|
&nreturn_vals,
|
2001-01-14 11:55:56 +08:00
|
|
|
PDB_STRING, GIMP_OBJECT (brush)->name,
|
1999-10-28 23:05:49 +08:00
|
|
|
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
|
|
|
|
PDB_INT32, bsp->spacing_value,
|
|
|
|
PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
|
|
|
|
PDB_INT32, brush->mask->width,
|
|
|
|
PDB_INT32, brush->mask->height,
|
|
|
|
PDB_INT32, brush->mask->width * brush->mask->height,
|
1999-10-27 02:27:27 +08:00
|
|
|
PDB_INT8ARRAY, temp_buf_data (brush->mask),
|
1999-10-28 23:05:49 +08:00
|
|
|
PDB_INT32, (gint) closing,
|
1999-10-27 02:27:27 +08:00
|
|
|
PDB_END);
|
|
|
|
|
|
|
|
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
|
|
|
|
g_message ("failed to run brush callback function");
|
|
|
|
|
|
|
|
procedural_db_destroy_args (return_vals, nreturn_vals);
|
|
|
|
}
|
|
|
|
busy = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close active dialogs that no longer have PDB registered for them */
|
|
|
|
|
|
|
|
void
|
|
|
|
brushes_check_dialogs (void)
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
2001-01-14 11:55:56 +08:00
|
|
|
GSList *list;
|
|
|
|
gchar *name;
|
|
|
|
ProcRecord *prec = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
list = brush_active_dialogs;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
bsp = (BrushSelect *) list->data;
|
1999-10-28 23:05:49 +08:00
|
|
|
list = g_slist_next (list);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
name = bsp->callback_name;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
prec = procedural_db_lookup (name);
|
|
|
|
|
|
|
|
if (!prec)
|
|
|
|
{
|
|
|
|
/* Can alter brush_active_dialogs list */
|
|
|
|
brush_select_close_callback (NULL, bsp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
static GimpBrush *
|
|
|
|
brush_select_drag_brush (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
|
|
|
return bsp->dnd_brush;
|
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
|
|
|
brush_select_drop_brush (GtkWidget *widget,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
|
|
|
gimp_context_set_brush (bsp->context, brush);
|
|
|
|
}
|
|
|
|
|
1999-04-29 16:50:22 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_brush_changed (GimpContext *context,
|
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp)
|
1999-04-29 16:50:22 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
if (brush)
|
1999-10-29 22:15:55 +08:00
|
|
|
{
|
|
|
|
brush_select_select (bsp, brush);
|
|
|
|
|
|
|
|
if (bsp->callback_name)
|
|
|
|
brush_change_callbacks (bsp, FALSE);
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1999-04-29 16:50:22 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
brush_select_opacity_changed (GimpContext *context,
|
|
|
|
gdouble opacity,
|
|
|
|
BrushSelect *bsp)
|
|
|
|
{
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->opacity_data),
|
|
|
|
opacity * 100.0);
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
|
1999-10-29 22:15:55 +08:00
|
|
|
|
|
|
|
if (bsp->callback_name)
|
|
|
|
brush_change_callbacks (bsp, FALSE);
|
1999-04-29 16:50:22 +08:00
|
|
|
}
|
|
|
|
|
1998-07-10 16:59:55 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_paint_mode_changed (GimpContext *context,
|
|
|
|
LayerModeEffects paint_mode,
|
|
|
|
BrushSelect *bsp)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2000-02-14 06:26:41 +08:00
|
|
|
gimp_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu),
|
|
|
|
(gpointer) paint_mode);
|
1999-10-29 22:15:55 +08:00
|
|
|
|
|
|
|
if (bsp->callback_name)
|
|
|
|
brush_change_callbacks (bsp, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
brush_select_select (BrushSelect *bsp,
|
|
|
|
GimpBrush *brush)
|
|
|
|
{
|
|
|
|
gint index;
|
|
|
|
gint row, col;
|
1999-10-28 23:05:49 +08:00
|
|
|
gint scroll_offset = 0;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-06 01:48:50 +08:00
|
|
|
index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list),
|
|
|
|
GIMP_OBJECT (brush));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (index < 0)
|
1999-10-27 02:27:27 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (bsp->edit_button, TRUE);
|
|
|
|
gtk_widget_set_sensitive (bsp->delete_button, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (bsp->edit_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (bsp->delete_button, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
update_active_brush_field (bsp);
|
|
|
|
|
|
|
|
row = index / bsp->NUM_BRUSH_COLUMNS;
|
|
|
|
col = index - row * (bsp->NUM_BRUSH_COLUMNS);
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* check if the new active brush is already in the preview */
|
|
|
|
if (((row + 1) * bsp->cell_height) >
|
|
|
|
(bsp->preview->allocation.height + bsp->scroll_offset))
|
|
|
|
{
|
|
|
|
scroll_offset = (((row + 1) * bsp->cell_height) -
|
|
|
|
(bsp->scroll_offset + bsp->preview->allocation.height));
|
|
|
|
}
|
|
|
|
else if ((row * bsp->cell_height) < bsp->scroll_offset)
|
|
|
|
{
|
|
|
|
scroll_offset = (row * bsp->cell_height) - bsp->scroll_offset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
brush_select_show_selected (bsp, row, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (bsp->sbar_data, bsp->scroll_offset + scroll_offset);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
brush_select_brush_dirty_callback (GimpBrush *brush,
|
|
|
|
BrushSelect *bsp)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2000-04-15 00:33:47 +08:00
|
|
|
gint index;
|
|
|
|
gboolean redraw;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-04-15 00:33:47 +08:00
|
|
|
if (!bsp || bsp->freeze)
|
1999-10-27 02:27:27 +08:00
|
|
|
return;
|
|
|
|
|
2001-02-06 01:48:50 +08:00
|
|
|
index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list),
|
|
|
|
GIMP_OBJECT (brush));
|
2000-04-15 00:33:47 +08:00
|
|
|
redraw = (brush != gimp_context_get_brush (bsp->context));
|
|
|
|
|
|
|
|
clear_brush (bsp, brush,
|
|
|
|
index % (bsp->NUM_BRUSH_COLUMNS),
|
|
|
|
index / (bsp->NUM_BRUSH_COLUMNS));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
display_brush (bsp, brush,
|
|
|
|
index % (bsp->NUM_BRUSH_COLUMNS),
|
2000-04-15 00:33:47 +08:00
|
|
|
index / (bsp->NUM_BRUSH_COLUMNS),
|
|
|
|
redraw);
|
1998-07-10 16:59:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-04 22:10:03 +08:00
|
|
|
brush_added_callback (GimpContainer *container,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp)
|
1998-07-10 16:59:55 +08:00
|
|
|
{
|
1999-09-02 17:20:48 +08:00
|
|
|
if (bsp->freeze)
|
|
|
|
return;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
preview_calc_scrollbar (bsp);
|
1998-07-10 16:59:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-04 22:10:03 +08:00
|
|
|
brush_removed_callback (GimpContainer *container,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush,
|
|
|
|
BrushSelect *bsp)
|
1998-07-10 16:59:55 +08:00
|
|
|
{
|
1999-09-02 17:20:48 +08:00
|
|
|
if (bsp->freeze)
|
|
|
|
return;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
preview_calc_scrollbar (bsp);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
static void
|
|
|
|
draw_brush_popup (GtkPreview *preview,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
gint brush_width, brush_height;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
guchar *mask, *buf, *b;
|
|
|
|
guchar bg;
|
|
|
|
|
|
|
|
brush_width = brush->mask->width;
|
|
|
|
brush_height = brush->mask->height;
|
|
|
|
offset_x = (width - brush_width) / 2;
|
|
|
|
offset_y = (height - brush_height) / 2;
|
|
|
|
|
|
|
|
mask = temp_buf_data (brush->mask);
|
|
|
|
buf = g_new (guchar, 3 * width);
|
|
|
|
memset (buf, 255, 3 * width);
|
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (gimp_brush_get_pixmap (brush))
|
1999-09-27 05:16:37 +08:00
|
|
|
{
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
guchar *pixmap = temp_buf_data (gimp_brush_get_pixmap (brush));
|
1999-09-27 05:16:37 +08:00
|
|
|
|
|
|
|
for (y = 0; y < offset_y; y++)
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
for (y = offset_y; y < brush_height + offset_y; y++)
|
|
|
|
{
|
|
|
|
b = buf + 3 * offset_x;
|
|
|
|
for (x = 0; x < brush_width ; x++)
|
|
|
|
{
|
|
|
|
bg = (255 - *mask);
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
mask++;
|
|
|
|
}
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
}
|
|
|
|
memset (buf, 255, 3 * width);
|
|
|
|
for (y = brush_height + offset_y; y < height; y++)
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (y = 0; y < offset_y; y++)
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
for (y = offset_y; y < brush_height + offset_y; y++)
|
|
|
|
{
|
|
|
|
b = buf + 3 * offset_x;
|
|
|
|
for (x = 0; x < brush_width ; x++)
|
|
|
|
{
|
|
|
|
bg = 255 - *mask++;
|
|
|
|
memset (b, bg, 3);
|
|
|
|
b += 3;
|
|
|
|
}
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
}
|
|
|
|
memset (buf, 255, 3 * width);
|
|
|
|
for (y = brush_height + offset_y; y < height; y++)
|
|
|
|
gtk_preview_draw_row (preview, buf, 0, y, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (buf);
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
|
|
|
gint x;
|
|
|
|
gint y;
|
|
|
|
GimpBrush *brush;
|
1999-05-02 05:37:34 +08:00
|
|
|
} popup_timeout_args_t;
|
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
static gint
|
|
|
|
brush_popup_anim_timeout (gpointer data)
|
|
|
|
{
|
|
|
|
popup_timeout_args_t *args = data;
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp = args->bsp;
|
1999-09-27 05:16:37 +08:00
|
|
|
GimpBrushPipe *pipe;
|
|
|
|
GimpBrush *brush;
|
|
|
|
|
|
|
|
if (bsp->brush_popup != NULL && !GTK_WIDGET_VISIBLE (bsp->brush_popup))
|
|
|
|
{
|
|
|
|
bsp->popup_anim_timeout_tag = 0;
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
pipe = GIMP_BRUSH_PIPE (args->brush);
|
|
|
|
if (++bsp->popup_pipe_index >= pipe->nbrushes)
|
|
|
|
bsp->popup_pipe_index = 0;
|
|
|
|
brush = GIMP_BRUSH (pipe->brushes[bsp->popup_pipe_index]);
|
|
|
|
|
|
|
|
draw_brush_popup (GTK_PREVIEW (bsp->brush_preview), brush, args->x, args->y);
|
|
|
|
gtk_widget_queue_draw (bsp->brush_preview);
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
1999-05-02 05:37:34 +08:00
|
|
|
static gboolean
|
|
|
|
brush_popup_timeout (gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-05-02 05:37:34 +08:00
|
|
|
popup_timeout_args_t *args = data;
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp = args->bsp;
|
|
|
|
GimpBrush *brush = args->brush;
|
1999-05-02 05:37:34 +08:00
|
|
|
gint x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
gint x_org, y_org;
|
|
|
|
gint scr_w, scr_h;
|
1999-09-03 01:27:28 +08:00
|
|
|
gint width, height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-02 05:37:34 +08:00
|
|
|
/* timeout has gone off so our tag is now invalid */
|
|
|
|
bsp->popup_timeout_tag = 0;
|
|
|
|
|
1997-12-18 12:19:11 +08:00
|
|
|
/* make sure the popup exists and is not visible */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (bsp->brush_popup == NULL)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
bsp->brush_popup = gtk_window_new (GTK_WINDOW_POPUP);
|
1999-05-02 05:37:34 +08:00
|
|
|
gtk_window_set_policy (GTK_WINDOW (bsp->brush_popup),
|
|
|
|
FALSE, FALSE, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (bsp->brush_popup), frame);
|
|
|
|
gtk_widget_show (frame);
|
1999-08-13 23:20:35 +08:00
|
|
|
bsp->brush_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), bsp->brush_preview);
|
|
|
|
gtk_widget_show (bsp->brush_preview);
|
|
|
|
}
|
|
|
|
else
|
1997-12-18 12:19:11 +08:00
|
|
|
{
|
|
|
|
gtk_widget_hide (bsp->brush_popup);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1997-12-18 12:19:11 +08:00
|
|
|
/* decide where to put the popup */
|
1999-09-03 01:27:28 +08:00
|
|
|
width = brush->mask->width;
|
|
|
|
height = brush->mask->height;
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (GIMP_IS_BRUSH_PIPE (brush))
|
1999-09-27 05:16:37 +08:00
|
|
|
{
|
|
|
|
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (brush);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
GimpBrush *tmp_brush;
|
1999-09-27 05:16:37 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 1; i < pipe->nbrushes; i++)
|
|
|
|
{
|
|
|
|
tmp_brush = GIMP_BRUSH (pipe->brushes[i]);
|
|
|
|
width = MAX (width, tmp_brush->mask->width);
|
|
|
|
height = MAX (height, tmp_brush->mask->height);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
gdk_window_get_origin (bsp->preview->window, &x_org, &y_org);
|
|
|
|
scr_w = gdk_screen_width ();
|
|
|
|
scr_h = gdk_screen_height ();
|
1999-09-03 01:27:28 +08:00
|
|
|
x = x_org + args->x - width * 0.5;
|
|
|
|
y = y_org + args->y - height * 0.5;
|
1997-11-25 06:05:25 +08:00
|
|
|
x = (x < 0) ? 0 : x;
|
|
|
|
y = (y < 0) ? 0 : y;
|
1999-09-03 01:27:28 +08:00
|
|
|
x = (x + width > scr_w) ? scr_w - width : x;
|
|
|
|
y = (y + height > scr_h) ? scr_h - height : y;
|
|
|
|
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview), width, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_popup (bsp->brush_popup, x, y);
|
1999-04-29 16:50:22 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Draw the brush preview */
|
1999-09-27 05:16:37 +08:00
|
|
|
draw_brush_popup (GTK_PREVIEW (bsp->brush_preview), brush, width, height);
|
1999-09-03 01:27:28 +08:00
|
|
|
gtk_widget_queue_draw (bsp->brush_preview);
|
1999-05-02 05:37:34 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (GIMP_IS_BRUSH_PIPE (brush) && bsp->popup_anim_timeout_tag == 0)
|
1999-09-27 05:16:37 +08:00
|
|
|
{
|
|
|
|
static popup_timeout_args_t timeout_args;
|
|
|
|
|
|
|
|
timeout_args.bsp = bsp;
|
|
|
|
timeout_args.x = width;
|
|
|
|
timeout_args.y = height;
|
|
|
|
timeout_args.brush = brush;
|
|
|
|
|
|
|
|
bsp->popup_pipe_index = 0;
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->popup_anim_timeout_tag =
|
|
|
|
gtk_timeout_add (300, brush_popup_anim_timeout, &timeout_args);
|
1999-09-27 05:16:37 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-05-02 05:37:34 +08:00
|
|
|
return FALSE; /* don't repeat */
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-05-02 05:37:34 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_popup_open (BrushSelect *bsp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpBrush *brush)
|
1999-05-02 05:37:34 +08:00
|
|
|
{
|
|
|
|
static popup_timeout_args_t popup_timeout_args;
|
|
|
|
|
|
|
|
/* if we've already got a timeout scheduled, then we complain */
|
|
|
|
g_return_if_fail (bsp->popup_timeout_tag == 0);
|
|
|
|
|
|
|
|
popup_timeout_args.bsp = bsp;
|
|
|
|
popup_timeout_args.x = x;
|
|
|
|
popup_timeout_args.y = y;
|
|
|
|
popup_timeout_args.brush = brush;
|
|
|
|
bsp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
|
|
|
|
brush_popup_timeout,
|
|
|
|
&popup_timeout_args);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_popup_close (BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-05-02 05:37:34 +08:00
|
|
|
if (bsp->popup_timeout_tag != 0)
|
|
|
|
gtk_timeout_remove (bsp->popup_timeout_tag);
|
|
|
|
bsp->popup_timeout_tag = 0;
|
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
if (bsp->popup_anim_timeout_tag != 0)
|
|
|
|
gtk_timeout_remove (bsp->popup_anim_timeout_tag);
|
|
|
|
bsp->popup_anim_timeout_tag = 0;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (bsp->brush_popup != NULL)
|
|
|
|
gtk_widget_hide (bsp->brush_popup);
|
|
|
|
}
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
display_setup (BrushSelect *bsp)
|
|
|
|
{
|
|
|
|
guchar * buf;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
buf = g_new (guchar, 3 * bsp->preview->allocation.width);
|
|
|
|
|
|
|
|
/* Set the buffer to white */
|
|
|
|
memset (buf, 255, bsp->preview->allocation.width * 3);
|
|
|
|
|
|
|
|
/* Set the image buffer to white */
|
|
|
|
for (i = 0; i < bsp->preview->allocation.height; i++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i,
|
|
|
|
bsp->preview->allocation.width);
|
|
|
|
|
|
|
|
g_free (buf);
|
|
|
|
}
|
|
|
|
|
2000-04-15 00:33:47 +08:00
|
|
|
static void
|
|
|
|
clear_brush (BrushSelect *bsp,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gint col,
|
|
|
|
gint row)
|
|
|
|
{
|
|
|
|
guchar *buf;
|
|
|
|
gint width, height;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
gint ystart, yend;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
width = bsp->cell_width - 2 * MARGIN_WIDTH;
|
|
|
|
height = bsp->cell_height - 2 * MARGIN_HEIGHT;
|
|
|
|
|
|
|
|
offset_x = col * bsp->cell_width + MARGIN_WIDTH;
|
|
|
|
offset_y = row * bsp->cell_height - bsp->scroll_offset + MARGIN_HEIGHT;
|
|
|
|
|
|
|
|
ystart = CLAMP (offset_y, 0, bsp->preview->allocation.height);
|
|
|
|
yend = CLAMP (offset_y + height, 0, bsp->preview->allocation.height);
|
|
|
|
|
|
|
|
buf = g_new (guchar, 3 * width);
|
|
|
|
|
|
|
|
memset (buf, 255, 3 * width * sizeof (guchar));
|
|
|
|
|
|
|
|
for (i = ystart; i < yend; i++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, width);
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
display_brush (BrushSelect *bsp,
|
|
|
|
GimpBrush *brush,
|
|
|
|
gint col,
|
2000-04-15 00:33:47 +08:00
|
|
|
gint row,
|
|
|
|
gboolean redraw)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-03 01:27:28 +08:00
|
|
|
TempBuf *mask_buf, *pixmap_buf = NULL;
|
|
|
|
guchar *mask, *buf, *b;
|
|
|
|
guchar bg;
|
1999-08-13 01:53:51 +08:00
|
|
|
gboolean scale = FALSE;
|
1999-09-27 05:16:37 +08:00
|
|
|
gint cell_width, cell_height;
|
1999-09-03 01:27:28 +08:00
|
|
|
gint width, height;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
gint yend;
|
|
|
|
gint ystart;
|
|
|
|
gint i, j;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
cell_width = bsp->cell_width - 2 * MARGIN_WIDTH;
|
|
|
|
cell_height = bsp->cell_height - 2 * MARGIN_HEIGHT;
|
1999-09-27 05:16:37 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
mask_buf = gimp_brush_get_mask (brush);
|
|
|
|
pixmap_buf = gimp_brush_get_pixmap (brush);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
if (mask_buf->width > cell_width || mask_buf->height > cell_height)
|
1999-08-13 01:53:51 +08:00
|
|
|
{
|
1999-09-27 05:16:37 +08:00
|
|
|
gdouble ratio_x = (gdouble)mask_buf->width / cell_width;
|
|
|
|
gdouble ratio_y = (gdouble)mask_buf->height / cell_height;
|
1999-08-13 01:53:51 +08:00
|
|
|
|
1999-09-03 01:27:28 +08:00
|
|
|
mask_buf = brush_scale_mask (mask_buf,
|
1999-09-27 05:16:37 +08:00
|
|
|
(gdouble)(mask_buf->width) / MAX (ratio_x, ratio_y) + 0.5,
|
|
|
|
(gdouble)(mask_buf->height) / MAX (ratio_x, ratio_y) + 0.5);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (pixmap_buf)
|
1999-09-03 01:27:28 +08:00
|
|
|
{
|
|
|
|
/* TODO: the scale function should scale the pixmap
|
|
|
|
and the mask in one run */
|
1999-10-27 02:27:27 +08:00
|
|
|
pixmap_buf = brush_scale_pixmap (pixmap_buf,
|
|
|
|
mask_buf->width, mask_buf->height);
|
1999-09-03 01:27:28 +08:00
|
|
|
}
|
1999-08-13 01:53:51 +08:00
|
|
|
scale = TRUE;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* calculate the offset into the image */
|
1999-09-27 05:16:37 +08:00
|
|
|
width = (mask_buf->width > cell_width) ? cell_width : mask_buf->width;
|
|
|
|
height = (mask_buf->height > cell_height) ? cell_height : mask_buf->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
offset_x = col * bsp->cell_width + ((cell_width - width) >> 1) + MARGIN_WIDTH;
|
|
|
|
offset_y = row * bsp->cell_height + ((cell_height - height) >> 1) - bsp->scroll_offset + MARGIN_HEIGHT;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
ystart = CLAMP (offset_y, 0, bsp->preview->allocation.height);
|
|
|
|
yend = CLAMP (offset_y + height, 0, bsp->preview->allocation.height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-13 19:03:37 +08:00
|
|
|
mask = temp_buf_data (mask_buf) + (ystart - offset_y) * mask_buf->width;
|
1999-09-27 05:16:37 +08:00
|
|
|
buf = g_new (guchar, 3 * cell_width);
|
1999-09-03 01:27:28 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (pixmap_buf)
|
1999-09-03 01:27:28 +08:00
|
|
|
{
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
guchar *pixmap =
|
|
|
|
temp_buf_data (pixmap_buf) + (ystart - offset_y) * mask_buf->width * 3;
|
|
|
|
|
1999-08-13 23:20:35 +08:00
|
|
|
for (i = ystart; i < yend; i++)
|
|
|
|
{
|
1999-09-03 01:27:28 +08:00
|
|
|
b = buf;
|
|
|
|
for (j = 0; j < width ; j++)
|
|
|
|
{
|
|
|
|
bg = (255 - *mask);
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
*b++ = bg + (*mask * *pixmap++) / 255;
|
|
|
|
mask++;
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, width);
|
1999-08-13 23:20:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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...
|
|
|
|
*/
|
|
|
|
b = buf;
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
1999-09-03 01:27:28 +08:00
|
|
|
bg = 255 - *mask++;
|
|
|
|
memset (b, bg, 3);
|
|
|
|
b += 3;
|
1999-08-13 23:20:35 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, width);
|
1999-08-13 23:20:35 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-09-03 01:27:28 +08:00
|
|
|
g_free (buf);
|
1999-08-13 01:53:51 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
offset_x = (col + 1) * bsp->cell_width - indicator_width - MARGIN_WIDTH;
|
|
|
|
offset_y = (row + 1) * bsp->cell_height - indicator_height - bsp->scroll_offset - MARGIN_HEIGHT;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-08-13 01:53:51 +08:00
|
|
|
if (scale)
|
|
|
|
{
|
1999-09-03 01:27:28 +08:00
|
|
|
temp_buf_free (mask_buf);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (pixmap_buf)
|
1999-09-03 01:27:28 +08:00
|
|
|
temp_buf_free (pixmap_buf);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
1999-09-27 05:16:37 +08:00
|
|
|
for (i = 0; i < indicator_height; i++, offset_y++)
|
|
|
|
{
|
|
|
|
if (offset_y > 0 && offset_y < bsp->preview->allocation.height)
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
(GIMP_IS_BRUSH_PIPE (brush)) ?
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
|
|
|
scale_pipe_indicator_bits[i][0],
|
1999-09-27 05:16:37 +08:00
|
|
|
offset_x, offset_y, indicator_width) :
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
|
|
|
scale_indicator_bits[i][0],
|
1999-09-27 05:16:37 +08:00
|
|
|
offset_x, offset_y, indicator_width);
|
|
|
|
}
|
|
|
|
}
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
else if (GIMP_IS_BRUSH_PIPE (brush))
|
1999-09-27 05:16:37 +08:00
|
|
|
{
|
|
|
|
for (i = 0; i < indicator_height; i++, offset_y++)
|
|
|
|
{
|
|
|
|
if (offset_y > 0 && offset_y < bsp->preview->allocation.height)
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
|
|
|
pipe_indicator_bits[i][0],
|
1999-09-27 05:16:37 +08:00
|
|
|
offset_x, offset_y, indicator_width);
|
|
|
|
}
|
1999-08-13 01:53:51 +08:00
|
|
|
}
|
2000-04-15 00:33:47 +08:00
|
|
|
|
|
|
|
if (redraw && bsp->redraw)
|
|
|
|
{
|
|
|
|
GdkRectangle area;
|
|
|
|
|
|
|
|
area.x = col * bsp->cell_width + MARGIN_WIDTH;
|
|
|
|
area.y = CLAMP (row * bsp->cell_height - bsp->scroll_offset +
|
|
|
|
MARGIN_HEIGHT,
|
|
|
|
0, bsp->preview->allocation.height);
|
|
|
|
area.width = cell_width;
|
|
|
|
area.height = CLAMP (row * bsp->cell_height - bsp->scroll_offset +
|
|
|
|
MARGIN_HEIGHT + cell_height,
|
|
|
|
0, bsp->preview->allocation.height);
|
|
|
|
|
|
|
|
gtk_widget_draw (bsp->preview, &area);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static gint brush_counter = 0;
|
1999-04-23 22:47:50 +08:00
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
do_display_brush (GimpBrush *brush,
|
|
|
|
BrushSelect *bsp)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
2000-04-15 00:33:47 +08:00
|
|
|
display_brush (bsp, brush,
|
|
|
|
brush_counter % (bsp->NUM_BRUSH_COLUMNS),
|
|
|
|
brush_counter / (bsp->NUM_BRUSH_COLUMNS),
|
|
|
|
FALSE);
|
1998-07-12 19:40:43 +08:00
|
|
|
brush_counter++;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
display_brushes (BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-05 01:34:30 +08:00
|
|
|
if (global_brush_list == NULL ||
|
|
|
|
gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) == 0)
|
1999-04-23 22:47:50 +08:00
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (bsp->options_box, FALSE);
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (bsp->options_box, TRUE);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* setup the display area */
|
|
|
|
display_setup (bsp);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
brush_counter = 0;
|
2001-02-05 01:34:30 +08:00
|
|
|
gimp_container_foreach (GIMP_CONTAINER (global_brush_list),
|
2001-02-04 22:10:03 +08:00
|
|
|
(GFunc) do_display_brush,
|
|
|
|
bsp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_show_selected (BrushSelect *bsp,
|
|
|
|
gint row,
|
|
|
|
gint col)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkRectangle area;
|
1999-10-27 02:27:27 +08:00
|
|
|
guchar *buf;
|
|
|
|
gint yend;
|
|
|
|
gint ystart;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
buf = g_new (guchar, 3 * bsp->cell_width);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
if (bsp->old_col != col || bsp->old_row != row)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* remove the old selection */
|
1998-09-19 08:40:27 +08:00
|
|
|
offset_x = bsp->old_col * bsp->cell_width;
|
|
|
|
offset_y = bsp->old_row * bsp->cell_height - bsp->scroll_offset;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
ystart = CLAMP (offset_y , 0, bsp->preview->allocation.height);
|
|
|
|
yend = CLAMP (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set the buf to white */
|
1999-10-27 02:27:27 +08:00
|
|
|
memset (buf, 255, 3 * bsp->cell_width);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = ystart; i < yend; i++)
|
|
|
|
{
|
|
|
|
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, bsp->cell_width);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, 1);
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x + bsp->cell_width - 1, i, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bsp->redraw)
|
|
|
|
{
|
|
|
|
area.x = offset_x;
|
|
|
|
area.y = ystart;
|
|
|
|
area.width = bsp->cell_width;
|
|
|
|
area.height = (yend - ystart);
|
|
|
|
gtk_widget_draw (bsp->preview, &area);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make the new selection */
|
|
|
|
offset_x = col * bsp->cell_width;
|
|
|
|
offset_y = row * bsp->cell_height - bsp->scroll_offset;
|
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
ystart = CLAMP (offset_y , 0, bsp->preview->allocation.height);
|
|
|
|
yend = CLAMP (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set the buf to black */
|
1999-08-13 23:20:35 +08:00
|
|
|
memset (buf, 0, bsp->cell_width * 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = ystart; i < yend; i++)
|
|
|
|
{
|
|
|
|
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
|
|
|
buf, offset_x, i, bsp->cell_width);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
1999-04-23 22:47:50 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x, i, 1);
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
|
|
|
offset_x + bsp->cell_width - 1, i, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bsp->redraw)
|
|
|
|
{
|
|
|
|
area.x = offset_x;
|
|
|
|
area.y = ystart;
|
|
|
|
area.width = bsp->cell_width;
|
|
|
|
area.height = (yend - ystart);
|
|
|
|
gtk_widget_draw (bsp->preview, &area);
|
|
|
|
}
|
|
|
|
|
1998-09-19 08:40:27 +08:00
|
|
|
bsp->old_row = row;
|
|
|
|
bsp->old_col = col;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
update_active_brush_field (BrushSelect *bsp)
|
|
|
|
{
|
|
|
|
GimpBrush *brush;
|
|
|
|
gchar buf[32];
|
|
|
|
|
|
|
|
brush = gimp_context_get_brush (bsp->context);
|
|
|
|
|
|
|
|
if (!brush)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Set brush name */
|
2001-01-14 11:55:56 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (bsp->brush_name), GIMP_OBJECT (brush)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* Set brush size */
|
1999-11-25 19:35:48 +08:00
|
|
|
g_snprintf (buf, sizeof (buf), "(%d x %d)",
|
1999-10-27 02:27:27 +08:00
|
|
|
brush->mask->width, brush->mask->height);
|
|
|
|
gtk_label_set_text (GTK_LABEL (bsp->brush_size), buf);
|
|
|
|
|
|
|
|
/* Set brush spacing */
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->spacing_data),
|
|
|
|
gimp_brush_get_spacing (brush));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
preview_calc_scrollbar (BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
gint num_rows;
|
|
|
|
gint page_size;
|
|
|
|
gint max;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-24 07:28:49 +08:00
|
|
|
bsp->scroll_offset = 0;
|
2001-02-05 01:34:30 +08:00
|
|
|
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
1999-10-27 02:27:27 +08:00
|
|
|
(bsp->NUM_BRUSH_COLUMNS) - 1)
|
|
|
|
/ (bsp->NUM_BRUSH_COLUMNS));
|
1997-11-25 06:05:25 +08:00
|
|
|
max = num_rows * bsp->cell_width;
|
1999-10-27 02:27:27 +08:00
|
|
|
if (!num_rows)
|
|
|
|
num_rows = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
page_size = bsp->preview->allocation.height;
|
1998-03-27 02:24:42 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp->sbar_data->value = bsp->scroll_offset;
|
|
|
|
bsp->sbar_data->upper = max;
|
|
|
|
bsp->sbar_data->page_size = ((page_size < max) ? page_size : max);
|
1997-11-25 06:05:25 +08:00
|
|
|
bsp->sbar_data->page_increment = (page_size >> 1);
|
|
|
|
bsp->sbar_data->step_increment = bsp->cell_width;
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "changed");
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "value_changed");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_resize (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-04-29 16:50:22 +08:00
|
|
|
/* calculate the best-fit approximation... */
|
|
|
|
gint wid;
|
|
|
|
gint now;
|
|
|
|
gint cell_size;
|
|
|
|
|
|
|
|
wid = widget->allocation.width;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
for (now = cell_size = MIN_CELL_SIZE;
|
|
|
|
now < MAX_CELL_SIZE; ++now)
|
1999-04-29 16:50:22 +08:00
|
|
|
{
|
|
|
|
if ((wid % now) < (wid % cell_size)) cell_size = now;
|
|
|
|
if ((wid % cell_size) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-04-23 22:47:50 +08:00
|
|
|
bsp->NUM_BRUSH_COLUMNS =
|
1999-04-29 16:50:22 +08:00
|
|
|
(gint) (wid / cell_size);
|
1999-04-23 22:47:50 +08:00
|
|
|
bsp->NUM_BRUSH_ROWS =
|
2001-02-05 01:34:30 +08:00
|
|
|
(gint) ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
2001-02-04 22:10:03 +08:00
|
|
|
bsp->NUM_BRUSH_COLUMNS - 1) /
|
1999-04-23 22:47:50 +08:00
|
|
|
bsp->NUM_BRUSH_COLUMNS);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
bsp->cell_width = cell_size;
|
1999-04-29 16:50:22 +08:00
|
|
|
bsp->cell_height = cell_size;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* recalculate scrollbar extents */
|
|
|
|
preview_calc_scrollbar (bsp);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush;
|
|
|
|
gint row, col, index;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
|
|
|
break;
|
|
|
|
|
1999-07-29 18:40:42 +08:00
|
|
|
case GDK_2BUTTON_PRESS:
|
1999-09-03 01:27:28 +08:00
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
col = bevent->x / bsp->cell_width;
|
|
|
|
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
|
|
|
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
|
|
|
|
|
|
|
/* Get the brush and check if it is editable */
|
2001-02-06 01:48:50 +08:00
|
|
|
brush = (GimpBrush *)
|
|
|
|
gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list),
|
|
|
|
index);
|
1999-09-03 01:27:28 +08:00
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_edit_brush_callback (NULL, bsp);
|
1999-07-29 18:40:42 +08:00
|
|
|
break;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
col = bevent->x / bsp->cell_width;
|
|
|
|
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
|
|
|
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
|
|
|
|
2001-02-06 01:48:50 +08:00
|
|
|
brush = (GimpBrush *)
|
|
|
|
gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list),
|
|
|
|
index);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
|
|
|
if (brush)
|
|
|
|
bsp->dnd_brush = brush;
|
|
|
|
else
|
|
|
|
bsp->dnd_brush = gimp_context_get_brush (bsp->context);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
|
|
|
/* Get the brush and display the popup brush preview */
|
1999-11-03 17:58:46 +08:00
|
|
|
if (brush)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
gdk_pointer_grab (bsp->preview->window, FALSE,
|
|
|
|
(GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK),
|
|
|
|
NULL, NULL, bevent->time);
|
|
|
|
|
|
|
|
/* Make this brush the active brush */
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_context_set_brush (bsp->context, brush);
|
|
|
|
|
1999-09-03 01:27:28 +08:00
|
|
|
/* only if dialog is main one */
|
1999-10-27 02:27:27 +08:00
|
|
|
if (bsp == brush_select_dialog &&
|
|
|
|
brush_edit_generated_dialog)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_edit_generated_set_brush (brush_edit_generated_dialog,
|
|
|
|
brush);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
1998-09-09 09:35:35 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Show the brush popup window if the brush is too large */
|
1999-11-10 06:01:28 +08:00
|
|
|
if (brush->mask->width > bsp->cell_width - 2 * MARGIN_WIDTH ||
|
|
|
|
brush->mask->height > bsp->cell_height - 2 * MARGIN_HEIGHT ||
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
GIMP_IS_BRUSH_PIPE (brush))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
brush_popup_open (bsp, bevent->x, bevent->y, brush);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
1999-07-25 00:27:47 +08:00
|
|
|
|
|
|
|
/* wheelmouse support */
|
|
|
|
else if (bevent->button == 4)
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj = bsp->sbar_data;
|
|
|
|
gfloat new_value = adj->value - adj->page_increment / 2;
|
|
|
|
new_value =
|
|
|
|
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
else if (bevent->button == 5)
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj = bsp->sbar_data;
|
|
|
|
gfloat new_value = adj->value + adj->page_increment / 2;
|
|
|
|
new_value =
|
|
|
|
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
|
|
|
/* Ungrab the pointer */
|
|
|
|
gdk_pointer_ungrab (bevent->time);
|
|
|
|
|
|
|
|
/* Close the brush popup window */
|
|
|
|
brush_popup_close (bsp);
|
|
|
|
}
|
|
|
|
break;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GDK_DELETE:
|
1998-05-30 15:32:37 +08:00
|
|
|
/* g_warning ("test"); */
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* Disabled until I've figured out how gtk window resizing *really* works.
|
|
|
|
* I don't think that the function below is the correct way to do it
|
|
|
|
* -- Michael
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_map_callback (GtkWidget *widget,
|
|
|
|
BrushSelect *bsp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
GtkAllocation allocation;
|
|
|
|
gint xdiff, ydiff;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
xdiff =
|
|
|
|
bsp->shell->allocation.width - bsp->preview->allocation.width;
|
|
|
|
ydiff =
|
|
|
|
bsp->shell->allocation.height - bsp->preview->allocation.height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
allocation = bsp->shell->allocation;
|
|
|
|
allocation.width = brush_select_session_info.width + xdiff;
|
|
|
|
allocation.height = brush_select_session_info.height + ydiff;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_widget_size_allocate (bsp->shell, &allocation);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_scroll_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
|
|
|
GimpBrush *active;
|
|
|
|
gint row, col, index;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp = (BrushSelect *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (bsp)
|
|
|
|
{
|
|
|
|
bsp->scroll_offset = adjustment->value;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
display_brushes (bsp);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
active = gimp_context_get_brush (bsp->context);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (active)
|
|
|
|
{
|
2001-02-06 01:48:50 +08:00
|
|
|
index =
|
|
|
|
gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list),
|
|
|
|
GIMP_OBJECT (active));
|
|
|
|
|
1998-07-24 16:56:18 +08:00
|
|
|
if (index < 0)
|
|
|
|
return;
|
2001-02-06 01:48:50 +08:00
|
|
|
|
1998-10-14 05:10:22 +08:00
|
|
|
row = index / bsp->NUM_BRUSH_COLUMNS;
|
|
|
|
col = index - row * bsp->NUM_BRUSH_COLUMNS;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
brush_select_show_selected (bsp, row, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bsp->redraw)
|
|
|
|
gtk_widget_draw (bsp->preview, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
opacity_scale_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
2000-02-14 06:26:41 +08:00
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (bsp->context), data);
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_context_set_opacity (bsp->context, adjustment->value / 100.0);
|
2000-02-14 06:26:41 +08:00
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->context), data);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
paint_mode_menu_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-14 06:26:41 +08:00
|
|
|
LayerModeEffects paint_mode;
|
|
|
|
BrushSelect *bsp;
|
2000-02-13 21:14:34 +08:00
|
|
|
|
|
|
|
paint_mode = (LayerModeEffects) gtk_object_get_user_data (GTK_OBJECT (widget));
|
2000-02-14 06:26:41 +08:00
|
|
|
bsp = (BrushSelect *) data;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2000-02-13 21:14:34 +08:00
|
|
|
gimp_context_set_paint_mode (((BrushSelect *) data)->context, paint_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
spacing_scale_update (GtkAdjustment *adjustment,
|
1997-11-25 06:05:25 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
1999-07-06 23:18:25 +08:00
|
|
|
if (bsp == brush_select_dialog)
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_brush_set_spacing (gimp_context_get_brush (bsp->context),
|
|
|
|
(gint) adjustment->value);
|
1999-07-06 23:18:25 +08:00
|
|
|
}
|
1998-09-19 08:40:27 +08:00
|
|
|
else
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
if (bsp->spacing_value != adjustment->value)
|
|
|
|
{
|
|
|
|
bsp->spacing_value = adjustment->value;
|
1999-10-28 23:05:49 +08:00
|
|
|
brush_change_callbacks (bsp, FALSE);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (bsp->shell))
|
|
|
|
gtk_widget_hide (bsp->shell);
|
|
|
|
|
|
|
|
/* Free memory if poping down dialog which is not the main one */
|
|
|
|
if (bsp != brush_select_dialog)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
/* Send data back */
|
1999-10-28 23:05:49 +08:00
|
|
|
brush_change_callbacks (bsp, TRUE);
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_widget_destroy (bsp->shell);
|
|
|
|
brush_select_free (bsp);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
brush_select_refresh_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-04-22 22:34:00 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
/* re-init the brush list */
|
|
|
|
brushes_init (FALSE);
|
1999-04-22 22:34:00 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
brush_select_new_brush_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
GimpBrush *brush;
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
|
|
|
|
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (brush)
|
|
|
|
{
|
2001-02-05 01:34:30 +08:00
|
|
|
gimp_container_add (GIMP_CONTAINER (global_brush_list),
|
2001-02-04 22:10:03 +08:00
|
|
|
GIMP_OBJECT (brush));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
gimp_context_set_brush (bsp->context, brush);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
if (brush_edit_generated_dialog)
|
|
|
|
brush_edit_generated_set_brush (brush_edit_generated_dialog, brush);
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
brush_select_edit_brush_callback (widget, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
brush_select_edit_brush_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
BrushSelect *bsp;
|
|
|
|
GimpBrush *brush;
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
brush = gimp_context_get_brush (bsp->context);
|
1998-09-19 08:40:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
if (!brush_edit_generated_dialog)
|
1998-09-19 08:40:27 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
/* Create the dialog... */
|
|
|
|
brush_edit_generated_dialog = brush_edit_generated_new ();
|
|
|
|
brush_edit_generated_set_brush (brush_edit_generated_dialog, brush);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Popup the dialog */
|
|
|
|
if (!GTK_WIDGET_VISIBLE (brush_edit_generated_dialog->shell))
|
|
|
|
gtk_widget_show (brush_edit_generated_dialog->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise (brush_edit_generated_dialog->shell->window);
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
else
|
2000-01-30 10:48:50 +08:00
|
|
|
/* this should never happen */
|
|
|
|
g_message (_("Sorry, this brush can't be edited."));
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
brush_select_delete_brush_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
BrushSelect *bsp;
|
|
|
|
GimpBrush *brush;
|
|
|
|
|
|
|
|
bsp = (BrushSelect *) data;
|
|
|
|
brush = gimp_context_get_brush (bsp->context);
|
|
|
|
|
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
if (GIMP_DATA (brush)->filename)
|
|
|
|
gimp_data_delete_from_disk (GIMP_DATA (brush));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
brush_select_freeze_all ();
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_container_remove (global_brush_list, GIMP_OBJECT (brush));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
brush_select_thaw_all ();
|
|
|
|
}
|
|
|
|
else
|
2001-02-04 22:10:03 +08:00
|
|
|
{
|
|
|
|
/* this should never happen */
|
|
|
|
g_message (_("Sorry, this brush can't be deleted."));
|
|
|
|
}
|
1998-09-19 08:40:27 +08:00
|
|
|
}
|