59
59
gdouble current_scale,
60
60
gboolean *vertically,
61
61
gboolean *horizontally);
62
static void gimp_display_shell_scale_viewport_coord_almost_centered
62
static gboolean gimp_display_shell_scale_viewport_coord_almost_centered
63
63
(GimpDisplayShell *shell,
66
66
gboolean *horizontally,
67
67
gboolean *vertically);
69
static void gimp_display_shell_scale_get_image_center_viewport
70
(GimpDisplayShell *shell,
72
gint *image_center_y);
69
75
static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
71
77
gdouble current_scale,
212
216
/* Adjust due to scrolling */
214
gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
215
&scaled_viewport_offset_x,
216
&scaled_viewport_offset_y);
218
horizontal_lower -= img2real (shell, TRUE,
220
(gdouble) scaled_viewport_offset_x));
221
horizontal_upper -= img2real (shell, TRUE,
223
(gdouble) scaled_viewport_offset_x));
225
vertical_lower -= img2real (shell, FALSE,
227
(gdouble) scaled_viewport_offset_y));
228
vertical_upper -= img2real (shell, FALSE,
230
(gdouble) scaled_viewport_offset_y));
220
horizontal_lower += img2real (shell, TRUE,
222
(gdouble) shell->offset_x));
223
horizontal_upper += img2real (shell, TRUE,
225
(gdouble) shell->offset_x));
227
vertical_lower += img2real (shell, FALSE,
229
(gdouble) shell->offset_y));
230
vertical_upper += img2real (shell, FALSE,
232
(gdouble) shell->offset_y));
233
235
/* Finally setup the actual rulers */
367
369
* get things rolling
369
371
gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, real_new_scale);
372
gimp_display_shell_scaled (shell);
370
374
gimp_display_shell_shrink_wrap (shell, FALSE);
374
gboolean starts_fitting_horizontally;
375
gboolean starts_fitting_vertically;
376
gboolean almost_centered_horizontally;
377
gboolean almost_centered_vertically;
378
gboolean starts_fitting_horiz;
379
gboolean starts_fitting_vert;
380
gboolean zoom_focus_almost_centered_horiz;
381
gboolean zoom_focus_almost_centered_vert;
382
gboolean image_center_almost_centered_horiz;
383
gboolean image_center_almost_centered_vert;
379
387
gimp_display_shell_scale_get_zoom_focus (shell,
393
404
gimp_display_shell_scale_image_starts_to_fit (shell,
396
&starts_fitting_horizontally,
397
&starts_fitting_vertically);
407
&starts_fitting_horiz,
408
&starts_fitting_vert);
398
410
gimp_display_shell_scale_viewport_coord_almost_centered (shell,
401
&almost_centered_horizontally,
402
&almost_centered_vertically);
413
&zoom_focus_almost_centered_horiz,
414
&zoom_focus_almost_centered_vert);
415
gimp_display_shell_scale_viewport_coord_almost_centered (shell,
418
&image_center_almost_centered_horiz,
419
&image_center_almost_centered_vert);
403
421
gimp_display_shell_scroll_center_image (shell,
404
starts_fitting_horizontally ||
405
almost_centered_horizontally,
406
starts_fitting_vertically ||
407
almost_centered_vertically);
422
starts_fitting_horiz ||
423
(zoom_focus_almost_centered_horiz &&
424
image_center_almost_centered_horiz),
425
starts_fitting_vert ||
426
(zoom_focus_almost_centered_vert &&
427
image_center_almost_centered_vert));
869
889
gimp_display_shell_scale_viewport_coord_almost_centered (GimpDisplayShell *shell,
872
892
gboolean *horizontally,
873
893
gboolean *vertically)
875
gint center_x = shell->disp_width / 2;
876
gint center_y = shell->disp_height / 2;
878
*horizontally = x > center_x - ALMOST_CENTERED_THRESHOLD &&
879
x < center_x + ALMOST_CENTERED_THRESHOLD;
881
*vertically = y > center_y - ALMOST_CENTERED_THRESHOLD &&
882
y < center_y + ALMOST_CENTERED_THRESHOLD;
895
gboolean local_horizontally;
896
gboolean local_vertically;
897
gint center_x = shell->disp_width / 2;
898
gint center_y = shell->disp_height / 2;
900
local_horizontally = (x > center_x - ALMOST_CENTERED_THRESHOLD &&
901
x < center_x + ALMOST_CENTERED_THRESHOLD);
903
local_vertically = (y > center_y - ALMOST_CENTERED_THRESHOLD &&
904
y < center_y + ALMOST_CENTERED_THRESHOLD);
906
if (horizontally) *horizontally = local_horizontally;
907
if (vertically) *vertically = local_vertically;
909
return local_horizontally && local_vertically;
913
gimp_display_shell_scale_get_image_center_viewport (GimpDisplayShell *shell,
914
gint *image_center_x,
915
gint *image_center_y)
919
gimp_display_shell_draw_get_scaled_image_size (shell,
923
if (image_center_x) *image_center_x = -shell->offset_x + sw / 2;
924
if (image_center_y) *image_center_y = -shell->offset_y + sh / 2;
901
943
GimpZoomFocus zoom_focus)
903
gint image_center_x, image_center_y;
904
gint other_x, other_y;
945
GimpZoomFocus real_zoom_focus = zoom_focus;
946
gint image_center_x, image_center_y;
947
gint other_x, other_y;
906
949
/* Calculate stops-to-fit focus point */
910
gimp_display_shell_draw_get_scaled_image_size (shell,
913
image_center_x = -shell->offset_x + sw / 2;
914
image_center_y = -shell->offset_y + sh / 2;
950
gimp_display_shell_scale_get_image_center_viewport (shell,
917
954
/* Calculate other focus point */
966
1003
/* Decide which one to use for each axis */
1004
if (zoom_focus == GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS)
1008
centered = gimp_display_shell_scale_viewport_coord_almost_centered (shell,
1013
real_zoom_focus = (centered ?
1014
GIMP_ZOOM_FOCUS_IMAGE_CENTER :
1015
GIMP_ZOOM_FOCUS_BEST_GUESS);
1019
real_zoom_focus = zoom_focus;
1022
switch (real_zoom_focus)
969
1024
case GIMP_ZOOM_FOCUS_POINTER: