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
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2003-08-08 15:57:33 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2003-08-20 01:20:05 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2003-08-20 02:04:40 +08:00
|
|
|
#include "base/boundary.h"
|
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2003-08-20 02:04:40 +08:00
|
|
|
#include "core/gimpbrush.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2003-10-02 01:32:14 +08:00
|
|
|
#include "core/gimpimage-unit.h"
|
2003-08-31 00:41:35 +08:00
|
|
|
#include "core/gimppaintinfo.h"
|
2001-12-02 05:02:34 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint/gimppaintcore.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "paint/gimppaintoptions.h"
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "display/gimpstatusbar.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
#include "gimpcoloroptions.h"
|
2002-02-20 19:37:20 +08:00
|
|
|
#include "gimpcolorpickertool.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimppainttool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-05 08:06:11 +08:00
|
|
|
|
1999-09-02 02:46:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#define TARGET_SIZE 15
|
|
|
|
#define STATUSBAR_SIZE 128
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_class_init (GimpPaintToolClass *klass);
|
|
|
|
static void gimp_paint_tool_init (GimpPaintTool *paint_tool);
|
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
static GObject * gimp_paint_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_finalize (GObject *object);
|
|
|
|
|
2002-02-19 01:00:09 +08:00
|
|
|
static void gimp_paint_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_paint_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_paint_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_paint_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2003-08-08 15:57:33 +08:00
|
|
|
static void gimp_paint_tool_arrow_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *gdisp);
|
2003-06-05 23:43:49 +08:00
|
|
|
static void gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_paint_tool_oper_update (GimpTool *tool,
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2003-07-11 00:01:45 +08:00
|
|
|
static void gimp_paint_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
|
|
|
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
static void gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
|
|
|
GimpImageType sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint color_index);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-08-20 01:20:05 +08:00
|
|
|
static void gimp_paint_tool_notify_brush (GimpDisplayConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpPaintTool *paint_tool);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
static GimpColorToolClass *parent_class = NULL;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paint_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpPaintToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_paint_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpPaintTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_paint_tool_init,
|
2001-02-27 13:21:12 +08:00
|
|
|
};
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
2003-07-11 00:01:45 +08:00
|
|
|
"GimpPaintTool",
|
2001-08-14 22:53:55 +08:00
|
|
|
&tool_info, 0);
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
GimpColorToolClass *color_tool_class;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
|
|
|
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
object_class->constructor = gimp_paint_tool_constructor;
|
2002-02-13 22:50:37 +08:00
|
|
|
object_class->finalize = gimp_paint_tool_finalize;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->control = gimp_paint_tool_control;
|
2001-02-28 03:18:01 +08:00
|
|
|
tool_class->button_press = gimp_paint_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_paint_tool_button_release;
|
|
|
|
tool_class->motion = gimp_paint_tool_motion;
|
2003-08-08 15:57:33 +08:00
|
|
|
tool_class->arrow_key = gimp_paint_tool_arrow_key;
|
2003-06-05 23:43:49 +08:00
|
|
|
tool_class->modifier_key = gimp_paint_tool_modifier_key;
|
|
|
|
tool_class->oper_update = gimp_paint_tool_oper_update;
|
2003-07-11 00:01:45 +08:00
|
|
|
tool_class->cursor_update = gimp_paint_tool_cursor_update;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_paint_tool_draw;
|
2003-06-05 23:43:49 +08:00
|
|
|
|
|
|
|
color_tool_class->picked = gimp_paint_tool_color_picked;
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-05 19:35:03 +08:00
|
|
|
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
2001-02-28 03:18:01 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
2002-02-05 19:35:03 +08:00
|
|
|
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
paint_tool->pick_colors = FALSE;
|
|
|
|
paint_tool->draw_line = FALSE;
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
paint_tool->draw_brush = TRUE;
|
|
|
|
paint_tool->brush_x = 0.0;
|
|
|
|
paint_tool->brush_y = 0.0;
|
2003-07-25 00:35:25 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
paint_tool->core = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_paint_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (object);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (object);
|
|
|
|
|
|
|
|
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
|
|
|
|
|
|
|
|
paint_tool->draw_brush =
|
|
|
|
GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config)->show_brush_outline;
|
2003-08-20 01:20:05 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
g_signal_connect_object (tool->tool_info->gimp->config,
|
|
|
|
"notify::show-brush-outline",
|
|
|
|
G_CALLBACK (gimp_paint_tool_notify_brush),
|
|
|
|
paint_tool, 0);
|
|
|
|
|
|
|
|
paint_tool->core = g_object_new (tool->tool_info->paint_info->paint_type,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return object;
|
2002-02-13 22:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_finalize (GObject *object)
|
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
2002-02-13 22:50:37 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (paint_tool->core)
|
2002-02-13 22:50:37 +08:00
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (paint_tool->core);
|
2002-02-15 03:31:16 +08:00
|
|
|
paint_tool->core = NULL;
|
2002-02-13 22:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-26 03:00:49 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_tool_enable_color_picker:
|
|
|
|
* @tool: a #GimpPaintTool
|
|
|
|
* @mode: the #GimpColorPickMode to set
|
|
|
|
*
|
|
|
|
* This is a convenience function used from the init method of paint
|
|
|
|
* tools that want the color picking functionality. The @mode that is
|
|
|
|
* set here is used to decide what cursor modifier to draw and if the
|
|
|
|
* picked color goes to the foreground or background color.
|
|
|
|
**/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_paint_tool_enable_color_picker (GimpPaintTool *tool,
|
|
|
|
GimpColorPickMode mode)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
|
|
tool->pick_colors = TRUE;
|
|
|
|
|
|
|
|
GIMP_COLOR_TOOL (tool)->pick_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-19 01:00:09 +08:00
|
|
|
gimp_paint_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp)
|
2001-02-28 03:18:01 +08:00
|
|
|
{
|
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
|
|
|
switch (action)
|
1999-05-13 19:12:32 +08:00
|
|
|
{
|
2001-02-28 03:18:01 +08:00
|
|
|
case HALT:
|
2002-02-16 01:44:05 +08:00
|
|
|
gimp_paint_core_paint (paint_tool->core,
|
|
|
|
drawable,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_PAINT_OPTIONS (tool->tool_info->tool_options),
|
2002-02-15 03:31:16 +08:00
|
|
|
FINISH_PAINT);
|
|
|
|
gimp_paint_core_cleanup (paint_tool->core);
|
2002-02-19 01:00:09 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* evil hack i'm thinking about... --mitch */
|
|
|
|
{
|
|
|
|
/* HALT means the current display is going to go away (TM),
|
|
|
|
* so try to find another display of the same image to make
|
|
|
|
* straight line drawing continue to work...
|
|
|
|
*/
|
|
|
|
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = display_list; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
GimpDisplay *tmp_disp;
|
|
|
|
|
|
|
|
tmp_disp = (GimpDisplay *) list->data;
|
|
|
|
|
|
|
|
if (tmp_disp != gdisp && tmp_disp->gimage == gdisp->gimage)
|
|
|
|
{
|
|
|
|
tool->gdisp = tmp_disp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2001-02-28 03:18:01 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1999-05-13 19:12:32 +08:00
|
|
|
}
|
|
|
|
|
2001-12-02 06:59:48 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_tool_round_line:
|
|
|
|
* @core: the #GimpPaintCore
|
|
|
|
* @state: the modifier state
|
|
|
|
*
|
|
|
|
* Adjusts core->last_coords and core_cur_coords in preparation to
|
|
|
|
* drawing a straight line. The rounding of the slope to 15 degree
|
|
|
|
* steps if ctrl is pressed happens, as does rounding the start and
|
|
|
|
* end coordinates (which may be fractional in high zoom modes) to
|
|
|
|
* the center of pixels.
|
|
|
|
**/
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_round_line (GimpPaintCore *core,
|
|
|
|
GdkModifierType state)
|
|
|
|
{
|
|
|
|
core->last_coords.x = floor (core->last_coords.x) + 0.5;
|
|
|
|
core->last_coords.y = floor (core->last_coords.y) + 0.5;
|
|
|
|
core->cur_coords.x = floor (core->cur_coords.x ) + 0.5;
|
|
|
|
core->cur_coords.y = floor (core->cur_coords.y ) + 0.5;
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/* Restrict to multiples of 15 degrees if ctrl is pressed */
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
|
|
|
gimp_paint_core_constrain (core);
|
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpPaintOptions *paint_options;
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpPaintCore *core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpBrush *current_brush;
|
|
|
|
GimpDrawable *drawable;
|
2003-10-30 04:57:21 +08:00
|
|
|
GdkDisplay *gdk_display;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpCoords curr_coords;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
|
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
|
|
|
|
2003-10-30 04:57:21 +08:00
|
|
|
gdk_display = gtk_widget_get_display (gdisp->shell);
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core = paint_tool->core;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
curr_coords = *coords;
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
curr_coords.x -= off_x;
|
|
|
|
curr_coords.y -= off_y;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
2002-02-19 01:00:09 +08:00
|
|
|
if (tool->gdisp &&
|
|
|
|
tool->gdisp != gdisp &&
|
|
|
|
tool->gdisp->gimage == gdisp->gimage)
|
|
|
|
{
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
* same image.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tool->gdisp = gdisp;
|
|
|
|
}
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
core->use_pressure = (gimp_devices_get_current (gdisp->gimage->gimp) !=
|
2003-10-30 04:57:21 +08:00
|
|
|
gdk_display_get_core_pointer (gdk_display));
|
2002-02-21 19:01:12 +08:00
|
|
|
|
2002-06-17 18:34:28 +08:00
|
|
|
if (! gimp_paint_core_start (core, drawable, paint_options, &curr_coords))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if ((gdisp != tool->gdisp) || ! paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* if this is a new image, reinit the core vals */
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core->start_coords = core->cur_coords;
|
|
|
|
core->last_coords = core->cur_coords;
|
2003-08-21 18:44:11 +08:00
|
|
|
|
|
|
|
core->distance = 0.0;
|
|
|
|
core->pixel_dist = 0.0;
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-07-11 00:01:45 +08:00
|
|
|
else if (paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* If shift is down and this is not the first paint
|
|
|
|
* stroke, then draw a line from the last coords to the pointer
|
|
|
|
*/
|
2002-02-15 03:31:16 +08:00
|
|
|
core->start_coords = core->last_coords;
|
1999-06-18 04:34:50 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
gimp_paint_tool_round_line (core, state);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
/* let the parent class activate the tool */
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool,
|
|
|
|
coords, time, state, gdisp);
|
|
|
|
|
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-05 19:35:03 +08:00
|
|
|
/* pause the current selection */
|
2001-09-26 01:44:03 +08:00
|
|
|
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Let the specific painting function initialize itself */
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
1997-11-25 06:05:25 +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
|
|
|
/* store the current brush pointer */
|
2002-02-15 03:31:16 +08:00
|
|
|
current_brush = core->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
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
2002-02-07 19:33:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Paint to the image */
|
2003-07-11 00:01:45 +08:00
|
|
|
if (paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_interpolate (core, drawable, paint_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
{
|
2002-02-21 19:01:12 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
}
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush_now (gdisp);
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, POSTTRACE_PAINT);
|
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
|
|
|
|
|
|
|
/* restore the current brush pointer */
|
2002-02-15 03:31:16 +08:00
|
|
|
core->brush = current_brush;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpPaintOptions *paint_options;
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpPaintCore *core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core = paint_tool->core;
|
|
|
|
|
2001-12-02 06:59:48 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Let the specific painting function finish up */
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
/* resume the current selection */
|
|
|
|
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
/* chain up to halt the tool */
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
|
|
|
|
coords, time, state, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 20:05:11 +08:00
|
|
|
if (state & GDK_BUTTON3_MASK)
|
|
|
|
gimp_paint_core_cancel (core, drawable);
|
|
|
|
else
|
|
|
|
gimp_paint_core_finish (core, drawable);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpPaintOptions *paint_options;
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpPaintCore *core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawable *drawable;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core = paint_tool->core;
|
|
|
|
|
2001-12-02 06:59:48 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
core->cur_coords = *coords;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
core->cur_coords.x -= off_x;
|
|
|
|
core->cur_coords.y -= off_y;
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
return;
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_interpolate (core, drawable, paint_options);
|
2002-02-07 19:33:01 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush_now (gdisp);
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, POSTTRACE_PAINT);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-08 15:57:33 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_arrow_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
if (tool->gdisp)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
gdouble opacity;
|
|
|
|
|
|
|
|
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
|
|
|
opacity = gimp_context_get_opacity (context);
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_Left:
|
|
|
|
opacity = CLAMP (opacity - 0.01, 0, 1);
|
|
|
|
break;
|
|
|
|
case GDK_Right:
|
|
|
|
opacity = CLAMP (opacity + 0.01, 0, 1);
|
|
|
|
break;
|
|
|
|
case GDK_Up:
|
|
|
|
opacity = CLAMP (opacity + 0.1, 0, 1);
|
|
|
|
break;
|
|
|
|
case GDK_Down:
|
|
|
|
opacity = CLAMP (opacity - 0.1, 0, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gimp_context_set_opacity (context, opacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2003-06-05 23:43:49 +08:00
|
|
|
gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
2003-07-11 00:01:45 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (key != GDK_CONTROL_MASK)
|
|
|
|
return;
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if (paint_tool->pick_colors && ! paint_tool->draw_line)
|
2003-06-05 23:43:49 +08:00
|
|
|
{
|
|
|
|
if (press)
|
|
|
|
{
|
2003-09-18 21:51:10 +08:00
|
|
|
GimpContainer *tool_info_list;
|
|
|
|
GimpToolInfo *info;
|
2003-06-05 23:43:49 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
tool_info_list = gdisp->gimage->gimp->tool_info_list;
|
2003-06-05 23:43:49 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (tool_info_list,
|
|
|
|
"gimp-color-picker-tool");
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
if (GIMP_IS_TOOL_INFO (info))
|
|
|
|
{
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
|
|
|
GIMP_COLOR_OPTIONS (info->tool_options));
|
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-09-18 21:51:10 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
2003-06-05 23:43:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_oper_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpDrawTool *draw_tool;
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpPaintCore *core;
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
2003-08-20 02:04:40 +08:00
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, gdisp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core = paint_tool->core;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_draw_tool_stop (draw_tool);
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2002-02-05 19:35:03 +08:00
|
|
|
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar),
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (tool)));
|
1999-05-15 08:02:47 +08:00
|
|
|
|
2002-02-19 01:00:09 +08:00
|
|
|
if (tool->gdisp &&
|
|
|
|
tool->gdisp != gdisp &&
|
|
|
|
tool->gdisp->gimage == gdisp->gimage)
|
|
|
|
{
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
* same image.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tool->gdisp = gdisp;
|
|
|
|
}
|
|
|
|
|
2003-08-20 02:04:40 +08:00
|
|
|
if ((drawable = gimp_image_active_drawable (gdisp->gimage)))
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
2003-07-11 00:01:45 +08:00
|
|
|
paint_tool->brush_x = coords->x;
|
|
|
|
paint_tool->brush_y = coords->y;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (gdisp == tool->gdisp && (state & GDK_SHIFT_MASK))
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* If shift is down and this is not the first paint stroke,
|
|
|
|
* draw a line
|
|
|
|
*/
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
gdouble dx, dy, dist;
|
2002-02-16 01:44:05 +08:00
|
|
|
gchar status_str[STATUSBAR_SIZE];
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2002-02-17 19:46:39 +08:00
|
|
|
core->cur_coords = *coords;
|
1999-08-21 21:16:20 +08:00
|
|
|
|
2003-08-20 02:04:40 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-17 19:46:39 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
core->cur_coords.x -= off_x;
|
|
|
|
core->cur_coords.y -= off_y;
|
1999-05-15 08:36:42 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
gimp_paint_tool_round_line (core, state);
|
1999-06-18 04:34:50 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
dx = core->cur_coords.x - core->last_coords.x;
|
|
|
|
dy = core->cur_coords.y - core->last_coords.y;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
/* show distance in statusbar */
|
|
|
|
if (shell->dot_for_dot)
|
|
|
|
{
|
|
|
|
dist = sqrt (SQR (dx) + SQR (dy));
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
g_snprintf (status_str, sizeof (status_str), "%.1f %s",
|
2002-02-16 01:44:05 +08:00
|
|
|
dist, _("pixels"));
|
2003-07-11 00:01:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar format_str[64];
|
2002-02-05 01:43:01 +08:00
|
|
|
|
|
|
|
g_snprintf (format_str, sizeof (format_str), "%%.%df %s",
|
2003-10-02 01:32:14 +08:00
|
|
|
gimp_image_unit_get_digits (gdisp->gimage),
|
|
|
|
gimp_image_unit_get_symbol (gdisp->gimage));
|
2002-02-05 01:43:01 +08:00
|
|
|
|
2003-10-02 01:32:14 +08:00
|
|
|
dist = (gimp_image_unit_get_factor (gdisp->gimage) *
|
2002-02-16 01:44:05 +08:00
|
|
|
sqrt (SQR (dx / gdisp->gimage->xresolution) +
|
|
|
|
SQR (dy / gdisp->gimage->yresolution)));
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
g_snprintf (status_str, sizeof (status_str), format_str,
|
2002-02-16 01:44:05 +08:00
|
|
|
dist);
|
2003-07-11 00:01:45 +08:00
|
|
|
}
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
|
2002-02-05 19:35:03 +08:00
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (tool)),
|
2002-02-03 20:10:23 +08:00
|
|
|
status_str);
|
1999-09-02 02:46:25 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
paint_tool->draw_line = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paint_tool->draw_line = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_start (draw_tool, gdisp);
|
2002-02-05 01:43:01 +08:00
|
|
|
}
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
2003-08-20 02:04:40 +08:00
|
|
|
if (gimp_image_active_drawable (gdisp->gimage))
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
|
|
|
if (! shell->proximity &&
|
|
|
|
gimp_draw_tool_is_active (draw_tool))
|
|
|
|
{
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
2002-02-07 19:33:01 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
GimpPaintCore *core;
|
2002-02-07 19:33:01 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
2003-07-11 00:01:45 +08:00
|
|
|
core = paint_tool->core;
|
|
|
|
|
|
|
|
if (paint_tool->draw_line)
|
|
|
|
{
|
|
|
|
/* Draw start target */
|
|
|
|
gimp_draw_tool_draw_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
core->last_coords.x,
|
|
|
|
core->last_coords.y,
|
|
|
|
TARGET_SIZE,
|
|
|
|
TARGET_SIZE,
|
|
|
|
GTK_ANCHOR_CENTER,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* Draw end target */
|
|
|
|
gimp_draw_tool_draw_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
core->cur_coords.x,
|
|
|
|
core->cur_coords.y,
|
|
|
|
TARGET_SIZE,
|
|
|
|
TARGET_SIZE,
|
|
|
|
GTK_ANCHOR_CENTER,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* Draw the line between the start and end coords */
|
|
|
|
gimp_draw_tool_draw_line (draw_tool,
|
|
|
|
core->last_coords.x,
|
|
|
|
core->last_coords.y,
|
|
|
|
core->cur_coords.x,
|
|
|
|
core->cur_coords.y,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (paint_tool->draw_brush)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpBrush *brush;
|
|
|
|
TempBuf *mask;
|
|
|
|
|
|
|
|
context =
|
|
|
|
GIMP_CONTEXT (GIMP_TOOL (draw_tool)->tool_info->tool_options);
|
|
|
|
|
|
|
|
brush = gimp_context_get_brush (context);
|
|
|
|
mask = gimp_brush_get_mask (brush);
|
|
|
|
|
2003-07-25 00:35:25 +08:00
|
|
|
if (brush != core->grr_brush && core->brush_bound_segs)
|
|
|
|
{
|
|
|
|
g_free (core->brush_bound_segs);
|
|
|
|
core->brush_bound_segs = NULL;
|
|
|
|
core->n_brush_bound_segs = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! core->brush_bound_segs)
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
|
|
|
PixelRegion PR = { 0, };
|
|
|
|
|
|
|
|
PR.data = temp_buf_data (mask);
|
|
|
|
PR.x = 0;
|
|
|
|
PR.y = 0;
|
|
|
|
PR.w = mask->width;
|
|
|
|
PR.h = mask->height;
|
|
|
|
PR.bytes = mask->bytes;
|
|
|
|
PR.rowstride = PR.w * PR.bytes;
|
|
|
|
|
2003-07-25 00:35:25 +08:00
|
|
|
core->brush_bound_segs =
|
|
|
|
find_mask_boundary (&PR, &core->n_brush_bound_segs,
|
2003-07-11 00:01:45 +08:00
|
|
|
WithinBounds,
|
|
|
|
0, 0,
|
|
|
|
PR.w, PR.h,
|
2003-07-14 22:50:41 +08:00
|
|
|
0);
|
2003-07-11 00:01:45 +08:00
|
|
|
}
|
|
|
|
|
2003-07-25 00:35:25 +08:00
|
|
|
if (core->brush_bound_segs)
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
2003-07-14 22:50:41 +08:00
|
|
|
GimpPaintOptions *paint_options;
|
|
|
|
gdouble brush_x, brush_y;
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-07-14 22:50:41 +08:00
|
|
|
paint_options = GIMP_PAINT_OPTIONS (context);
|
|
|
|
|
|
|
|
brush_x = paint_tool->brush_x - ((gdouble) mask->width / 2.0);
|
|
|
|
brush_y = paint_tool->brush_y - ((gdouble) mask->height / 2.0);
|
|
|
|
|
|
|
|
if (paint_options->hard)
|
|
|
|
{
|
2003-07-17 00:19:16 +08:00
|
|
|
#define EPSILON 0.000001
|
|
|
|
|
|
|
|
/* Add EPSILON before rounding since e.g.
|
|
|
|
* (5.0 - 0.5) may end up at (4.499999999....)
|
|
|
|
* due to floating point fnords
|
|
|
|
*/
|
|
|
|
brush_x = RINT (brush_x + EPSILON);
|
|
|
|
brush_y = RINT (brush_y + EPSILON);
|
|
|
|
|
|
|
|
#undef EPSILON
|
2003-07-14 22:50:41 +08:00
|
|
|
}
|
2003-07-11 00:01:45 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_draw_boundary (draw_tool,
|
2003-07-25 00:35:25 +08:00
|
|
|
core->brush_bound_segs,
|
|
|
|
core->n_brush_bound_segs,
|
2003-07-11 00:01:45 +08:00
|
|
|
brush_x,
|
|
|
|
brush_y);
|
|
|
|
}
|
|
|
|
}
|
2002-02-07 19:33:01 +08:00
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
|
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
static void
|
2003-06-05 23:43:49 +08:00
|
|
|
gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
|
|
|
GimpImageType sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint color_index)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (tool->gdisp)
|
2002-02-20 19:37:20 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
2003-10-26 03:00:49 +08:00
|
|
|
|
|
|
|
switch (color_tool->pick_mode)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_PICK_MODE_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_FOREGROUND:
|
|
|
|
gimp_context_set_foreground (context, color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_BACKGROUND:
|
|
|
|
gimp_context_set_background (context, color);
|
|
|
|
break;
|
|
|
|
}
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-08-20 01:20:05 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_notify_brush (GimpDisplayConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpPaintTool *paint_tool)
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (paint_tool));
|
|
|
|
|
|
|
|
paint_tool->draw_brush = config->show_brush_outline;
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
|
|
|
}
|