Commit dd672dde authored by Martin Nordholts's avatar Martin Nordholts Committed by Martin Nordholts

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
parent ad693bbf
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.
2008-08-26 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell-scroll.c
......
......@@ -137,6 +137,12 @@ gimp_display_shell_autoscroll_timeout (gpointer data)
info->time += AUTOSCROLL_DT;
gimp_display_shell_scroll_unoverscrollify (shell,
scroll_amount_x,
scroll_amount_y,
&scroll_amount_x,
&scroll_amount_y);
gimp_display_shell_scroll (shell,
scroll_amount_x,
scroll_amount_y);
......
......@@ -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:
......
......@@ -31,6 +31,11 @@ void gimp_display_shell_scroll_set_offset (GimpDisplayShell
gint offset_y);
void gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell);
void gimp_display_shell_scroll_clamp_and_update (GimpDisplayShell *shell);
void gimp_display_shell_scroll_unoverscrollify (GimpDisplayShell *shell,
gint in_offset_x,
gint in_offset_y,
gint *out_offset_x,
gint *out_offset_y);
void gimp_display_shell_scroll_center_image (GimpDisplayShell *shell,
gboolean horizontally,
gboolean vertically);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment