Bug 553534 – centering issues after image scaling and setting zoom
to 100% * app/display/display-enums.h: Added a GimpZoomFocus enum with 'best guess', 'pointer' or 'image center' values. * app/display/gimpdisplayshell-scale.[ch] (gimp_display_shell_scale): Take a GimpZoomFocus parameter and pass it on to (gimp_display_shell_scale_get_zoom_focus): which returns the requested zoom focus point if one was given, else makes a best guess. * app/actions/view-commands.c * app/display/gimpstatusbar.c * app/display/gimpnavigationeditor.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-scale-dialog.c: For explicit-zoom commands like "zoom to 100%", always use the image center as the zoom focus point. For all other zooming, continue to use the best-guess method. * app/display/display-enums.c: Regenerated. svn path=/trunk/; revision=27104
This commit is contained in:
27
ChangeLog
27
ChangeLog
@ -1,3 +1,30 @@
|
||||
2008-10-02 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
Bug 553534 – centering issues after image scaling and setting zoom
|
||||
to 100%
|
||||
|
||||
* app/display/display-enums.h: Added a GimpZoomFocus enum with
|
||||
'best guess', 'pointer' or 'image center' values.
|
||||
|
||||
* app/display/gimpdisplayshell-scale.[ch]
|
||||
(gimp_display_shell_scale): Take a GimpZoomFocus parameter and
|
||||
pass it on to
|
||||
|
||||
(gimp_display_shell_scale_get_zoom_focus): which returns the
|
||||
requested zoom focus point if one was given, else makes a best
|
||||
guess.
|
||||
|
||||
* app/actions/view-commands.c
|
||||
* app/display/gimpstatusbar.c
|
||||
* app/display/gimpnavigationeditor.c
|
||||
* app/display/gimpdisplayshell-callbacks.c
|
||||
* app/display/gimpdisplayshell-scale-dialog.c: For explicit-zoom
|
||||
commands like "zoom to 100%", always use the image center as the
|
||||
zoom focus point. For all other zooming, continue to use the
|
||||
best-guess method.
|
||||
|
||||
* app/display/display-enums.c: Regenerated.
|
||||
|
||||
2008-10-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/file-uri/uri-backend-wget.c: removed spurious commas
|
||||
|
@ -134,27 +134,45 @@ view_zoom_cmd_callback (GtkAction *action,
|
||||
switch ((GimpActionSelectType) value)
|
||||
{
|
||||
case GIMP_ACTION_SELECT_FIRST:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MAX, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_OUT_MAX,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GIMP_ACTION_SELECT_LAST:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MAX, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_IN_MAX,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GIMP_ACTION_SELECT_PREVIOUS:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_OUT,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GIMP_ACTION_SELECT_NEXT:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_IN,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GIMP_ACTION_SELECT_SKIP_PREVIOUS:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MORE, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_OUT_MORE,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GIMP_ACTION_SELECT_SKIP_NEXT:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MORE, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_IN_MORE,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -171,7 +189,10 @@ view_zoom_cmd_callback (GtkAction *action,
|
||||
/* scale = min * (max / min)**(i/n), i = 0..n */
|
||||
scale = pow (65536.0, scale / 512.0) / 256.0;
|
||||
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_TO,
|
||||
scale,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -194,7 +215,10 @@ view_zoom_explicit_cmd_callback (GtkAction *action,
|
||||
if (value != 0 /* not Other... */)
|
||||
{
|
||||
if (fabs (value - gimp_zoom_model_get_factor (shell->zoom)) > 0.0001)
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) value / 10000);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_TO,
|
||||
(gdouble) value / 10000,
|
||||
GIMP_ZOOM_FOCUS_IMAGE_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,6 +158,36 @@ gimp_zoom_quality_get_type (void)
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_zoom_focus_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_ZOOM_FOCUS_BEST_GUESS, "GIMP_ZOOM_FOCUS_BEST_GUESS", "best-guess" },
|
||||
{ GIMP_ZOOM_FOCUS_POINTER, "GIMP_ZOOM_FOCUS_POINTER", "pointer" },
|
||||
{ GIMP_ZOOM_FOCUS_IMAGE_CENTER, "GIMP_ZOOM_FOCUS_IMAGE_CENTER", "image-center" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_ZOOM_FOCUS_BEST_GUESS, "GIMP_ZOOM_FOCUS_BEST_GUESS", NULL },
|
||||
{ GIMP_ZOOM_FOCUS_POINTER, "GIMP_ZOOM_FOCUS_POINTER", NULL },
|
||||
{ GIMP_ZOOM_FOCUS_IMAGE_CENTER, "GIMP_ZOOM_FOCUS_IMAGE_CENTER", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
type = g_enum_register_static ("GimpZoomFocus", values);
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/* Generated data ends here */
|
||||
|
||||
|
@ -81,4 +81,16 @@ typedef enum
|
||||
} GimpZoomQuality;
|
||||
|
||||
|
||||
#define GIMP_TYPE_ZOOM_FOCUS (gimp_zoom_focus_get_type ())
|
||||
|
||||
GType gimp_zoom_focus_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS, /* Make a best guess */
|
||||
GIMP_ZOOM_FOCUS_POINTER, /* Use the mouse cursor (if within canvas) */
|
||||
GIMP_ZOOM_FOCUS_IMAGE_CENTER /* Use the image center */
|
||||
} GimpZoomFocus;
|
||||
|
||||
|
||||
#endif /* __DISPLAY_ENUMS_H__ */
|
||||
|
@ -1040,11 +1040,17 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
||||
switch (direction)
|
||||
{
|
||||
case GDK_SCROLL_UP:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_IN,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
case GDK_SCROLL_DOWN:
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_OUT,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -217,7 +217,10 @@ gimp_display_shell_scale_dialog_response (GtkWidget *widget,
|
||||
|
||||
scale = gtk_adjustment_get_value (GTK_ADJUSTMENT (dialog->scale_adj));
|
||||
|
||||
gimp_display_shell_scale (dialog->shell, GIMP_ZOOM_TO, scale / 100.0);
|
||||
gimp_display_shell_scale (dialog->shell,
|
||||
GIMP_ZOOM_TO,
|
||||
scale / 100.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,7 +70,8 @@ static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shel
|
||||
gdouble new_scale,
|
||||
gdouble current_scale,
|
||||
gint *x,
|
||||
gint *y);
|
||||
gint *y,
|
||||
GimpZoomFocus zoom_focus);
|
||||
|
||||
static gdouble img2real (GimpDisplayShell *shell,
|
||||
gboolean xdir,
|
||||
@ -334,7 +335,8 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
||||
void
|
||||
gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
GimpZoomType zoom_type,
|
||||
gdouble new_scale)
|
||||
gdouble new_scale,
|
||||
GimpZoomFocus zoom_focus)
|
||||
{
|
||||
gint x, y;
|
||||
gdouble current_scale;
|
||||
@ -375,7 +377,8 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
real_new_scale,
|
||||
current_scale,
|
||||
&x,
|
||||
&y);
|
||||
&y,
|
||||
zoom_focus);
|
||||
|
||||
gimp_display_shell_scale_to (shell, real_new_scale, x, y);
|
||||
|
||||
@ -438,7 +441,11 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
|
||||
zoom_factor = MIN ((gdouble) shell->disp_width / (gdouble) image_width,
|
||||
(gdouble) shell->disp_height / (gdouble) image_height);
|
||||
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_TO,
|
||||
zoom_factor,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
|
||||
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
|
||||
}
|
||||
|
||||
@ -510,7 +517,11 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell)
|
||||
zoom_factor = MAX ((gdouble) shell->disp_width / (gdouble) image_width,
|
||||
(gdouble) shell->disp_height / (gdouble) image_height);
|
||||
|
||||
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
|
||||
gimp_display_shell_scale (shell,
|
||||
GIMP_ZOOM_TO,
|
||||
zoom_factor,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
|
||||
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
|
||||
}
|
||||
|
||||
@ -883,7 +894,8 @@ gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
|
||||
gdouble new_scale,
|
||||
gdouble current_scale,
|
||||
gint *x,
|
||||
gint *y)
|
||||
gint *y,
|
||||
GimpZoomFocus zoom_focus)
|
||||
{
|
||||
gint image_center_x, image_center_y;
|
||||
gint other_x, other_y;
|
||||
@ -949,23 +961,39 @@ gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
|
||||
}
|
||||
|
||||
/* Decide which one to use for each axis */
|
||||
{
|
||||
gboolean within_horizontally, within_vertically;
|
||||
gboolean stops_horizontally, stops_vertically;
|
||||
switch (zoom_focus)
|
||||
{
|
||||
case GIMP_ZOOM_FOCUS_POINTER:
|
||||
*x = other_x;
|
||||
*y = other_y;
|
||||
break;
|
||||
|
||||
gimp_display_shell_scale_image_is_within_viewport (shell,
|
||||
&within_horizontally,
|
||||
&within_vertically);
|
||||
case GIMP_ZOOM_FOCUS_IMAGE_CENTER:
|
||||
*x = image_center_x;
|
||||
*y = image_center_y;
|
||||
break;
|
||||
|
||||
gimp_display_shell_scale_image_stops_to_fit (shell,
|
||||
new_scale,
|
||||
current_scale,
|
||||
&stops_horizontally,
|
||||
&stops_vertically);
|
||||
case GIMP_ZOOM_FOCUS_BEST_GUESS:
|
||||
default:
|
||||
{
|
||||
gboolean within_horizontally, within_vertically;
|
||||
gboolean stops_horizontally, stops_vertically;
|
||||
|
||||
*x = within_horizontally && ! stops_horizontally ? image_center_x : other_x;
|
||||
*y = within_vertically && ! stops_vertically ? image_center_y : other_y;
|
||||
}
|
||||
gimp_display_shell_scale_image_is_within_viewport (shell,
|
||||
&within_horizontally,
|
||||
&within_vertically);
|
||||
|
||||
gimp_display_shell_scale_image_stops_to_fit (shell,
|
||||
new_scale,
|
||||
current_scale,
|
||||
&stops_horizontally,
|
||||
&stops_vertically);
|
||||
|
||||
*x = within_horizontally && ! stops_horizontally ? image_center_x : other_x;
|
||||
*y = within_vertically && ! stops_vertically ? image_center_y : other_y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* scale image coord to realworld units (cm, inches, pixels)
|
||||
|
@ -32,7 +32,8 @@ void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell
|
||||
|
||||
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
GimpZoomType zoom_type,
|
||||
gdouble scale);
|
||||
gdouble scale,
|
||||
GimpZoomFocus zoom_focus);
|
||||
void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
|
||||
gboolean *horizontally,
|
||||
|
@ -534,7 +534,10 @@ gimp_navigation_editor_zoom (GimpNavigationView *view,
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
gimp_display_shell_scale (editor->shell, direction, 0.0);
|
||||
gimp_display_shell_scale (editor->shell,
|
||||
direction,
|
||||
0.0,
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -588,8 +591,10 @@ static void
|
||||
gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_TO,
|
||||
pow (2.0, gtk_adjustment_get_value (adj)));
|
||||
gimp_display_shell_scale (editor->shell,
|
||||
GIMP_ZOOM_TO,
|
||||
pow (2.0, gtk_adjustment_get_value (adj)),
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1386,7 +1386,8 @@ gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
|
||||
{
|
||||
gimp_display_shell_scale (statusbar->shell,
|
||||
GIMP_ZOOM_TO,
|
||||
gimp_scale_combo_box_get_scale (combo));
|
||||
gimp_scale_combo_box_get_scale (combo),
|
||||
GIMP_ZOOM_FOCUS_BEST_GUESS);
|
||||
}
|
||||
|
||||
static guint
|
||||
|
Reference in New Issue
Block a user