2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
#include <stdlib.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2007-03-09 13:00:01 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2008-08-03 11:35:53 +00:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2001-07-07 17:36:00 +00:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2008-08-22 15:57:41 +00:00
|
|
|
#include "gimpcanvas.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-13 12:52:30 +00:00
|
|
|
#include "gimpdisplay-foreach.h"
|
2001-10-31 21:20:09 +00:00
|
|
|
#include "gimpdisplayshell.h"
|
2009-10-02 23:55:26 +02:00
|
|
|
#include "gimpdisplayshell-expose.h"
|
2016-07-16 19:21:56 +00:00
|
|
|
#include "gimpdisplayshell-rotate.h"
|
2016-01-05 18:02:59 +01:00
|
|
|
#include "gimpdisplayshell-rulers.h"
|
2003-03-21 16:28:06 +00:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2001-11-02 09:31:21 +00:00
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2016-01-05 18:02:59 +01:00
|
|
|
#include "gimpdisplayshell-scrollbars.h"
|
2016-01-05 15:14:08 +01:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2016-01-05 18:02:59 +01:00
|
|
|
#define OVERPAN_FACTOR 0.5
|
2008-07-12 14:48:09 +00:00
|
|
|
|
|
|
|
|
2016-01-05 17:33:22 +01:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll:
|
|
|
|
* @shell:
|
|
|
|
* @x_offset:
|
|
|
|
* @y_offset:
|
|
|
|
*
|
|
|
|
* This function scrolls the image in the shell's viewport. It does
|
|
|
|
* actual scrolling of the pixels, so only the newly scrolled-in parts
|
|
|
|
* are freshly redrawn.
|
|
|
|
*
|
|
|
|
* Use it for incremental actual panning.
|
|
|
|
**/
|
2008-07-10 18:44:30 +00:00
|
|
|
void
|
2008-08-10 11:11:19 +00:00
|
|
|
gimp_display_shell_scroll (GimpDisplayShell *shell,
|
|
|
|
gint x_offset,
|
|
|
|
gint y_offset)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-02-21 13:07:15 +00:00
|
|
|
gint old_x;
|
|
|
|
gint old_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2008-07-10 18:44:30 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2001-10-13 12:52:30 +00:00
|
|
|
|
2008-08-26 17:53:54 +00:00
|
|
|
if (x_offset == 0 && y_offset == 0)
|
|
|
|
return;
|
|
|
|
|
2001-11-02 09:31:21 +00:00
|
|
|
old_x = shell->offset_x;
|
|
|
|
old_y = shell->offset_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2016-01-05 17:33:22 +01:00
|
|
|
/* freeze the active tool */
|
|
|
|
gimp_display_shell_pause (shell);
|
|
|
|
|
2001-11-02 09:31:21 +00:00
|
|
|
shell->offset_x += x_offset;
|
|
|
|
shell->offset_y += y_offset;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2016-01-05 17:33:22 +01:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* the actual changes in offset */
|
2001-11-02 09:31:21 +00:00
|
|
|
x_offset = (shell->offset_x - old_x);
|
|
|
|
y_offset = (shell->offset_y - old_y);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
if (x_offset || y_offset)
|
|
|
|
{
|
2016-01-05 20:29:54 +01:00
|
|
|
gimp_display_shell_scrolled (shell);
|
|
|
|
|
2009-10-18 22:19:29 +02:00
|
|
|
gimp_overlay_box_scroll (GIMP_OVERLAY_BOX (shell->canvas),
|
|
|
|
-x_offset, -y_offset);
|
2003-03-07 12:34:40 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2016-01-05 17:33:22 +01:00
|
|
|
|
|
|
|
/* re-enable the active tool */
|
|
|
|
gimp_display_shell_resume (shell);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2001-10-13 12:52:30 +00:00
|
|
|
|
2016-01-05 17:33:22 +01:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll_set_offsets:
|
|
|
|
* @shell:
|
|
|
|
* @offset_x:
|
|
|
|
* @offset_y:
|
|
|
|
*
|
|
|
|
* This function scrolls the image in the shell's viewport. It redraws
|
|
|
|
* the entire canvas.
|
|
|
|
*
|
|
|
|
* Use it for setting the scroll offset on freshly scaled images or
|
|
|
|
* when the window is resized. For panning, use
|
|
|
|
* gimp_display_shell_scroll().
|
|
|
|
**/
|
2008-08-10 13:09:24 +00:00
|
|
|
void
|
|
|
|
gimp_display_shell_scroll_set_offset (GimpDisplayShell *shell,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
if (shell->offset_x == offset_x &&
|
|
|
|
shell->offset_y == offset_y)
|
|
|
|
return;
|
|
|
|
|
2016-01-05 19:18:40 +01:00
|
|
|
gimp_display_shell_scale_save_revert_values (shell);
|
2008-08-10 13:09:24 +00:00
|
|
|
|
|
|
|
/* freeze the active tool */
|
|
|
|
gimp_display_shell_pause (shell);
|
|
|
|
|
|
|
|
shell->offset_x = offset_x;
|
|
|
|
shell->offset_y = offset_y;
|
|
|
|
|
2008-08-14 14:41:29 +00:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
|
|
|
|
2016-01-05 17:33:22 +01:00
|
|
|
gimp_display_shell_scrolled (shell);
|
|
|
|
|
2016-01-05 20:29:54 +01:00
|
|
|
gimp_display_shell_expose_full (shell);
|
|
|
|
|
2008-08-10 13:09:24 +00:00
|
|
|
/* re-enable the active tool */
|
|
|
|
gimp_display_shell_resume (shell);
|
|
|
|
}
|
|
|
|
|
2016-01-05 17:38:56 +01:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll_clamp_and_update:
|
|
|
|
* @shell:
|
|
|
|
*
|
|
|
|
* Helper function for calling two functions that are commonly called
|
|
|
|
* in pairs.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_scroll_clamp_and_update (GimpDisplayShell *shell)
|
2001-10-13 12:52:30 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image;
|
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2001-10-13 12:52:30 +00:00
|
|
|
|
2009-10-06 19:20:44 +02:00
|
|
|
image = gimp_display_get_image (shell->display);
|
|
|
|
|
|
|
|
if (image)
|
2008-03-18 21:22:21 +00:00
|
|
|
{
|
2016-07-16 19:21:56 +00:00
|
|
|
gdouble dx, dy;
|
|
|
|
gdouble dw, dh;
|
|
|
|
gint min_offset_x;
|
|
|
|
gint max_offset_x;
|
|
|
|
gint min_offset_y;
|
|
|
|
gint max_offset_y;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
|
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
|
|
|
|
gimp_display_shell_transform_bounds (shell,
|
|
|
|
0, 0,
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image),
|
|
|
|
&dx, &dy,
|
|
|
|
&dw, &dh);
|
|
|
|
|
|
|
|
/* Convert scrolled (x1, y1, x2, y2) to unscrolled (x, y, width, height). */
|
|
|
|
dw -= dx;
|
|
|
|
dh -= dy;
|
|
|
|
dx += shell->offset_x;
|
|
|
|
dy += shell->offset_y;
|
|
|
|
|
|
|
|
if (shell->disp_width < dw)
|
2008-07-12 07:00:46 +00:00
|
|
|
{
|
2016-07-16 19:21:56 +00:00
|
|
|
min_offset_x = dx - shell->disp_width * OVERPAN_FACTOR;
|
|
|
|
max_offset_x = dx + dw - shell->disp_width * (1.0 - OVERPAN_FACTOR);
|
2008-07-12 07:00:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-12 14:48:09 +00:00
|
|
|
gint overpan_amount;
|
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
overpan_amount = shell->disp_width - dw * (1.0 - OVERPAN_FACTOR);
|
2008-07-12 07:00:46 +00:00
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
min_offset_x = dx - overpan_amount;
|
|
|
|
max_offset_x = dx + dw + overpan_amount - shell->disp_width;
|
2008-07-12 07:00:46 +00:00
|
|
|
}
|
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
if (shell->disp_height < dh)
|
2008-07-12 07:00:46 +00:00
|
|
|
{
|
2016-07-16 19:21:56 +00:00
|
|
|
min_offset_y = dy - shell->disp_height * OVERPAN_FACTOR;
|
|
|
|
max_offset_y = dy + dh - shell->disp_height * (1.0 - OVERPAN_FACTOR);
|
2008-07-12 07:00:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-12 14:48:09 +00:00
|
|
|
gint overpan_amount;
|
2008-07-12 07:00:46 +00:00
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
overpan_amount = shell->disp_height - dh * (1.0 - OVERPAN_FACTOR);
|
2008-07-12 14:48:09 +00:00
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
min_offset_y = dy - overpan_amount;
|
|
|
|
max_offset_y = dy + dh + overpan_amount - shell->disp_height;
|
2008-07-12 07:00:46 +00:00
|
|
|
}
|
2008-07-12 14:48:09 +00:00
|
|
|
|
2008-07-13 14:48:44 +00:00
|
|
|
/* Clamp */
|
|
|
|
|
2016-07-16 19:21:56 +00:00
|
|
|
offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
|
|
|
|
offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);
|
|
|
|
|
|
|
|
if (offset_x != shell->offset_x || offset_y != shell->offset_y)
|
|
|
|
{
|
|
|
|
shell->offset_x = offset_x;
|
|
|
|
shell->offset_y = offset_y;
|
|
|
|
|
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
}
|
2016-01-05 20:53:34 +01:00
|
|
|
|
|
|
|
/* Set scrollbar stepper sensitiity */
|
|
|
|
|
|
|
|
gimp_display_shell_scrollbars_update_steppers (shell,
|
|
|
|
min_offset_x,
|
|
|
|
max_offset_x,
|
|
|
|
min_offset_y,
|
|
|
|
max_offset_y);
|
2008-03-18 21:22:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->offset_x = 0;
|
|
|
|
shell->offset_y = 0;
|
|
|
|
}
|
2013-04-18 18:45:55 +02:00
|
|
|
|
2016-01-05 18:02:59 +01:00
|
|
|
gimp_display_shell_scrollbars_update (shell);
|
|
|
|
gimp_display_shell_rulers_update (shell);
|
2008-08-14 14:41:29 +00:00
|
|
|
}
|
|
|
|
|
2008-08-26 18:50:54 +00:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll_unoverscrollify:
|
|
|
|
* @shell:
|
|
|
|
* @in_offset_x:
|
|
|
|
* @in_offset_y:
|
|
|
|
* @out_offset_x:
|
|
|
|
* @out_offset_y:
|
|
|
|
*
|
|
|
|
* Takes a scroll offset and returns the offset that will not result
|
|
|
|
* in a scroll beyond the image border. If the image is already
|
|
|
|
* overscrolled, the return value is 0 for that given axis.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_scroll_unoverscrollify (GimpDisplayShell *shell,
|
|
|
|
gint in_offset_x,
|
|
|
|
gint in_offset_y,
|
|
|
|
gint *out_offset_x,
|
|
|
|
gint *out_offset_y)
|
|
|
|
{
|
|
|
|
gint sw, sh;
|
|
|
|
gint out_offset_x_dummy, out_offset_y_dummy;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
if (! out_offset_x) out_offset_x = &out_offset_x_dummy;
|
|
|
|
if (! out_offset_y) out_offset_y = &out_offset_y_dummy;
|
|
|
|
|
|
|
|
*out_offset_x = in_offset_x;
|
|
|
|
*out_offset_y = in_offset_y;
|
|
|
|
|
2013-04-18 19:06:17 +02:00
|
|
|
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
2008-08-26 18:50:54 +00:00
|
|
|
|
|
|
|
if (in_offset_x < 0)
|
|
|
|
{
|
|
|
|
*out_offset_x = MAX (in_offset_x,
|
|
|
|
MIN (0, 0 - shell->offset_x));
|
|
|
|
}
|
|
|
|
else if (in_offset_x > 0)
|
|
|
|
{
|
|
|
|
gint min_offset = sw - shell->disp_width;
|
|
|
|
|
|
|
|
*out_offset_x = MIN (in_offset_x,
|
|
|
|
MAX (0, min_offset - shell->offset_x));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_offset_y < 0)
|
|
|
|
{
|
|
|
|
*out_offset_y = MAX (in_offset_y,
|
|
|
|
MIN (0, 0 - shell->offset_y));
|
|
|
|
}
|
|
|
|
else if (in_offset_y > 0)
|
|
|
|
{
|
2008-08-26 18:59:23 +00:00
|
|
|
gint min_offset = sh - shell->disp_height;
|
2008-08-26 18:50:54 +00:00
|
|
|
|
|
|
|
*out_offset_y = MIN (in_offset_y,
|
|
|
|
MAX (0, min_offset - shell->offset_y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll_center_image_xy:
|
|
|
|
* @shell:
|
|
|
|
* @image_x:
|
|
|
|
* @image_y:
|
|
|
|
*
|
|
|
|
* Center the viewport around the passed image coordinate
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_scroll_center_image_xy (GimpDisplayShell *shell,
|
|
|
|
gdouble image_x,
|
|
|
|
gdouble image_y)
|
|
|
|
{
|
|
|
|
gint viewport_x;
|
|
|
|
gint viewport_y;
|
|
|
|
|
|
|
|
gimp_display_shell_transform_xy (shell,
|
|
|
|
image_x, image_y,
|
|
|
|
&viewport_x, &viewport_y);
|
|
|
|
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
viewport_x - shell->disp_width / 2,
|
|
|
|
viewport_y - shell->disp_height / 2);
|
|
|
|
}
|
|
|
|
|
2008-08-10 07:23:14 +00:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_scroll_center_image:
|
|
|
|
* @shell:
|
|
|
|
* @horizontally:
|
|
|
|
* @vertically:
|
|
|
|
*
|
|
|
|
* Centers the image in the display shell on the desired axes.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_scroll_center_image (GimpDisplayShell *shell,
|
|
|
|
gboolean horizontally,
|
|
|
|
gboolean vertically)
|
|
|
|
{
|
2016-01-05 15:50:09 +01:00
|
|
|
GimpImage *image;
|
|
|
|
gint center_x;
|
|
|
|
gint center_y;
|
|
|
|
gint offset_x = 0;
|
|
|
|
gint offset_y = 0;
|
2008-08-10 07:23:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2009-10-06 19:20:44 +02:00
|
|
|
if (! shell->display ||
|
|
|
|
! gimp_display_get_image (shell->display) ||
|
2008-08-14 19:23:28 +00:00
|
|
|
(! vertically && ! horizontally))
|
2008-08-10 07:23:14 +00:00
|
|
|
return;
|
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
image = gimp_display_get_image (shell->display);
|
2008-08-10 07:23:14 +00:00
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_transform_xy (shell,
|
|
|
|
gimp_image_get_width (image) / 2,
|
|
|
|
gimp_image_get_height (image) / 2,
|
|
|
|
¢er_x,
|
|
|
|
¢er_y);
|
2008-08-10 07:23:14 +00:00
|
|
|
|
|
|
|
if (horizontally)
|
2016-01-05 15:50:09 +01:00
|
|
|
offset_x = center_x - shell->disp_width / 2;
|
2008-08-10 07:23:14 +00:00
|
|
|
|
|
|
|
if (vertically)
|
2016-01-05 15:50:09 +01:00
|
|
|
offset_y = center_y - shell->disp_height / 2;
|
2008-08-10 07:23:14 +00:00
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_scroll (shell, offset_x, offset_y);
|
2008-08-10 07:23:14 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
typedef struct
|
2008-08-10 07:23:14 +00:00
|
|
|
{
|
2016-01-05 15:50:09 +01:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gboolean vertically;
|
|
|
|
gboolean horizontally;
|
|
|
|
} CenterImageData;
|
2008-08-10 07:23:14 +00:00
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
static void
|
|
|
|
gimp_display_shell_scroll_center_image_callback (GtkWidget *canvas,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
CenterImageData *data)
|
|
|
|
{
|
2008-08-10 07:23:14 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (canvas,
|
|
|
|
gimp_display_shell_scroll_center_image_callback,
|
2008-08-16 18:50:38 +00:00
|
|
|
data);
|
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_scroll_center_image (data->shell,
|
|
|
|
data->horizontally,
|
|
|
|
data->vertically);
|
|
|
|
|
|
|
|
g_slice_free (CenterImageData, data);
|
2008-08-10 07:23:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-05 15:50:09 +01:00
|
|
|
* gimp_display_shell_scroll_center_image_on_size_allocate:
|
2008-08-10 07:23:14 +00:00
|
|
|
* @shell:
|
|
|
|
*
|
|
|
|
* Centers the image in the display as soon as the canvas has got its
|
2008-08-16 18:25:32 +00:00
|
|
|
* new size.
|
|
|
|
*
|
|
|
|
* Only call this if you are sure the canvas size will change.
|
|
|
|
* (Otherwise the signal connection and centering will lurk until the
|
|
|
|
* canvas size is changed e.g. by toggling the rulers.)
|
2008-08-10 07:23:14 +00:00
|
|
|
**/
|
|
|
|
void
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_scroll_center_image_on_size_allocate (GimpDisplayShell *shell,
|
|
|
|
gboolean horizontally,
|
|
|
|
gboolean vertically)
|
2008-08-10 07:23:14 +00:00
|
|
|
{
|
2016-01-05 15:50:09 +01:00
|
|
|
CenterImageData *data;
|
2008-08-16 18:50:38 +00:00
|
|
|
|
2008-08-10 07:23:14 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
data = g_slice_new (CenterImageData);
|
2008-09-04 08:37:32 +00:00
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
data->shell = shell;
|
|
|
|
data->horizontally = horizontally;
|
|
|
|
data->vertically = vertically;
|
2008-08-16 18:50:38 +00:00
|
|
|
|
2016-01-05 15:50:09 +01:00
|
|
|
g_signal_connect (shell->canvas, "size-allocate",
|
|
|
|
G_CALLBACK (gimp_display_shell_scroll_center_image_callback),
|
|
|
|
data);
|
2008-08-10 07:23:14 +00:00
|
|
|
}
|
|
|
|
|
2008-07-10 20:19:17 +00:00
|
|
|
/**
|
2008-08-10 09:08:11 +00:00
|
|
|
* gimp_display_shell_scroll_get_scaled_viewport:
|
2008-07-10 20:19:17 +00:00
|
|
|
* @shell:
|
|
|
|
* @x:
|
|
|
|
* @y:
|
|
|
|
* @w:
|
|
|
|
* @h:
|
|
|
|
*
|
|
|
|
* Gets the viewport in screen coordinates, with origin at (0, 0) in
|
2016-01-05 15:50:09 +01:00
|
|
|
* the image.
|
2008-07-10 20:19:17 +00:00
|
|
|
**/
|
|
|
|
void
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_scroll_get_scaled_viewport (GimpDisplayShell *shell,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *w,
|
|
|
|
gint *h)
|
2008-07-10 20:19:17 +00:00
|
|
|
{
|
2008-07-11 20:03:36 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2008-11-13 23:16:11 +00:00
|
|
|
*x = shell->offset_x;
|
|
|
|
*y = shell->offset_y;
|
|
|
|
*w = shell->disp_width;
|
|
|
|
*h = shell->disp_height;
|
2008-07-10 20:19:17 +00:00
|
|
|
}
|
2008-07-11 03:20:17 +00:00
|
|
|
|
|
|
|
/**
|
2008-08-10 09:08:11 +00:00
|
|
|
* gimp_display_shell_scroll_get_viewport:
|
2008-07-11 03:20:17 +00:00
|
|
|
* @shell:
|
|
|
|
* @x:
|
|
|
|
* @y:
|
|
|
|
* @w:
|
|
|
|
* @h:
|
|
|
|
*
|
2016-01-05 15:50:09 +01:00
|
|
|
* Gets the viewport in image coordinates.
|
2008-07-11 03:20:17 +00:00
|
|
|
**/
|
|
|
|
void
|
2016-01-05 15:50:09 +01:00
|
|
|
gimp_display_shell_scroll_get_viewport (GimpDisplayShell *shell,
|
|
|
|
gdouble *x,
|
|
|
|
gdouble *y,
|
|
|
|
gdouble *w,
|
|
|
|
gdouble *h)
|
2008-07-11 03:20:17 +00:00
|
|
|
{
|
2008-07-11 20:03:36 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2008-11-13 23:16:11 +00:00
|
|
|
*x = shell->offset_x / shell->scale_x;
|
|
|
|
*y = shell->offset_y / shell->scale_y;
|
|
|
|
*w = shell->disp_width / shell->scale_x;
|
|
|
|
*h = shell->disp_height / shell->scale_y;
|
2008-07-12 07:00:46 +00:00
|
|
|
}
|