Chopped up the display stuff (beware: unfinished)...

2001-10-31  Michael Natterer  <mitch@gimp.org>

	Chopped up the display stuff (beware: unfinished)...

	The plan is that GimpDisplay is the object which collects
	updates from the image, compresses them and waits for the GIMP
	to be idle to actually paint them. It should be a non-GUI object
	which is the model for the actual widget to connect to.

	GimpDisplayShell has all the widgets and handles painting and
	exposing of the result. Nobody should actually be required to
	update ot look at it as it should be a view on the GimpDisplay
	object.

	Much stuff is still in the wrong place and the functions don't
	follow their files' filename namespace any more. More to come...

	* app/display/Makefile.am
	* app/display/gimpdisplay-ops.[ch]: removed. It's functions didn't
	belong together anyway.

	* app/display/gimpdisplay-area.[ch]: new files: the GimpArea
	functions.

	* app/display/gimpdisplay-handlers.[ch]: new files: signal
	handlers for GimpImage signals. Mostly from app/gui.c.

	* app/display/gimpdisplay.[ch]: removed all widgets and other
	GUI stuff. There is still much undecided here...

	* app/display/gimpdisplayshell.[ch]: actually use the object and
	filled it with all the stuff from GimpDisplay.

	* app/display/gimpdisplay-callbacks.[ch]
	* app/display/gimpdisplay-foreach.[ch]
	* app/display/gimpdisplay-render.c
	* app/display/gimpdisplay-scale.[ch]
	* app/display/gimpdisplay-scroll.[ch]
	* app/display/gimpdisplay-selection.c: changed accordingly.

	* app/core/gimp.[ch]: return a GimpObject from
	gimp_create_display() so it can be used as single GUI independent
	point to create displays, require the initial scale as parameter.

	* app/core/gimpcontext.c: changed the ugly EEKWrapper according to
	the GimpDisplay structure changes. Bugfix: set the image to NULL
	in gimp_context_display_destroyed().

	* app/core/gimpedit.c
	* app/core/gimpimage-new.c: changed gimp_create_display() calls
	accordingly.

	* app/core/gimpimage-convert.c: invalidate the layer & image
	previews here, not in the caller.

	* app/core/gimpimage-crop.c: update the whole image after cropping.

	* app/core/gimpimage.[ch]: added gimp_image_find_guide(),
	gimp_image_snap_point() and gimp_image_snap_rectangle(). Added
	"resolution_changed" and "unit_changed" signals and corresp.
	public convenience functions to emit them.

	* app/core/gimplayer.c: emit the image's "alpha_changed" signal
	when adding alpha to the bottom (and only) layer of the image.

	* app/gimpprogress.c
	* app/image_map.c
	* app/nav_window.c
	* app/qmask.c
	* app/undo.c
	* app/user_install.c: changed accordingly.

	* app/gui/edit-commands.c
	* app/gui/file-commands.c
	* app/gui/file-open-dialog.c
	* app/gui/image-commands.c
	* app/gui/info-window.c
	* app/gui/preferences-dialog.c
	* app/gui/toolbox.c
	* app/gui/view-commands.c: ditto.

	* app/gui/gui.[ch]: removed most gimp->images handlers as the
	displays connect to them themselves now. chaged gui_display_new()
	according to the gimp_create_display() changes.
	Added gui_get_screen_resolution().

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpdrawtool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpinktool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.c
	* app/tools/gimprectselecttool.c
	* app/tools/gimpselectiontool.c
	* app/tools/gimptexttool.c
	* app/tools/gimptool.c
	* app/tools/gimptransformtool.c
	* app/tools/xinput_airbrush.c: lots of changes because GimpDisplay
	has become two objects. Lots of gdisp->shell casting uglyness
	added. This is fine because exactly these parts will have to go
	away.

	(GimpDisplay will provide methods for XOR drawing upon the display
	in image coordinates without the need to transform coordinates all
	the time. Also the tools shouldn't see GdkEvents but get more
	useful virtual functions which speak in image coordinates too).

	* app/widgets/gimpcomponentlistitem.c: removed a now useless image
	update.

	* tools/pdbgen/pdb/display.pdb: use gimp_create_display().

	* app/pdb/display_cmds.c: regenerated.
This commit is contained in:
Michael Natterer
2001-10-31 21:18:57 +00:00
committed by Michael Natterer
parent 4158715b25
commit 5f63e079b8
43 changed files with 3267 additions and 1387 deletions

View File

