New function.

2008-08-26  Martin Nordholts  <martinn@svn.gnome.org>

	* app/display/gimpdisplayshell-scroll.c
	(gimp_display_shell_scroll_unoverscrollify): New function.

	* app/display/gimpdisplayshell-autoscroll.c
	(gimp_display_shell_autoscroll_timeout): Make sure the autoscroll
	does not result in overscroll. This more or less finalizes the
	implementation of the enhancement request in bug #362915.

svn path=/trunk/; revision=26775
This commit is contained in:
Martin Nordholts
2008-08-26 18:50:54 +00:00
committed by Martin Nordholts
parent ad693bbf9e
commit dd672dde70
4 changed files with 81 additions and 0 deletions

View File

@ -257,6 +257,66 @@ gimp_display_shell_scroll_clamp_and_update (GimpDisplayShell *shell)
gimp_display_shell_update_scrollbars_and_rulers (shell);
}
/**
* 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;
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
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)
{
gint min_offset = sh - shell->disp_width;
*out_offset_y = MIN (in_offset_y,
MAX (0, min_offset - shell->offset_y));
}
}
/**
* gimp_display_shell_scroll_center_image:
* @shell: