removed ClutterReal; added clutter-units

This commit is contained in:
Tomas Frydrych 2007-05-22 09:31:40 +00:00
parent 8bbc7c27a8
commit a338a95796
24 changed files with 572 additions and 492 deletions

View File

@ -1,3 +1,23 @@
2007-05-22 Tomas Frydrych <tf@openedhand.com>
* configure.ac:
* Makefile.am:
* clutter.pc.in:
* clutter/Makefile.am:
* clutter/clutter-actor.c:
* clutter/clutter-actor.h:
* clutter/clutter-group.c:
* clutter/clutter-label.c:
* clutter/clutter-real.h:
* clutter/clutter-units.h:
* clutter/clutter.h:
* clutter/egl/clutter-stage-egl.c:
* clutter/glx/clutter-stage-glx.c:
* clutter/sdl/clutter-stage-sdl.c:
* examples/Makefile.am:
* tests/Makefile.am:
Removed ClutterReal; added clutter-units.
2007-05-18 Tomas Frydrych <tf@openedhand.com> 2007-05-18 Tomas Frydrych <tf@openedhand.com>
* configure.ac: * configure.ac:

View File

@ -1,8 +1,8 @@
SUBDIRS=clutter doc examples tests SUBDIRS=clutter doc examples tests
pcfiles = clutter@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc pcfiles = clutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc
%@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc: %.pc %-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc: %.pc
cp $< $@ cp $< $@
pkgconfig_DATA = $(pcfiles) pkgconfig_DATA = $(pcfiles)

View File

@ -3,12 +3,11 @@ exec_prefix=${prefix}
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
includedir=${prefix}/include includedir=${prefix}/include
backend=@clutterbackend@ backend=@clutterbackend@
real=@CLUTTER_REAL@
apiversion=@CLUTTER_API_VERSION@ apiversion=@CLUTTER_API_VERSION@
Name: Clutter Name: Clutter
Description: Clutter Core Library (${backend} backend) Description: Clutter Core Library (${backend} backend)
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lclutter${real}-${backend}-${apiversion} Libs: -L${libdir} -lclutter-${backend}-${apiversion}
Cflags: -I${includedir}/clutter-${apiversion} Cflags: -I${includedir}/clutter-${apiversion}
Requires: glib-2.0 >= 2.10 gobject-2.0 gthread-2.0 pangoft2 gdk-pixbuf-2.0 gdk-pixbuf-xlib-2.0 Requires: glib-2.0 >= 2.10 gobject-2.0 gthread-2.0 pangoft2 gdk-pixbuf-2.0 gdk-pixbuf-xlib-2.0

View File

@ -60,6 +60,7 @@ source_h = \
$(srcdir)/clutter-texture.h \ $(srcdir)/clutter-texture.h \
$(srcdir)/clutter-timeline.h \ $(srcdir)/clutter-timeline.h \
$(srcdir)/clutter-effect.h \ $(srcdir)/clutter-effect.h \
$(srcdir)/clutter-units.h \
$(srcdir)/clutter-util.h \ $(srcdir)/clutter-util.h \
$(srcdir)/clutter-version.h \ $(srcdir)/clutter-version.h \
$(NULL) $(NULL)
@ -159,19 +160,19 @@ source_h_priv = \
$(NULL) $(NULL)
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \ libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \
$(CLUTTER_LIBS) pango/libpangoclutter.la \ $(CLUTTER_LIBS) pango/libpangoclutter.la \
@CLUTTER_FLAVOUR@/libclutter-@CLUTTER_FLAVOUR@.la \ @CLUTTER_FLAVOUR@/libclutter-@CLUTTER_FLAVOUR@.la \
cogl/@CLUTTER_COGL@/libclutter-cogl.la cogl/@CLUTTER_COGL@/libclutter-cogl.la
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_SOURCES = \ libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_SOURCES = \
$(source_c) $(source_h) $(source_h_priv) $(source_c) $(source_h) $(source_h_priv)
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LDFLAGS = $(LDADD) libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LDFLAGS = $(LDADD)
lib_LTLIBRARIES = $(clutterbackendlib) lib_LTLIBRARIES = $(clutterbackendlib)
EXTRA_LTLIBRARIES = libclutter@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la EXTRA_LTLIBRARIES = libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la
clutterdir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter clutterdir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter

View File

