renamed newly added members to scale_x and scale_y and removed the

2007-03-14  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell.[ch]: renamed newly added members
	to scale_x and scale_y and removed the SCALEFACTOR macros.

	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-render.c
	* app/display/gimpdisplayshell-scale.c
	* app/display/gimpdisplayshell-transform.c
	* app/display/gimpnavigationeditor.c
	* app/tools/gimpforegroundselecttool.c
	* app/tools/gimprectangletool.c: changed accordingly.


svn path=/trunk/; revision=22120
This commit is contained in:
Sven Neumann 2007-03-14 10:26:19 +00:00 committed by Sven Neumann
parent 94fe72a220
commit b95ead41e3
10 changed files with 94 additions and 107 deletions

View File

@ -1,3 +1,16 @@
2007-03-14 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell.[ch]: renamed newly added members
to scale_x and scale_y and removed the SCALEFACTOR macros.
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-transform.c
* app/display/gimpnavigationeditor.c
* app/tools/gimpforegroundselecttool.c
* app/tools/gimprectangletool.c: changed accordingly.
2007-03-14 Michael Natterer <mitch@gimp.org>
* app/core/gimpbrush.c

View File

@ -416,7 +416,7 @@ static void
gimp_display_shell_resolution_changed_handler (GimpImage *image,
GimpDisplayShell *shell)
{
gimp_display_shell_scale_factor_changed (shell);
gimp_display_shell_scale_changed (shell);
if (shell->dot_for_dot)
{
@ -587,7 +587,7 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
shell->monitor_yres = GIMP_DISPLAY_CONFIG (config)->monitor_yres;
}
gimp_display_shell_scale_factor_changed (shell);
gimp_display_shell_scale_changed (shell);
if (! shell->dot_for_dot)
{

View File

@ -841,8 +841,8 @@ render_image_init_info_full (RenderInfo *info,
info->shell = shell;
info->w = w;
info->h = h;
info->scalex = SCALEFACTOR_X (shell);
info->scaley = SCALEFACTOR_Y (shell);
info->scalex = shell->scale_x;
info->scaley = shell->scale_y;
info->dest_bpp = 3;
info->dest_bpl = info->dest_bpp * GIMP_RENDER_BUF_WIDTH;
info->dest_width = info->dest_bpp * info->w;

View File

@ -91,7 +91,6 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
GtkRuler *hruler;
GtkRuler *vruler;
gfloat sx, sy;
gfloat stepx, stepy;
gint image_width, image_height;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@ -102,22 +101,20 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
image_width = shell->display->image->width;
image_height = shell->display->image->height;
sx = SCALEX (shell, image_width);
sy = SCALEY (shell, image_height);
stepx = SCALEFACTOR_X (shell);
stepy = SCALEFACTOR_Y (shell);
sx = SCALEX (shell, image_width);
sy = SCALEY (shell, image_height);
shell->hsbdata->value = shell->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 = stepx;
shell->hsbdata->step_increment = shell->scale_x;
shell->vsbdata->value = shell->offset_y;
shell->vsbdata->upper = sy;
shell->vsbdata->page_size = MIN (sy, shell->disp_height);
shell->vsbdata->page_increment = shell->disp_height / 2;
shell->vsbdata->step_increment = stepy;
shell->vsbdata->step_increment = shell->scale_y;
gtk_adjustment_changed (shell->hsbdata);
gtk_adjustment_changed (shell->vsbdata);
@ -266,7 +263,7 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
shell->dot_for_dot = dot_for_dot;
gimp_display_shell_scale_factor_changed (shell);
gimp_display_shell_scale_changed (shell);
gimp_display_shell_scale_resize (shell,
GIMP_DISPLAY_CONFIG (gimp->config)->resize_windows_on_zoom,

View File

@ -54,8 +54,8 @@ gimp_display_shell_transform_coordinate (GimpDisplayShell *shell,
*display_coords = *image_coords;
display_coords->x = SCALEFACTOR_X (shell) * image_coords->x;
display_coords->y = SCALEFACTOR_Y (shell) * image_coords->y;
display_coords->x = shell->scale_x * image_coords->x;
display_coords->y = shell->scale_y * image_coords->y;
display_coords->x += - shell->offset_x + shell->disp_xoffset;
display_coords->y += - shell->offset_y + shell->disp_yoffset;
@ -84,8 +84,8 @@ gimp_display_shell_untransform_coordinate (GimpDisplayShell *shell,
image_coords->x = display_coords->x - shell->disp_xoffset + shell->offset_x;
image_coords->y = display_coords->y - shell->disp_yoffset + shell->offset_y;
image_coords->x /= SCALEFACTOR_X (shell);
image_coords->y /= SCALEFACTOR_Y (shell);
image_coords->x /= shell->scale_x;
image_coords->y /= shell->scale_y;
}
void
@ -111,8 +111,8 @@ gimp_display_shell_transform_xy (GimpDisplayShell *shell,
gimp_item_offsets (item, &offset_x, &offset_y);
}
x = SCALEFACTOR_X (shell) * (x + offset_x) - shell->offset_x;
y = SCALEFACTOR_Y (shell) * (y + offset_y) - shell->offset_y;
x = shell->scale_x * (x + offset_x) - shell->offset_x;
y = shell->scale_y * (y + offset_y) - shell->offset_y;
/* The projected coordinates can easily overflow a gint in the case of big
images at high zoom levels, so we clamp them here to avoid problems. */
@ -168,13 +168,13 @@ gimp_display_shell_untransform_xy (GimpDisplayShell *shell,
if (round)
{
*nx = ROUND ((x + shell->offset_x) / SCALEFACTOR_X (shell) - offset_x);
*ny = ROUND ((y + shell->offset_y) / SCALEFACTOR_Y (shell) - offset_y);
*nx = ROUND ((x + shell->offset_x) / shell->scale_x - offset_x);
*ny = ROUND ((y + shell->offset_y) / shell->scale_y - offset_y);
}
else
{
*nx = (gint) ((x + shell->offset_x) / SCALEFACTOR_X (shell) - offset_x);
*ny = (gint) ((y + shell->offset_y) / SCALEFACTOR_Y (shell) - offset_y);
*nx = (gint) ((x + shell->offset_x) / shell->scale_x - offset_x);
*ny = (gint) ((y + shell->offset_y) / shell->scale_y - offset_y);
}
}
@ -214,8 +214,8 @@ gimp_display_shell_transform_xy_f (GimpDisplayShell *shell,
gimp_item_offsets (item, &offset_x, &offset_y);
}
*nx = SCALEFACTOR_X (shell) * (x + offset_x) - shell->offset_x;
*ny = SCALEFACTOR_Y (shell) * (y + offset_y) - shell->offset_y;
*nx = shell->scale_x * (x + offset_x) - shell->offset_x;
*ny = shell->scale_y * (y + offset_y) - shell->offset_y;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
@ -261,8 +261,8 @@ gimp_display_shell_untransform_xy_f (GimpDisplayShell *shell,
gimp_item_offsets (item, &offset_x, &offset_y);
}
*nx = (x + shell->offset_x) / SCALEFACTOR_X (shell) - offset_x;
*ny = (y + shell->offset_y) / SCALEFACTOR_Y (shell) - offset_y;
*nx = (x + shell->offset_x) / shell->scale_x - offset_x;
*ny = (y + shell->offset_y) / shell->scale_y - offset_y;
}
/**
@ -284,18 +284,12 @@ gimp_display_shell_transform_points (GimpDisplayShell *shell,
gint n_points,
gboolean use_offsets)
{
gdouble scalex;
gdouble scaley;
gint offset_x = 0;
gint offset_y = 0;
gint i;
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* transform from image coordinates to screen coordinates */
scalex = SCALEFACTOR_X (shell);
scaley = SCALEFACTOR_Y (shell);
if (use_offsets)
{
GimpItem *item;
@ -306,8 +300,10 @@ gimp_display_shell_transform_points (GimpDisplayShell *shell,
for (i = 0; i < n_points ; i++)
{
gdouble x = scalex * (points[i * 2] + offset_x) - shell->offset_x;
gdouble y = scaley * (points[i * 2 + 1] + offset_y) - shell->offset_y;
gdouble x, y;
x = shell->scale_x * (points[i * 2] + offset_x) - shell->offset_x;
y = shell->scale_y * (points[i * 2 + 1] + offset_y) - shell->offset_y;
/* The projected coordinates can easily overflow a gint in the
case of big images at high zoom levels, so we clamp them here
@ -340,18 +336,12 @@ gimp_display_shell_transform_coords (GimpDisplayShell *shell,
gint n_coords,
gboolean use_offsets)
{
gdouble scalex;
gdouble scaley;
gint offset_x = 0;
gint offset_y = 0;
gint i;
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* transform from image coordinates to screen coordinates */
scalex = SCALEFACTOR_X (shell);
scaley = SCALEFACTOR_Y (shell);
if (use_offsets)
{
GimpItem *item;
@ -362,8 +352,10 @@ gimp_display_shell_transform_coords (GimpDisplayShell *shell,
for (i = 0; i < n_coords ; i++)
{
gdouble x = scalex * (image_coords[i].x + offset_x) - shell->offset_x;
gdouble y = scaley * (image_coords[i].y + offset_y) - shell->offset_y;
gdouble x, y;
x = shell->scale_x * (image_coords[i].x + offset_x) - shell->offset_x;
y = shell->scale_y * (image_coords[i].y + offset_y) - shell->offset_y;
/* The projected coordinates can easily overflow a gint in the
case of big images at high zoom levels, so we clamp them here
@ -396,18 +388,12 @@ gimp_display_shell_transform_segments (GimpDisplayShell *shell,
gint n_segs,
gboolean use_offsets)
{
gdouble scalex;
gdouble scaley;
gint offset_x = 0;
gint offset_y = 0;
gint i;
gint offset_x = 0;
gint offset_y = 0;
gint i;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* transform from image coordinates to screen coordinates */
scalex = SCALEFACTOR_X (shell);
scaley = SCALEFACTOR_Y (shell);
if (use_offsets)
{
GimpItem *item;
@ -418,10 +404,13 @@ gimp_display_shell_transform_segments (GimpDisplayShell *shell,
for (i = 0; i < n_segs ; i++)
{
gdouble x1 = scalex * (src_segs[i].x1 + offset_x) - shell->offset_x;
gdouble x2 = scalex * (src_segs[i].x2 + offset_x) - shell->offset_x;
gdouble y1 = scaley * (src_segs[i].y1 + offset_y) - shell->offset_y;
gdouble y2 = scaley * (src_segs[i].y2 + offset_y) - shell->offset_y;
gdouble x1, x2;
gdouble y1, y2;
x1 = shell->scale_x * (src_segs[i].x1 + offset_x) - shell->offset_x;
x2 = shell->scale_x * (src_segs[i].x2 + offset_x) - shell->offset_x;
y1 = shell->scale_y * (src_segs[i].y1 + offset_y) - shell->offset_y;
y2 = shell->scale_y * (src_segs[i].y2 + offset_y) - shell->offset_y;
/* The projected coordinates can easily overflow a gint in the
case of big images at high zoom levels, so we clamp them here

View File

@ -220,9 +220,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->offset_x = 0;
shell->offset_y = 0;
shell->scale_factor_x = 1.0;
shell->scale_factor_y = 1.0;
shell->scale_x = 1.0;
shell->scale_y = 1.0;
shell->last_scale = 0.0;
shell->last_scale_time = 0;
@ -328,7 +327,7 @@ gimp_display_shell_init (GimpDisplayShell *shell)
/* zoom model callback */
g_signal_connect_swapped (shell->zoom, "zoomed",
G_CALLBACK (gimp_display_shell_scale_factor_changed),
G_CALLBACK (gimp_display_shell_scale_changed),
shell);
/* active display callback */
@ -1111,17 +1110,17 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell)
* shell and call this function whenever they need to be recalculated.
*/
void
gimp_display_shell_scale_factor_changed (GimpDisplayShell *shell)
gimp_display_shell_scale_changed (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
shell->scale_factor_x = (gimp_zoom_model_get_factor (shell->zoom)
* SCREEN_XRES (shell)
/ shell->display->image->xresolution);
shell->scale_x = (gimp_zoom_model_get_factor (shell->zoom)
* SCREEN_XRES (shell)
/ shell->display->image->xresolution);
shell->scale_factor_y = (gimp_zoom_model_get_factor (shell->zoom)
* SCREEN_YRES (shell)
/ shell->display->image->yresolution);
shell->scale_y = (gimp_zoom_model_get_factor (shell->zoom)
* SCREEN_YRES (shell)
/ shell->display->image->yresolution);
}
void

View File

@ -34,20 +34,16 @@
#define SCREEN_YRES(s) ((s)->dot_for_dot ? \
(s)->display->image->yresolution : (s)->monitor_yres)
/* calculate scale factors (double) */
#define SCALEFACTOR_X(s) (s->scale_factor_x)
#define SCALEFACTOR_Y(s) (s->scale_factor_y)
/* scale values */
#define SCALEX(s,x) PROJ_ROUND ((x) * SCALEFACTOR_X(s))
#define SCALEY(s,y) PROJ_ROUND ((y) * SCALEFACTOR_Y(s))
#define SCALEX(s,x) PROJ_ROUND ((x) * (s)->scale_x)
#define SCALEY(s,y) PROJ_ROUND ((y) * (s)->scale_y)
/* unscale values */
#define UNSCALEX(s,x) ((gint) ((x) / SCALEFACTOR_X(s)))
#define UNSCALEY(s,y) ((gint) ((y) / SCALEFACTOR_Y(s)))
#define UNSCALEX(s,x) ((gint) ((x) / (s)->scale_x))
#define UNSCALEY(s,y) ((gint) ((y) / (s)->scale_y))
/* (and float-returning versions) */
#define FUNSCALEX(s,x) ((x) / SCALEFACTOR_X(s))
#define FUNSCALEY(s,y) ((y) / SCALEFACTOR_Y(s))
#define FUNSCALEX(s,x) ((x) / (s)->scale_x)
#define FUNSCALEY(s,y) ((y) / (s)->scale_y)
#define GIMP_TYPE_DISPLAY_SHELL (gimp_display_shell_get_type ())
@ -81,8 +77,8 @@ struct _GimpDisplayShell
gint offset_x; /* offset of display image into raw image */
gint offset_y;
gdouble scale_factor_x; /* cache for scale factor */
gdouble scale_factor_y; /* cache for scale factor */
gdouble scale_x; /* horizontal scale factor */
gdouble scale_y; /* vertical scale factor */
gdouble last_scale; /* scale used when reverting zoom */
guint last_scale_time; /* time when last_scale was set */
@ -201,7 +197,7 @@ GtkWidget * gimp_display_shell_new (GimpDisplay *display,
void gimp_display_shell_reconnect (GimpDisplayShell *shell);
void gimp_display_shell_scale_factor_changed (GimpDisplayShell *shell);
void gimp_display_shell_scale_changed (GimpDisplayShell *shell);
void gimp_display_shell_scaled (GimpDisplayShell *shell);
void gimp_display_shell_scrolled (GimpDisplayShell *shell);

View File

@ -493,13 +493,10 @@ gimp_navigation_editor_marker_changed (GimpNavigationView *view,
if (editor->shell)
{
GimpDisplayShell *shell = editor->shell;
gint xoffset;
gint yoffset;
xoffset = RINT (x * SCALEFACTOR_X (shell) - shell->offset_x);
yoffset = RINT (y * SCALEFACTOR_Y (shell) - shell->offset_y);
gimp_display_shell_scroll (shell, xoffset, yoffset);
gimp_display_shell_scroll (shell,
RINT (x * shell->scale_x - shell->offset_x),
RINT (y * shell->scale_y - shell->offset_y));
}
}
@ -636,15 +633,13 @@ gimp_navigation_editor_update_marker (GimpNavigationEditor *editor)
{
GimpViewRenderer *renderer = GIMP_VIEW (editor->view)->renderer;
GimpDisplayShell *shell = editor->shell;
gdouble xratio = SCALEFACTOR_X (shell);
gdouble yratio = SCALEFACTOR_Y (shell);
if (renderer->dot_for_dot != shell->dot_for_dot)
gimp_view_renderer_set_dot_for_dot (renderer, shell->dot_for_dot);
gimp_navigation_view_set_marker (GIMP_NAVIGATION_VIEW (editor->view),
shell->offset_x / xratio,
shell->offset_y / yratio,
shell->disp_width / xratio,
shell->disp_height / yratio);
shell->offset_x / shell->scale_x,
shell->offset_y / shell->scale_y,
shell->disp_width / shell->scale_x,
shell->disp_height / shell->scale_y);
}

View File

@ -566,14 +566,13 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
if (fg_select->mask)
{
GimpFreeSelectTool *sel = GIMP_FREE_SELECT_TOOL (tool);
gint x = sel->last_coords.x;
gint y = sel->last_coords.y;
GimpFreeSelectTool *sel = GIMP_FREE_SELECT_TOOL (tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
gint x = sel->last_coords.x;
gint y = sel->last_coords.y;
gdouble radius;
radius = (options->stroke_width /
SCALEFACTOR_Y (GIMP_DISPLAY_SHELL (draw_tool->display->shell)));
radius /= 2;
radius = (options->stroke_width / shell->scale_y) / 2;
/* warn if the user is drawing outside of the working area */
if (FALSE)
@ -802,8 +801,7 @@ gimp_foreground_select_tool_push_stroke (GimpForegroundSelectTool *fg_select,
stroke = g_new (FgSelectStroke, 1);
stroke->background = options->background;
stroke->width = ROUND ((gdouble) options->stroke_width /
SCALEFACTOR_Y (shell));
stroke->width = ROUND ((gdouble) options->stroke_width / shell->scale_y);
stroke->num_points = fg_select->stroke->len;
stroke->points = (GimpVector2 *) g_array_free (fg_select->stroke, FALSE);

View File

@ -1362,8 +1362,8 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
coords->y > private->y1 && coords->y < private->y2)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
gdouble handle_w = private->handle_w / SCALEFACTOR_X (shell);
gdouble handle_h = private->handle_h / SCALEFACTOR_Y (shell);
gdouble handle_w = private->handle_w / shell->scale_x;
gdouble handle_h = private->handle_h / shell->scale_y;
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,