1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools/tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2001-05-14 05:51:20 +08:00
|
|
|
#include "widgets/gimpcursor.h"
|
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gdisplay.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "scale.h"
|
|
|
|
#include "scroll.h"
|
1999-08-13 06:21:04 +08:00
|
|
|
#include "nav_window.h"
|
2001-01-22 09:46:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* This is the delay before dithering begins
|
|
|
|
* for example, after an operation such as scrolling
|
|
|
|
*/
|
|
|
|
#define DITHER_DELAY 250 /* milliseconds */
|
|
|
|
|
|
|
|
/* STATIC variables */
|
|
|
|
/* These are the values of the initial pointer grab */
|
2001-01-23 04:46:50 +08:00
|
|
|
static gint startx, starty;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
start_grab_and_scroll (GDisplay *gdisp,
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
{
|
2001-05-14 05:51:20 +08:00
|
|
|
GdkCursor *cursor;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
startx = bevent->x + gdisp->offset_x;
|
|
|
|
starty = bevent->y + gdisp->offset_y;
|
|
|
|
|
2001-05-14 05:51:20 +08:00
|
|
|
cursor = gimp_cursor_new (GDK_FLEUR,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
gdk_window_set_cursor (gdisp->canvas->window, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
end_grab_and_scroll (GDisplay *gdisp,
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
{
|
2000-06-09 20:31:19 +08:00
|
|
|
gdisplay_real_install_tool_cursor (gdisp,
|
|
|
|
gdisp->current_cursor,
|
2001-02-25 03:29:47 +08:00
|
|
|
gdisp->tool_cursor,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE,
|
2000-06-09 20:31:19 +08:00
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
grab_and_scroll (GDisplay *gdisp,
|
|
|
|
GdkEventMotion *mevent)
|
|
|
|
{
|
2000-06-09 20:31:19 +08:00
|
|
|
if (mevent && mevent->window != gdisp->canvas->window)
|
2001-01-23 04:46:50 +08:00
|
|
|
return;
|
1999-04-06 07:33:50 +08:00
|
|
|
|
2000-06-09 20:31:19 +08:00
|
|
|
scroll_display (gdisp,
|
|
|
|
startx - mevent->x - gdisp->offset_x,
|
|
|
|
starty - mevent->y - gdisp->offset_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
scroll_to_pointer_position (GDisplay *gdisp,
|
|
|
|
GdkEventMotion *mevent)
|
|
|
|
{
|
2001-01-23 04:46:50 +08:00
|
|
|
gdouble child_x, child_y;
|
|
|
|
gint off_x, off_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
off_x = off_y = 0;
|
|
|
|
|
|
|
|
/* The cases for scrolling */
|
|
|
|
if (mevent->x < 0)
|
|
|
|
off_x = mevent->x;
|
|
|
|
else if (mevent->x > gdisp->disp_width)
|
|
|
|
off_x = mevent->x - gdisp->disp_width;
|
2001-01-23 04:46:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (mevent->y < 0)
|
|
|
|
off_y = mevent->y;
|
|
|
|
else if (mevent->y > gdisp->disp_height)
|
|
|
|
off_y = mevent->y - gdisp->disp_height;
|
|
|
|
|
|
|
|
if (scroll_display (gdisp, off_x, off_y))
|
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: replace gdk_input_window_get_pointer()
|
|
|
|
#endif
|
|
|
|
#if 0
|
1998-06-06 11:49:01 +08:00
|
|
|
gdk_input_window_get_pointer (gdisp->canvas->window, mevent->deviceid,
|
|
|
|
&child_x, &child_y,
|
|
|
|
NULL, NULL, NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (child_x == mevent->x && child_y == mevent->y)
|
|
|
|
/* Put this event back on the queue -- so it keeps scrolling */
|
|
|
|
gdk_event_put ((GdkEvent *) mevent);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-23 04:46:50 +08:00
|
|
|
gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
scroll_display (GDisplay *gdisp,
|
1999-08-13 06:21:04 +08:00
|
|
|
gint x_offset,
|
|
|
|
gint y_offset)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-23 04:46:50 +08:00
|
|
|
gint old_x, old_y;
|
|
|
|
gint src_x, src_y;
|
|
|
|
gint dest_x, dest_y;
|
1997-12-18 14:30:11 +08:00
|
|
|
GdkEvent *event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
old_x = gdisp->offset_x;
|
|
|
|
old_y = gdisp->offset_y;
|
|
|
|
|
|
|
|
gdisp->offset_x += x_offset;
|
|
|
|
gdisp->offset_y += y_offset;
|
|
|
|
|
|
|
|
bounds_checking (gdisp);
|
|
|
|
|
|
|
|
/* the actual changes in offset */
|
|
|
|
x_offset = (gdisp->offset_x - old_x);
|
|
|
|
y_offset = (gdisp->offset_y - old_y);
|
|
|
|
|
|
|
|
if (x_offset || y_offset)
|
|
|
|
{
|
|
|
|
setup_scale (gdisp);
|
|
|
|
|
|
|
|
src_x = (x_offset < 0) ? 0 : x_offset;
|
|
|
|
src_y = (y_offset < 0) ? 0 : y_offset;
|
|
|
|
dest_x = (x_offset < 0) ? -x_offset : 0;
|
|
|
|
dest_y = (y_offset < 0) ? -y_offset : 0;
|
|
|
|
|
|
|
|
/* reset the old values so that the tool can accurately redraw */
|
|
|
|
gdisp->offset_x = old_x;
|
|
|
|
gdisp->offset_y = old_y;
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
/* freeze the active tool */
|
|
|
|
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set the offsets back to the new values */
|
|
|
|
gdisp->offset_x += x_offset;
|
|
|
|
gdisp->offset_y += y_offset;
|
|
|
|
|
|
|
|
gdk_draw_pixmap (gdisp->canvas->window,
|
1997-12-18 14:30:11 +08:00
|
|
|
gdisp->scroll_gc,
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisp->canvas->window,
|
|
|
|
src_x, src_y,
|
|
|
|
dest_x, dest_y,
|
|
|
|
(gdisp->disp_width - abs (x_offset)),
|
|
|
|
(gdisp->disp_height - abs (y_offset)));
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
/* re-enable the active tool */
|
|
|
|
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* scale the image into the exposed regions */
|
|
|
|
if (x_offset)
|
|
|
|
{
|
|
|
|
src_x = (x_offset < 0) ? 0 : gdisp->disp_width - x_offset;
|
|
|
|
src_y = 0;
|
|
|
|
gdisplay_expose_area (gdisp,
|
|
|
|
src_x, src_y,
|
|
|
|
abs (x_offset), gdisp->disp_height);
|
|
|
|
}
|
|
|
|
if (y_offset)
|
|
|
|
{
|
|
|
|
src_x = 0;
|
|
|
|
src_y = (y_offset < 0) ? 0 : gdisp->disp_height - y_offset;
|
|
|
|
gdisplay_expose_area (gdisp,
|
|
|
|
src_x, src_y,
|
|
|
|
gdisp->disp_width, abs (y_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x_offset || y_offset)
|
|
|
|
gdisplays_flush ();
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
|
|
|
|
|
|
|
if (gdisp->nav_popup)
|
|
|
|
nav_dialog_update_window_marker (gdisp->nav_popup);
|
1997-12-18 14:30:11 +08:00
|
|
|
|
|
|
|
/* Make sure graphics expose events are processed before scrolling
|
2001-06-18 21:10:03 +08:00
|
|
|
* again
|
|
|
|
*/
|
|
|
|
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window)))
|
|
|
|
{
|
|
|
|
gtk_widget_event (gdisp->canvas, event);
|
|
|
|
|
|
|
|
if (event->expose.count == 0)
|
|
|
|
{
|
|
|
|
gdk_event_free (event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_event_free (event);
|
|
|
|
}
|
1997-12-18 14:30:11 +08:00
|
|
|
|
2001-01-23 04:46:50 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-01-23 04:46:50 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|