gimp/app/tools/gimpdrawtool.c

808 lines
23 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
*
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "tools-types.h"
#include "display/gimpdisplay.h"
2001-11-01 05:20:09 +08:00
#include "display/gimpdisplayshell.h"
#include "gimpdrawtool.h"
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
static void gimp_draw_tool_init (GimpDrawTool *draw_tool);
static void gimp_draw_tool_finalize (GObject *object);
static void gimp_draw_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp);
static inline void gimp_draw_tool_shift_to_north_west
(gdouble x,
gdouble y,
gint handle_width,
gint handle_height,
GtkAnchorType anchor,
gdouble *shifted_x,
gdouble *shifted_y);
static inline void gimp_draw_tool_shift_to_center
(gdouble x,
gdouble y,
gint handle_width,
gint handle_height,
GtkAnchorType anchor,
gdouble *shifted_x,
gdouble *shifted_y);
static GimpToolClass *parent_class = NULL;
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
GType
gimp_draw_tool_get_type (void)
{
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
static GType tool_type = 0;
if (! tool_type)
{
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
static const GTypeInfo tool_info =
{
sizeof (GimpDrawToolClass),
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_draw_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpDrawTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_draw_tool_init,
};
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
tool_type = g_type_register_static (GIMP_TYPE_TOOL,
"GimpDrawTool",
&tool_info, 0);
}
return tool_type;
}
static void
gimp_draw_tool_class_init (GimpDrawToolClass *klass)
{
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
GObjectClass *object_class;
GimpToolClass *tool_class;
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
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);
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
object_class->finalize = gimp_draw_tool_finalize;
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
tool_class->control = gimp_draw_tool_control;
klass->draw = NULL;
}
static void
gimp_draw_tool_init (GimpDrawTool *draw_tool)
{
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
draw_tool->win = NULL;
draw_tool->gc = NULL;
draw_tool->paused_count = 0;
draw_tool->line_width = 0;
draw_tool->line_style = GDK_LINE_SOLID;
draw_tool->cap_style = GDK_CAP_NOT_LAST;
draw_tool->join_style = GDK_JOIN_MITER;
}
static void
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
gimp_draw_tool_finalize (GObject *object)
{
GimpDrawTool *draw_tool;
draw_tool = GIMP_DRAW_TOOL (object);
if (draw_tool->gc)
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
{
g_object_unref (G_OBJECT (draw_tool->gc));
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
draw_tool->gc = NULL;
}
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.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/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/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 19:47:11 +08:00
gimp_draw_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpDrawTool *draw_tool;
draw_tool = GIMP_DRAW_TOOL (tool);
switch (action)
{
case PAUSE:
gimp_draw_tool_pause (draw_tool);
break;
case RESUME:
gimp_draw_tool_resume (draw_tool);
break;
case HALT:
gimp_draw_tool_stop (draw_tool);
break;
default:
break;
}
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
build display/ before tools/. 2001-11-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am: build display/ before tools/. * app/devices.c: devices_check_change(): added all events which have a GdkDevice pointer. * app/gimpprogress.c: include "display-types.h" instead of "core-types.h". * app/core/Makefile.am * app/core/gimpdrawable-bucket-fill.[ch]: new files: the bucket_fill stuff taken from tools/gimpbucketfilltool.[ch]. * app/core/core-types.h: added "BucketFillMode". * app/core/gimpimage-mask-select.[ch]: cleanup. * app/core/gimpmarshal.list: added more marshallers for GimpTool's new signal signatures. * app/core/gimpmarshal.[ch]: regenerated. * app/display/Makefile.am * app/display/gimpdisplayshell-dnd.[ch] * app/display/gimpdisplayshell-layer-select.[ch]: new files: the canvas drop callbacks from gimpdisplayshell-callbacks.[ch] and the stuff formerly knows as gui/layer-select.[ch]. * app/display/gimpdisplay.h: don't include "gui/gui-types.h". * app/display/gximage.c: include "display-types.h". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplayshell.[ch]: call gdsplay_delete(), don't destroy the shell widget. * app/gui/Makefile.am * app/gui/layer-select.[ch]: removed. * app/gui/gradients-commands.c: fixed "Save as POV" fprintf()s. * app/gui/preferences-dialog.c: removed the layer_select stuff because it is useless with the new preview system. * app/gui/tool-options-dialog.c: send the correct data to the close_callback. * app/gui/tools-commands.c: changed to follow the new gimp_tool_initialize() semantics (see below). Tool & canvas event handling chainsawing: * app/tools/tools-types.h: new struct GimpCoords which contains x, y, pressure, tilt etc. * app/display/gimpdisplayshell-callbacks.[ch]: added utility functions which transparently retreive the current event's GimpCoords or take it from the device directly if the event has none. Pass GimpCoords _in_image_coordinates_ to all tool functions. Most important: don't pass GdkEvents and display coordinates to tools any more. * app/tools/gimptool.[ch]: changed virtual functions to take GimpCoords, time and state separately instead of GdkEvents. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.[ch] * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.[ch] * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.[ch] * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpselectiontool.[ch] * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.[ch] * app/tools/path_tool.[ch] * app/tools/selection_options.c: tons and tons of changes: - changed to use the new virtual function parameters. - removed zillions of gdisplay_untransform_coords(). - get the active drawable's offsets manually in many cases. (questionable, but IMHO ok because it's obvious and not simply a "TRUE" passed to some function) - reordered some functions to be consistent across tools. - some tools had to be changed to work on image coords, not display ones (esp. crop). - fixed strange rotate tool behaviour which should be backported to stable. - some stuff i came across. - indentation and other paranoia. - rounding of coordinated may be broken in some tools. - new bugs guaranteed. * app/tools/tool_manager.[ch]: new semantic of tool_manager_initialize_active() (looked at the places where it was used from and put common code together). Should be a bit better now :) * app/tools/gimpblendtool.c * app/tools/transform_options.c: use the new GTK+ feature that a widget (toggle button) can be a frame's title for this tools' tool options. * app/widgets/widgets-types.h: stuff. * themes/Default/gtkrc: s/GtkDialog/GimpDialog/. * tools/pdbgen/Makefile.am: don't scan tools/gimpbucketfilltool.h any more. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb/tools.pdb: changed bucket_fill wrapper. * app/pdb/tools_cmds.c: regenerated.
2001-11-09 03:14:51 +08:00
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
void
gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *win)
{
GdkColor fg, bg;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (GDK_IS_WINDOW (win));
if (draw_tool->draw_state != GIMP_DRAW_TOOL_STATE_INVISIBLE)
gimp_draw_tool_stop (draw_tool); /* this seems backwards ;) */
draw_tool->win = win;
draw_tool->paused_count = 0; /* reset pause counter to 0 */
/* create a new graphics context */
if (! draw_tool->gc)
draw_tool->gc = gdk_gc_new (win);
gdk_gc_set_function (draw_tool->gc, GDK_INVERT);
fg.pixel = 0xFFFFFFFF;
bg.pixel = 0x00000000;
gdk_gc_set_foreground (draw_tool->gc, &fg);
gdk_gc_set_background (draw_tool->gc, &bg);
gdk_gc_set_line_attributes (draw_tool->gc,
draw_tool->line_width,
draw_tool->line_style,
draw_tool->cap_style,
draw_tool->join_style);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
}
void
gimp_draw_tool_stop (GimpDrawTool *draw_tool)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
if (draw_tool->draw_state == GIMP_DRAW_TOOL_STATE_INVISIBLE)
return;
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
}
void
gimp_draw_tool_pause (GimpDrawTool *draw_tool)
{
if (draw_tool->paused_count == 0)
{
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
}
draw_tool->paused_count++;
}
void
gimp_draw_tool_resume (GimpDrawTool *draw_tool)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
if (draw_tool->paused_count > 0)
draw_tool->paused_count--;
if (draw_tool->paused_count == 0)
{
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
}
}
gdouble
gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2)
{
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0);
gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE);
gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE);
return sqrt (SQR (tx2 - tx1) + SQR (ty2 - ty1));
}
gboolean
gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gint radius)
{
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE);
gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE);
return (SQR (tx2 - tx1) + SQR (ty2 - ty1)) < SQR (radius);
}
void
gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean use_offsets)
{
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
gdisplay_transform_coords_f (tool->gdisp, x1, y1, &tx1, &ty1, use_offsets);
gdisplay_transform_coords_f (tool->gdisp, x2, y2, &tx2, &ty2, use_offsets);
gdk_draw_line (draw_tool->win,
draw_tool->gc,
RINT (tx1), RINT (ty1),
RINT (tx2), RINT (ty2));
}
void
gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean use_offsets)
{
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
tx1 = MIN (x, x + width);
ty1 = MIN (y, y + height);
tx2 = MAX (x, x + width);
ty2 = MAX (y, y + height);
gdisplay_transform_coords_f (tool->gdisp, tx1, ty1, &tx1, &ty1, use_offsets);
gdisplay_transform_coords_f (tool->gdisp, tx2, ty2, &tx2, &ty2, use_offsets);
gdk_draw_rectangle (draw_tool->win,
draw_tool->gc,
filled,
RINT (tx1), RINT (ty1),
RINT (tx2 - tx1), RINT (ty2 - ty1));
}
void
gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gint angle1,
gint angle2,
gboolean use_offsets)
{
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
tx1 = MIN (x, x + width);
ty1 = MIN (y, y + height);
tx2 = MAX (x, x + width);
ty2 = MAX (y, y + height);
gdisplay_transform_coords_f (tool->gdisp, tx1, ty1, &tx1, &ty1, use_offsets);
gdisplay_transform_coords_f (tool->gdisp, tx2, ty2, &tx2, &ty2, use_offsets);
gdk_draw_arc (draw_tool->win,
draw_tool->gc,
filled,
RINT (tx1), RINT (ty1),
RINT (tx2 - tx1), RINT (ty2 - ty1),
angle1, angle2);
}
void
gimp_draw_tool_draw_rectangle_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx, ty;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
gimp_draw_tool_shift_to_north_west (tx, ty,
width, height,
anchor,
&tx, &ty);
if (filled)
{
width++;
height++;
}
gdk_draw_rectangle (draw_tool->win,
draw_tool->gc,
filled,
RINT (tx), RINT (ty),
width, height);
}
void
gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint radius_x,
gint radius_y,
gint angle1,
gint angle2,
GtkAnchorType anchor,
gboolean use_offsets)
{
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx, ty;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
/* well... */
radius_x *= 2;
radius_y *= 2;
gimp_draw_tool_shift_to_north_west (tx, ty,
radius_x, radius_y,
anchor,
&tx, &ty);
if (filled)
{
radius_x += 1;
radius_y += 1;
}
gdk_draw_arc (draw_tool->win,
draw_tool->gc,
filled,
RINT (tx), RINT (ty),
radius_x, radius_y,
angle1, angle2);
}
void
gimp_draw_tool_draw_cross_by_anchor (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
2001-11-01 05:20:09 +08:00
GimpTool *tool;
GimpDisplayShell *shell;
gdouble tx, ty;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
2001-11-01 05:20:09 +08:00
tool = GIMP_TOOL (draw_tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
gimp_draw_tool_shift_to_center (tx, ty,
width, height,
anchor,
&tx, &ty);
gdk_draw_line (draw_tool->win,
draw_tool->gc,
RINT (tx), RINT (ty) - (height >> 1),
RINT (tx), RINT (ty) + (height >> 1));
gdk_draw_line (draw_tool->win,
draw_tool->gc,
RINT (tx) - (width >> 1), RINT (ty),
RINT (tx) + (width >> 1), RINT (ty));
}
void
gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
switch (type)
2001-11-01 05:20:09 +08:00
{
case GIMP_HANDLE_SQUARE:
gimp_draw_tool_draw_rectangle_by_anchor (draw_tool,
FALSE,
x, y,
width,
height,
anchor,
use_offsets);
break;
case GIMP_HANDLE_FILLED_SQUARE:
gimp_draw_tool_draw_rectangle_by_anchor (draw_tool,
TRUE,
x, y,
width,
height,
anchor,
use_offsets);
break;
case GIMP_HANDLE_CIRCLE:
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
FALSE,
x, y,
width >> 1,
height >> 1,
0, 360 * 64,
anchor,
use_offsets);
break;
case GIMP_HANDLE_FILLED_CIRCLE:
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
TRUE,
x, y,
width >> 1,
height >> 1,
0, 360 * 64,
anchor,
use_offsets);
break;
case GIMP_HANDLE_CROSS:
gimp_draw_tool_draw_cross_by_anchor (draw_tool,
x, y,
width,
height,
anchor,
use_offsets);
break;
default:
g_warning ("%s: invalid handle type %d", G_GNUC_PRETTY_FUNCTION, type);
break;
2001-11-01 05:20:09 +08:00
}
}
gboolean
gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x,
gdouble y,
GimpHandleType type,
gdouble handle_x,
gdouble handle_y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
gdouble tx, ty;
gdouble handle_tx, handle_ty;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0);
gdisplay_transform_coords_f (gdisp, x, y, &tx, &ty, use_offsets);
gdisplay_transform_coords_f (gdisp,
handle_x, handle_y,
&handle_tx, &handle_ty,
use_offsets);
switch (type)
{
case GIMP_HANDLE_SQUARE:
case GIMP_HANDLE_FILLED_SQUARE:
case GIMP_HANDLE_CROSS:
gimp_draw_tool_shift_to_north_west (handle_tx, handle_ty,
width, height,
anchor,
&handle_tx, &handle_ty);
return (tx == CLAMP (tx, handle_tx, handle_tx + width) &&
ty == CLAMP (ty, handle_ty, handle_ty + height));
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
gimp_draw_tool_shift_to_center (handle_tx, handle_ty,
width, height,
anchor,
&handle_tx, &handle_ty);
/* FIXME */
if (width != height)
width = (width + height) >> 1;
return ((SQR (handle_tx - tx) + SQR (handle_ty - ty)) < SQR (width));
default:
g_warning ("%s: invalid handle type %d", G_GNUC_PRETTY_FUNCTION, type);
break;
}
return FALSE;
}
void
gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
2001-11-01 05:20:09 +08:00
gdouble *points,
gint npoints,
gint filled)
{
2001-11-01 05:20:09 +08:00
GimpTool *tool;
GimpDisplayShell *shell;
GdkPoint *coords;
gint i;
gdouble sx, sy;
2001-11-01 05:20:09 +08:00
tool = GIMP_TOOL (draw_tool);
2001-11-01 05:20:09 +08:00
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
2001-11-01 05:20:09 +08:00
coords = g_new (GdkPoint, npoints);
for (i = 0; i < npoints ; i++)
{
gdisplay_transform_coords_f (tool->gdisp, points[i*2], points[i*2+1],
&sx, &sy, TRUE);
coords[i].x = ROUND (sx);
coords[i].y = ROUND (sy);
}
if (filled)
2001-11-01 05:20:09 +08:00
{
gdk_draw_polygon (shell->canvas->window,
draw_tool->gc, TRUE,
coords, npoints);
}
else
2001-11-01 05:20:09 +08:00
{
gdk_draw_lines (shell->canvas->window,
draw_tool->gc,
coords, npoints);
}
g_free (coords);
}
/* private functions */
static inline void
gimp_draw_tool_shift_to_north_west (gdouble x,
gdouble y,
gint handle_width,
gint handle_height,
GtkAnchorType anchor,
gdouble *shifted_x,
gdouble *shifted_y)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
x -= (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH:
x -= (handle_width >> 1);
break;
case GTK_ANCHOR_NORTH_WEST:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH_EAST:
x -= handle_width;
break;
case GTK_ANCHOR_SOUTH:
x -= (handle_width >> 1);
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_WEST:
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= handle_width;
y -= handle_height;
break;
case GTK_ANCHOR_WEST:
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_EAST:
x -= handle_width;
y -= (handle_height >> 1);
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = y;
}
static inline void
gimp_draw_tool_shift_to_center (gdouble x,
gdouble y,
gint handle_width,
gint handle_height,
GtkAnchorType anchor,
gdouble *shifted_x,
gdouble *shifted_y)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH:
y += (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH_WEST:
x += (handle_width >> 1);
y += (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH_EAST:
x -= (handle_width >> 1);
y += (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH:
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH_WEST:
x += (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_WEST:
x += (handle_width >> 1);
break;
case GTK_ANCHOR_EAST:
x -= (handle_width >> 1);
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = y;
}