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-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
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-02-21 20:18:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-13 20:52:30 +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-scale.h"
|
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-23 04:46:50 +08:00
|
|
|
gboolean
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scroll (GimpDisplayShell *shell,
|
|
|
|
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;
|
1997-12-18 14:30:11 +08:00
|
|
|
GdkEvent *event;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
old_x = shell->offset_x;
|
|
|
|
old_y = shell->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
shell->offset_x += x_offset;
|
|
|
|
shell->offset_y += y_offset;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scroll_clamp_offsets (shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* the actual changes in offset */
|
2001-11-02 17:31:21 +08:00
|
|
|
x_offset = (shell->offset_x - old_x);
|
|
|
|
y_offset = (shell->offset_y - old_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (x_offset || y_offset)
|
|
|
|
{
|
2001-10-13 20:52:30 +08:00
|
|
|
/* FIXME: I'm sure this is useless if all other places are correct --mitch
|
|
|
|
*/
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale_setup (shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* reset the old values so that the tool can accurately redraw */
|
2001-11-02 17:31:21 +08:00
|
|
|
shell->offset_x = old_x;
|
|
|
|
shell->offset_y = old_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
|
|
|
|
shell->gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gdk_window_scroll (shell->canvas->window, -x_offset, -y_offset);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* set the offsets back to the new values */
|
2001-11-02 17:31:21 +08:00
|
|
|
shell->offset_x += x_offset;
|
|
|
|
shell->offset_y += y_offset;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
|
|
|
|
shell->gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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
|
|
|
|
*/
|
2001-11-01 05:20:09 +08:00
|
|
|
while ((event = gdk_event_get_graphics_expose (shell->canvas->window)))
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-11-02 18:55:10 +08:00
|
|
|
gdk_window_invalidate_rect (shell->canvas->window,
|
|
|
|
&event->expose.area,
|
|
|
|
FALSE);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-02 18:55:10 +08:00
|
|
|
if (event->expose.count == 0)
|
|
|
|
{
|
|
|
|
gdk_event_free (event);
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gdk_event_free (event);
|
|
|
|
}
|
1997-12-18 14:30:11 +08:00
|
|
|
|
2001-11-02 18:55:10 +08:00
|
|
|
gdk_window_process_updates (shell->canvas->window, FALSE);
|
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gimp_display_shell_scrolled (shell);
|
|
|
|
|
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
|
|
|
}
|
2001-10-13 20:52:30 +08:00
|
|
|
|
|
|
|
void
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
|
2001-10-13 20:52:30 +08:00
|
|
|
{
|
|
|
|
gint sx, sy;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
sx = SCALEX (shell, shell->gdisp->gimage->width);
|
|
|
|
sy = SCALEY (shell, shell->gdisp->gimage->height);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
shell->offset_x = CLAMP (shell->offset_x, 0,
|
|
|
|
MAX (sx - shell->disp_width, 0));
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
shell->offset_y = CLAMP (shell->offset_y, 0,
|
|
|
|
MAX (sy - shell->disp_height, 0));
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|