2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
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"
|
|
|
|
|
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"
|
2003-03-22 00:28:06 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#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
|
|
|
{
|
2003-02-21 21:07:15 +08:00
|
|
|
gint old_x;
|
|
|
|
gint old_y;
|
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)
|
|
|
|
{
|
|
|
|
/* 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
|
|
|
|
2003-09-12 06:24:30 +08:00
|
|
|
gimp_display_shell_pause (shell);
|
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
|
|
|
|
2003-03-22 00:28:06 +08:00
|
|
|
gdk_window_scroll (shell->canvas->window, -x_offset, -y_offset);
|
|
|
|
|
2003-03-07 20:34:40 +08:00
|
|
|
/* Make sure expose events are processed before scrolling again */
|
|
|
|
gdk_window_process_updates (shell->canvas->window, FALSE);
|
|
|
|
|
2003-03-22 00:28:06 +08:00
|
|
|
/* Update scrollbars and rulers */
|
|
|
|
gimp_display_shell_scale_setup (shell);
|
|
|
|
|
2003-09-12 06:24:30 +08:00
|
|
|
gimp_display_shell_resume (shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (shell->display->image)
|
|
|
|
{
|
2008-07-05 23:43:39 +08:00
|
|
|
gint sw, sh;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2008-07-05 23:43:39 +08:00
|
|
|
sw = SCALEX (shell, gimp_image_get_width (shell->display->image));
|
|
|
|
sh = SCALEY (shell, gimp_image_get_height (shell->display->image));
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
shell->offset_x = CLAMP (shell->offset_x, 0,
|
2008-07-05 23:43:39 +08:00
|
|
|
MAX (sw - shell->disp_width, 0));
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
shell->offset_y = CLAMP (shell->offset_y, 0,
|
2008-07-05 23:43:39 +08:00
|
|
|
MAX (sh - shell->disp_height, 0));
|
2008-03-19 05:22:21 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->offset_x = 0;
|
|
|
|
shell->offset_y = 0;
|
|
|
|
}
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|