gimp/app/tools/gimpbrushtool.c

419 lines
15 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (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, see <http://www.gnu.org/licenses/>.
1997-11-25 06:05:25 +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"
#include <string.h>
#include <gegl.h>
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
devel-docs/Makefile.am new file documenting the core's include policy. 2002-05-03 Michael Natterer <mitch@gimp.org> * devel-docs/Makefile.am * devel-docs/includes.txt: new file documenting the core's include policy. * HACKING: mention it here. * libgimptool/gimptooltypes.h: removed GimpToolOptions here. * app/core/core-types.h: and added it here. This is a temp hack needed because GimpToolInfo needs to know the GimpToolOptions type. * libgimpproxy/gimpproxytypes.h: regenerated. * libgimptool/gimptoolmodule.h: don't include gimptooltypes.h here... * libgimptool/gimptoolmodule.c: ...but here. * app/config/gimpconfig-params.c: include "libgimpbase/gimpbase.h" entirely, not single files from it. * app/core/gimp.c * app/core/gimpcontext.c * app/core/gimpcoreconfig.c * app/core/gimpdatafactory.c * app/core/gimpdocuments.c * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-guides.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage-qmask.c * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c * app/core/gimpimage.c * app/core/gimpitem.c * app/core/gimpmodules.c * app/core/gimppaintinfo.c * app/core/gimpparasite.c * app/core/gimppreviewcache.c * app/core/gimptoolinfo.c * app/core/gimpunit.c: include "core-types.h" and no other types file. * app/display/gimpdisplay.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell.c: include "tools/tools-types.h" instead of "libgimptool/gimptooltypes.h", warn about inclusion on "gui/gui-types.h" * app/file/file-open.c * app/file/file-save.c: don't include "libgimptool/gimptooltypes.h". * app/gui/about-dialog.c * app/gui/brush-select.c * app/gui/brushes-commands.c * app/gui/color-select.c * app/gui/data-commands.c * app/gui/device-status-dialog.c * app/gui/dialogs.c * app/gui/gradients-commands.c * app/gui/help-commands.c * app/gui/info-window.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/resize-dialog.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c: include "gui-types.h" and no other types file. * app/paint/gimpairbrush.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/paint/gimppaintcore-stroke.c * app/paint/gimppaintcore.c * app/paint/gimppaintoptions.c * app/paint/gimppencil.c * app/paint/gimpsmudge.c * app/paint/paint.c: include "paint-types.h" and no other types file. * app/pdb/pdb-types.h: don't include "libgimptool/gimptooltypes.h". * app/plug-in/plug-in-progress.c: warn about inclusion of "display/display-types.h" * app/tools/tools-types.h: include "libgimptool/gimptooltypes.h". * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppaintbrushtool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimppenciltool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpselectiontool.c * app/tools/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimptoolcontrol.c * app/tools/gimptoolcontrol.h * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/tools/tools.c: include "tools-types.h" and no other types file, warn about inclusion of "gui/gui-types.h". * app/widgets/gimpcolorpanel.c * app/widgets/gimptoolbox-color-area.c: warn about inclusion of "gui/gui-types.h". * app/xcf/xcf-load.c * app/xcf/xcf.c: don't include "libgimptool/gimptooltypes.h". Split tool-safe-mode up in two files, one including libgimpproxy, one libgimp. * plug-ins/tools/Makefile.am * plug-ins/tools/tool-safe-mode-plug-in.[ch]: new files including libgimp/ stuff only. * plug-ins/tools/tool-safe-mode.[ch]: include libgimpproxy/ and libgimptool/ but don't include libgimp/ because of conflicting declarations. Unrelated: * app/tools/gimpclonetool.c: create the clone core so we don't crash. * app/gui/file-open-dialog.c: changed the way we create previews so that only out-of-date previews are created on a click in the preview area. Unconditional creation can still be forced by <Ctrl>+click. Changed the tooltip to document this.
2002-05-03 20:45:22 +08:00
#include "tools-types.h"
#include "config/gimpdisplayconfig.h"
app/Makefile.am removed. 2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
2001-07-07 20:17:23 +08:00
#include "core/gimp.h"
#include "core/gimpbezierdesc.h"
#include "core/gimpbrush.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpbrushcore.h"
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 22:39:40 +08:00
#include "paint/gimppaintoptions.h"
Core/UI separation for the paint tools: 2002-02-14 Michael Natterer <mitch@gimp.org> Core/UI separation for the paint tools: * configure.in * app/Makefile.am * app/paint/.cvsignore * app/paint/Makefile.am: added new directory for the paint methods without GUI and tools around them. * app/paint/paint-types.h: typedefs for this module. * app/paint/gimppaintcore-kernels.h * app/paint/gimppaintcore.[ch]: the general paint logic taken from GimpPaintTool. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.[ch] * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: subclasses of GimpPaintCore, implementing their own paint() methods. Needs more hacking to get the GtkWidget pointers out of the options structs. * app/tools/gimppainttool_kernels.h: removed. * app/tools/tools-types.h: removed the paint tool enums. * app/tools/gimpairbrushtool.[ch] * app/tools/gimpclonetool.[ch] * app/tools/gimpconvolvetool.[ch] * app/tools/gimpdodgeburntool.[ch] * app/tools/gimperasertool.[ch] * app/tools/gimppaintbrushtool.[ch] * app/tools/gimppainttool.[ch] * app/tools/gimppenciltool.[ch] * app/tools/gimpsmudgetool.[ch]: all paint tools are pure GUI things now. PaintOptions and friends still need to be chopped up though... * app/undo.c: changed PaintUndo to GimpPaintCoreUndo, some minor cleanup. * tools/kernelgen.c: changed accordingly. * tools/pdbgen/Makefile.am: scan paint/paint-types.h for enums. * tools/pdbgen/pdb/paint_tools.pdb: hardcode "success = FALSE" for all paint PDB wrappers. The non-gui stuff is completely broken. More commits to come... * app/pdb/paint_tools_cmds.c * tools/pdbgen/enums.pl: regenerated.
2002-02-15 03:31:16 +08:00
#include "display/gimpcanvashandle.h"
#include "display/gimpcanvaspath.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "gimpbrushtool.h"
#include "gimptoolcontrol.h"
static void gimp_brush_tool_constructed (GObject *object);
static void gimp_brush_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brush_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_brush_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_brush_tool_options_notify (GimpTool *tool,
GimpToolOptions *options,
const GParamSpec *pspec);
static void gimp_brush_tool_draw (GimpDrawTool *draw_tool);
static void gimp_brush_tool_brush_changed (GimpContext *context,
GimpBrush *brush,
GimpBrushTool *brush_tool);
static void gimp_brush_tool_set_brush (GimpBrushCore *brush_core,
GimpBrush *brush,
GimpBrushTool *brush_tool);
static void gimp_brush_tool_notify_brush (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpBrushTool *brush_tool);
1997-11-25 06:05:25 +08:00
G_DEFINE_TYPE (GimpBrushTool, gimp_brush_tool, GIMP_TYPE_PAINT_TOOL)
#define parent_class gimp_brush_tool_parent_class
static void
gimp_brush_tool_class_init (GimpBrushToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
object_class->constructed = gimp_brush_tool_constructed;
tool_class->motion = gimp_brush_tool_motion;
tool_class->oper_update = gimp_brush_tool_oper_update;
tool_class->cursor_update = gimp_brush_tool_cursor_update;
tool_class->options_notify = gimp_brush_tool_options_notify;
draw_tool_class->draw = gimp_brush_tool_draw;
}
1997-11-25 06:05:25 +08:00
static void
gimp_brush_tool_init (GimpBrushTool *brush_tool)
{
GimpTool *tool = GIMP_TOOL (brush_tool);
2002-02-05 19:35:03 +08:00
gimp_tool_control_set_action_value_2 (tool->control,
"tools/tools-paint-brush-size-set");
gimp_tool_control_set_action_value_3 (tool->control,
"context/context-brush-aspect-set");
gimp_tool_control_set_action_value_4 (tool->control,
"context/context-brush-angle-set");
gimp_tool_control_set_action_object_1 (tool->control,
"context/context-brush-select-set");
brush_tool->show_cursor = TRUE;
brush_tool->draw_brush = TRUE;
brush_tool->brush_x = 0.0;
brush_tool->brush_y = 0.0;
}
static void
gimp_brush_tool_constructed (GObject *object)
{
GimpTool *tool = GIMP_TOOL (object);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (object);
GimpDisplayConfig *display_config;
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert (GIMP_IS_BRUSH_CORE (paint_tool->core));
display_config = GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config);
brush_tool->show_cursor = display_config->show_paint_tool_cursor;
brush_tool->draw_brush = display_config->show_brush_outline;
g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
G_CALLBACK (gimp_brush_tool_notify_brush),
brush_tool, 0);
g_signal_connect_object (display_config, "notify::show-brush-outline",
G_CALLBACK (gimp_brush_tool_notify_brush),
brush_tool, 0);
g_signal_connect_object (gimp_tool_get_options (tool), "brush-changed",
G_CALLBACK (gimp_brush_tool_brush_changed),
brush_tool, 0);
2009-04-26 01:53:09 +08:00
2011-04-04 06:01:30 +08:00
g_signal_connect_object (paint_tool->core, "set-brush",
G_CALLBACK (gimp_brush_tool_set_brush),
brush_tool, 0);
}
static void
gimp_brush_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (tool);
1997-11-25 06:05:25 +08:00
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
{
brush_tool->brush_x = coords->x;
brush_tool->brush_y = coords->y;
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_brush_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (tool);
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
1997-11-25 06:05:25 +08:00
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state,
proximity, display);
drawable = gimp_image_get_active_drawable (gimp_display_get_image (display));
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)) &&
drawable && proximity)
{
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
brush_tool->brush_x = coords->x;
brush_tool->brush_y = coords->y;
gimp_brush_core_set_brush (brush_core,
gimp_context_get_brush (context));
gimp_brush_core_set_dynamics (brush_core,
gimp_context_get_dynamics (context));
if (GIMP_BRUSH_CORE_GET_CLASS (brush_core)->handles_transforming_brush)
{
gimp_brush_core_eval_transform_dynamics (brush_core,
drawable,
paint_options,
coords);
}
added fields for both the tool's toggled and untoggled GdkCursorType, 2002-02-04 Michael Natterer <mitch@gimp.org> * app/tools/gimptool.[ch]: added fields for both the tool's toggled and untoggled GdkCursorType, GimpToolCursorType and GimpCursorModifier. Added a default implementation of gimp_tool_cursor_update() which uses the new fields. Added gimp_tool_set_cursor() as simple wrapper around the resp. GimpDisplayShell functions so tools don't need to know them. Tool implementations can either set the new fields in their cursor_update() function and chain up or call the new wrapper. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpdodgeburntool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimpselectiontool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.c: changed accordingly: - set default values in the tools' instance_init functions. - changed the cursor_update() stuff. - removed inclusion of subclasses in gimppainttool.c - the cursor_update() functions are better than before but still evil. - i probably broke some of them...
2002-02-05 01:43:01 +08:00
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
updated. 2001-02-24 Michael Natterer <mitch@gimp.org> * TODO.xml: updated. * app/appenums.h * app/apptypes.h: prefixed the cursor stuff with "Gimp", added the new stock tool cursor enum. Removed the old ToolType enum. * app/cursorutil.[ch] * app/gdisplay.[ch]: removed the old ToolType enum and prefixed the functions with "gimp_". Also stripped all "toggle cursor" stuff from the cursor code, so the new API is easier and not depending on the tool system. All existing tool cursors can be used via the new stock tool cursor enum, so no tool has to fiddle around with bitmap cursors. There will be an cursorutil function for registering stock tool cursor types on the fly. * app/disp_callbacks.c * app/scroll.[ch]: moved the display scrollbar callbacks from scroll.[ch] to disp_callbacks.c. Removed some crap from scroll.h * app/tools/tool.[ch]: removed the BitmapCursor pointers from the tool class struct and add cursor and toggle cursor IDs to the GimpTool struct. Work in progress. * app/dialog_handler.c * app/tools/bezier_select.c * app/tools/blend.c * app/tools/bucket_fill.c * app/tools/by_color_select.c * app/tools/clone.c * app/tools/color_picker.c * app/tools/convolve.c * app/tools/crop.c * app/tools/dodgeburn.c * app/tools/edit_selection.c * app/tools/ellipse_select.c * app/tools/flip_tool.c * app/tools/free_select.c * app/tools/fuzzy_select.c * app/tools/ink.c * app/tools/iscissors.c * app/tools/magnify.c * app/tools/measure.c * app/tools/move.c * app/tools/paint_core.[ch] * app/tools/perspective_tool.c * app/tools/rect_select.c * app/tools/rotate_tool.c * app/tools/scale_tool.c * app/tools/shear_tool.c * app/tools/text_tool.c * app/tools/transform_core.[ch]: changed accordingly. Did this "blind" for most tools because they don't compile. The changes are minimal, so there should be no conflicts.
2001-02-25 03:29:47 +08:00
static void
gimp_brush_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (tool);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (GIMP_PAINT_TOOL (brush_tool)->core);
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
{
if (! brush_core->main_brush || ! brush_core->dynamics)
{
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
gimp_tool_control_get_tool_cursor (tool->control),
GIMP_CURSOR_MODIFIER_BAD);
return;
}
else if (! brush_tool->show_cursor &&
gimp_tool_control_get_cursor_modifier (tool->control) !=
GIMP_CURSOR_MODIFIER_BAD)
{
gimp_tool_set_cursor (tool, display,
GIMP_CURSOR_NONE,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
return;
}
}
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
1997-11-25 06:05:25 +08:00
}
static void
gimp_brush_tool_options_notify (GimpTool *tool,
GimpToolOptions *options,
const GParamSpec *pspec)
{
GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
if (! strcmp (pspec->name, "brush-size") ||
! strcmp (pspec->name, "brush-angle") ||
! strcmp (pspec->name, "brush-aspect-ratio"))
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
g_signal_emit_by_name (brush_core, "set-brush",
brush_core->main_brush);
}
}
static void
gimp_brush_tool_draw (GimpDrawTool *draw_tool)
1997-11-25 06:05:25 +08:00
{
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (draw_tool);
GimpCanvasItem *item;
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
return;
item = gimp_brush_tool_create_outline (brush_tool,
draw_tool->display,
brush_tool->brush_x,
brush_tool->brush_y,
! brush_tool->show_cursor);
if (item)
{
gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item);
}
}
GimpCanvasItem *
gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
GimpDisplay *display,
gdouble x,
gdouble y,
gboolean draw_fallback)
{
GimpBrushCore *brush_core;
GimpPaintOptions *options;
GimpDisplayShell *shell;
const GimpBezierDesc *boundary = NULL;
gint width = 0;
gint height = 0;
g_return_val_if_fail (GIMP_IS_BRUSH_TOOL (brush_tool), NULL);
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
if (! brush_tool->draw_brush)
return NULL;
brush_core = GIMP_BRUSH_CORE (GIMP_PAINT_TOOL (brush_tool)->core);
options = GIMP_PAINT_TOOL_GET_OPTIONS (brush_tool);
shell = gimp_display_get_shell (display);
if (! brush_core->main_brush || ! brush_core->dynamics)
return NULL;
if (brush_core->scale > 0.0)
boundary = gimp_brush_transform_boundary (brush_core->main_brush,
brush_core->scale,
brush_core->aspect_ratio,
brush_core->angle,
brush_core->hardness,
&width,
&height);
/* don't draw the boundary if it becomes too small */
if (boundary &&
SCALEX (shell, width) > 4 &&
SCALEY (shell, height) > 4)
{
x -= width / 2.0;
y -= height / 2.0;
if (gimp_paint_options_get_brush_mode (options) == GIMP_BRUSH_HARD)
{
#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
*/
x = RINT (x + EPSILON);
y = RINT (y + EPSILON);
#undef EPSILON
}
return gimp_canvas_path_new (shell, boundary, x, y, FALSE,
GIMP_PATH_STYLE_OUTLINE);
}
else if (draw_fallback)
{
return gimp_canvas_handle_new (shell,
GIMP_HANDLE_CROSS,
GIMP_HANDLE_ANCHOR_CENTER,
x, y,
GIMP_TOOL_HANDLE_SIZE_SMALL,
GIMP_TOOL_HANDLE_SIZE_SMALL);
made the gimp_object_get_memsize() debugging output configurable by a 2002-02-06 Michael Natterer <mitch@gimp.org> * app/core/gimpobject.c: made the gimp_object_get_memsize() debugging output configurable by a global "gimp_debug_memsize" boolean. * app/display/gimpdisplay.c: removed duplicated prototype. * app/display/gimpdisplayshell.[ch]: renamed the various cursor functions to be more consistent and shorter. Compress window title updates by adding a "gboolean title_dirty" and updating the title in gimp_display_shell_flush(). Added "%m" (memory size) to the possible title string substitutions. * app/display/gimpdisplay-foreach.c * app/display/gimpdisplayshell-handlers.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimptool.c: changed accordingly. * app/display/gimpdisplayshell-callbacks.c: forgot to grab the pointer when dragging guides from the rulers. Coincidentially, this also fixes the buggy offset between guide and mouse pointer... Cleaned up the main tool event callback a but more. * app/widgets/gimppreview.c * app/gui/commands.c: set the new global "gimp_debug_memsize" toggle to TRUE while calling gimp_object_get_memsize(). * app/gui/preferences-dialog.c: added a image title example containing the new "%m" feature. * docs/gimprc-1.3.5.in: document "%m" in the manpage. * app/tools/gimpbezierselecttool.c: reordered some statements. * app/tools/gimpdrawtool.[ch]: store the GimpDisplay passed to gimp_draw_tool_start() in draw_tool->gdisp and use it for coordinate transfomration. This way we can paint on a display which is not tool->gdisp. * app/tools/gimppainttool.c: changed the gimp_draw_tool_foo() calls needed to make the straight_line preview work in a way that does not interfere with paint_tool subclasses which want to do their own drawing (like the clone tool). Also changed the paint_tools PRETRACE_PAINT and POSTTRACE_PAINT flags usage in a way that subclasses can use them without major hackery: don't simply wrap gimp_display_flush_now() with PRETRACE/POSTTRACE calls, but wrap the actual painting calls, so subclasses are able to do useful things with paint_tool->*_coords. * app/tools/gimpclonetool.c: removed poking around in draw_tool internals and simply suspend()/resume() it in PRETRACE_PAINT/POSTTRACE_PAINT to get the clone_src indicator drawn correctly.
2002-02-07 19:33:01 +08:00
}
return NULL;
}
static void
gimp_brush_tool_brush_changed (GimpContext *context,
GimpBrush *brush,
GimpBrushTool *brush_tool)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (brush_tool);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
gimp_brush_core_set_brush (brush_core, brush);
}
static void
gimp_brush_tool_set_brush (GimpBrushCore *brush_core,
GimpBrush *brush,
GimpBrushTool *brush_tool)
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (brush_tool));
if (GIMP_BRUSH_CORE_GET_CLASS (brush_core)->handles_transforming_brush)
{
GimpPaintCore *paint_core = GIMP_PAINT_CORE (brush_core);
gimp_brush_core_eval_transform_dynamics (brush_core,
NULL,
GIMP_PAINT_TOOL_GET_OPTIONS (brush_tool),
&paint_core->cur_coords);
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (brush_tool));
}
static void
gimp_brush_tool_notify_brush (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpBrushTool *brush_tool)
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (brush_tool));
brush_tool->show_cursor = config->show_paint_tool_cursor;
brush_tool->draw_brush = config->show_brush_outline;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (brush_tool));
}