1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2001-04-07 23:58:26 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-11-30 00:44:51 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-11-30 22:41:56 +08:00
|
|
|
#include "core/gimpimage-qmask.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "tools/tools-types.h"
|
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tools/gimpmovetool.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "widgets/gimpcursor.h"
|
2001-07-20 18:07:51 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2001-11-30 22:41:56 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
#include "gui/dialogs.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-11-30 22:41:56 +08:00
|
|
|
#include "gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "gimpdisplayshell-layer-select.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-07-03 04:57:58 +08:00
|
|
|
#include "devices.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimprc.h"
|
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
static void gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
|
|
|
static gboolean gimp_display_shell_get_state (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state);
|
|
|
|
static void gimp_display_shell_get_device_state (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state);
|
|
|
|
static gboolean gimp_display_shell_get_coords (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords);
|
|
|
|
static void gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords);
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static GdkModifierType
|
2001-12-01 00:39:40 +08:00
|
|
|
gimp_display_shell_key_to_state (gint key);
|
1999-05-05 17:10:35 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void gimp_display_shell_origin_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gpointer data);
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* public functions */
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDisplayShell *shell)
|
1999-06-04 02:28:39 +08:00
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_KEY_PRESS:
|
2001-04-21 00:27:44 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_SCROLL:
|
1999-06-20 21:53:15 +08:00
|
|
|
/* Setting the context's display automatically sets the image, too */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_context_set_display (gimp_get_user_context (shell->gdisp->gimage->gimp),
|
|
|
|
shell->gdisp);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
1999-06-04 02:28:39 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-06-20 21:53:15 +08:00
|
|
|
}
|
|
|
|
|
1999-06-04 02:28:39 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_realize (GtkWidget *canvas,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
2001-11-16 23:08:59 +08:00
|
|
|
GdkColor color;
|
|
|
|
guchar r, g, b;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
gdisp = shell->gdisp;
|
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gtk_widget_grab_focus (shell->canvas);
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
if (TRUE /* gimprc.use_style_padding_color */)
|
|
|
|
{
|
|
|
|
r = shell->canvas->style->bg[GTK_STATE_NORMAL].red >> 8;
|
|
|
|
g = shell->canvas->style->bg[GTK_STATE_NORMAL].green >> 8;
|
|
|
|
b = shell->canvas->style->bg[GTK_STATE_NORMAL].blue >> 8;
|
|
|
|
|
|
|
|
gimp_rgb_set_uchar (&shell->padding_color, r, g, b);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (shell->padding_button),
|
|
|
|
gimp_display_shell_color_changed,
|
|
|
|
shell);
|
|
|
|
|
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (shell->padding_button),
|
|
|
|
&shell->padding_color);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (shell->padding_button),
|
|
|
|
gimp_display_shell_color_changed,
|
|
|
|
shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (&shell->padding_color, &r, &g, &b);
|
|
|
|
|
|
|
|
shell->padding_gc = gdk_gc_new (canvas->window);
|
|
|
|
|
|
|
|
color.red = (r << 8) | r;
|
|
|
|
color.green = (g << 8) | g;
|
|
|
|
color.blue = (b << 8) | b;
|
|
|
|
|
|
|
|
gdk_gc_set_rgb_fg_color (shell->padding_gc, &color);
|
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gdk_window_set_back_pixmap (shell->canvas->window, NULL, FALSE);
|
|
|
|
|
|
|
|
gimp_display_shell_resize_cursor_label (shell);
|
|
|
|
gimp_display_shell_update_title (shell);
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
/* create the selection object */
|
2001-11-11 07:03:22 +08:00
|
|
|
shell->select = gimp_display_shell_selection_create (canvas->window,
|
|
|
|
shell,
|
|
|
|
gdisp->gimage->height,
|
|
|
|
gdisp->gimage->width,
|
|
|
|
gimprc.marching_speed);
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
shell->disp_width = canvas->allocation.width;
|
|
|
|
shell->disp_height = canvas->allocation.height;
|
|
|
|
|
|
|
|
/* create GC for scrolling */
|
|
|
|
shell->scroll_gc = gdk_gc_new (shell->canvas->window);
|
|
|
|
gdk_gc_set_exposures (shell->scroll_gc, TRUE);
|
|
|
|
|
|
|
|
/* set up the scrollbar observers */
|
|
|
|
g_signal_connect (G_OBJECT (shell->hsbdata), "value_changed",
|
|
|
|
G_CALLBACK (gimp_display_shell_hscrollbar_update),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (G_OBJECT (shell->vsbdata), "value_changed",
|
|
|
|
G_CALLBACK (gimp_display_shell_vscrollbar_update),
|
|
|
|
shell);
|
|
|
|
|
|
|
|
/* setup scale properly */
|
|
|
|
gimp_display_shell_scale_setup (shell);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
|
|
|
/* set the initial cursor */
|
|
|
|
gimp_display_shell_install_tool_cursor (shell,
|
|
|
|
GDK_TOP_LEFT_ARROW,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2001-11-02 17:31:21 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_configure (GtkWidget *widget,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2001-12-01 00:39:40 +08:00
|
|
|
if ((shell->disp_width != shell->canvas->allocation.width) ||
|
|
|
|
(shell->disp_height != shell->canvas->allocation.height))
|
|
|
|
{
|
|
|
|
shell->disp_width = shell->canvas->allocation.width;
|
|
|
|
shell->disp_height = shell->canvas->allocation.height;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gimp_display_shell_scale_resize (shell, FALSE, FALSE);
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
return TRUE;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2001-12-01 00:39:40 +08:00
|
|
|
glong x1, y1, x2, y2;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
x1 = eevent->area.x;
|
|
|
|
y1 = eevent->area.y;
|
|
|
|
x2 = (eevent->area.x + eevent->area.width);
|
|
|
|
y2 = (eevent->area.y + eevent->area.height);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
x1 = CLAMP (x1, 0, shell->disp_width);
|
|
|
|
y1 = CLAMP (y1, 0, shell->disp_height);
|
|
|
|
x2 = CLAMP (x2, 0, shell->disp_width);
|
|
|
|
y2 = CLAMP (y2, 0, shell->disp_height);
|
|
|
|
|
|
|
|
if ((x2 - x1) && (y2 - y1))
|
|
|
|
{
|
|
|
|
gimp_display_shell_add_expose_area (shell,
|
|
|
|
x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1));
|
|
|
|
gimp_display_shell_flush (shell);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_focus_in (GtkWidget *widget,
|
|
|
|
GdkEventFocus *fevent,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
|
|
|
|
|
|
|
|
/* stop the signal because otherwise gtk+ exposes the whole
|
|
|
|
* canvas to get the non-existant focus indicator drawn
|
|
|
|
*/
|
|
|
|
return TRUE;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_focus_out (GtkWidget *widget,
|
|
|
|
GdkEventFocus *fevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2001-12-01 00:39:40 +08:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
|
|
|
|
|
|
|
|
/* stop the signal because otherwise gtk+ exposes the whole
|
|
|
|
* canvas to get the non-existant focus indicator drawn
|
|
|
|
*/
|
|
|
|
return TRUE;
|
2001-11-30 22:41:56 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2001-12-01 00:39:40 +08:00
|
|
|
GList *list;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* gdk_devices_list() returns an internal list, so we shouldn't
|
|
|
|
* free it afterwards
|
|
|
|
*/
|
|
|
|
for (list = gdk_devices_list (); list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GdkDevice *device = (GdkDevice *) list->data;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
if (device == current_device)
|
|
|
|
{
|
|
|
|
shell->draw_cursor = ! device->has_cursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-12-01 00:39:40 +08:00
|
|
|
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-11-30 22:41:56 +08:00
|
|
|
GimpImage *gimage;
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords display_coords;
|
|
|
|
GimpCoords image_coords;
|
|
|
|
GdkModifierType state;
|
|
|
|
guint32 time;
|
2001-11-02 17:31:21 +08:00
|
|
|
gboolean return_val = FALSE;
|
|
|
|
gboolean update_cursor = FALSE;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
static GdkModifierType press_state;
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
static gboolean scrolling = FALSE;
|
|
|
|
static gint scroll_start_x = 0;
|
|
|
|
static gint scroll_start_y = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
if (! canvas->window)
|
2001-11-02 17:31:21 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
g_warning ("%s: called unrealized", G_STRLOC);
|
2001-11-02 17:31:21 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1998-02-05 08:07:31 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
/* Find out what device the event occurred upon */
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimage->gimp->busy && devices_check_change (event))
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_check_device_cursor (shell);
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_display_shell_get_coords (shell, event, current_device, &display_coords);
|
|
|
|
gimp_display_shell_get_state (shell, event, current_device, &state);
|
|
|
|
time = gdk_event_get_time (event);
|
|
|
|
|
|
|
|
image_coords = display_coords;
|
|
|
|
|
|
|
|
/* GimpCoords passed to tools are ALWAYS in image coordinates */
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_ENTER_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventCrossing *cevent;
|
|
|
|
|
|
|
|
cevent = (GdkEventCrossing *) event;
|
|
|
|
|
|
|
|
if (cevent->mode != GDK_CROSSING_NORMAL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* press modifier keys when entering the canvas */
|
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_SHIFT_MASK, TRUE, state,
|
|
|
|
gdisp);
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_CONTROL_MASK, TRUE, state,
|
|
|
|
gdisp);
|
|
|
|
if (state & GDK_MOD1_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_MOD1_MASK, TRUE, state,
|
|
|
|
gdisp);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
1998-06-06 11:49:01 +08:00
|
|
|
break;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventCrossing *cevent;
|
|
|
|
|
|
|
|
cevent = (GdkEventCrossing *) event;
|
|
|
|
|
|
|
|
if (cevent->mode != GDK_CROSSING_NORMAL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
gimp_display_shell_update_cursor (shell, -1, -1);
|
|
|
|
|
|
|
|
shell->proximity = FALSE;
|
|
|
|
|
|
|
|
/* release modifier keys when leaving the canvas */
|
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
if (state & GDK_MOD1_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_MOD1_MASK, FALSE, 0,
|
|
|
|
gdisp);
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_CONTROL_MASK, FALSE, 0,
|
|
|
|
gdisp);
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
GDK_SHIFT_MASK, FALSE, 0,
|
|
|
|
gdisp);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, 0,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_PROXIMITY_IN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_PROXIMITY_OUT:
|
|
|
|
shell->proximity = FALSE;
|
1998-06-06 11:49:01 +08:00
|
|
|
break;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
/* ignore new mouse events */
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
2001-11-15 01:12:51 +08:00
|
|
|
|
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
state |= GDK_BUTTON1_MASK;
|
|
|
|
|
|
|
|
gtk_grab_add (canvas);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* save the current modifier state because tools don't get
|
|
|
|
* key events while BUTTON1 is down
|
2001-11-15 01:12:51 +08:00
|
|
|
*/
|
2001-11-30 22:41:56 +08:00
|
|
|
press_state = state;
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
if (active_tool && (! gimp_image_is_empty (gimage) ||
|
2001-11-30 00:44:51 +08:00
|
|
|
active_tool->handle_empty_image))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
if (active_tool->auto_snap_to)
|
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize the current tool if it has no drawable
|
|
|
|
*/
|
|
|
|
if (! active_tool->drawable)
|
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_initialize_active (gimage->gimp, gdisp);
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
2001-11-30 00:44:51 +08:00
|
|
|
else if ((active_tool->drawable !=
|
2001-11-30 22:41:56 +08:00
|
|
|
gimp_image_active_drawable (gimage)) &&
|
2001-11-15 01:12:51 +08:00
|
|
|
! active_tool->preserve)
|
|
|
|
{
|
|
|
|
/* create a new one, deleting the current
|
|
|
|
*/
|
2001-11-30 22:41:56 +08:00
|
|
|
gimp_context_tool_changed (gimp_get_user_context (gimage->gimp));
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_initialize_active (gimage->gimp, gdisp);
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_button_press_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, time, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
state |= GDK_BUTTON2_MASK;
|
|
|
|
|
|
|
|
scrolling = TRUE;
|
|
|
|
|
|
|
|
scroll_start_x = bevent->x + shell->offset_x;
|
|
|
|
scroll_start_y = bevent->y + shell->offset_y;
|
|
|
|
|
|
|
|
gtk_grab_add (canvas);
|
|
|
|
|
|
|
|
gimp_display_shell_install_override_cursor (shell, GDK_FLEUR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
state |= GDK_BUTTON3_MASK;
|
2001-11-30 22:41:56 +08:00
|
|
|
gimp_item_factory_popup_with_data (shell->ifactory,
|
|
|
|
gimage,
|
|
|
|
NULL);
|
2001-11-15 01:12:51 +08:00
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
2001-11-15 01:12:51 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
state &= ~GDK_BUTTON1_MASK;
|
|
|
|
|
|
|
|
gtk_grab_remove (canvas);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
if (active_tool && (! gimp_image_is_empty (gimage) ||
|
2001-11-30 00:44:51 +08:00
|
|
|
active_tool->handle_empty_image))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
if (active_tool->state == ACTIVE)
|
|
|
|
{
|
|
|
|
if (active_tool->auto_snap_to)
|
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_button_release_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, time, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
|
|
|
|
/* restore the tool's modifier state because it didn't get
|
|
|
|
* key events while BUTTON1 was down
|
|
|
|
*/
|
|
|
|
if ((press_state & GDK_SHIFT_MASK) != (state & GDK_SHIFT_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
(state & GDK_SHIFT_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((press_state & GDK_CONTROL_MASK) != (state & GDK_CONTROL_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
|
|
|
GDK_CONTROL_MASK,
|
|
|
|
(state & GDK_CONTROL_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((press_state & GDK_MOD1_MASK) != (state & GDK_MOD1_MASK))
|
|
|
|
{
|
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
|
|
|
GDK_MOD1_MASK,
|
|
|
|
(state & GDK_MOD1_MASK) ?
|
|
|
|
TRUE : FALSE,
|
|
|
|
state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2001-11-15 01:12:51 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
state &= ~GDK_BUTTON2_MASK;
|
|
|
|
|
|
|
|
scrolling = FALSE;
|
|
|
|
|
|
|
|
scroll_start_x = 0;
|
|
|
|
scroll_start_y = 0;
|
|
|
|
|
|
|
|
gtk_grab_remove (canvas);
|
|
|
|
|
|
|
|
gimp_display_shell_remove_override_cursor (shell);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
state &= ~GDK_BUTTON3_MASK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-08-10 00:39:08 +08:00
|
|
|
break;
|
1999-07-10 07:03:11 +08:00
|
|
|
|
2001-08-10 00:39:08 +08:00
|
|
|
case GDK_SCROLL:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventScroll *sevent;
|
|
|
|
|
|
|
|
sevent = (GdkEventScroll *) event;
|
|
|
|
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
if (sevent->direction == GDK_SCROLL_UP)
|
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_IN);
|
|
|
|
else
|
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
|
|
|
adj = shell->hsbdata;
|
|
|
|
else
|
|
|
|
adj = shell->vsbdata;
|
|
|
|
|
|
|
|
value = adj->value + ((sevent->direction == GDK_SCROLL_UP) ?
|
|
|
|
-adj->page_increment / 2 :
|
|
|
|
adj->page_increment / 2);
|
|
|
|
value = CLAMP (value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
return_val = TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventMotion *mevent;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* Ask for the pointer position, but ignore it except for cursor
|
|
|
|
* handling, so motion events sync with the button press/release events
|
|
|
|
*/
|
|
|
|
if (mevent->is_hint)
|
|
|
|
{
|
|
|
|
gimp_display_shell_get_device_coords (shell,
|
|
|
|
mevent->device,
|
|
|
|
&display_coords);
|
|
|
|
}
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
|
|
|
|
if (! shell->proximity)
|
|
|
|
{
|
|
|
|
shell->proximity = TRUE;
|
|
|
|
gimp_display_shell_check_device_cursor (shell);
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
2001-11-30 00:44:51 +08:00
|
|
|
|
2001-11-15 01:12:51 +08:00
|
|
|
if ((state & GDK_BUTTON1_MASK) &&
|
2001-11-30 22:41:56 +08:00
|
|
|
active_tool && (! gimp_image_is_empty (gimage) ||
|
2001-11-30 00:44:51 +08:00
|
|
|
active_tool->handle_empty_image))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
if (active_tool->state == ACTIVE)
|
|
|
|
{
|
|
|
|
/* if the first mouse button is down, check for automatic
|
|
|
|
* scrolling...
|
|
|
|
*/
|
|
|
|
if ((mevent->x < 0 ||
|
|
|
|
mevent->y < 0 ||
|
|
|
|
mevent->x > shell->disp_width ||
|
|
|
|
mevent->y > shell->disp_height) &&
|
|
|
|
! active_tool->scroll_lock)
|
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
off_x = off_y = 0;
|
|
|
|
|
|
|
|
/* The cases for scrolling */
|
|
|
|
if (mevent->x < 0)
|
|
|
|
off_x = mevent->x;
|
|
|
|
else if (mevent->x > shell->disp_width)
|
|
|
|
off_x = mevent->x - shell->disp_width;
|
|
|
|
|
|
|
|
if (mevent->y < 0)
|
|
|
|
off_y = mevent->y;
|
|
|
|
else if (mevent->y > shell->disp_height)
|
|
|
|
off_y = mevent->y - shell->disp_height;
|
|
|
|
|
|
|
|
if (gimp_display_shell_scroll (shell, off_x, off_y))
|
|
|
|
{
|
|
|
|
GimpCoords device_coords;
|
|
|
|
|
|
|
|
gimp_display_shell_get_device_coords (shell,
|
|
|
|
mevent->device,
|
|
|
|
&device_coords);
|
|
|
|
|
|
|
|
if (device_coords.x == mevent->x &&
|
|
|
|
device_coords.y == mevent->y)
|
|
|
|
{
|
|
|
|
/* Put this event back on the queue
|
|
|
|
* so it keeps scrolling
|
|
|
|
*/
|
|
|
|
gdk_event_put ((GdkEvent *) mevent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_tool->auto_snap_to)
|
|
|
|
{
|
|
|
|
gimp_display_shell_snap_point (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y,
|
|
|
|
&display_coords.x,
|
|
|
|
&display_coords.y);
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_coords (shell,
|
|
|
|
&display_coords,
|
|
|
|
&image_coords);
|
|
|
|
|
|
|
|
update_cursor = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_motion_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, time, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((state & GDK_BUTTON2_MASK) && scrolling)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
(scroll_start_x - mevent->x -
|
|
|
|
shell->offset_x),
|
|
|
|
(scroll_start_y - mevent->y -
|
|
|
|
shell->offset_y));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KEY_PRESS:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventKey *kevent;
|
|
|
|
|
|
|
|
kevent = (GdkEventKey *) event;
|
|
|
|
|
|
|
|
/* ignore any key presses */
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* do not process any key event while BUTTON1 is down. We do this
|
|
|
|
* so tools keep the modifier state they were in when BUTTON1 was
|
|
|
|
* pressed and to prevent accelerators from being invoked.
|
|
|
|
*/
|
|
|
|
if (state & GDK_BUTTON1_MASK)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
GdkModifierType key;
|
|
|
|
|
|
|
|
case GDK_Left: case GDK_Right:
|
|
|
|
case GDK_Up: case GDK_Down:
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_arrow_key_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
kevent,
|
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Tab:
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
gimp_display_shell_layer_select_init (gdisp->gimage,
|
|
|
|
1, kevent->time);
|
|
|
|
}
|
|
|
|
else if (state & GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
gimp_display_shell_layer_select_init (gdisp->gimage,
|
|
|
|
-1, kevent->time);
|
|
|
|
}
|
2001-11-15 01:12:51 +08:00
|
|
|
}
|
|
|
|
else if (! state)
|
|
|
|
{
|
|
|
|
/* Hide or show all dialogs */
|
|
|
|
|
|
|
|
gimp_dialog_factories_toggle (global_dialog_factory,
|
|
|
|
"gimp:toolbox");
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Update the state based on modifiers being pressed */
|
|
|
|
case GDK_Alt_L: case GDK_Alt_R:
|
|
|
|
case GDK_Shift_L: case GDK_Shift_R:
|
|
|
|
case GDK_Control_L: case GDK_Control_R:
|
|
|
|
key = gimp_display_shell_key_to_state (kevent->keyval);
|
|
|
|
state |= key;
|
|
|
|
|
|
|
|
/* For all modifier keys: call the tools modifier_key *and*
|
|
|
|
* oper_update method so tools can choose if they are interested
|
|
|
|
* in the release itself or only in the resulting state
|
|
|
|
*/
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-21 11:54:09 +08:00
|
|
|
key, TRUE, state,
|
2001-11-15 01:12:51 +08:00
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_oper_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_KEY_RELEASE:
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
|
|
|
GdkEventKey *kevent;
|
|
|
|
|
|
|
|
kevent = (GdkEventKey *) event;
|
|
|
|
|
|
|
|
/* ignore any key releases */
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* do not process any key event while BUTTON1 is down. We do this
|
|
|
|
* so tools keep the modifier state they were in when BUTTON1 was
|
|
|
|
* pressed and to prevent accelerators from being invoked.
|
|
|
|
*/
|
|
|
|
if (state & GDK_BUTTON1_MASK)
|
2001-11-15 01:12:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
GdkModifierType key;
|
|
|
|
|
|
|
|
/* Update the state based on modifiers being pressed */
|
|
|
|
case GDK_Alt_L: case GDK_Alt_R:
|
|
|
|
case GDK_Shift_L: case GDK_Shift_R:
|
|
|
|
case GDK_Control_L: case GDK_Control_R:
|
|
|
|
key = gimp_display_shell_key_to_state (kevent->keyval);
|
|
|
|
state &= ~key;
|
|
|
|
|
|
|
|
/* For all modifier keys: call the tools modifier_key *and*
|
|
|
|
* oper_update method so tools can choose if they are interested
|
|
|
|
* in the press itself or only in the resulting state
|
|
|
|
*/
|
2001-11-30 22:41:56 +08:00
|
|
|
if (! gimp_image_is_empty (gimage))
|
2001-11-15 01:12:51 +08:00
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_modifier_key_active (gimage->gimp,
|
2001-11-21 11:54:09 +08:00
|
|
|
key, FALSE, state,
|
2001-11-15 01:12:51 +08:00
|
|
|
gdisp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tool_manager_oper_update_active (gdisp->gimage->gimp,
|
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-03-26 02:19:40 +08:00
|
|
|
/* if we reached this point in gimp_busy mode, return now */
|
2001-11-30 22:41:56 +08:00
|
|
|
if (gimage->gimp->busy)
|
2000-03-26 02:17:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
/* cursor update support */
|
|
|
|
|
2001-08-07 20:42:23 +08:00
|
|
|
if (! gimprc.no_cursor_updating)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-15 01:12:51 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (active_tool)
|
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
if ((! gimp_image_is_empty (gimage) ||
|
2001-11-30 00:44:51 +08:00
|
|
|
active_tool->handle_empty_image) &&
|
2001-11-09 03:14:51 +08:00
|
|
|
! (state & (GDK_BUTTON1_MASK |
|
|
|
|
GDK_BUTTON2_MASK |
|
|
|
|
GDK_BUTTON3_MASK)))
|
|
|
|
{
|
2001-11-30 22:41:56 +08:00
|
|
|
tool_manager_cursor_update_active (gimage->gimp,
|
2001-11-15 01:12:51 +08:00
|
|
|
&image_coords, state,
|
|
|
|
gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
else if (gimp_image_is_empty (gimage))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_install_tool_cursor (shell,
|
|
|
|
GIMP_BAD_CURSOR,
|
|
|
|
active_tool->tool_cursor,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_display_shell_install_tool_cursor (shell,
|
2001-11-01 05:20:09 +08:00
|
|
|
GIMP_BAD_CURSOR,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-07-16 11:23:14 +08:00
|
|
|
if (update_cursor)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_update_cursor (shell,
|
|
|
|
display_coords.x,
|
|
|
|
display_coords.y);
|
|
|
|
}
|
1998-06-06 11:49:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_hruler_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
if (gdisp->gimage->gimp->busy)
|
2000-03-26 02:17:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (event->button == 1)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpTool *active_tool;
|
1998-03-13 11:35:33 +08:00
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
|
|
|
|
"gimp:move_tool");
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
|
|
|
|
tool_info);
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
|
|
|
|
|
|
|
if (active_tool)
|
|
|
|
{
|
|
|
|
gimp_move_tool_start_hguide (active_tool, gdisp);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_grab_add (shell->canvas);
|
2001-07-08 01:36:00 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_vruler_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
if (gdisp->gimage->gimp->busy)
|
2000-03-26 02:17:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (event->button == 1)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
|
|
|
|
"gimp:move_tool");
|
2001-07-08 01:36:00 +08:00
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
|
|
|
|
tool_info);
|
1998-03-13 11:35:33 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
if (active_tool)
|
|
|
|
{
|
|
|
|
gimp_move_tool_start_vguide (active_tool, gdisp);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_grab_add (shell->canvas);
|
2001-07-08 01:36:00 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1998-06-09 17:20:46 +08:00
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_origin_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1998-06-09 17:20:46 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = shell->gdisp;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
if (! gdisp->gimage->gimp->busy && event->button == 1)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2001-04-21 00:27:44 +08:00
|
|
|
gint x, y;
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_origin_menu_position (GTK_MENU (shell->ifactory->widget),
|
|
|
|
&x, &y, widget);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_item_factory_popup_with_data (shell->ifactory,
|
2001-11-30 22:41:56 +08:00
|
|
|
gdisp->gimage,
|
|
|
|
NULL,
|
2001-04-21 00:27:44 +08:00
|
|
|
x, y,
|
|
|
|
1, event->time);
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-29 22:09:50 +08:00
|
|
|
/* Return TRUE to stop signal emission so the button doesn't grab the
|
2001-08-07 20:42:23 +08:00
|
|
|
* pointer away from us.
|
|
|
|
*/
|
2001-07-29 22:09:50 +08:00
|
|
|
return TRUE;
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
2001-11-16 23:08:59 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_color_changed (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GdkColor color;
|
|
|
|
guchar r, g, b;
|
|
|
|
|
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget),
|
|
|
|
&shell->padding_color);
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (&shell->padding_color, &r, &g, &b);
|
|
|
|
|
|
|
|
color.red = r + r * 256;
|
|
|
|
color.green = g + g * 256;
|
|
|
|
color.blue = b + b * 256;
|
|
|
|
|
|
|
|
gdk_gc_set_rgb_fg_color (shell->padding_gc, &color);
|
|
|
|
|
|
|
|
gimp_display_shell_expose_full (shell);
|
|
|
|
gimp_display_shell_flush (shell);
|
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = shell->gdisp;
|
|
|
|
|
|
|
|
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3))
|
|
|
|
{
|
|
|
|
GtkItemFactory *factory;
|
|
|
|
|
|
|
|
factory = gtk_item_factory_from_path ("<QMask>");
|
|
|
|
|
|
|
|
gimp_item_factory_popup_with_data (factory, shell, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_qmask_toggled (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_image_set_qmask_state (shell->gdisp->gimage,
|
|
|
|
GTK_TOGGLE_BUTTON (widget)->active);
|
|
|
|
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
2001-12-01 00:39:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell, 0, (adjustment->value - shell->offset_y));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll (shell, (adjustment->value - shell->offset_x), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_get_coords (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
/* initialize extended axes to something meaningful because each of
|
|
|
|
* the following *_get_axis() calls may return FALSE and leave the
|
|
|
|
* passed gdouble location untouched
|
|
|
|
*/
|
|
|
|
coords->pressure = 1.0;
|
|
|
|
coords->xtilt = 0.5;
|
|
|
|
coords->ytilt = 0.5;
|
|
|
|
coords->wheel = 0.5;
|
|
|
|
|
|
|
|
if (gdk_event_get_axis (event, GDK_AXIS_X, &coords->x))
|
|
|
|
{
|
|
|
|
gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y);
|
|
|
|
gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure);
|
|
|
|
gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt);
|
|
|
|
gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt);
|
|
|
|
gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_get_device_coords (shell, device, coords);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
gdouble axes[GDK_AXIS_LAST];
|
|
|
|
|
|
|
|
gdk_device_get_state (device, shell->canvas->window, axes, NULL);
|
|
|
|
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_PRESSURE, &coords->pressure);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_XTILT, &coords->xtilt);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_YTILT, &coords->ytilt);
|
|
|
|
gdk_device_get_axis (device, axes, GDK_AXIS_WHEEL, &coords->wheel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_get_state (GimpDisplayShell *shell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state)
|
|
|
|
{
|
|
|
|
if (gdk_event_get_state (event, state))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_get_device_state (shell, device, state);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkModifierType *state)
|
|
|
|
{
|
|
|
|
gdk_device_get_state (device, shell->canvas->window, NULL, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkModifierType
|
|
|
|
gimp_display_shell_key_to_state (gint key)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case GDK_Alt_L:
|
|
|
|
case GDK_Alt_R:
|
|
|
|
return GDK_MOD1_MASK;
|
|
|
|
case GDK_Shift_L:
|
|
|
|
case GDK_Shift_R:
|
|
|
|
return GDK_SHIFT_MASK;
|
|
|
|
case GDK_Control_L:
|
|
|
|
case GDK_Control_R:
|
|
|
|
return GDK_CONTROL_MASK;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_origin_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *origin;
|
|
|
|
gint origin_x;
|
|
|
|
gint origin_y;
|
|
|
|
|
|
|
|
origin = (GtkWidget *) data;
|
|
|
|
|
|
|
|
gdk_window_get_origin (origin->window, &origin_x, &origin_y);
|
|
|
|
|
|
|
|
*x = origin_x + origin->allocation.x + origin->allocation.width - 1;
|
|
|
|
*y = origin_y + origin->allocation.y + (origin->allocation.height - 1) / 2;
|
|
|
|
|
|
|
|
if (*x + GTK_WIDGET (menu)->allocation.width > gdk_screen_width ())
|
|
|
|
*x -= (GTK_WIDGET (menu)->allocation.width + origin->allocation.width);
|
|
|
|
|
|
|
|
if (*y + GTK_WIDGET (menu)->allocation.height > gdk_screen_height ())
|
|
|
|
*y -= (GTK_WIDGET (menu)->allocation.height);
|
|
|
|
}
|