If the image is within the viewport and we are zooming out, make the focus

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

	* app/display/gimpdisplayshell-scale.c
	(gimp_display_shell_scale_get_zoom_focus): If the image is within
	the viewport and we are zooming out, make the focus point be the
	center of the image.

svn path=/trunk/; revision=26560
This commit is contained in:
Martin Nordholts
2008-08-14 17:41:38 +00:00
committed by Martin Nordholts
parent 57ec836f3e
commit de82d2f7ec
2 changed files with 61 additions and 33 deletions

View File

@ -1,3 +1,10 @@
2008-08-14 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_get_zoom_focus): If the image is within
the viewport and we are zooming out, make the focus point be the
center of the image.
2008-08-14 Martin Nordholts <martinn@svn.gnome.org> 2008-08-14 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scale.c

View File

@ -74,6 +74,7 @@ static void gimp_display_shell_scale_to (GimpDisplayShell *shell,
gdouble x, gdouble x,
gdouble y); gdouble y);
static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell, static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
gdouble new_scale,
gint *x, gint *x,
gint *y); gint *y);
@ -363,7 +364,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
if (! SCALE_EQUALS (real_new_scale, current_scale)) if (! SCALE_EQUALS (real_new_scale, current_scale))
{ {
gimp_display_shell_scale_get_zoom_focus (shell, &x, &y); gimp_display_shell_scale_get_zoom_focus (shell, real_new_scale, &x, &y);
gimp_display_shell_scale_to (shell, real_new_scale, x, y); gimp_display_shell_scale_to (shell, real_new_scale, x, y);
} }
@ -888,6 +889,7 @@ gimp_display_shell_scale_to (GimpDisplayShell *shell,
/** /**
* gimp_display_shell_scale_get_zoom_focus: * gimp_display_shell_scale_get_zoom_focus:
* @shell: * @shell:
* @new_scale:
* @x: * @x:
* @y: * @y:
* *
@ -895,11 +897,29 @@ gimp_display_shell_scale_to (GimpDisplayShell *shell,
**/ **/
static void static void
gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell, gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
gdouble new_scale,
gint *x, gint *x,
gint *y) gint *y)
{ {
GdkEvent *event; GdkEvent *event;
gdouble current_scale = gimp_zoom_model_get_factor (shell->zoom);
if (new_scale < current_scale &&
gimp_display_shell_scale_image_is_within_viewport (shell))
{
/* If the image is within the viewport and we are zooming out, put
* the zoom focus in the center of the image
*/
gint sw, sh;
gimp_display_shell_draw_get_scaled_image_size (shell,
&sw,
&sh);
*x = -shell->offset_x + sw / 2;
*y = -shell->offset_y + sh / 2;
}
else
{
*x = shell->disp_width / 2; *x = shell->disp_width / 2;
*y = shell->disp_height / 2; *y = shell->disp_height / 2;
@ -939,6 +959,7 @@ gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
} }
} }
} }
}
static void static void
update_zoom_values (GtkAdjustment *adj, update_zoom_values (GtkAdjustment *adj,