@ -39,6 +39,7 @@
#include "clutter-marshal.h" #include "clutter-marshal.h"
#include "clutter-private.h" #include "clutter-private.h"
#include "clutter-debug.h" #include "clutter-debug.h"
#include "clutter-units.h"
#include "cogl.h" #include "cogl.h"
#include <GL/gl.h> #include <GL/gl.h>
@ -55,7 +56,7 @@ static guint32 __id = 0;
struct _ClutterActorPrivate struct _ClutterActorPrivate
{ {
ClutterActorBoxReal coords; ClutterActorBox coords;
ClutterGeometry clip; ClutterGeometry clip;
guint has_clip : 1; guint has_clip : 1;
@ -308,8 +309,8 @@ clutter_actor_paint (ClutterActor *self)
if (clutter_actor_get_parent (self) != NULL) if (clutter_actor_get_parent (self) != NULL)
{ {
cogl_translate (CLUTTER_REAL_TO_FLOAT (priv->coords.x1), cogl_translate (CLUTTER_FIXED_TO_FLOAT (priv->coords.x1),
CLUTTER_REAL_TO_FLOAT (priv->coords.y1), CLUTTER_FIXED_TO_FLOAT (priv->coords.y1),
0); 0);
} }
@ -383,9 +384,19 @@ clutter_actor_paint (ClutterActor *self)
cogl_pop_matrix(); cogl_pop_matrix();
} }
/**
* clutter_actor_request_coords:
* @self: A #ClutterActor
* @box: A #ClutterActorBox with requested new co-ordinates.
*
* Requests new co-ordinates for the #ClutterActor ralative to any parent.
*
* This function should not be called directly by applications instead
* the various position/geometry methods should be used.
**/
void void
_clutter_actor_request_coords_real (ClutterActor *self, clutter_actor_request_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterActorClass *klass; ClutterActorClass *klass;
gboolean x_change, y_change, width_change, height_change; gboolean x_change, y_change, width_change, height_change;
@ -395,11 +406,11 @@ _clutter_actor_request_coords_real (ClutterActor *self,
if (klass->request_coords) if (klass->request_coords)
klass->request_coords (self, box); klass->request_coords (self, box);
x_change = CLUTTER_REAL_NE (self->priv->coords.x1, box->x1); x_change = (self->priv->coords.x1 != box->x1);
y_change = CLUTTER_REAL_NE (self->priv->coords.y1, box->y1); y_change = (self->priv->coords.y1 != box->y1);
width_change = CLUTTER_REAL_NE ((self->priv->coords.x2 - self->priv->coords.x1), width_change = ((self->priv->coords.x2 - self->priv->coords.x1) !=
(box->x2 - box->x1)); (box->x2 - box->x1));
height_change = CLUTTER_REAL_NE ((self->priv->coords.y2 - self->priv->coords.y1), height_change = ((self->priv->coords.y2 - self->priv->coords.y1) !=
(box->y2 - box->y1)); (box->y2 - box->y1));
if (x_change || y_change || width_change || height_change) if (x_change || y_change || width_change || height_change)
@ -432,59 +443,6 @@ _clutter_actor_request_coords_real (ClutterActor *self,
} }
} }
/**
* clutter_actor_request_coords:
* @self: A #ClutterActor
* @box: A #ClutterActorBox with requested new co-ordinates.
*
* Requests new co-ordinates for the #ClutterActor ralative to any parent.
*
* This function should not be called directly by applications instead
* the various position/geometry methods should be used.
**/
void
clutter_actor_request_coords (ClutterActor *self,
ClutterActorBox *box)
{
ClutterActorBoxReal rbox;
rbox.x1 = CLUTTER_REAL_FROM_INT (box->x1);
rbox.y1 = CLUTTER_REAL_FROM_INT (box->y1);
rbox.x2 = CLUTTER_REAL_FROM_INT (box->x2);
rbox.y2 = CLUTTER_REAL_FROM_INT (box->y2);
_clutter_actor_request_coords_real (self, &rbox);
}
void
_clutter_actor_allocate_coords_real (ClutterActor *self,
ClutterActorBoxReal *rbox)
{
ClutterActorClass *klass;
klass = CLUTTER_ACTOR_GET_CLASS (self);
rbox->x1 = self->priv->coords.x1;
rbox->y1 = self->priv->coords.y1;
rbox->x2 = self->priv->coords.x2;
rbox->y2 = self->priv->coords.y2;
if (klass->allocate_coords)
{
/* FIXME: This is kind of a cludge - we pass out *private*
* co-ords down to any subclasses so they can modify
* we then resync any changes. Needed for group class.
* Need to figure out nicer way.
*/
klass->allocate_coords(self, rbox);
self->priv->coords.x1 = rbox->x1;
self->priv->coords.y1 = rbox->y1;
self->priv->coords.x2 = rbox->x2;
self->priv->coords.y2 = rbox->y2;
}
}
/** /**
* clutter_actor_allocate_coords: * clutter_actor_allocate_coords:
* @self: A #ClutterActor * @self: A #ClutterActor
@ -500,14 +458,29 @@ void
clutter_actor_allocate_coords (ClutterActor *self, clutter_actor_allocate_coords (ClutterActor *self,
ClutterActorBox *box) ClutterActorBox *box)
{ {
ClutterActorBoxReal rbox; ClutterActorClass *klass;
_clutter_actor_allocate_coords_real (self, &rbox); klass = CLUTTER_ACTOR_GET_CLASS (self);
box->x1 = CLUTTER_REAL_TO_INT (rbox.x1); box->x1 = self->priv->coords.x1;
box->y1 = CLUTTER_REAL_TO_INT (rbox.y1); box->y1 = self->priv->coords.y1;
box->x2 = CLUTTER_REAL_TO_INT (rbox.x2); box->x2 = self->priv->coords.x2;
box->y2 = CLUTTER_REAL_TO_INT (rbox.y2); box->y2 = self->priv->coords.y2;
if (klass->allocate_coords)
{
/* FIXME: This is kind of a cludge - we pass out *private*
* co-ords down to any subclasses so they can modify
* we then resync any changes. Needed for group class.
* Need to figure out nicer way.
*/
klass->allocate_coords(self, box);
self->priv->coords.x1 = box->x1;
self->priv->coords.y1 = box->y1;
self->priv->coords.x2 = box->x2;
self->priv->coords.y2 = box->y2;
}
} }
static void static void
@ -926,10 +899,10 @@ clutter_actor_set_geometry (ClutterActor *self,
{ {
ClutterActorBox box; ClutterActorBox box;
box.x1 = geometry->x; box.x1 = CLUTTER_UNITS_FROM_INT (geometry->x);
box.y1 = geometry->y; box.y1 = CLUTTER_UNITS_FROM_INT (geometry->y);
box.x2 = geometry->x + geometry->width; box.x2 = CLUTTER_UNITS_FROM_INT (geometry->x + geometry->width);
box.y2 = geometry->y + geometry->height; box.y2 = CLUTTER_UNITS_FROM_INT (geometry->y + geometry->height);
clutter_actor_request_coords (self, &box); clutter_actor_request_coords (self, &box);
} }
@ -951,10 +924,10 @@ clutter_actor_get_geometry (ClutterActor *self,
clutter_actor_allocate_coords (self, &box); clutter_actor_allocate_coords (self, &box);
geometry->x = box.x1; geometry->x = CLUTTER_UNITS_TO_INT (box.x1);
geometry->y = box.y1; geometry->y = CLUTTER_UNITS_TO_INT (box.y1);
geometry->width = box.x2 - box.x1; geometry->width = CLUTTER_UNITS_TO_INT (box.x2 - box.x1);
geometry->height = box.y2 - box.y1; geometry->height = CLUTTER_UNITS_TO_INT (box.y2 - box.y1);
} }
/** /**
@ -975,43 +948,23 @@ clutter_actor_get_coords (ClutterActor *self,
gint *x2, gint *x2,
gint *y2) gint *y2)
{ {
ClutterActorBoxReal box; ClutterActorBox box;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
_clutter_actor_allocate_coords_real (self, &box); clutter_actor_allocate_coords (self, &box);
if (x1) if (x1)
*x1 = CLUTTER_REAL_TO_INT (box.x1); *x1 = CLUTTER_UNITS_TO_INT (box.x1);
if (y1) if (y1)
*y1 = CLUTTER_REAL_TO_INT (box.y1); *y1 = CLUTTER_UNITS_TO_INT (box.y1);
if (x2) if (x2)
*x2 = CLUTTER_REAL_TO_INT (box.x2); *x2 = CLUTTER_UNITS_TO_INT (box.x2);
if (y2) if (y2)
*y2 = CLUTTER_REAL_TO_INT (box.y2); *y2 = CLUTTER_UNITS_TO_INT (box.y2);
}
static void
_clutter_actor_set_position_real (ClutterActor *self,
ClutterReal x,
ClutterReal y)
{
ClutterActorBoxReal box;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
_clutter_actor_allocate_coords_real (self, &box);
box.x2 += (x - box.x1);
box.y2 += (y - box.y1);
box.x1 = x;
box.y1 = y;
_clutter_actor_request_coords_real (self, &box);
} }
/** /**
@ -1028,10 +981,19 @@ clutter_actor_set_position (ClutterActor *self,
gint x, gint x,
gint y) gint y)
{ {
ClutterReal xr = CLUTTER_REAL_FROM_INT (x); ClutterActorBox box;
ClutterReal yr = CLUTTER_REAL_FROM_INT (y);
_clutter_actor_set_position_real (self, xr, yr); g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
box.x2 += (CLUTTER_UNITS_FROM_INT (x) - box.x1);
box.y2 += (CLUTTER_UNITS_FROM_INT (y) - box.y1);
box.x1 = CLUTTER_UNITS_FROM_INT (x);
box.y1 = CLUTTER_UNITS_FROM_INT (y);
clutter_actor_request_coords (self, &box);
} }
/** /**
@ -1050,20 +1012,20 @@ clutter_actor_move_by (ClutterActor *self,
gint dx, gint dx,
gint dy) gint dy)
{ {
ClutterActorBoxReal box; ClutterActorBox box;
ClutterReal dxr = CLUTTER_REAL_FROM_INT (dx); gint32 dxu = CLUTTER_UNITS_FROM_INT (dx);
ClutterReal dyr = CLUTTER_REAL_FROM_INT (dy); gint32 dyu = CLUTTER_UNITS_FROM_INT (dy);
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
_clutter_actor_allocate_coords_real (self, &box); clutter_actor_allocate_coords (self, &box);
box.x2 += dxr; box.x2 += dxu;
box.y2 += dyr; box.y2 += dyu;
box.x1 += dxr; box.x1 += dxu;
box.y1 += dyr; box.y1 += dyu;
_clutter_actor_request_coords_real (self, &box); clutter_actor_request_coords (self, &box);
} }
/** /**
@ -1080,16 +1042,16 @@ clutter_actor_set_size (ClutterActor *self,
gint width, gint width,
gint height) gint height)
{ {
ClutterActorBoxReal box; ClutterActorBox box;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
_clutter_actor_allocate_coords_real (self, &box); clutter_actor_allocate_coords (self, &box);
box.x2 = CLUTTER_REAL_ADD_INT (box.x1, width); box.x2 = box.x1 + CLUTTER_UNITS_FROM_INT (width);
box.y2 = CLUTTER_REAL_ADD_INT (box.y1, height); box.y2 = box.y1 + CLUTTER_UNITS_FROM_INT (height);
_clutter_actor_request_coords_real (self, &box); clutter_actor_request_coords (self, &box);
} }
/** /**
@ -1116,52 +1078,6 @@ clutter_actor_get_size (ClutterActor *self,
*height = clutter_actor_get_height (self); *height = clutter_actor_get_height (self);
} }
void
_clutter_actor_get_abs_position_real (ClutterActor *self,
ClutterReal *x,
ClutterReal *y)
{
ClutterActorBoxReal box;
ClutterActor *parent;
ClutterReal px = 0, py = 0;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
_clutter_actor_allocate_coords_real (self, &box);
parent = self->priv->parent_actor;
/* FIXME: must be nicer way to get 0,0 for stage ? */
if (parent)
{
ClutterFixed parent_scale_x, parent_scale_y;
ClutterReal sx, sy;
clutter_actor_get_scalex (parent,
&parent_scale_x,
&parent_scale_y);
sx = CLUTTER_REAL_FROM_FIXED (parent_scale_x);
sy = CLUTTER_REAL_FROM_FIXED (parent_scale_y);
if (parent_scale_x != CFX_ONE ||
parent_scale_y != CFX_ONE)
{
box.x1 = CLUTTER_REAL_MUL (box.x1, sx);
box.y1 = CLUTTER_REAL_MUL (box.y1, sy);
}
if (!CLUTTER_IS_STAGE (parent))
_clutter_actor_get_abs_position_real (parent, &px, &py);
}
if (x)
*x = px + box.x1;
if (y)
*y = py + box.y1;
}
/** /**
* clutter_actor_get_abs_position * clutter_actor_get_abs_position
* @self: A #ClutterActor * @self: A #ClutterActor
@ -1176,14 +1092,64 @@ clutter_actor_get_abs_position (ClutterActor *self,
gint *x, gint *x,
gint *y) gint *y)
{ {
ClutterReal xr, yr; gint32 xu, yu;
_clutter_actor_get_abs_position_real (self, &xr, &yr); clutter_actor_get_abs_position_units (self, &xu, &yu);
*x = CLUTTER_UNITS_TO_INT (xu);
*y = CLUTTER_UNITS_TO_INT (yu);
}
/**
* clutter_actor_get_abs_position_units
* @self: A #ClutterActor
* @x: Location to store x position if non NULL.
* @y: Location to store y position if non NULL.
*
* Gets the absolute position of an actor in clutter units relative
* to the stage.
*
* Since: 0.4
*/
void
clutter_actor_get_abs_position_units (ClutterActor *self,
gint32 *x,
gint32 *y)
{
ClutterActorBox box;
ClutterActor *parent;
gint32 px = 0, py = 0;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
parent = self->priv->parent_actor;
/* FIXME: must be nicer way to get 0,0 for stage ? */
if (parent)
{
ClutterFixed parent_scale_x, parent_scale_y;
clutter_actor_get_scalex (parent,
&parent_scale_x,
&parent_scale_y);
if (parent_scale_x != CFX_ONE ||
parent_scale_y != CFX_ONE)
{
box.x1 = CFX_MUL (box.x1, parent_scale_x);
box.y1 = CFX_MUL (box.y1, parent_scale_y);
}
if (!CLUTTER_IS_STAGE (parent))
clutter_actor_get_abs_position_units (parent, &px, &py);
}
if (x) if (x)
*x = CLUTTER_REAL_TO_INT (xr); *x = px + box.x1;
if (y) if (y)
*y = CLUTTER_REAL_TO_INT (yr); *y = py + box.y1;
} }
/** /**
@ -1199,6 +1165,29 @@ void
clutter_actor_get_abs_size (ClutterActor *self, clutter_actor_get_abs_size (ClutterActor *self,
guint *width, guint *width,
guint *height) guint *height)
{
gint32 wu, hu;
clutter_actor_get_abs_size_units (self, &wu, &hu);
*width = CLUTTER_UNITS_TO_INT (wu);
*height = CLUTTER_UNITS_TO_INT (hu);
}
/**
* clutter_actor_get_abs_size_units:
* @self: A #ClutterActor
* @width: Location to store width if non NULL.
* @height: Location to store height if non NULL.
*
* Gets the absolute size of an actor in clutter units taking into account
* an scaling factors.
*
* Since: 0.4
*/
void
clutter_actor_get_abs_size_units (ClutterActor *self,
gint32 *width,
gint32 *height)
{ {
ClutterActorBox box; ClutterActorBox box;
ClutterActor *parent; ClutterActor *parent;
@ -1222,56 +1211,16 @@ clutter_actor_get_abs_size (ClutterActor *self,
if (width) if (width)
{ {
fx = CLUTTER_FIXED_MUL (CLUTTER_INT_TO_FIXED (*width), fx = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (*width),
parent->priv->scale_x); parent->priv->scale_x);
*width = CLUTTER_FIXED_INT (fx); *width = CLUTTER_UNITS_FROM_FIXED (fx);
} }
if (height) if (height)
{ {
fy = CLUTTER_FIXED_MUL (CLUTTER_INT_TO_FIXED (*height), fy = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (*height),
parent->priv->scale_x); parent->priv->scale_x);
*height = CLUTTER_FIXED_INT (fy); *height = CLUTTER_UNITS_FROM_FIXED (fy);
}
}
}
while ((parent = clutter_actor_get_parent (parent)) != NULL);
}
static void
_clutter_actor_get_abs_size_real (ClutterActor *self,
ClutterReal *width,
ClutterReal *height)
{
ClutterActorBoxReal box;
ClutterActor *parent;
_clutter_actor_allocate_coords_real (self, &box);
if (width)
*width = box.x2 - box.x1;
if (height)
*height = box.y2 - box.y1;
parent = self;
do
{
if (parent->priv->scale_x != CFX_ONE ||
parent->priv->scale_y != CFX_ONE)
{
if (width)
{
ClutterReal scale = CLUTTER_REAL_FROM_FIXED (parent->priv->scale_x);
*width = CLUTTER_REAL_MUL (*width, scale);
}
if (height)
{
ClutterReal scale = CLUTTER_REAL_FROM_FIXED (parent->priv->scale_y);
*height = CLUTTER_REAL_MUL (*height, scale);
} }
} }
} }
@ -1296,7 +1245,7 @@ clutter_actor_get_width (ClutterActor *self)
clutter_actor_allocate_coords (self, &box); clutter_actor_allocate_coords (self, &box);
return box.x2 - box.x1; return CLUTTER_UNITS_TO_INT (box.x2 - box.x1);
} }
/** /**
@ -1316,7 +1265,7 @@ clutter_actor_get_height (ClutterActor *self)
clutter_actor_allocate_coords (self, &box); clutter_actor_allocate_coords (self, &box);
return box.y2 - box.y1; return CLUTTER_UNITS_TO_INT (box.y2 - box.y1);
} }
/** /**
@ -1371,19 +1320,7 @@ clutter_actor_get_x (ClutterActor *self)
clutter_actor_allocate_coords (self, &box); clutter_actor_allocate_coords (self, &box);
return box.x1; return CLUTTER_UNITS_TO_INT (box.x1);
}
static ClutterReal
_clutter_actor_get_x_real (ClutterActor *self)
{
ClutterActorBoxReal box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
_clutter_actor_allocate_coords_real (self, &box);
return box.x1;
} }
/** /**
@ -1403,19 +1340,7 @@ clutter_actor_get_y (ClutterActor *self)
clutter_actor_allocate_coords (self, &box); clutter_actor_allocate_coords (self, &box);
return box.y1; return CLUTTER_UNITS_TO_INT (box.y1);
}
static ClutterReal
_clutter_actor_get_y_real (ClutterActor *self)
{
ClutterActorBoxReal box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
_clutter_actor_allocate_coords_real (self, &box);
return box.y1;
} }
/** /**
@ -1524,20 +1449,22 @@ clutter_actor_scalex (ClutterActor *self,
ClutterFixed scale_y, ClutterFixed scale_y,
ClutterGravity gravity) ClutterGravity gravity)
{ {
ClutterReal sw, sh, w, h; ClutterActorBox box;
ClutterReal x, y; gint32 sw, sh, w, h;
gint32 x, y;
_clutter_actor_get_abs_size_real (self, &w, &h); clutter_actor_get_abs_size_units (self, &w, &h);
clutter_actor_set_scalex (self, scale_x, scale_y); clutter_actor_set_scalex (self, scale_x, scale_y);
if (gravity == CLUTTER_GRAVITY_NONE || if (gravity == CLUTTER_GRAVITY_NONE ||
gravity == CLUTTER_GRAVITY_NORTH_WEST) gravity == CLUTTER_GRAVITY_NORTH_WEST)
return; return;
_clutter_actor_get_abs_size_real (self, &sw, &sh); clutter_actor_get_abs_size_units (self, &sw, &sh);
x = _clutter_actor_get_x_real (self); clutter_actor_allocate_coords (self, &box);
y = _clutter_actor_get_y_real (self); x = box.x1;
y = box.y1;
switch (gravity) switch (gravity)
{ {
@ -1572,7 +1499,12 @@ clutter_actor_scalex (ClutterActor *self,
break; break;
} }
_clutter_actor_set_position_real (self, x, y); box.x2 += (x - box.x1);
box.y2 += (y - box.y1);
box.x1 = x;
box.y1 = y;
clutter_actor_request_coords (self, &box);
} }
/** /**
@ -2185,28 +2117,3 @@ clutter_actor_box_get_type (void)
return our_type; return our_type;
} }
/*
* ClutterActorBoxReal
*/
static ClutterActorBoxReal *
clutter_actor_box_real_copy (const ClutterActorBoxReal *box)
{
ClutterActorBoxReal *result = g_new (ClutterActorBoxReal, 1);
*result = *box;
return result;
}
GType
clutter_actor_box_real_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static (
g_intern_static_string ("ClutterActorBoxReal"),
(GBoxedCopyFunc) clutter_actor_box_real_copy,
(GBoxedFreeFunc) g_free);
return our_type;
}

