Commit fa537489 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed gdisp->scale, gdisp->dot_for_dot, the scaling marcos and the

2002-06-27  Michael Natterer  <mitch@gimp.org>

	* app/display/gimpdisplay.[ch]: removed gdisp->scale,
	gdisp->dot_for_dot, the scaling marcos and the
	gdisplay_[un]transform[_f]() functions.

	* app/display/gimpdisplayshell.[ch]: added them here. Named the
	transform functions gimp_display_shell_[un]transform_xy[_f]().

	Made the gimp_display_shell_[un]transform_coords() functions copy
	all values of the GimpCoords struct, not just x and y.

	* app/display/gimpstatusbar.[ch]: keep a pointer to
	GimpDisplayShell, not GimpDisplay.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-render.c
	* app/display/gimpdisplayshell-scale.c
	* app/display/gimpdisplayshell-scroll.c
	* app/display/gimpdisplayshell-selection.c
	* app/display/gimpnavigationview.c
	* app/gui/image-commands.c
	* app/gui/info-window.c
	* app/gui/select-commands.c
	* app/gui/view-commands.c
	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpdrawtool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c
	* app/tools/gimpvectortool.c: changed accordingly.

	* app/gui/layers-commands.c: if(gimage->selection_mask) is always
	TRUE, use if(!gimp_image_mask_is_empty(gimage)) instead.

	* app/tools/gimpfuzzyselecttool.[ch]: moved global variables
	to the object struct.
