gimp/app/tools/gimptool.c

660 lines
21 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
2002-03-29 11:50:29 +08:00
* Copyright (C) 1995-2002 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 "tools-types.h"
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 19:31:08 +08:00
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 19:31:08 +08:00
#include "display/gimpdisplay.h"
2001-11-01 05:20:09 +08:00
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-cursor.h"
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
#include "display/gimpstatusbar.h"
#include "gimptool.h"
#include "gimptoolcontrol.h"
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 19:31:08 +08:00
enum
{
PROP_0,
PROP_TOOL_INFO
};
static void gimp_tool_finalize (GObject *object);
static void gimp_tool_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_tool_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static gboolean gimp_tool_real_has_display (GimpTool *tool,
GimpDisplay *display);
static GimpDisplay * gimp_tool_real_has_image (GimpTool *tool,
GimpImage *image);
static gboolean gimp_tool_real_initialize (GimpTool *tool,
GimpDisplay *display);
static void gimp_tool_real_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_tool_real_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_tool_real_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_tool_real_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static gboolean gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display);
static void gimp_tool_real_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_tool_real_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_tool_real_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
G_DEFINE_TYPE (GimpTool, gimp_tool, GIMP_TYPE_OBJECT)
#define parent_class gimp_tool_parent_class
static gint global_tool_ID = 1;
static void
gimp_tool_class_init (GimpToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_tool_finalize;
object_class->set_property = gimp_tool_set_property;
object_class->get_property = gimp_tool_get_property;
klass->has_display = gimp_tool_real_has_display;
klass->has_image = gimp_tool_real_has_image;
klass->initialize = gimp_tool_real_initialize;
klass->control = gimp_tool_real_control;
klass->button_press = gimp_tool_real_button_press;
klass->button_release = gimp_tool_real_button_release;
klass->motion = gimp_tool_real_motion;
klass->key_press = gimp_tool_real_key_press;
klass->modifier_key = gimp_tool_real_modifier_key;
klass->oper_update = gimp_tool_real_oper_update;
klass->cursor_update = gimp_tool_real_cursor_update;
g_object_class_install_property (object_class, PROP_TOOL_INFO,
g_param_spec_object ("tool-info",
NULL, NULL,
GIMP_TYPE_TOOL_INFO,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_tool_init (GimpTool *tool)
{
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
tool->tool_info = NULL;
tool->ID = global_tool_ID++;
tool->control = g_object_new (GIMP_TYPE_TOOL_CONTROL, NULL);
tool->display = NULL;
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
tool->drawable = NULL;
tool->focus_display = NULL;
tool->modifier_state = 0;
}
static void
gimp_tool_finalize (GObject *object)
{
GimpTool *tool = GIMP_TOOL (object);
if (tool->tool_info)
{
g_object_unref (tool->tool_info);
tool->tool_info = NULL;
}
if (tool->control)
{
g_object_unref (tool->control);
tool->control = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_tool_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpTool *tool = GIMP_TOOL (object);
switch (property_id)
{
case PROP_TOOL_INFO:
tool->tool_info = GIMP_TOOL_INFO (g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_tool_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpTool *tool = GIMP_TOOL (object);
switch (property_id)
{
case PROP_TOOL_INFO:
g_value_set_object (value, tool->tool_info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* standard member functions */
static gboolean
gimp_tool_real_has_display (GimpTool *tool,
GimpDisplay *display)
{
return (display == tool->display);
}
static GimpDisplay *
gimp_tool_real_has_image (GimpTool *tool,
GimpImage *image)
{
if (tool->display)
{
if (image && tool->display->image == image)
return tool->display;
/* NULL image means any display */
if (! image)
return tool->display;
}
return NULL;
}
static gboolean
gimp_tool_real_initialize (GimpTool *tool,
GimpDisplay *display)
{
return TRUE;
}
static void
gimp_tool_real_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
tool->display = NULL;
break;
}
}
static void
gimp_tool_real_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
tool->display = display;
tool->drawable = gimp_image_active_drawable (display->image);
gimp_tool_control_activate (tool->control);
}
static void
gimp_tool_real_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
gimp_tool_control_halt (tool->control);
}
static void
gimp_tool_real_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
}
static gboolean
gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
{
return FALSE;
}
static void
gimp_tool_real_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
}
static void
gimp_tool_real_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
}
static void
gimp_tool_real_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
gimp_tool_control_get_tool_cursor (tool->control),
gimp_tool_control_get_cursor_modifier (tool->control));
}
/* public functions */
gboolean
gimp_tool_has_display (GimpTool *tool,
GimpDisplay *display)
{
g_return_val_if_fail (GIMP_IS_TOOL (tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
return GIMP_TOOL_GET_CLASS (tool)->has_display (tool, display);
}
GimpDisplay *
gimp_tool_has_image (GimpTool *tool,
GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_TOOL (tool), NULL);
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
return GIMP_TOOL_GET_CLASS (tool)->has_image (tool, image);
}
gboolean
gimp_tool_initialize (GimpTool *tool,
GimpDisplay *display)
{
g_return_val_if_fail (GIMP_IS_TOOL (tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
return GIMP_TOOL_GET_CLASS (tool)->initialize (tool, display);
}
void
gimp_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
if (! gimp_tool_control_is_paused (tool->control))
GIMP_TOOL_GET_CLASS (tool)->control (tool, action, display);
gimp_tool_control_pause (tool->control);
break;
case GIMP_TOOL_ACTION_RESUME:
if (gimp_tool_control_is_paused (tool->control))
{
gimp_tool_control_resume (tool->control);
if (! gimp_tool_control_is_paused (tool->control))
GIMP_TOOL_GET_CLASS (tool)->control (tool, action, display);
}
else
{
g_warning ("gimp_tool_control: unable to RESUME tool with "
"tool->control->paused_count == 0");
}
break;
case GIMP_TOOL_ACTION_HALT:
GIMP_TOOL_GET_CLASS (tool)->control (tool, action, display);
if (gimp_tool_control_is_active (tool->control))
gimp_tool_control_halt (tool->control);
break;
}
}
void
gimp_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_TOOL_GET_CLASS (tool)->button_press (tool, coords, time, state, display);
}
void
gimp_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_TOOL_GET_CLASS (tool)->button_release (tool, coords, time, state, display);
}
void
gimp_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (gimp_tool_control_is_active (tool->control));
GIMP_TOOL_GET_CLASS (tool)->motion (tool, coords, time, state, display);
}
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
void
gimp_tool_set_focus_display (GimpTool *tool,
GimpDisplay *display)
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (display == NULL || GIMP_IS_DISPLAY (display));
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
#ifdef DEBUG_FOCUS
g_printerr ("gimp_tool_set_focus_display: display: %p focus_display: %p\n",
display, tool->focus_display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
#endif
if (display != tool->focus_display)
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
{
if (tool->focus_display)
{
if (tool->modifier_state != 0)
gimp_tool_set_modifier_state (tool, 0, tool->focus_display);
}
tool->focus_display = display;
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
}
}
gboolean
gimp_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
{
g_return_val_if_fail (GIMP_IS_TOOL (tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
g_return_val_if_fail (display == tool->focus_display, FALSE);
return GIMP_TOOL_GET_CLASS (tool)->key_press (tool, kevent, display);
}
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
static void
gimp_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (display == tool->focus_display);
GIMP_TOOL_GET_CLASS (tool)->modifier_key (tool, key, press, state, display);
}
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
void
gimp_tool_set_modifier_state (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
#ifdef DEBUG_FOCUS
g_printerr ("gimp_tool_set_modifier_state: display: %p focus_display: %p\n",
display, tool->focus_display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
#endif
g_return_if_fail (display == tool->focus_display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
if ((tool->modifier_state & GDK_SHIFT_MASK) != (state & GDK_SHIFT_MASK))
{
gimp_tool_modifier_key (tool, GDK_SHIFT_MASK,
(state & GDK_SHIFT_MASK) ? TRUE : FALSE, state,
display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
}
if ((tool->modifier_state & GDK_CONTROL_MASK) != (state & GDK_CONTROL_MASK))
{
gimp_tool_modifier_key (tool, GDK_CONTROL_MASK,
(state & GDK_CONTROL_MASK) ? TRUE : FALSE, state,
display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
}
if ((tool->modifier_state & GDK_MOD1_MASK) != (state & GDK_MOD1_MASK))
{
gimp_tool_modifier_key (tool, GDK_MOD1_MASK,
(state & GDK_MOD1_MASK) ? TRUE : FALSE, state,
display);
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
}
tool->modifier_state = state;
}
void
gimp_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_TOOL_GET_CLASS (tool)->oper_update (tool, coords, state, proximity,
display);
}
void
gimp_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_TOOL_GET_CLASS (tool)->cursor_update (tool, coords, state, display);
}
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
void
gimp_tool_push_status (GimpTool *tool,
GimpDisplay *display,
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
const gchar *message)
{
GimpDisplayShell *shell;
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
shell = GIMP_DISPLAY_SHELL (display->shell);
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool),
message);
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
}
void
gimp_tool_push_status_coords (GimpTool *tool,
GimpDisplay *display,
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y)
{
GimpDisplayShell *shell;
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
shell = GIMP_DISPLAY_SHELL (display->shell);
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
gimp_statusbar_push_coords (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool),
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
title, x, separator, y);
}
void
gimp_tool_push_status_length (GimpTool *tool,
GimpDisplay *display,
const gchar *title,
GimpOrientationType axis,
gdouble value)
{
GimpDisplayShell *shell;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
shell = GIMP_DISPLAY_SHELL (display->shell);
gimp_statusbar_push_length (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool),
title, axis, value);
}
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
void
gimp_tool_replace_status (GimpTool *tool,
GimpDisplay *display,
const gchar *message)
{
GimpDisplayShell *shell;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
shell = GIMP_DISPLAY_SHELL (display->shell);
gimp_statusbar_replace (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool),
message);
}
void
gimp_tool_pop_status (GimpTool *tool,
GimpDisplay *display)
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
{
GimpDisplayShell *shell;
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
shell = GIMP_DISPLAY_SHELL (display->shell);
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool));
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
}
void
gimp_tool_set_cursor (GimpTool *tool,
GimpDisplay *display,
GimpCursorType cursor,
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
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
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_display_shell_set_cursor (GIMP_DISPLAY_SHELL (display->shell),
Refactored modifier handling of displays and tools. Hopefully finally 2003-10-14 Michael Natterer <mitch@gimp.org> Refactored modifier handling of displays and tools. Hopefully finally fixes bug #124135. * app/tools/gimptool.[ch] (struct GimpTool): added private members "focus_display" and "modifier_state" so tools are aware of their modifier state. * app/tools/gimptool.[ch] * app/tools/tool_manager.[ch]: removed all public modifier_key() API and added set_focus_display() and set_modifier_state() instead. * app/tools/tool_manager.c (tool_manager_select_tool) * app/display/gimpdisplay.c (gimp_display_delete): set the active_tool's focus_display to NULL. * app/display/gimpdisplayshell.[ch] (struct GimpDisplayShell): added almost the whole stuff that used to be static variables of gimp_display_shell_tool_events(). Cleaned up the struct a bit. * app/display/gimpdisplayshell-callbacks.c: removed utility function gimp_display_shell_update_tool_modifiers(). (gimp_display_shell_tool_events): - Replaced all calls to gimp_display_shell_update_tool_modifiers() and tool_manager_modifier_key_active() by tool_manager_modifier_state_active(). - Call tool_manager_focus_display_active() before setting the tool's modifier_state. Set the tool's focus_display to NULL when we get a focus_out event. - Don't grab/ungrab the keyboard twice when <space>-selecting the move tool. - Removed most static variables and use the new members of GimpDisplayShell. Don't remember any old modifier states since GimpTool does that by itself now.
2003-10-14 19:14:28 +08:00
cursor, tool_cursor, modifier);
app/display/Makefile.am app/display/display-types.h new widget derived 2002-02-03 Michael Natterer <mitch@gimp.org> * app/display/Makefile.am * app/display/display-types.h * app/display/gimpstatusbar.[ch]: new widget derived from GtkStatusbar. Contains the coordinates display, a progress bar which is also used for status message display and a cancel button. Added a simplified API for pushing/popping messages which takes a string as context_id and does the conversion to guint internally on each call. * app/display/gimpdisplayshell.[ch]: removed the status bar code. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/gui/view-commands.c * app/gimpprogress.c: changed accordingly. Removed knowledge about GimpDisplayShell from tools: * app/tools/gimptool.[ch]: added gimp_tool_push_status() and gimp_tool_pop_status() so tools don't need to fiddle with display details. * app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of a GdkWindow to gimp_draw_tool_start() (the window passed was always gdisp->shell->canvas->window). * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.[ch] * app/tools/gimpmovetool.c * app/tools/gimppainttool.[ch] * app/tools/gimppathtool.c * app/tools/gimprectselecttool.[ch] * app/tools/gimptransformtool.c: changed accordingly: - pass GimpDisplay to gimp_draw_tool_start(). - use GimpTool's new status push/pop functions. - removed the statusbar context_id from all tool structs. * app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation of dockable editor dialogs.
2002-02-03 20:10:23 +08:00
}