View File

@ -29,8 +29,7 @@
/* clutter-actor.h */ /* clutter-actor.h */
#include <glib-object.h> #include <glib-object.h>
#include <clutter/clutter-fixed.h>
#include "clutter-real.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -74,7 +73,6 @@ typedef enum { /*< prefix=CLUTTER_GRAVITY >*/
typedef struct _ClutterActor ClutterActor; typedef struct _ClutterActor ClutterActor;
typedef struct _ClutterActorClass ClutterActorClass; typedef struct _ClutterActorClass ClutterActorClass;
typedef struct _ClutterActorBox ClutterActorBox; typedef struct _ClutterActorBox ClutterActorBox;
typedef struct _ClutterActorBoxReal ClutterActorBoxReal;
typedef struct _ClutterActorPrivate ClutterActorPrivate; typedef struct _ClutterActorPrivate ClutterActorPrivate;
typedef struct _ClutterGeometry ClutterGeometry; typedef struct _ClutterGeometry ClutterGeometry;
@ -86,6 +84,8 @@ struct _ClutterGeometry
/* FIXME: /* FIXME:
* It is likely gonna save a load of pain if we make * It is likely gonna save a load of pain if we make
* x,y unsigned... * x,y unsigned...
*
* No, no, no, usigned is evil; we should make width and height signed.
*/ */
gint x; gint x;
gint y; gint y;
@ -101,8 +101,7 @@ typedef enum
CLUTTER_ACTOR_REALIZED = 1 << 2 CLUTTER_ACTOR_REALIZED = 1 << 2
} ClutterActorFlags; } ClutterActorFlags;
struct _ClutterActorBox { gint x1, y1, x2, y2; }; struct _ClutterActorBox { gint32 x1, y1, x2, y2; };
struct _ClutterActorBoxReal { ClutterReal x1, y1, x2, y2; };
GType clutter_actor_box_get_type (void) G_GNUC_CONST; GType clutter_actor_box_get_type (void) G_GNUC_CONST;
@ -130,9 +129,9 @@ struct _ClutterActorClass
void (* unrealize) (ClutterActor *actor); void (* unrealize) (ClutterActor *actor);
void (* paint) (ClutterActor *actor); void (* paint) (ClutterActor *actor);
void (* request_coords) (ClutterActor *actor, void (* request_coords) (ClutterActor *actor,
ClutterActorBoxReal *box); ClutterActorBox *box);
void (* allocate_coords) (ClutterActor *actor, void (* allocate_coords) (ClutterActor *actor,
ClutterActorBoxReal *box); ClutterActorBox *box);
void (* set_depth) (ClutterActor *actor, void (* set_depth) (ClutterActor *actor,
gint depth); gint depth);
gint (* get_depth) (ClutterActor *actor); gint (* get_depth) (ClutterActor *actor);
@ -185,6 +184,9 @@ void clutter_actor_set_position (ClutterActor *sel
void clutter_actor_get_abs_position (ClutterActor *self, void clutter_actor_get_abs_position (ClutterActor *self,
gint *x, gint *x,
gint *y); gint *y);
void clutter_actor_get_abs_position_units (ClutterActor *self,
gint32 *x,
gint32 *y);
guint clutter_actor_get_width (ClutterActor *self); guint clutter_actor_get_width (ClutterActor *self);
guint clutter_actor_get_height (ClutterActor *self); guint clutter_actor_get_height (ClutterActor *self);
@ -259,6 +261,9 @@ void clutter_actor_scalex (ClutterActor *sel
void clutter_actor_get_abs_size (ClutterActor *self, void clutter_actor_get_abs_size (ClutterActor *self,
guint *width, guint *width,
guint *height); guint *height);
void clutter_actor_get_abs_size_units (ClutterActor *self,
gint32 *width,
gint32 *height);
void clutter_actor_get_size (ClutterActor *self, void clutter_actor_get_size (ClutterActor *self,
guint *width, guint *width,
guint *height); guint *height);
@ -266,13 +271,6 @@ void clutter_actor_move_by (ClutterActor *sel
gint dx, gint dx,
gint dy); gint dy);
/*<private*/
void _clutter_actor_request_coords_real (ClutterActor *self,
ClutterActorBoxReal *rbox);
void _clutter_actor_allocate_coords_real (ClutterActor *self,
ClutterActorBoxReal *rbox);
G_END_DECLS G_END_DECLS
#endif /* _HAVE_CLUTTER_ACTOR_H */ #endif /* _HAVE_CLUTTER_ACTOR_H */

View File

@ -97,11 +97,11 @@ clutter_group_paint (ClutterActor *actor)
static void static void
clutter_group_request_coords (ClutterActor *self, clutter_group_request_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterActorBoxReal cbox; ClutterActorBox cbox;
_clutter_actor_allocate_coords_real (self, &cbox); clutter_actor_allocate_coords (self, &cbox);
/* Only positioning works. /* Only positioning works.
* Sizing requests fail, use scale() instead * Sizing requests fail, use scale() instead
@ -112,7 +112,7 @@ clutter_group_request_coords (ClutterActor *self,
static void static void
clutter_group_allocate_coords (ClutterActor *self, clutter_group_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterGroupPrivate *priv; ClutterGroupPrivate *priv;
GList *child_item; GList *child_item;
@ -132,21 +132,19 @@ clutter_group_allocate_coords (ClutterActor *self,
/* Once added we include in sizing - doesn't matter if visible */ /* Once added we include in sizing - doesn't matter if visible */
/* if (CLUTTER_ACTOR_IS_VISIBLE (child)) */ /* if (CLUTTER_ACTOR_IS_VISIBLE (child)) */
{ {
ClutterActorBoxReal cbox; ClutterActorBox cbox;
_clutter_actor_allocate_coords_real (child, &cbox); clutter_actor_allocate_coords (child, &cbox);
/* Ignore any children with offscreen ( negaive ) /* Ignore any children with offscreen ( negaive )
* positions. * positions.
* *
* Also x1 and x2 will be set by parent caller. * Also x1 and x2 will be set by parent caller.
*/ */
if (CLUTTER_REAL_EZ (box->x2) || if (box->x2 == 0 || cbox.x2 > box->x2)
CLUTTER_REAL_GT (cbox.x2, box->x2))
box->x2 = cbox.x2; box->x2 = cbox.x2;
if (CLUTTER_REAL_EZ (box->y2) || if (box->y2 == 0 || cbox.y2 > box->y2)
CLUTTER_REAL_GT (cbox.y2, box->y2))
box->y2 = cbox.y2; box->y2 = cbox.y2;
} }
} }