parent 3d232821
2002-06-27 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplay.[ch]: removed gdisp->scale,
gdisp->dot_for_dot, the scaling marcos and the
gdisplay_[un]transform[_f]() functions.
* app/display/gimpdisplayshell.[ch]: added them here. Named the
transform functions gimp_display_shell_[un]transform_xy[_f]().
Made the gimp_display_shell_[un]transform_coords() functions copy
all values of the GimpCoords struct, not just x and y.
* app/display/gimpstatusbar.[ch]: keep a pointer to
GimpDisplayShell, not GimpDisplay.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/display/gimpdisplayshell-selection.c
* app/display/gimpnavigationview.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/select-commands.c
* app/gui/view-commands.c
* app/tools/gimpbezierselecttool.c
* app/tools/gimpcroptool.c
* app/tools/gimpdrawtool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/tools/gimppainttool.c
* app/tools/gimppathtool.c
* app/tools/gimprotatetool.c
* app/tools/gimpscaletool.c
* app/tools/gimpvectortool.c: changed accordingly.
* app/gui/layers-commands.c: if(gimage->selection_mask) is always
TRUE, use if(!gimp_image_mask_is_empty(gimage)) instead.
* app/tools/gimpfuzzyselecttool.[ch]: moved global variables
to the object struct.
2002-06-25 Simon Budig <simon@gimp.org>
* docs/Wilber.svg: Fixed the SVG so that the Adobe Plugin
......
......@@ -35,6 +35,7 @@
#include "core/gimpimage-scale.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpprogress.h"
#include "convert-dialog.h"
......@@ -134,7 +135,7 @@ image_resize_cmd_callback (GtkWidget *widget,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_CALLBACK (image_resize_callback),
NULL,
image_resize);
......@@ -171,7 +172,7 @@ image_scale_cmd_callback (GtkWidget *widget,
gimage->xresolution,
gimage->yresolution,
gimage->unit,
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_CALLBACK (image_scale_callback),
NULL,
image_scale);
......
......@@ -895,7 +895,7 @@ layers_add_mask_query (GimpLayer *layer)
G_CONNECT_SWAPPED);
/* The radio frame and box */
if (gimage->selection_mask)
if (! gimp_image_mask_is_empty (gimage))
{
options->add_mask_type = GIMP_ADD_SELECTION_MASK;
......
......@@ -31,6 +31,7 @@
#include "core/gimpimage-mask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "libgimp/gimpintl.h"
......@@ -135,7 +136,7 @@ select_feather_cmd_callback (GtkWidget *widget,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_OBJECT (gdisp->gimage), "disconnect",
gimp_image_mask_feather_callback, gdisp->gimage);
gtk_widget_show (qbox);
......@@ -170,7 +171,7 @@ select_shrink_cmd_callback (GtkWidget *widget,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_OBJECT (gdisp->gimage), "disconnect",
gimp_image_mask_shrink_callback, gdisp->gimage);
......@@ -203,7 +204,7 @@ select_grow_cmd_callback (GtkWidget *widget,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_OBJECT (gdisp->gimage), "disconnect",
gimp_image_mask_grow_callback, gdisp->gimage);
gtk_widget_show (qbox);
......@@ -225,7 +226,7 @@ select_border_cmd_callback (GtkWidget *widget,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
G_OBJECT (gdisp->gimage), "disconnect",
gimp_image_mask_border_callback, gdisp->gimage);
gtk_widget_show (qbox);
......
......@@ -288,7 +288,8 @@ view_new_view_cmd_callback (GtkWidget *widget,
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
gimp_create_display (gdisp->gimage->gimp, gdisp->gimage, gdisp->scale);
gimp_create_display (gdisp->gimage->gimp, gdisp->gimage,
GIMP_DISPLAY_SHELL (gdisp->shell)->scale);
}
void
......
......@@ -142,8 +142,6 @@ gimp_display_init (GimpDisplay *gdisp)
gdisp->shell = NULL;
gdisp->scale = 0;
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
gdisp->draw_guides = TRUE;
gdisp->snap_to_guides = TRUE;
......@@ -224,11 +222,8 @@ gimp_display_new (GimpImage *gimage,
/* refs the image */
gimp_display_connect (gdisp, gimage);
/* FIXME: this needs to go to GimpDisplayShell */
gdisp->scale = scale;
/* create the shell for the image */
gdisp->shell = gimp_display_shell_new (gdisp);
gdisp->shell = gimp_display_shell_new (gdisp, scale);
gtk_widget_show (gdisp->shell);
......@@ -394,192 +389,20 @@ gimp_display_finish_draw (GimpDisplay *gdisp)
}
/* stuff that will go to GimpDisplayShell */
void
gdisplay_transform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* transform from image coordinates to screen coordinates */
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
{
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&offset_x, &offset_y);
}
else
{
offset_x = offset_y = 0;
}
*nx = (gint) (scalex * (x + offset_x) - shell->offset_x);
*ny = (gint) (scaley * (y + offset_y) - shell->offset_y);
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
gdisplay_untransform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean round,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
{
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&offset_x, &offset_y);
}
else
{
offset_x = offset_y = 0;
}
if (round)
{
*nx = ROUND ((x + shell->offset_x) / scalex - offset_x);
*ny = ROUND ((y + shell->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + shell->offset_x) / scalex - offset_x);
*ny = (int) ((y + shell->offset_y) / scaley - offset_y);
}
}
void
gdisplay_transform_coords_f (GimpDisplay *gdisp,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* transform from gimp coordinates to screen coordinates */
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
{
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&offset_x, &offset_y);
}
else
{
offset_x = offset_y = 0;
}
*nx = scalex * (x + offset_x) - shell->offset_x;
*ny = scaley * (y + offset_y) - shell->offset_y;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
gdisplay_untransform_coords_f (GimpDisplay *gdisp,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
{
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&offset_x, &offset_y);
}
else
{
offset_x = offset_y = 0;
}
*nx = (x + shell->offset_x) / scalex - offset_x;
*ny = (y + shell->offset_y) / scaley - offset_y;
}
/* private functions */
static void
gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* Flush the items in the displays and updates lists -
* but only if gdisplay has been mapped and exposed
*/
if (! GIMP_DISPLAY_SHELL (gdisp->shell)->select)
if (! shell->select)
{
g_warning ("gimp_display_flush_whenever(): called unrealized");
return;
......@@ -620,14 +443,13 @@ gimp_display_flush_whenever (GimpDisplay *gdisp,
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
/* Next the displays... */
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell));
gimp_display_shell_flush (shell);
/* ensure the consistency of the tear-off menus */
if (! now && gimp_context_get_display (gimp_get_user_context
(gdisp->gimage->gimp)) == gdisp)
{
gimp_display_shell_set_menu_sensitivity (GIMP_DISPLAY_SHELL (gdisp->shell),
gdisp->gimage->gimp);
gimp_display_shell_set_menu_sensitivity (shell, gdisp->gimage->gimp);
}
}
......@@ -797,20 +619,20 @@ gimp_display_paint_area (GimpDisplay *gdisp,
h = (y2 - y1);
/* calculate the extents of the update as limited by what's visible */
gdisplay_untransform_coords (gdisp,
0, 0,
&x1, &y1,
FALSE, FALSE);
gdisplay_untransform_coords (gdisp,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);
gimp_display_shell_untransform_xy (shell,
0, 0,
&x1, &y1,
FALSE, FALSE);
gimp_display_shell_untransform_xy (shell,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);
gimp_image_invalidate (gdisp->gimage, x, y, w, h, x1, y1, x2, y2);
/* display the area */
gdisplay_transform_coords (gdisp, x, y, &x1, &y1, FALSE);
gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, FALSE);
gimp_display_shell_transform_xy (shell, x, y, &x1, &y1, FALSE);
gimp_display_shell_transform_xy (shell, x + w, y + h, &x2, &y2, FALSE);
gimp_display_shell_add_expose_area (shell,
x1, y1, (x2 - x1), (y2 - y1));
......
......@@ -23,36 +23,6 @@
#include "core/gimpobject.h"
/* some useful macros */
/* unpacking the user scale level (char) */
#define SCALESRC(g) (g->scale & 0x00ff)
#define SCALEDEST(g) (g->scale >> 8)
/* finding the effective screen resolution (double) */
#define SCREEN_XRES(g) (g->dot_for_dot ? \
g->gimage->xresolution : gimprc.monitor_xres)
#define SCREEN_YRES(g) (g->dot_for_dot ? \
g->gimage->yresolution : gimprc.monitor_yres)
/* calculate scale factors (double) */
#define SCALEFACTOR_X(g) ((SCALEDEST(g) * SCREEN_XRES(g)) / \
(SCALESRC(g) * g->gimage->xresolution))
#define SCALEFACTOR_Y(g) ((SCALEDEST(g) * SCREEN_YRES(g)) / \
(SCALESRC(g) * g->gimage->yresolution))
/* scale values */
#define SCALEX(g,x) ((gint) (x * SCALEFACTOR_X(g)))
#define SCALEY(g,y) ((gint) (y * SCALEFACTOR_Y(g)))
/* unscale values */
#define UNSCALEX(g,x) ((gint) (x / SCALEFACTOR_X(g)))
#define UNSCALEY(g,y) ((gint) (y / SCALEFACTOR_Y(g)))
/* (and float-returning versions) */
#define FUNSCALEX(g,x) (x / SCALEFACTOR_X(g))
#define FUNSCALEY(g,y) (y / SCALEFACTOR_Y(g))
typedef struct _IdleRenderStruct IdleRenderStruct;
struct _IdleRenderStruct
......@@ -90,8 +60,6 @@ struct _GimpDisplay
GtkWidget *shell; /* shell widget for this gdisplay */
gint scale; /* scale factor from original raw image */
gboolean dot_for_dot; /* is monitor resolution being ignored? */
gboolean draw_guides; /* should the guides be drawn? */
gboolean snap_to_guides; /* should the guides be snapped to? */
......@@ -131,33 +99,4 @@ void gimp_display_flush_now (GimpDisplay *gdisp);
void gimp_display_finish_draw (GimpDisplay *gdisp);
/* stuff that will go to GimpDisplayShell */
void gdisplay_transform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean use_offsets);
void gdisplay_untransform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean round,
gboolean use_offsets);
void gdisplay_transform_coords_f (GimpDisplay *gdisp,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets);
void gdisplay_untransform_coords_f (GimpDisplay *gdisp,
gdouble x,
gdouble y,
gdouble *nx,
gdouble *ny,
gboolean use_offsets);
#endif /* __GIMP_DISPLAY_H__ */
......@@ -594,14 +594,17 @@ info_window_free (InfoDialog *info_win)
void
info_window_update (GimpDisplay *gdisp)
{
InfoWinData *iwd;
gint type;
gdouble unit_factor;
gint unit_digits;
gchar format_buf[32];
InfoDialog *info_win;
GimpDisplayShell *shell;
InfoWinData *iwd;
gint type;
gdouble unit_factor;
gint unit_digits;
gchar format_buf[32];
InfoDialog *info_win;
info_win = GIMP_DISPLAY_SHELL (gdisp->shell)->info_dialog;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
info_win = shell->info_dialog;
if (! info_win && info_window_auto != NULL)
info_win = info_window_auto;
......@@ -646,7 +649,7 @@ info_window_update (GimpDisplay *gdisp)
/* user zoom ratio */
g_snprintf (iwd->scale_str, MAX_BUF, "%d:%d",
SCALEDEST (gdisp), SCALESRC (gdisp));
SCALEDEST (shell), SCALESRC (shell));
type = gimp_image_base_type (gdisp->gimage);
......
......@@ -142,8 +142,6 @@ gimp_display_init (GimpDisplay *gdisp)
gdisp->shell = NULL;
gdisp->scale = 0;
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
gdisp->draw_guides = TRUE;
gdisp->snap_to_guides = TRUE;
......@@ -224,11 +222,8 @@ gimp_display_new (GimpImage *gimage,
/* refs the image */
gimp_display_connect (gdisp, gimage);
/* FIXME: this needs to go to GimpDisplayShell */
gdisp->scale = scale;
/* create the shell for the image */
gdisp->shell = gimp_display_shell_new (gdisp);
gdisp->shell = gimp_display_shell_new (gdisp, scale);
gtk_widget_show (gdisp->shell);
......@@ -394,192 +389,20 @@ gimp_display_finish_draw (GimpDisplay *gdisp)
}
/* stuff that will go to GimpDisplayShell */
void
gdisplay_transform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* transform from image coordinates to screen coordinates */
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
{
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&offset_x, &offset_y);
}
else
{
offset_x = offset_y = 0;
}
*nx = (gint) (scalex * (x + offset_x) - shell->offset_x);
*ny = (gint) (scaley * (y + offset_y) - shell->offset_y);
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
gdisplay_untransform_coords (GimpDisplay *gdisp,
gint x,
gint y,
gint *nx,
gint *ny,
gboolean round,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gdouble scalex;
gdouble scaley;
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_return_if_fail (nx != NULL);
g_return_if_fail (ny != NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to image coordinates */