mirror of https://github.com/GNOME/gimp.git
Kill disp_[xy]offset! We now keep store that information by using negative
2008-07-12 Martin Nordholts <martinn@svn.gnome.org> * app/display/gimpdisplayshell.c: Kill disp_[xy]offset! We now keep store that information by using negative values in offset_[xy]. * app/display/gimpdisplayshell-scroll.[ch] (gimp_display_shell_scroll_clamp_offsets) (gimp_display_shell_get_scaled_image_viewport_offset): Adjust accordingly to preserve current behaviour. (gimp_display_shell_get_disp_offset): New function to get the old disp_[xy]offset based on the new offset_[xy]. (gimp_display_shell_get_render_start_offset): New function to get th old offset_[xy] based on the new offset_[xy]. * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-render.c: Get rid of disp_[xy]offset and use gimp_display_shell_get_render_start_offset() and gimp_display_shell_get_disp_offset() instead. svn path=/trunk/; revision=26146
This commit is contained in:
parent
da6205f349
commit
a33d80107b
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2008-07-12 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
* app/display/gimpdisplayshell.c: Kill disp_[xy]offset! We now
|
||||
keep store that information by using negative values in
|
||||
offset_[xy].
|
||||
|
||||
* app/display/gimpdisplayshell-scroll.[ch]
|
||||
(gimp_display_shell_scroll_clamp_offsets)
|
||||
(gimp_display_shell_get_scaled_image_viewport_offset): Adjust
|
||||
accordingly to preserve current behaviour.
|
||||
|
||||
(gimp_display_shell_get_disp_offset): New function to get the old
|
||||
disp_[xy]offset based on the new offset_[xy].
|
||||
|
||||
(gimp_display_shell_get_render_start_offset): New function to get
|
||||
th old offset_[xy] based on the new offset_[xy].
|
||||
|
||||
* app/display/gimpdisplayshell-draw.c
|
||||
* app/display/gimpdisplayshell-scale.c
|
||||
* app/display/gimpdisplayshell-render.c: Get rid of
|
||||
disp_[xy]offset and use
|
||||
gimp_display_shell_get_render_start_offset() and
|
||||
gimp_display_shell_get_disp_offset() instead.
|
||||
|
||||
2008-07-11 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
* app/display/gimpdisplayshell-scale.c
|
||||
|
|
|
@ -572,14 +572,19 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell,
|
|||
{
|
||||
for (j = x; j < x2; j += GIMP_DISPLAY_RENDER_BUF_WIDTH)
|
||||
{
|
||||
gint disp_xoffset, disp_yoffset;
|
||||
gint dx, dy;
|
||||
|
||||
dx = MIN (x2 - j, GIMP_DISPLAY_RENDER_BUF_WIDTH);
|
||||
dy = MIN (y2 - i, GIMP_DISPLAY_RENDER_BUF_HEIGHT);
|
||||
|
||||
gimp_display_shell_get_disp_offset (shell,
|
||||
&disp_xoffset,
|
||||
&disp_yoffset);
|
||||
|
||||
gimp_display_shell_render (shell,
|
||||
j - shell->disp_xoffset,
|
||||
i - shell->disp_yoffset,
|
||||
j - disp_xoffset,
|
||||
i - disp_yoffset,
|
||||
dx, dy,
|
||||
shell->highlight ? &rect : NULL);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-filter.h"
|
||||
#include "gimpdisplayshell-render.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
|
||||
#define GIMP_DISPLAY_ZOOM_FAST (1 << 0) /* use the fastest possible code
|
||||
path trading quality for speed
|
||||
|
@ -223,6 +224,8 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||
GimpImage *image;
|
||||
RenderInfo info;
|
||||
GimpImageType type;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (w > 0 && h > 0);
|
||||
|
@ -230,13 +233,15 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||
image = shell->display->image;
|
||||
projection = image->projection;
|
||||
|
||||
gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
|
||||
|
||||
/* Initialize RenderInfo with values that don't change during the
|
||||
* call of this function.
|
||||
*/
|
||||
info.shell = shell;
|
||||
|
||||
info.x = x + shell->offset_x;
|
||||
info.y = y + shell->offset_y;
|
||||
info.x = x + offset_x;
|
||||
info.y = y + offset_y;
|
||||
info.w = w;
|
||||
info.h = h;
|
||||
|
||||
|
@ -310,12 +315,20 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
/* put it to the screen */
|
||||
{
|
||||
gint disp_xoffset, disp_yoffset;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
gimp_display_shell_get_disp_offset (shell, &disp_xoffset, &disp_yoffset);
|
||||
gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
|
||||
|
||||
gimp_canvas_draw_rgb (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_RENDER,
|
||||
x + shell->disp_xoffset, y + shell->disp_yoffset,
|
||||
x + disp_xoffset, y + disp_yoffset,
|
||||
w, h,
|
||||
shell->render_buf,
|
||||
3 * GIMP_DISPLAY_RENDER_BUF_WIDTH,
|
||||
shell->offset_x, shell->offset_y);
|
||||
offset_x, offset_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,16 +351,20 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
|
|||
{
|
||||
guchar *buf = shell->render_buf;
|
||||
GdkRectangle rect;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
rect.x = shell->offset_x + x;
|
||||
rect.y = shell->offset_y + y;
|
||||
gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
|
||||
|
||||
rect.x = x + offset_x;
|
||||
rect.y = y + offset_y;
|
||||
rect.width = w;
|
||||
rect.height = h;
|
||||
|
||||
if (gdk_rectangle_intersect (highlight, &rect, &rect))
|
||||
{
|
||||
rect.x -= shell->offset_x + x;
|
||||
rect.y -= shell->offset_y + y;
|
||||
rect.x -= x + offset_x;
|
||||
rect.y -= y + offset_y;
|
||||
|
||||
for (y = 0; y < rect.y; y++)
|
||||
{
|
||||
|
|
|
@ -92,6 +92,8 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
|
|||
gfloat sx, sy;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -117,13 +119,15 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
|
|||
sy = image_height;
|
||||
}
|
||||
|
||||
shell->hsbdata->value = shell->offset_x;
|
||||
gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
|
||||
|
||||
shell->hsbdata->value = offset_x;
|
||||
shell->hsbdata->upper = sx;
|
||||
shell->hsbdata->page_size = MIN (sx, shell->disp_width);
|
||||
shell->hsbdata->page_increment = shell->disp_width / 2;
|
||||
shell->hsbdata->step_increment = shell->scale_x;
|
||||
|
||||
shell->vsbdata->value = shell->offset_y;
|
||||
shell->vsbdata->value = offset_y;
|
||||
shell->vsbdata->upper = sy;
|
||||
shell->vsbdata->page_size = MIN (sy, shell->disp_height);
|
||||
shell->vsbdata->page_increment = shell->disp_height / 2;
|
||||
|
@ -167,29 +171,6 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
|
|||
}
|
||||
|
||||
|
||||
/* Center the image if its scaled width/height fits within the
|
||||
* viewport
|
||||
*/
|
||||
|
||||
if (image && sx < shell->disp_width)
|
||||
{
|
||||
shell->disp_xoffset = (shell->disp_width - sx) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
shell->disp_xoffset = 0;
|
||||
}
|
||||
|
||||
if (image && sy < shell->disp_height)
|
||||
{
|
||||
shell->disp_yoffset = (shell->disp_height - sy) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
shell->disp_yoffset = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Adjust due to scrolling */
|
||||
|
||||
gimp_display_shell_get_scaled_image_viewport_offset (shell,
|
||||
|
|
|
@ -121,11 +121,29 @@ gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
|
|||
sw = SCALEX (shell, gimp_image_get_width (shell->display->image));
|
||||
sh = SCALEY (shell, gimp_image_get_height (shell->display->image));
|
||||
|
||||
shell->offset_x = CLAMP (shell->offset_x, 0,
|
||||
MAX (sw - shell->disp_width, 0));
|
||||
if (shell->disp_width > sw)
|
||||
{
|
||||
shell->offset_x = -(shell->disp_width - sw) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint min_offset_x = 0;
|
||||
gint max_offset_x = sw - shell->disp_width;
|
||||
|
||||
shell->offset_y = CLAMP (shell->offset_y, 0,
|
||||
MAX (sh - shell->disp_height, 0));
|
||||
shell->offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
|
||||
}
|
||||
|
||||
if (shell->disp_height > sh)
|
||||
{
|
||||
shell->offset_y = -(shell->disp_height - sh) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint min_offset_y = 0;
|
||||
gint max_offset_y = sh - shell->disp_height;
|
||||
|
||||
shell->offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -211,6 +229,69 @@ gimp_display_shell_get_scaled_image_viewport_offset (const GimpDisplayShell *she
|
|||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (x) *x = shell->disp_xoffset - shell->offset_x;
|
||||
if (y) *y = shell->disp_yoffset - shell->offset_y;
|
||||
if (x) *x = -shell->offset_x;
|
||||
if (y) *y = -shell->offset_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_get_disp_offset:
|
||||
* @shell:
|
||||
* @disp_xoffset:
|
||||
* @disp_yoffset:
|
||||
*
|
||||
* In viewport coordinates, get the offset of where to start rendering
|
||||
* the scaled image.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_get_disp_offset (const GimpDisplayShell *shell,
|
||||
gint *disp_xoffset,
|
||||
gint *disp_yoffset)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (disp_xoffset)
|
||||
{
|
||||
if (shell->offset_x < 0)
|
||||
{
|
||||
*disp_xoffset = -shell->offset_x;
|
||||
}
|
||||
else
|
||||
{
|
||||
*disp_xoffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (disp_yoffset)
|
||||
{
|
||||
if (shell->offset_y < 0)
|
||||
{
|
||||
*disp_yoffset = -shell->offset_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
*disp_yoffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_get_render_start_offset:
|
||||
* @shell:
|
||||
* @offset_x:
|
||||
* @offset_y:
|
||||
*
|
||||
* Get the offset into the scaled image that we should start render
|
||||
* from
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_get_render_start_offset (const GimpDisplayShell *shell,
|
||||
gint *offset_x,
|
||||
gint *offset_y)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (offset_x) *offset_x = MAX (0, shell->offset_x);
|
||||
if (offset_y) *offset_y = MAX (0, shell->offset_y);
|
||||
}
|
||||
|
|
|
@ -42,5 +42,13 @@ void gimp_display_shell_get_scaled_image_viewport_offset (const GimpDispla
|
|||
gint *x,
|
||||
gint *y);
|
||||
|
||||
void gimp_display_shell_get_disp_offset (const GimpDisplayShell *shell,
|
||||
gint *disp_xoffset,
|
||||
gint *disp_yoffset);
|
||||
|
||||
void gimp_display_shell_get_render_start_offset (const GimpDisplayShell *shell,
|
||||
gint *offset_x,
|
||||
gint *offset_y);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */
|
||||
|
|
|
@ -257,8 +257,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
|
|||
|
||||
shell->disp_width = 0;
|
||||
shell->disp_height = 0;
|
||||
shell->disp_xoffset = 0;
|
||||
shell->disp_yoffset = 0;
|
||||
|
||||
shell->proximity = FALSE;
|
||||
shell->snap_to_guides = TRUE;
|
||||
|
|
|
@ -99,8 +99,6 @@ struct _GimpDisplayShell
|
|||
|
||||
gint disp_width; /* width of drawing area */
|
||||
gint disp_height; /* height of drawing area */
|
||||
gint disp_xoffset;
|
||||
gint disp_yoffset;
|
||||
|
||||
gboolean proximity; /* is a device in proximity */
|
||||
gboolean snap_to_guides; /* should the guides be snapped to? */
|
||||
|
|
Loading…
Reference in New Issue