[gimp/gimp-2-10] app: behave as if "show all" is disabled in scroll/zoom actions when keeping padding
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: behave as if "show all" is disabled in scroll/zoom actions when keeping padding
- Date: Sun, 15 Sep 2019 13:42:30 +0000 (UTC)
commit f7582614f42c98b7d2c94c8c3ac9a4c647d139f3
Author: Ell <ell_se yahoo com>
Date: Sun Sep 15 16:22:06 2019 +0300
app: behave as if "show all" is disabled in scroll/zoom actions when keeping padding
app/display/gimpdisplayshell-appearance.c | 9 +++++-
app/display/gimpdisplayshell-callbacks.c | 2 +-
app/display/gimpdisplayshell-handlers.c | 2 +-
app/display/gimpdisplayshell-scale.c | 51 ++++++++++++++++++++++++++++---
app/display/gimpdisplayshell-scale.h | 6 ++++
app/display/gimpdisplayshell-scroll.c | 21 ++++++++++---
app/display/gimpdisplayshell-scrollbars.c | 30 ++++++++++++++----
app/display/gimpdisplayshell.c | 9 ++++++
app/display/gimpdisplayshell.h | 2 ++
app/display/gimpimagewindow.c | 14 +++++++--
10 files changed, 125 insertions(+), 21 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c
index fbb4e0de1a..9f6af6cb15 100644
--- a/app/display/gimpdisplayshell-appearance.c
+++ b/app/display/gimpdisplayshell-appearance.c
@@ -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"
@@ -561,7 +563,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",
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index cffb9ae51c..9b65529b3c 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -207,7 +207,7 @@ gimp_display_shell_canvas_size_allocate (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,
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 11844de412..7680467a83 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -884,7 +884,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);
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index 0e782c1625..482a9fe133 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -274,6 +274,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:
@@ -405,7 +435,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);
diff --git a/app/display/gimpdisplayshell-scale.h b/app/display/gimpdisplayshell-scale.h
index 7f38eb0264..b97f9fb509 100644
--- a/app/display/gimpdisplayshell-scale.h
+++ b/app/display/gimpdisplayshell-scale.h
@@ -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,
diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c
index 64b15b81c0..ec5084d85f 100644
--- a/app/display/gimpdisplayshell-scroll.c
+++ b/app/display/gimpdisplayshell-scroll.c
@@ -436,11 +436,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)
{
diff --git a/app/display/gimpdisplayshell-scrollbars.c b/app/display/gimpdisplayshell-scrollbars.c
index 58d964eb8a..3696e01843 100644
--- a/app/display/gimpdisplayshell-scrollbars.c
+++ b/app/display/gimpdisplayshell-scrollbars.c
@@ -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;
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index c3586df74e..d3c9934c1d 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1902,6 +1902,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)
{
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index da0af22031..efa9a73119 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -312,6 +312,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);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 59f52aa8c5..fd5c501d8a 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -1497,9 +1497,17 @@ gimp_image_window_shrink_wrap (GimpImageWindow *window,
gtk_widget_get_window (widget));
gdk_screen_get_monitor_workarea (screen, 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]