Commit 2d6e80b8 authored by Ell's avatar Ell

app: behave as if "show all" is disabled in scroll/zoom actions when keeping padding

parent 235a20b6
......@@ -38,6 +38,8 @@
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-expose.h"
#include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-scrollbars.h"
#include "gimpimagewindow.h"
#include "gimpstatusbar.h"
......@@ -541,7 +543,12 @@ gimp_display_shell_set_padding_in_show_all (GimpDisplayShell *shell,
g_object_set (options, "padding-in-show-all", keep, NULL);
if (shell->display)
gimp_display_shell_expose_full (shell);
{
gimp_display_shell_scroll_clamp_and_update (shell);
gimp_display_shell_scrollbars_update (shell);
gimp_display_shell_expose_full (shell);
}
gimp_display_shell_set_action_active (shell,
"view-padding-color-in-show-all",
......
......@@ -190,7 +190,7 @@ gimp_display_shell_canvas_tick (GtkWidget *widget,
center_horizontally = sw <= shell->disp_width;
center_vertically = sh <= shell->disp_height;
if (! shell->show_all)
if (! gimp_display_shell_get_infinite_canvas (shell))
{
gimp_display_shell_scroll_center_image (shell,
center_horizontally,
......
......@@ -885,7 +885,7 @@ gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
shell->offset_x + scaled_previous_origin_x,
shell->offset_y + scaled_previous_origin_y);
if (! shell->show_all)
if (! gimp_display_shell_get_infinite_canvas (shell))
{
gimp_display_shell_scroll_center_image (shell,
horizontally, vertically);
......
......@@ -275,6 +275,36 @@ gimp_display_shell_scale_get_image_bounds (GimpDisplayShell *shell,
if (h) *h = y2 - y1;
}
/**
* gimp_display_shell_scale_get_image_unrotated_bounds:
* @shell:
* @x:
* @y:
* @w:
* @h:
*
* Gets the screen-space boudning box of the image, after it has
* been scaled and scrolled, but before it has been rotated.
**/
void
gimp_display_shell_scale_get_image_unrotated_bounds (GimpDisplayShell *shell,
gint *x,
gint *y,
gint *w,
gint *h)
{
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
image = gimp_display_get_image (shell->display);
if (x) *x = -shell->offset_x;
if (y) *y = -shell->offset_y;
if (w) *w = floor (gimp_image_get_width (image) * shell->scale_x);
if (h) *h = floor (gimp_image_get_height (image) * shell->scale_y);
}
/**
* gimp_display_shell_scale_get_image_bounding_box:
* @shell:
......@@ -406,7 +436,7 @@ gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
if (! horizontally) horizontally = &horizontally_dummy;
if (! vertically) vertically = &vertically_dummy;
if (! shell->show_all)
if (! gimp_display_shell_get_infinite_canvas (shell))
{
gint sx, sy;
gint sw, sh;
......@@ -1130,7 +1160,19 @@ gimp_display_shell_scale_fit_or_fill (GimpDisplayShell *shell,
gdouble current_scale;
gdouble zoom_factor;
bounding_box = gimp_display_shell_get_bounding_box (shell);
if (! gimp_display_shell_get_infinite_canvas (shell))
{
GimpImage *image = gimp_display_get_image (shell->display);
bounding_box.x = 0;
bounding_box.y = 0;
bounding_box.width = gimp_image_get_width (image);
bounding_box.height = gimp_image_get_height (image);
}
else
{
bounding_box = gimp_display_shell_get_bounding_box (shell);
}
gimp_display_shell_transform_bounds (shell,
bounding_box.x,
......@@ -1180,7 +1222,8 @@ gimp_display_shell_scale_image_starts_to_fit (GimpDisplayShell *shell,
if (! horizontally) horizontally = &horizontally_dummy;
/* The image can only start to fit if we zoom out */
if (new_scale > current_scale || shell->show_all)
if (new_scale > current_scale ||
gimp_display_shell_get_infinite_canvas (shell))
{
*vertically = FALSE;
*horizontally = FALSE;
......@@ -1246,7 +1289,7 @@ gimp_display_shell_scale_viewport_coord_almost_centered (GimpDisplayShell *shell
gint center_x = shell->disp_width / 2;
gint center_y = shell->disp_height / 2;
if (! shell->show_all)
if (! gimp_display_shell_get_infinite_canvas (shell))
{
local_horizontally = (x > center_x - ALMOST_CENTERED_THRESHOLD &&
x < center_x + ALMOST_CENTERED_THRESHOLD);
......
......@@ -34,6 +34,12 @@ void gimp_display_shell_scale_get_image_bounds (GimpDisplayShell *shell,
gint *y,
gint *w,
gint *h);
void gimp_display_shell_scale_get_image_unrotated_bounds
(GimpDisplayShell *shell,
gint *x,
gint *y,
gint *w,
gint *h);
void gimp_display_shell_scale_get_image_bounding_box
(GimpDisplayShell *shell,
gint *x,
......
......@@ -480,11 +480,22 @@ gimp_display_shell_scroll_center_content (GimpDisplayShell *shell,
(! vertically && ! horizontally))
return;
gimp_display_shell_scale_get_image_bounding_box (shell,
&content_x,
&content_y,
&content_width,
&content_height);
if (! gimp_display_shell_get_infinite_canvas (shell))
{
gimp_display_shell_scale_get_image_bounds (shell,
&content_x,
&content_y,
&content_width,
&content_height);
}
else
{
gimp_display_shell_scale_get_image_bounding_box (shell,
&content_x,
&content_y,
&content_width,
&content_height);
}
if (shell->disp_width > content_width)
{
......
......@@ -110,9 +110,18 @@ gimp_display_shell_scrollbars_setup_horizontal (GimpDisplayShell *shell,
&bounds_x, NULL,
&bounds_width, NULL);
gimp_display_shell_scale_get_image_bounding_box (shell,
&bounding_box_x, NULL,
&bounding_box_width, NULL);
if (! gimp_display_shell_get_infinite_canvas (shell))
{
bounding_box_x = bounds_x;
bounding_box_width = bounds_width;
}
else
{
gimp_display_shell_scale_get_image_bounding_box (
shell,
&bounding_box_x, NULL,
&bounding_box_width, NULL);
}
x1 = bounding_box_x;
x2 = bounding_box_x + bounding_box_width;
......@@ -162,9 +171,18 @@ gimp_display_shell_scrollbars_setup_vertical (GimpDisplayShell *shell,
NULL, &bounds_y,
NULL, &bounds_height);
gimp_display_shell_scale_get_image_bounding_box (shell,
NULL, &bounding_box_y,
NULL, &bounding_box_height);
if (! gimp_display_shell_get_infinite_canvas (shell))
{
bounding_box_y = bounds_y;
bounding_box_height = bounds_height;
}
else
{
gimp_display_shell_scale_get_image_bounding_box (
shell,
NULL, &bounding_box_y,
NULL, &bounding_box_height);
}
y1 = bounding_box_y;
y2 = bounding_box_y + bounding_box_height;
......
......@@ -1846,6 +1846,15 @@ gimp_display_shell_get_bounding_box (GimpDisplayShell *shell)
return bounding_box;
}
gboolean
gimp_display_shell_get_infinite_canvas (GimpDisplayShell *shell)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
return shell->show_all &&
! gimp_display_shell_get_padding_in_show_all (shell);
}
void
gimp_display_shell_update_priority_rect (GimpDisplayShell *shell)
{
......
......@@ -319,6 +319,8 @@ void gimp_display_shell_set_show_all (GimpDisplayShell *shell,
GimpPickable * gimp_display_shell_get_pickable (GimpDisplayShell *shell);
GeglRectangle gimp_display_shell_get_bounding_box
(GimpDisplayShell *shell);
gboolean gimp_display_shell_get_infinite_canvas
(GimpDisplayShell *shell);
void gimp_display_shell_update_priority_rect
(GimpDisplayShell *shell);
......
......@@ -1472,9 +1472,17 @@ gimp_image_window_shrink_wrap (GimpImageWindow *window,
gdk_monitor_get_workarea (monitor, &rect);
gimp_display_shell_scale_get_image_bounding_box (active_shell,
NULL, NULL,
&width, &height);
if (! gimp_display_shell_get_infinite_canvas (active_shell))
{
gimp_display_shell_scale_get_image_size (active_shell,
&width, &height);
}
else
{
gimp_display_shell_scale_get_image_bounding_box (active_shell,
NULL, NULL,
&width, &height);
}
disp_width = active_shell->disp_width;
disp_height = active_shell->disp_height;
......
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