Extend the interface with this function

2008-07-10  Martin Nordholts  <martinn@svn.gnome.org>

	* app/display/gimpdisplayshell-scroll.c
	(gimp_display_shell_get_scaled_viewport): Extend the interface
	with this function

	* app/tools/gimprectangletool.c
	(gimp_rectangle_tool_update_handle_sizes): Forget anything we knew
	about how to interpret the icky GimpDisplayShell offset variables

svn path=/trunk/; revision=26111
This commit is contained in:
Martin Nordholts 2008-07-10 20:19:17 +00:00 committed by Martin Nordholts
parent 8f21264592
commit 19325009fa
4 changed files with 48 additions and 8 deletions

View File

@ -1,3 +1,13 @@
2008-07-10 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell-scroll.c
(gimp_display_shell_get_scaled_viewport): Extend the interface
with this function
* app/tools/gimprectangletool.c
(gimp_rectangle_tool_update_handle_sizes): Forget anything we knew
about how to interpret the icky GimpDisplayShell offset variables
2008-07-10 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell-scroll.[ch]: Make

View File

@ -133,3 +133,27 @@ gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
shell->offset_y = 0;
}
}
/**
* gimp_display_shell_get_scaled_viewport:
* @shell:
* @x:
* @y:
* @w:
* @h:
*
* Gets the viewport in screen coordinates, with origin at (0, 0) in
* the image
**/
void
gimp_display_shell_get_scaled_viewport (GimpDisplayShell *shell,
gint *x,
gint *y,
gint *w,
gint *h)
{
if (x) *x = -shell->disp_xoffset + shell->offset_x;
if (y) *y = -shell->disp_yoffset + shell->offset_y;
if (w) *w = shell->disp_width;
if (h) *h = shell->disp_height;
}

View File

@ -26,5 +26,11 @@ void gimp_display_shell_scroll (GimpDisplayShell *shell,
void gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell);
void gimp_display_shell_get_scaled_viewport (GimpDisplayShell *shell,
gint *x,
gint *y,
gint *w,
gint *h);
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */

View File

@ -41,6 +41,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scroll.h"
#include "display/gimpdisplayshell-transform.h"
#include "gimpdrawtool.h"
@ -1847,15 +1848,14 @@ gimp_rectangle_tool_update_handle_sizes (GimpRectangleTool *rect_tool)
/* Calculate rectangles of the selection rectangle and the display shell,
* with origin at (0, 0) of image, and in screen coordinate scale.
*/
gint x1 = pub_x1 * shell->scale_x;
gint y1 = pub_y1 * shell->scale_y;
gint w1 = (pub_x2 - pub_x1) * shell->scale_x;
gint h1 = (pub_y2 - pub_y1) * shell->scale_y;
gint x1 = pub_x1 * shell->scale_x;
gint y1 = pub_y1 * shell->scale_y;
gint w1 = (pub_x2 - pub_x1) * shell->scale_x;
gint h1 = (pub_y2 - pub_y1) * shell->scale_y;
gint x2 = -shell->disp_xoffset + shell->offset_x;
gint y2 = -shell->disp_yoffset + shell->offset_y;
gint w2 = shell->disp_width;
gint h2 = shell->disp_height;
gint x2, y2, w2, h2;
gimp_display_shell_get_scaled_viewport (shell, &x2, &y2, &w2, &h2);
rectangle_width = w1;
rectangle_height = h1;