View File

@ -37,6 +37,7 @@
#include "clutter-enum-types.h" #include "clutter-enum-types.h"
#include "clutter-private.h" #include "clutter-private.h"
#include "clutter-debug.h" #include "clutter-debug.h"
#include "clutter-units.h"
#include "pangoclutter.h" #include "pangoclutter.h"
@ -264,7 +265,7 @@ clutter_label_paint (ClutterActor *self)
static void static void
clutter_label_allocate_coords (ClutterActor *self, clutter_label_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterLabel *label = CLUTTER_LABEL(self); ClutterLabel *label = CLUTTER_LABEL(self);
ClutterLabelPrivate *priv; ClutterLabelPrivate *priv;
@ -272,19 +273,19 @@ clutter_label_allocate_coords (ClutterActor *self,
priv = label->priv; priv = label->priv;
clutter_label_ensure_layout (label, CLUTTER_REAL_TO_INT (box->x2 - box->x1)); clutter_label_ensure_layout (label, CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
pango_layout_get_extents (priv->layout, NULL, &logical_rect); pango_layout_get_extents (priv->layout, NULL, &logical_rect);
box->x2 = box->x1 + PANGO_PIXELS (logical_rect.width); box->x2 = box->x1 + CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.width);
box->y2 = box->y1 + PANGO_PIXELS (logical_rect.height); box->y2 = box->y1 + CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.height);
return; return;
} }
static void static void
clutter_label_request_coords (ClutterActor *self, clutter_label_request_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
/* do we need to do anything ? */ /* do we need to do anything ? */
clutter_label_clear_layout (CLUTTER_LABEL(self)); clutter_label_clear_layout (CLUTTER_LABEL(self));

View File

@ -1,125 +0,0 @@
/* -*- mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Tomas Frydrych <tf@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:clutter-real
* @short_description: An abstract numeric type encapsulating either float
* or fixed point number, depending whether clutter was configured using
* FPU or not.
*
* Since: 0.4
*/
#ifndef _HAVE_CLUTTER_REAL_H
#define _HAVE_CLUTTER_REAL_H
#include "clutter-fixed.h"
#if 1
#if CLUTTER_NO_FPU
#define CLUTTER_REAL_IS_FIXED() 1
#define CLUTTER_REAL_IS_FLOAT() 0
typedef ClutterFixed ClutterReal;
#define CLUTTER_REAL_MUL(x,y) CFX_MUL((x),(y))
#define CLUTTER_REAL_DIV(x,y) CFX_DIV((x),(y))
#define CLUTTER_REAL_ADD_INT(x,i) ((x) + CLUTTER_INT_TO_FIXED(i))
#define CLUTTER_REAL_SUB_INT(x,i) ((x) - CLUTTER_INT_TO_FIXED(i))
#define CLUTTER_REAL_TO_INT(x) CFX_INT((x) + (CFX_ONE >> 1))
#define CLUTTER_REAL_FROM_INT(i) CLUTTER_INT_TO_FIXED(i)
#define CLUTTER_REAL_TO_FLOAT(x) CLUTTER_FIXED_TO_FLOAT(x)
#define CLUTTER_REAL_FROM_FLOAT(f) CLUTTER_FLOAT_TO_FIXED(f)
#define CLUTTER_REAL_TO_FIXED(x) (x)
#define CLUTTER_REAL_FROM_FIXED(x) (x)
#define CLUTTER_REAL_ZERO 0
#else
#define CLUTTER_REAL_IS_FIXED() 0
#define CLUTTER_REAL_IS_FLOAT() 1
typedef float ClutterReal;
#define CLUTTER_REAL_MUL(x,y) ((x)*(y))
#define CLUTTER_REAL_DIV(x,y) ((x)/(y))
#define CLUTTER_REAL_ADD_INT(x,i) (x+i)
#define CLUTTER_REAL_SUB_INT(x,i) (x-i)
#define CLUTTER_REAL_TO_INT(x) CLUTTER_FLOAT_TO_INT(x+0.5)
#define CLUTTER_REAL_FROM_INT(i) ((float)i)
#define CLUTTER_REAL_TO_FLOAT(x) (x)
#define CLUTTER_REAL_FROM_FLOAT(f) (f)
#define CLUTTER_REAL_TO_FIXED(x) CLLUTER_FLOAT_TO_FIXED(x)
#define CLUTTER_REAL_FROM_FIXED(x) CLUTTER_FIXED_TO_FLOAT(x)
#define CLUTTER_REAL_ZERO 0.0
#endif
#else
/*
* This is an int defintion for reference / debugging purposes only
*
* FIXME : remove this when no longer needed.
*/
typedef gint ClutterReal;
#define CLUTTER_REAL_MUL(x,y) ((x)*(y))
#define CLUTTER_REAL_DIV(x,y) ((x)/(y))
#define CLUTTER_REAL_ADD_INT(x,i) (x + i)
#define CLUTTER_REAL_SUB_INT(x,i) (x - i)
#define CLUTTER_REAL_TO_INT(x) (x)
#define CLUTTER_REAL_FROM_INT(i) (i)
#define CLUTTER_REAL_TO_FLOAT(x) ((float)(x))
#define CLUTTER_REAL_FROM_FLOAT(f) ((gint)(f))
#define CLUTTER_REAL_TO_FIXED(x) CLUTTER_INT_TO_FIXED(x)
#define CLUTTER_REAL_FROM_FIXED(x) CFX_INT(x)
#define CLUTTER_REAL_ZERO 0
#endif
#define CLUTTER_REAL_EZ(x) (CLUTTER_REAL_TO_INT(x) == 0)
#define CLUTTER_REAL_NZ(x) (CLUTTER_REAL_TO_INT(x) != 0)
#define CLUTTER_REAL_EQ(x,y) (CLUTTER_REAL_TO_INT(x) == CLUTTER_REAL_TO_INT(y))
#define CLUTTER_REAL_NE(x,y) (CLUTTER_REAL_TO_INT(x) != CLUTTER_REAL_TO_INT(y))
#define CLUTTER_REAL_LT(x,y) (CLUTTER_REAL_TO_INT(x) < CLUTTER_REAL_TO_INT(y))
#define CLUTTER_REAL_GT(x,y) (CLUTTER_REAL_TO_INT(x) > CLUTTER_REAL_TO_INT(y))
#define CLUTTER_REAL_LE(x,y) (CLUTTER_REAL_TO_INT(x) <= CLUTTER_REAL_TO_INT(y))
#define CLUTTER_REAL_GE(x,y) (CLUTTER_REAL_TO_INT(x) >= CLUTTER_REAL_TO_INT(y))
#endif /* ifndef _HAVE_CLUTTER_REAL_H */

74
clutter/clutter-units.h Normal file
View File

@ -0,0 +1,74 @@
/* -*- mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Tomas Frydrych <tf@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:clutter-units
* @short_description: A logical distance unit.
*
* Clutter units are logical units with granularity greater than that of the
* device units; they are used by #ClutterActorBox and the _units() family of
* ClutterActor functions. To convert between clutter units and device units,
* use #CLUTTER_UNITS_FROM_DEVICE and #CLUTTER_UNITS_TO_DEVICE macros.
*
* Note: It is expected that as of version 0.6 all dimensions in the public
* Clutter API will be given in clutter units. In order to ease the transition,
* two extra macros have been provided, #CLUTTER_UNITS_TMP_TO_DEVICE and
* #CLUTTER_UNITS_TMP_FROM_DEVICE. In version 0.4 these are identity macros,
* but when the API transition happens will map to #CLUTTER_UNITS_TO_DEVICE and
* #CLUTTER_UNITS_FROM_DEVICE respectively. You can use these in newly written
* code as place holders.
*
* Since: 0.4
*/
#ifndef _HAVE_CLUTTER_UNITS_H
#define _HAVE_CLUTTER_UNITS_H
#include <clutter/clutter-fixed.h>
/*
* Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the
* _FROM_FIXED and _TO_FIXED macros should always be used in case that we
* decide to change this relationship in the future.
*/
#define CLUTTER_UNITS_FROM_DEVICE(x) CLUTTER_UNITS_FROM_INT (x)
#define CLUTTER_UNITS_TO_DEVICE(x) CLUTTER_UNITS_TO_INT (x)
#define CLUTTER_UNITS_TMP_FROM_DEVICE(x) (x)
#define CLUTTER_UNITS_TMP_TO_DEVICE(x) (x)
#define CLUTTER_UNITS_FROM_INT(x) CLUTTER_INT_TO_FIXED (x)
#define CLUTTER_UNITS_TO_INT(x) CFX_INT (x)
#define CLUTTER_UNITS_FROM_FLOAT(x) CLUTTER_FLOAT_TO_FIXED (x)
#define CLUTTER_UNITS_TO_FLOAT(x) CLUTTER_FIXED_TO_FLOAT (x)
#define CLUTTER_UNITS_FROM_FIXED(x) (x)
#define CLUTTER_UNITS_TO_FIXED(x) (x)
#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) (x << 6)
#endif /* _HAVE_CLUTTER_UNITS_H */

View File

@ -52,5 +52,6 @@
#include "clutter-feature.h" #include "clutter-feature.h"
#include "clutter-version.h" #include "clutter-version.h"
#include "clutter-enum-types.h" #include "clutter-enum-types.h"
#include "clutter-units.h"
#endif #endif

View File

@ -11,6 +11,7 @@
#include "../clutter-enum-types.h" #include "../clutter-enum-types.h"
#include "../clutter-private.h" #include "../clutter-private.h"
#include "../clutter-debug.h" #include "../clutter-debug.h"
#include "../clutter-units.h"
#ifdef HAVE_XFIXES #ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>
@ -239,25 +240,25 @@ clutter_stage_egl_paint (ClutterActor *self)
static void static void
clutter_stage_egl_allocate_coords (ClutterActor *self, clutter_stage_egl_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self); ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self);
box->x1 = box->y1 = 0; box->x1 = box->y1 = 0;
box->x2 = CLUTTER_REAL_ADD_INT (box->x1, stage_egl->xwin_width); box->x2 = box->x1 + CLUTTER_UNITS_FROM_INT (stage_egl->xwin_width);
box->y2 = CLUTTER_REAL_ADD_INT (box->y1, stage_egl->xwin_height); box->y2 = box->y1 + CLUTTER_UNITS_FROM_INT (stage_egl->xwin_height);
} }
static void static void
clutter_stage_egl_request_coords (ClutterActor *self, clutter_stage_egl_request_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self); ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self);
gint new_width, new_height; gint new_width, new_height;
/* FIXME: some how have X configure_notfiys call this ? */ /* FIXME: some how have X configure_notfiys call this ? */
new_width = ABS (CLUTTER_REAL_TO_INT (box->x2 - box->x1)); new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
new_height = ABS (CLUTTER_REAL_TO_INT (box->y2 - box->y1)); new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
if (new_width != stage_egl->xwin_width || if (new_width != stage_egl->xwin_width ||
new_height != stage_egl->xwin_height) new_height != stage_egl->xwin_height)
@ -277,8 +278,8 @@ clutter_stage_egl_request_coords (ClutterActor *self,
if (stage_egl->xwin != None) /* Do we want to bother ? */ if (stage_egl->xwin != None) /* Do we want to bother ? */
XMoveWindow (stage_egl->xdpy, XMoveWindow (stage_egl->xdpy,
stage_egl->xwin, stage_egl->xwin,
CLUTTER_REAL_TO_INT (box->x1), CLUTTER_UNITS_TO_INT (box->x1),
CLUTTER_REAL_TO_INT (box->y1)); CLUTTER_UNITS_TO_INT (box->y1));
} }
static void static void