@ -63,6 +63,8 @@
#define TRC(x)
#endif
#define GUIDE_EPSILON 5
/* Local function declarations */
static void gimp_image_class_init (GimpImageClass *klass);
@ -171,6 +173,8 @@ enum
COMPONENT_VISIBILITY_CHANGED,
COMPONENT_ACTIVE_CHANGED,
MASK_CHANGED,
RESOLUTION_CHANGED,
UNIT_CHANGED,
SELECTION_CONTROL,
CLEAN,
@ -302,6 +306,24 @@ gimp_image_class_init (GimpImageClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[RESOLUTION_CHANGED] =
g_signal_new ("resolution_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, resolution_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[UNIT_CHANGED] =
g_signal_new ("unit_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, unit_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[SELECTION_CONTROL] =
g_signal_new ("selection_control",
G_TYPE_FROM_CLASS (klass),
@ -763,22 +785,22 @@ gimp_image_set_resolution (GimpImage *gimage,
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* nothing to do if setting res to the same as before */
if ((ABS (gimage->xresolution - xresolution) < 1e-5) &&
(ABS (gimage->yresolution - yresolution) < 1e-5))
return;
/* don't allow to set the resolution out of bounds */
if (xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
return;
undo_push_resolution (gimage);
if ((ABS (gimage->xresolution - xresolution) >= 1e-5) ||
(ABS (gimage->yresolution - yresolution) >= 1e-5))
{
undo_push_resolution (gimage);
gimage->xresolution = xresolution;
gimage->yresolution = yresolution;
gimage->xresolution = xresolution;
gimage->yresolution = yresolution;
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
gimp_image_resolution_changed (gimage);
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
}
}
void
@ -799,9 +821,14 @@ gimp_image_set_unit (GimpImage *gimage,
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
undo_push_resolution (gimage);
if (gimage->unit != unit)
{
undo_push_resolution (gimage);
gimage->unit = unit;
gimage->unit = unit;
gimp_image_unit_changed (gimage);
}
}
GimpUnit
@ -1609,6 +1636,152 @@ gimp_image_delete_guide (GimpImage *gimage,
}
}
GimpGuide *
gimp_image_find_guide (GimpImage *gimage,
gint x,
gint y)
{
GList *list;
GimpGuide *guide;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (x < 0 || x >= gimage->width ||
y < 0 || y >= gimage->height)
{
return NULL;
}
for (list = gimage->guides; list; list = g_list_next (list))
{
guide = (GimpGuide *) list->data;
if (guide->position < 0)
continue;
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
if (ABS (guide->position - y) < GUIDE_EPSILON)
return guide;
break;
case ORIENTATION_VERTICAL:
if (ABS (guide->position - x) < GUIDE_EPSILON)
return guide;
break;
default:
break;
}
}
return NULL;
}
gboolean
gimp_image_snap_point (GimpImage *gimage,
gint x,
gint y,
gint *tx,
gint *ty)
{
GList *list;
GimpGuide *guide;
gint minxdist, minydist;
gint dist;
gboolean snapped = FALSE;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (tx != NULL, FALSE);
g_return_val_if_fail (ty != NULL, FALSE);
*tx = x;
*ty = y;
if (x < 0 || x >= gimage->width ||
y < 0 || y >= gimage->height)
{
return FALSE;
}
minxdist = G_MAXINT;
minydist = G_MAXINT;
for (list = gimage->guides; list; list = g_list_next (list))
{
guide = (GimpGuide *) list->data;
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
dist = ABS (guide->position - y);
if (dist < MIN (GUIDE_EPSILON, minydist))
{
minydist = dist;
*ty = guide->position;
snapped = TRUE;
}
break;
case ORIENTATION_VERTICAL:
dist = ABS (guide->position - x);
if (dist < MIN (GUIDE_EPSILON, minxdist))
{
minxdist = dist;
*tx = guide->position;
snapped = TRUE;
}
break;
default:
break;
}
}
return snapped;
}
gboolean
gimp_image_snap_rectangle (GimpImage *gimage,
gint x1,
gint y1,
gint x2,
gint y2,
gint *tx1,
gint *ty1)
{
gint nx1, ny1;
gint nx2, ny2;
gboolean snap1, snap2;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (tx1 != NULL, FALSE);
g_return_val_if_fail (ty1 != NULL, FALSE);
*tx1 = x1;
*ty1 = y1;
snap1 = gimp_image_snap_point (gimage, x1, y1, &nx1, &ny1);
snap2 = gimp_image_snap_point (gimage, x2, y2, &nx2, &ny2);
if (snap1 || snap2)
{
if (x1 != nx1)
*tx1 = nx1;
else if (x2 != nx2)
*tx1 = x1 + (nx2 - x2);
if (y1 != ny1)
*ty1 = ny1;
else if (y2 != ny2)
*ty1 = y1 + (ny2 - y2);
}
return snap1 || snap2;
}
GimpParasite *
gimp_image_parasite_find (const GimpImage *gimage,
@ -1835,6 +2008,22 @@ gimp_image_mask_changed (GimpImage *gimage)
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[MASK_CHANGED], 0);
}
void
gimp_image_resolution_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[RESOLUTION_CHANGED], 0);
}
void
gimp_image_unit_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
}
void
gimp_image_alpha_changed (GimpImage *gimage)
{
@ -2726,6 +2915,8 @@ gimp_image_set_component_visible (GimpImage *gimage,
g_signal_emit (G_OBJECT (gimage),
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED], 0,
type);
gimp_image_update (gimage, 0, 0, gimage->width, gimage->height);
}
}