mirror of https://github.com/GNOME/gimp.git
app: add "clip" parameter to gimp_display_shell_untransform_viewport()
... which specifies whether to clip the viewport to the canvas (previously, it would always be clipped). Use the appropriate value in all callers, depending on the shell's "show all" mode. In particular, this commit avoids clipping the image projection's priority rect to the canvas in "show all" mode.
This commit is contained in:
parent
86dc451bce
commit
788b136bbf
|
@ -74,7 +74,7 @@ buffers_paste_cmd_callback (GimpAction *action,
|
|||
{
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell,
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
image = gimp_display_get_image (display);
|
||||
|
|
|
@ -610,7 +610,8 @@ edit_paste (GimpDisplay *display,
|
|||
/* the actual paste-type conversion happens in gimp_edit_paste() */
|
||||
}
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
if (gimp_edit_paste (image, drawable, paste,
|
||||
paste_type, x, y, width, height))
|
||||
|
|
|
@ -179,7 +179,8 @@ gimp_display_shell_dnd_position_item (GimpDisplayShell *shell,
|
|||
gint x, y;
|
||||
gint width, height;
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
off_x = x + (width - item_width) / 2;
|
||||
off_y = y + (height - item_height) / 2;
|
||||
|
@ -493,7 +494,8 @@ gimp_display_shell_drop_buffer (GtkWidget *widget,
|
|||
|
||||
buffer = GIMP_BUFFER (viewable);
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
/* FIXME: popup a menu for selecting "Paste Into" */
|
||||
|
||||
|
@ -565,7 +567,9 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
|
|||
gint height = gimp_image_get_height (image);
|
||||
|
||||
if (gimp_display_get_image (shell->display))
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y,
|
||||
gimp_display_shell_untransform_viewport (shell,
|
||||
! shell->show_all,
|
||||
&x, &y,
|
||||
&width, &height);
|
||||
|
||||
gimp_image_add_layers (image, new_layers,
|
||||
|
|
|
@ -956,6 +956,7 @@ gimp_display_shell_untransform_bounds_with_scale (GimpDisplayShell *shell,
|
|||
/**
|
||||
* gimp_display_shell_untransform_viewport:
|
||||
* @shell: a #GimpDisplayShell
|
||||
* @clip: whether to clip the result to the image bounds
|
||||
* @x: returns image x coordinate of display upper left corner
|
||||
* @y: returns image y coordinate of display upper left corner
|
||||
* @width: returns width of display measured in image coordinates
|
||||
|
@ -966,13 +967,13 @@ gimp_display_shell_untransform_bounds_with_scale (GimpDisplayShell *shell,
|
|||
**/
|
||||
void
|
||||
gimp_display_shell_untransform_viewport (GimpDisplayShell *shell,
|
||||
gboolean clip,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpImage *image;
|
||||
gdouble x1, y1, x2, y2;
|
||||
gdouble x1, y1, x2, y2;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -987,19 +988,15 @@ gimp_display_shell_untransform_viewport (GimpDisplayShell *shell,
|
|||
x2 = ceil (x2);
|
||||
y2 = ceil (y2);
|
||||
|
||||
image = gimp_display_get_image (shell->display);
|
||||
if (clip)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (shell->display);
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0;
|
||||
|
||||
if (x2 > gimp_image_get_width (image))
|
||||
x2 = gimp_image_get_width (image);
|
||||
|
||||
if (y2 > gimp_image_get_height (image))
|
||||
y2 = gimp_image_get_height (image);
|
||||
x1 = MAX (x1, 0);
|
||||
y1 = MAX (y1, 0);
|
||||
x2 = MIN (x2, gimp_image_get_width (image));
|
||||
y2 = MIN (y2, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (x) *x = x1;
|
||||
if (y) *y = y1;
|
||||
|
|
|
@ -190,6 +190,7 @@ void gimp_display_shell_untransform_bounds_with_scale (GimpDisplayShell *shel
|
|||
gdouble *ny2);
|
||||
|
||||
void gimp_display_shell_untransform_viewport (GimpDisplayShell *shell,
|
||||
gboolean clip,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *width,
|
||||
|
|
|
@ -973,7 +973,8 @@ gimp_display_shell_set_priority_viewport (GimpDisplayShell *shell)
|
|||
gint x, y;
|
||||
gint width, height;
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &width, &height);
|
||||
gimp_projection_set_priority_rect (projection, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
@ -1788,6 +1789,8 @@ gimp_display_shell_set_show_all (GimpDisplayShell *shell,
|
|||
|
||||
gimp_display_update_bounding_box (shell->display);
|
||||
|
||||
gimp_display_shell_set_priority_viewport (shell);
|
||||
|
||||
gimp_display_shell_expose_full (shell);
|
||||
|
||||
g_object_notify (G_OBJECT (shell), "show-all");
|
||||
|
|
|
@ -729,7 +729,7 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
GimpItem *item = GIMP_ITEM (tool->drawable);
|
||||
gint x, y, width, height;
|
||||
|
||||
gimp_display_shell_untransform_viewport (shell,
|
||||
gimp_display_shell_untransform_viewport (shell, TRUE,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
if (gimp_rectangle_intersect (gimp_item_get_offset_x (item),
|
||||
|
|
|
@ -792,7 +792,8 @@ gimp_seamless_clone_tool_filter_update (GimpSeamlessCloneTool *sc)
|
|||
|
||||
/* Find out at which x,y is the top left corner of the currently
|
||||
* displayed part */
|
||||
gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);
|
||||
gimp_display_shell_untransform_viewport (shell, ! shell->show_all,
|
||||
&x, &y, &w, &h);
|
||||
|
||||
/* Find out where is our drawable positioned */
|
||||
gimp_item_get_offset (item, &off_x, &off_y);
|
||||
|
|
Loading…
Reference in New Issue