View File

@ -35,6 +35,7 @@
#include "../clutter-enum-types.h" #include "../clutter-enum-types.h"
#include "../clutter-private.h" #include "../clutter-private.h"
#include "../clutter-debug.h" #include "../clutter-debug.h"
#include "../clutter-units.h"
#include "cogl.h" #include "cogl.h"
@ -370,24 +371,24 @@ clutter_stage_glx_paint (ClutterActor *self)
static void static void
clutter_stage_glx_allocate_coords (ClutterActor *self, clutter_stage_glx_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self); ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self);
box->x1 = box->y1 = 0; box->x1 = box->y1 = 0;
box->x2 = CLUTTER_REAL_ADD_INT (box->x1, stage_glx->xwin_width); box->x2 = box->x1 + CLUTTER_UNITS_FROM_INT (stage_glx->xwin_width);
box->y2 = CLUTTER_REAL_ADD_INT (box->y1, stage_glx->xwin_height); box->y2 = box->y1 + CLUTTER_UNITS_FROM_INT (stage_glx->xwin_height);
} }
static void static void
clutter_stage_glx_request_coords (ClutterActor *self, clutter_stage_glx_request_coords (ClutterActor *self,
ClutterActorBoxReal *box) ClutterActorBox *box)
{ {
ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self); ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self);
gint new_width, new_height; gint new_width, new_height;
new_width = ABS (CLUTTER_REAL_TO_INT (box->x2 - box->x1)); new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
new_height = ABS (CLUTTER_REAL_TO_INT (box->y2 - box->y1)); new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
if (new_width != stage_glx->xwin_width || if (new_width != stage_glx->xwin_width ||
new_height != stage_glx->xwin_height) new_height != stage_glx->xwin_height)
@ -414,8 +415,8 @@ clutter_stage_glx_request_coords (ClutterActor *self,
if (stage_glx->xwin != None) /* Do we want to bother ? */ if (stage_glx->xwin != None) /* Do we want to bother ? */
XMoveWindow (stage_glx->xdpy, XMoveWindow (stage_glx->xdpy,
stage_glx->xwin, stage_glx->xwin,
CLUTTER_REAL_TO_INT (box->x1), CLUTTER_UNITS_TO_INT (box->x1),
CLUTTER_REAL_TO_INT (box->y1)); CLUTTER_UNITS_TO_INT (box->y1));
} }
static void static void

View File

@ -11,6 +11,7 @@
#include "../clutter-enum-types.h" #include "../clutter-enum-types.h"
#include "../clutter-private.h" #include "../clutter-private.h"
#include "../clutter-debug.h" #include "../clutter-debug.h"
#include "../clutter-units.h"
#include "cogl.h" #include "cogl.h"
@ -130,8 +131,8 @@ clutter_stage_sdl_allocate_coords (ClutterActor *self,
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self); ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self);
box->x1 = box->y1 = 0; box->x1 = box->y1 = 0;
box->x2 = box->x1 + stage_sdl->win_width; box->x2 = box->x1 + CLUTTER_UNITS_FROM_INT (stage_sdl->win_width);
box->y2 = box->y1 + stage_sdl->win_height; box->y2 = box->y1 + CLUTTER_UNITS_FROM_INT (stage_sdl->win_height);
} }
static void static void
@ -142,8 +143,8 @@ clutter_stage_sdl_request_coords (ClutterActor *self,
gint new_width, new_height; gint new_width, new_height;
/* FIXME: some how have X configure_notfiys call this ? */ /* FIXME: some how have X configure_notfiys call this ? */
new_width = ABS (box->x2 - box->x1); new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
new_height = ABS (box->y2 - box->y1); new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
if (new_width != stage_sdl->win_width || if (new_width != stage_sdl->win_width ||
new_height != stage_sdl->win_height) new_height != stage_sdl->win_height)

View File

@ -93,8 +93,6 @@ if $PKG_CONFIG --exists xfixes ; then
fi fi
CLUTTER_NO_FPU="0" CLUTTER_NO_FPU="0"
CLUTTER_REAL=""
AC_ARG_WITH(fpu, AC_ARG_WITH(fpu,
AS_HELP_STRING([--without-fpu], AS_HELP_STRING([--without-fpu],
[Assume target hardware has no fpu]), [Assume target hardware has no fpu]),
@ -103,11 +101,9 @@ AC_ARG_WITH(fpu,
if test "x$with_fpu" != "xyes" ; then if test "x$with_fpu" != "xyes" ; then
CLUTTER_NO_FPU="1" CLUTTER_NO_FPU="1"
CLUTTER_REAL="-fx"
fi fi
AC_SUBST(CLUTTER_NO_FPU) AC_SUBST(CLUTTER_NO_FPU)
AC_SUBST(CLUTTER_REAL)
clutterbackend=glx clutterbackend=glx
AC_ARG_WITH([flavour], AC_ARG_WITH([flavour],

View File

@ -1,3 +1,15 @@
2007-05-22 Tomas Frydrych <tf@openedhand.com>
* clutter-sections.txt:
* clutter-docs.sgml:
* tmpl/clutter-units.sgml:
Added clutter-units.
* tmpl/clutter-alpha.sgml:
* tmpl/clutter-actor.sgml:
* tmpl/clutter-media.sgml:
Updated templates.
2007-05-17 Emmanuele Bassi <ebassi@openedhand.com> 2007-05-17 Emmanuele Bassi <ebassi@openedhand.com>
* Makefile.am: Ignore the sdl backend. * Makefile.am: Ignore the sdl backend.

View File

@ -94,6 +94,7 @@
<xi:include href="xml/clutter-util.xml"/> <xi:include href="xml/clutter-util.xml"/>
<xi:include href="xml/clutter-fixed.xml"/> <xi:include href="xml/clutter-fixed.xml"/>
<xi:include href="xml/clutter-version.xml"/> <xi:include href="xml/clutter-version.xml"/>
<xi:include href="xml/clutter-units.xml"/>
</chapter> </chapter>
<chapter> <chapter>
<title>Clutter Backends</title> <title>Clutter Backends</title>

View File

@ -24,6 +24,22 @@ CLUTTER_MEDIA_GET_INTERFACE
clutter_media_get_type clutter_media_get_type
</SECTION> </SECTION>
<SECTION>
<FILE>clutter-units</FILE>
<TITLE>clutter-units</TITLE>
CLUTTER_UNITS_FROM_DEVICE
CLUTTER_UNITS_FROM_FIXED
CLUTTER_UNITS_FROM_FLOAT
CLUTTER_UNITS_FROM_INT
CLUTTER_UNITS_FROM_PANGO_UNIT
CLUTTER_UNITS_TMP_FROM_DEVICE
CLUTTER_UNITS_TMP_TO_DEVICE
CLUTTER_UNITS_TO_DEVICE
CLUTTER_UNITS_TO_FIXED
CLUTTER_UNITS_TO_FLOAT
CLUTTER_UNITS_TO_INT
</SECTION>
<SECTION> <SECTION>
<FILE>clutter-label</FILE> <FILE>clutter-label</FILE>
<TITLE>ClutterLabel</TITLE> <TITLE>ClutterLabel</TITLE>

View File

@ -61,7 +61,8 @@ Evaluates to %TRUE if an actor is visible.
<!-- ##### STRUCT ClutterActorBox ##### --> <!-- ##### STRUCT ClutterActorBox ##### -->
<para> <para>
Coordinates (top-left to bottom-right) of a box surrounding an actor. Coordinates (top-left to bottom-right) of a box surrounding an actor; in
cluttter units.
</para> </para>
@x1: X coordinate of the top left corner of the box @x1: X coordinate of the top left corner of the box

View File

@ -219,6 +219,57 @@ Symbolic name for passing clutter_sine_func().
@Returns: @Returns:
<!-- ##### MACRO CLUTTER_ALPHA_SINE_INC ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_sine_inc_func ##### -->
<para>
</para>
@alpha:
@dummy:
@Returns:
<!-- ##### MACRO CLUTTER_ALPHA_SINE_DEC ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_sine_dec_func ##### -->
<para>
</para>
@alpha:
@dummy:
@Returns:
<!-- ##### MACRO CLUTTER_ALPHA_SINE_HALF ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_sine_half_func ##### -->
<para>
</para>
@alpha:
@dummy:
@Returns:
<!-- ##### MACRO CLUTTER_ALPHA_SQUARE ##### --> <!-- ##### MACRO CLUTTER_ALPHA_SQUARE ##### -->
<para> <para>
@ -253,3 +304,37 @@ Symbolic name for passing clutter_sine_func().
@Returns: @Returns:
<!-- ##### MACRO CLUTTER_ALPHA_EXP_INC ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_exp_inc_func ##### -->
<para>
</para>
@alpha:
@dummy:
@Returns:
<!-- ##### MACRO CLUTTER_ALPHA_EXP_DEC ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_exp_dec_func ##### -->
<para>
</para>
@alpha:
@dummy:
@Returns:

View File

@ -23,21 +23,6 @@ clutter-media
</para> </para>
<!-- ##### SIGNAL ClutterMedia::eos ##### -->
<para>
</para>
@cluttermedia: the object which received the signal.
<!-- ##### SIGNAL ClutterMedia::error ##### -->
<para>
</para>
@cluttermedia: the object which received the signal.
@arg1:
<!-- ##### ARG ClutterMedia:buffer-percent ##### --> <!-- ##### ARG ClutterMedia:buffer-percent ##### -->
<para> <para>

View File

@ -0,0 +1,107 @@
<!-- ##### SECTION Title ##### -->
Clutter Units
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO CLUTTER_UNITS_FROM_DEVICE ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_FROM_FIXED ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_FROM_FLOAT ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_FROM_INT ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_FROM_PANGO_UNIT ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TMP_FROM_DEVICE ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TMP_TO_DEVICE ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TO_DEVICE ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TO_FIXED ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TO_FLOAT ##### -->
<para>
</para>
@x:
<!-- ##### MACRO CLUTTER_UNITS_TO_INT ##### -->
<para>
</para>
@x:

View File

@ -1,7 +1,7 @@
noinst_PROGRAMS = test super-oh behave test-text slider noinst_PROGRAMS = test super-oh behave test-text slider
INCLUDES = -I$(top_srcdir)/ INCLUDES = -I$(top_srcdir)/
LDADD = $(top_builddir)/clutter/libclutter@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
AM_CFLAGS = $(CLUTTER_CFLAGS) AM_CFLAGS = $(CLUTTER_CFLAGS)
LDFLAGS = $(CLUTTER_LIBS) LDFLAGS = $(CLUTTER_LIBS)

View File

@ -1,7 +1,7 @@
noinst_PROGRAMS = test-textures test-events noinst_PROGRAMS = test-textures test-events
INCLUDES = -I$(top_srcdir)/ INCLUDES = -I$(top_srcdir)/
LDADD = $(top_builddir)/clutter/libclutter@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
AM_CFLAGS = $(CLUTTER_CFLAGS) AM_CFLAGS = $(CLUTTER_CFLAGS)
LDFLAGS = $(CLUTTER_LIBS) LDFLAGS = $(CLUTTER_LIBS)