1
0
Fork 0

ClutterReal type

This commit is contained in:
Tomas Frydrych 2007-05-18 07:30:06 +00:00
parent 55388b8f50
commit 47b3d6db56
15 changed files with 465 additions and 254 deletions

View file

@ -1,3 +1,22 @@
2007-05-18 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-behaviour-scale.c:
* clutter/clutter-behaviour-scale.h:
* clutter/clutter-group.c:
* clutter/clutter-label.c:
* clutter/clutter-real.h:
* clutter/egl/clutter-stage-egl.c:
* clutter/glx/clutter-stage-glx.c:
* examples/Makefile.am:
* tests/Makefile.am:
ClutterReal type.
2007-05-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-main.c: Use clutter_base_init() inside the

View file

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

View file

@ -3,11 +3,12 @@ exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
backend=@clutterbackend@
real=@CLUTTER_REAL@
apiversion=@CLUTTER_API_VERSION@
Name: Clutter
Description: Clutter Core Library (${backend} backend)
Version: @VERSION@
Libs: -L${libdir} -lclutter-${backend}-${apiversion}
Libs: -L${libdir} -lclutter${real}-${backend}-${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

View file

@ -159,19 +159,19 @@ source_h_priv = \
$(NULL)
libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \
$(CLUTTER_LIBS) pango/libpangoclutter.la \
@CLUTTER_FLAVOUR@/libclutter-@CLUTTER_FLAVOUR@.la \
cogl/@CLUTTER_COGL@/libclutter-cogl.la
libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_SOURCES = \
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_SOURCES = \
$(source_c) $(source_h) $(source_h_priv)
libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LDFLAGS = $(LDADD)
libclutter@CLUTTER_REAL@_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LDFLAGS = $(LDADD)
lib_LTLIBRARIES = $(clutterbackendlib)
EXTRA_LTLIBRARIES = libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la
EXTRA_LTLIBRARIES = libclutter@CLUTTER_REAL@-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la
clutterdir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter

View file

@ -55,7 +55,8 @@ static guint32 __id = 0;
struct _ClutterActorPrivate
{
ClutterActorBox coords;
ClutterActorBoxReal coords;
ClutterGeometry clip;
guint has_clip : 1;
ClutterFixed rxang, ryang, rzang; /* Rotation*/
@ -307,8 +308,8 @@ clutter_actor_paint (ClutterActor *self)
if (clutter_actor_get_parent (self) != NULL)
{
cogl_translate ((priv->coords.x1),
(priv->coords.y1),
cogl_translate (CLUTTER_REAL_TO_FLOAT (priv->coords.x1),
CLUTTER_REAL_TO_FLOAT (priv->coords.y1),
0);
}
@ -382,34 +383,24 @@ clutter_actor_paint (ClutterActor *self)
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
clutter_actor_request_coords (ClutterActor *self,
ClutterActorBox *box)
_clutter_actor_request_coords_real (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterActorClass *klass;
gboolean x_change, y_change, width_change, height_change;
klass = CLUTTER_ACTOR_GET_CLASS (self);
if (klass->request_coords)
klass->request_coords (self, box);
x_change = (self->priv->coords.x1 != box->x1);
y_change = (self->priv->coords.y1 != box->y1);
width_change = (self->priv->coords.x2 - self->priv->coords.x1
!= box->x2 - box->x1);
height_change = (self->priv->coords.y2 - self->priv->coords.y1
!= box->y2 - box->y1);
x_change = CLUTTER_REAL_NE (self->priv->coords.x1, box->x1);
y_change = CLUTTER_REAL_NE (self->priv->coords.y1, box->y1);
width_change = CLUTTER_REAL_NE ((self->priv->coords.x2 - self->priv->coords.x1),
(box->x2 - box->x1));
height_change = CLUTTER_REAL_NE ((self->priv->coords.y2 - self->priv->coords.y1),
(box->y2 - box->y1));
if (x_change || y_change || width_change || height_change)
{
@ -420,7 +411,7 @@ clutter_actor_request_coords (ClutterActor *self,
if (CLUTTER_ACTOR_IS_VISIBLE (self))
clutter_actor_queue_redraw (self);
g_object_ref (self);
g_object_freeze_notify (G_OBJECT (self));
@ -441,6 +432,59 @@ clutter_actor_request_coords (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:
* @self: A #ClutterActor
@ -456,29 +500,14 @@ void
clutter_actor_allocate_coords (ClutterActor *self,
ClutterActorBox *box)
{
ClutterActorClass *klass;
ClutterActorBoxReal rbox;
_clutter_actor_allocate_coords_real (self, &rbox);
klass = CLUTTER_ACTOR_GET_CLASS (self);
box->x1 = self->priv->coords.x1;
box->y1 = self->priv->coords.y1;
box->x2 = self->priv->coords.x2;
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;
}
box->x1 = CLUTTER_REAL_TO_INT (rbox.x1);
box->y1 = CLUTTER_REAL_TO_INT (rbox.y1);
box->x2 = CLUTTER_REAL_TO_INT (rbox.x2);
box->y2 = CLUTTER_REAL_TO_INT (rbox.y2);
}
static void
@ -946,23 +975,43 @@ clutter_actor_get_coords (ClutterActor *self,
gint *x2,
gint *y2)
{
ClutterActorBox box;
ClutterActorBoxReal box;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
_clutter_actor_allocate_coords_real (self, &box);
if (x1)
*x1 = box.x1;
*x1 = CLUTTER_REAL_TO_INT (box.x1);
if (y1)
*y1 = box.y1;
*y1 = CLUTTER_REAL_TO_INT (box.y1);
if (x2)
*x2 = box.x2;
*x2 = CLUTTER_REAL_TO_INT (box.x2);
if (y2)
*y2 = box.y2;
*y2 = CLUTTER_REAL_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);
}
/**
@ -979,19 +1028,10 @@ clutter_actor_set_position (ClutterActor *self,
gint x,
gint y)
{
ClutterActorBox box;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
box.x2 += (x - box.x1);
box.y2 += (y - box.y1);
box.x1 = x;
box.y1 = y;
clutter_actor_request_coords (self, &box);
ClutterReal xr = CLUTTER_REAL_FROM_INT (x);
ClutterReal yr = CLUTTER_REAL_FROM_INT (y);
_clutter_actor_set_position_real (self, xr, yr);
}
/**
@ -1010,18 +1050,20 @@ clutter_actor_move_by (ClutterActor *self,
gint dx,
gint dy)
{
ClutterActorBox box;
ClutterActorBoxReal box;
ClutterReal dxr = CLUTTER_REAL_FROM_INT (dx);
ClutterReal dyr = CLUTTER_REAL_FROM_INT (dy);
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
_clutter_actor_allocate_coords_real (self, &box);
box.x2 += dx;
box.y2 += dy;
box.x1 += dx;
box.y1 += dy;
box.x2 += dxr;
box.y2 += dyr;
box.x1 += dxr;
box.y1 += dyr;
clutter_actor_request_coords (self, &box);
_clutter_actor_request_coords_real (self, &box);
}
/**
@ -1038,16 +1080,16 @@ clutter_actor_set_size (ClutterActor *self,
gint width,
gint height)
{
ClutterActorBox box;
ClutterActorBoxReal box;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_allocate_coords (self, &box);
_clutter_actor_allocate_coords_real (self, &box);
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
box.x2 = CLUTTER_REAL_ADD_INT (box.x1, width);
box.y2 = CLUTTER_REAL_ADD_INT (box.y1, height);
clutter_actor_request_coords (self, &box);
_clutter_actor_request_coords_real (self, &box);
}
/**
@ -1074,6 +1116,52 @@ clutter_actor_get_size (ClutterActor *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
* @self: A #ClutterActor
@ -1088,45 +1176,14 @@ clutter_actor_get_abs_position (ClutterActor *self,
gint *x,
gint *y)
{
ClutterActorBox box;
ClutterActor *parent;
gint px = 0, py = 0;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
ClutterReal xr, yr;
_clutter_actor_get_abs_position_real (self, &xr, &yr);
clutter_actor_allocate_coords (self, &box);
if (x)
*x = CLUTTER_REAL_TO_INT (xr);
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;
ClutterFixed fx, fy;
clutter_actor_get_scalex (parent,
&parent_scale_x,
&parent_scale_y);
if (parent_scale_x != CFX_ONE ||
parent_scale_y != CFX_ONE)
{
fx = box.x1 * parent_scale_x;
fy = box.y1 * parent_scale_y;
box.x1 = CLUTTER_FIXED_INT (fx);
box.y1 = CLUTTER_FIXED_INT (fy);
}
if (!CLUTTER_IS_STAGE (parent))
clutter_actor_get_abs_position (parent, &px, &py);
}
if (x)
*x = px + box.x1;
if (y)
*y = py + box.y1;
if (y)
*y = CLUTTER_REAL_TO_INT (yr);
}
/**
@ -1181,6 +1238,46 @@ clutter_actor_get_abs_size (ClutterActor *self,
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);
}
}
}
while ((parent = clutter_actor_get_parent (parent)) != NULL);
}
/**
* clutter_actor_get_width
@ -1277,6 +1374,18 @@ clutter_actor_get_x (ClutterActor *self)
return 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;
}
/**
* clutter_actor_get_y:
* @self: A #ClutterActor
@ -1297,6 +1406,18 @@ clutter_actor_get_y (ClutterActor *self)
return 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;
}
/**
* clutter_actor_set_scalex:
* @self: A #ClutterActor
@ -1385,6 +1506,74 @@ clutter_actor_get_scale (ClutterActor *self,
*scale_y = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_y);
}
/**
* clutter_actor_scalex:
* @self: A #ClutterActor
* @scale_x: #ClutterFixed scaling factor for x axis
* @scale_y: #ClutterFixed scaling factor for y axis
* @gravity: #ClutterGravity to apply to scaling.
*
* Scales the actor by scale_x, scale_y taking into consideration the
* required gravity.
*
* Since: 0.4
*/
void
clutter_actor_scalex (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y,
ClutterGravity gravity)
{
ClutterReal sw, sh, w, h;
ClutterReal x, y;
_clutter_actor_get_abs_size_real (self, &w, &h);
clutter_actor_set_scalex (self, scale_x, scale_y);
if (gravity == CLUTTER_GRAVITY_NONE ||
gravity == CLUTTER_GRAVITY_NORTH_WEST)
return;
_clutter_actor_get_abs_size_real (self, &sw, &sh);
x = _clutter_actor_get_x_real (self);
y = _clutter_actor_get_y_real (self);
switch (gravity)
{
case CLUTTER_GRAVITY_NORTH:
x = x - ((sw - w) / 2);
break;
case CLUTTER_GRAVITY_NORTH_EAST:
x = x + w - sw;
break;
case CLUTTER_GRAVITY_EAST:
x = x + w - sw;
y = y - ((sh - h) / 2);
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
x = x + w - sw;
y = y + h - sh;
break;
case CLUTTER_GRAVITY_SOUTH:
x = x - ((sw - w) / 2);
y = y + h - sh;
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
y = y + h - sh;
break;
case CLUTTER_GRAVITY_WEST:
y = y - ((sh - h) / 2);
break;
case CLUTTER_GRAVITY_CENTER:
x = x - ((sw - w) / 2);
y = y - ((sh - h) / 2);
default:
break;
}
_clutter_actor_set_position_real (self, x, y);
}
/**
* clutter_actor_set_opacity:
@ -1995,3 +2184,29 @@ clutter_actor_box_get_type (void)
(GBoxedFreeFunc) g_free);
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

@ -30,7 +30,7 @@
#include <glib-object.h>
#include "clutter-fixed.h"
#include "clutter-real.h"
G_BEGIN_DECLS
@ -58,9 +58,23 @@ G_BEGIN_DECLS
#define CLUTTER_ACTOR_IS_VISIBLE(e) (CLUTTER_ACTOR_IS_MAPPED (e) && \
CLUTTER_ACTOR_IS_REALIZED (e))
typedef enum { /*< prefix=CLUTTER_GRAVITY >*/
CLUTTER_GRAVITY_NONE = 0,
CLUTTER_GRAVITY_NORTH,
CLUTTER_GRAVITY_NORTH_EAST,
CLUTTER_GRAVITY_EAST,
CLUTTER_GRAVITY_SOUTH_EAST,
CLUTTER_GRAVITY_SOUTH,
CLUTTER_GRAVITY_SOUTH_WEST,
CLUTTER_GRAVITY_WEST,
CLUTTER_GRAVITY_NORTH_WEST,
CLUTTER_GRAVITY_CENTER
} ClutterGravity;
typedef struct _ClutterActor ClutterActor;
typedef struct _ClutterActorClass ClutterActorClass;
typedef struct _ClutterActorBox ClutterActorBox;
typedef struct _ClutterActorBoxReal ClutterActorBoxReal;
typedef struct _ClutterActorPrivate ClutterActorPrivate;
typedef struct _ClutterGeometry ClutterGeometry;
@ -88,6 +102,7 @@ typedef enum
} ClutterActorFlags;
struct _ClutterActorBox { gint x1, y1, x2, y2; };
struct _ClutterActorBoxReal { ClutterReal x1, y1, x2, y2; };
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
@ -107,22 +122,22 @@ struct _ClutterActorClass
{
GObjectClass parent_class;
void (* show) (ClutterActor *actor);
void (* show_all) (ClutterActor *actor);
void (* hide) (ClutterActor *actor);
void (* hide_all) (ClutterActor *actor);
void (* realize) (ClutterActor *actor);
void (* unrealize) (ClutterActor *actor);
void (* paint) (ClutterActor *actor);
void (* request_coords) (ClutterActor *actor,
ClutterActorBox *box);
void (* allocate_coords) (ClutterActor *actor,
ClutterActorBox *box);
void (* set_depth) (ClutterActor *actor,
gint depth);
gint (* get_depth) (ClutterActor *actor);
void (* parent_set) (ClutterActor *actor,
ClutterActor *old_parent);
void (* show) (ClutterActor *actor);
void (* show_all) (ClutterActor *actor);
void (* hide) (ClutterActor *actor);
void (* hide_all) (ClutterActor *actor);
void (* realize) (ClutterActor *actor);
void (* unrealize) (ClutterActor *actor);
void (* paint) (ClutterActor *actor);
void (* request_coords) (ClutterActor *actor,
ClutterActorBoxReal *box);
void (* allocate_coords) (ClutterActor *actor,
ClutterActorBoxReal *box);
void (* set_depth) (ClutterActor *actor,
gint depth);
gint (* get_depth) (ClutterActor *actor);
void (* parent_set) (ClutterActor *actor,
ClutterActor *old_parent);
void (* destroy) (ClutterActor *actor);
@ -235,6 +250,12 @@ void clutter_actor_get_scalex (ClutterActor *sel
void clutter_actor_get_scale (ClutterActor *self,
gdouble *scale_x,
gdouble *scale_y);
void clutter_actor_scalex (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y,
ClutterGravity gravity);
void clutter_actor_get_abs_size (ClutterActor *self,
guint *width,
guint *height);
@ -245,6 +266,13 @@ void clutter_actor_move_by (ClutterActor *sel
gint dx,
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
#endif /* _HAVE_CLUTTER_ACTOR_H */

View file

@ -78,55 +78,12 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
ClutterActor *actor,
gpointer data)
{
ClutterBehaviourScalePrivate *priv;
guint sw, sh, w, h;
gint x, y;
guint scale = GPOINTER_TO_UINT (data);
ClutterBehaviourScalePrivate *priv =
CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
ClutterFixed scale = GPOINTER_TO_UINT (data);
ClutterGravity gravity = priv->gravity;
priv = CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
clutter_actor_get_abs_size (actor, &w, &h);
clutter_actor_set_scalex (actor, scale, scale);
if (priv->gravity == CLUTTER_GRAVITY_NONE ||
priv->gravity == CLUTTER_GRAVITY_NORTH_WEST)
return;
clutter_actor_get_abs_size (actor, &sw, &sh);
x = clutter_actor_get_x (actor);
y = clutter_actor_get_y (actor);
switch (priv->gravity)
{
case CLUTTER_GRAVITY_NORTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y);
break;
case CLUTTER_GRAVITY_NORTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y);
break;
case CLUTTER_GRAVITY_EAST:
clutter_actor_set_position (actor, x + w - sw, y - (sh - h) / 2);
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
clutter_actor_set_position (actor, x, y + h - sh);
break;
case CLUTTER_GRAVITY_WEST:
clutter_actor_set_position (actor, x, y - ((sh - h) / 2));
break;
case CLUTTER_GRAVITY_CENTER:
clutter_actor_set_position (actor,
x - ((sw - w) / 2),
y - ((sh - h) / 2));
default:
break;
}
clutter_actor_scalex (actor, scale, scale, gravity);
}
static void

View file

@ -30,6 +30,7 @@
#include <clutter/clutter-alpha.h>
#include <clutter/clutter-behaviour.h>
#include <clutter/clutter-actor.h>
G_BEGIN_DECLS
@ -55,19 +56,6 @@ G_BEGIN_DECLS
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CLUTTER_TYPE_BEHAVIOUR_SCALE, ClutterBehaviourScaleClass))
typedef enum { /*< prefix=CLUTTER_GRAVITY >*/
CLUTTER_GRAVITY_NONE = 0,
CLUTTER_GRAVITY_NORTH,
CLUTTER_GRAVITY_NORTH_EAST,
CLUTTER_GRAVITY_EAST,
CLUTTER_GRAVITY_SOUTH_EAST,
CLUTTER_GRAVITY_SOUTH,
CLUTTER_GRAVITY_SOUTH_WEST,
CLUTTER_GRAVITY_WEST,
CLUTTER_GRAVITY_NORTH_WEST,
CLUTTER_GRAVITY_CENTER
} ClutterGravity;
typedef struct _ClutterBehaviourScale ClutterBehaviourScale;
typedef struct _ClutterBehaviourScalePrivate ClutterBehaviourScalePrivate;
typedef struct _ClutterBehaviourScaleClass ClutterBehaviourScaleClass;

View file

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

View file

@ -263,8 +263,8 @@ clutter_label_paint (ClutterActor *self)
}
static void
clutter_label_allocate_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_label_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterLabel *label = CLUTTER_LABEL(self);
ClutterLabelPrivate *priv;
@ -272,7 +272,7 @@ clutter_label_allocate_coords (ClutterActor *self,
priv = label->priv;
clutter_label_ensure_layout (label, box->x2 - box->x1);
clutter_label_ensure_layout (label, CLUTTER_REAL_TO_INT (box->x2 - box->x1));
pango_layout_get_extents (priv->layout, NULL, &logical_rect);
@ -283,8 +283,8 @@ clutter_label_allocate_coords (ClutterActor *self,
}
static void
clutter_label_request_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_label_request_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
/* do we need to do anything ? */
clutter_label_clear_layout (CLUTTER_LABEL(self));

View file

@ -238,26 +238,26 @@ clutter_stage_egl_paint (ClutterActor *self)
}
static void
clutter_stage_egl_allocate_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_stage_egl_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self);
box->x1 = box->y1 = 0;
box->x2 = box->x1 + stage_egl->xwin_width;
box->y2 = box->y1 + stage_egl->xwin_height;
box->x2 = CLUTTER_REAL_ADD_INT (box->x1, stage_egl->xwin_width);
box->y2 = CLUTTER_REAL_ADD_INT (box->y1, stage_egl->xwin_height);
}
static void
clutter_stage_egl_request_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_stage_egl_request_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterStageEgl *stage_egl = CLUTTER_STAGE_EGL (self);
gint new_width, new_height;
/* FIXME: some how have X configure_notfiys call this ? */
new_width = ABS (box->x2 - box->x1);
new_height = ABS (box->y2 - box->y1);
new_width = ABS (CLUTTER_REAL_TO_INT (box->x2 - box->x1));
new_height = ABS (CLUTTER_REAL_TO_INT (box->y2 - box->y1));
if (new_width != stage_egl->xwin_width ||
new_height != stage_egl->xwin_height)
@ -277,8 +277,8 @@ clutter_stage_egl_request_coords (ClutterActor *self,
if (stage_egl->xwin != None) /* Do we want to bother ? */
XMoveWindow (stage_egl->xdpy,
stage_egl->xwin,
box->x1,
box->y1);
CLUTTER_REAL_TO_INT (box->x1),
CLUTTER_REAL_TO_INT (box->y1));
}
static void

View file

@ -369,25 +369,25 @@ clutter_stage_glx_paint (ClutterActor *self)
}
static void
clutter_stage_glx_allocate_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_stage_glx_allocate_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self);
box->x1 = box->y1 = 0;
box->x2 = box->x1 + stage_glx->xwin_width;
box->y2 = box->y1 + stage_glx->xwin_height;
box->x2 = CLUTTER_REAL_ADD_INT (box->x1, stage_glx->xwin_width);
box->y2 = CLUTTER_REAL_ADD_INT (box->y1, stage_glx->xwin_height);
}
static void
clutter_stage_glx_request_coords (ClutterActor *self,
ClutterActorBox *box)
clutter_stage_glx_request_coords (ClutterActor *self,
ClutterActorBoxReal *box)
{
ClutterStageGlx *stage_glx = CLUTTER_STAGE_GLX (self);
gint new_width, new_height;
new_width = ABS (box->x2 - box->x1);
new_height = ABS (box->y2 - box->y1);
new_width = ABS (CLUTTER_REAL_TO_INT (box->x2 - box->x1));
new_height = ABS (CLUTTER_REAL_TO_INT (box->y2 - box->y1));
if (new_width != stage_glx->xwin_width ||
new_height != stage_glx->xwin_height)
@ -414,8 +414,8 @@ clutter_stage_glx_request_coords (ClutterActor *self,
if (stage_glx->xwin != None) /* Do we want to bother ? */
XMoveWindow (stage_glx->xdpy,
stage_glx->xwin,
box->x1,
box->y1);
CLUTTER_REAL_TO_INT (box->x1),
CLUTTER_REAL_TO_INT (box->y1));
}
static void

View file

@ -92,6 +92,22 @@ if $PKG_CONFIG --exists xfixes ; then
X11_LIBS="$X11_LIBS -lXfixes"
fi
CLUTTER_NO_FPU="0"
CLUTTER_REAL=""
AC_ARG_WITH(fpu,
AS_HELP_STRING([--without-fpu],
[Assume target hardware has no fpu]),
[with_fpu=$withval],
[with_fpu=yes])
if test "x$with_fpu" != "xyes" ; then
CLUTTER_NO_FPU="1"
CLUTTER_REAL="-fx"
fi
AC_SUBST(CLUTTER_NO_FPU)
AC_SUBST(CLUTTER_REAL)
clutterbackend=glx
AC_ARG_WITH([flavour],
@ -201,7 +217,7 @@ AC_SUBST([clutterbackend])
AC_SUBST(CLUTTER_FLAVOUR)
AC_SUBST(CLUTTER_COGL)
clutterbackendlib=libclutter-$clutterbackend-$CLUTTER_MAJORMINOR.la
clutterbackendlib=libclutter$CLUTTER_REAL-$clutterbackend-$CLUTTER_MAJORMINOR.la
AC_SUBST([clutterbackendlib])
dnl ========================================================================
@ -239,21 +255,6 @@ fi
AC_SUBST(CLUTTER_DEBUG_CFLAGS)
CLUTTER_NO_FPU=0
AC_ARG_WITH(fpu,
AS_HELP_STRING([--without-fpu],
[Assume target hardware has no fpu]),
[with_fpu=$withval],
[with_fpu=yes])
if test "x$with_fpu" != "xyes" ; then
CLUTTER_NO_FPU=1
CLUTTER_FIXED_CFLAGS="-DCFX_NO_FPU"
fi
AC_SUBST(CLUTTER_NO_FPU)
dnl = GTK Doc check ========================================================
GTK_DOC_CHECK([1.4])
@ -262,7 +263,7 @@ dnl ========================================================================
AC_SUBST(GCC_FLAGS)
CLUTTER_CFLAGS="$SDL_CFLAGS $EGL_CFLAGS $GLX_CFLAGS $CLUTTER_DEPS_CFLAGS $CLUTTER_FIXED_CFLAGS"
CLUTTER_CFLAGS="$SDL_CFLAGS $EGL_CFLAGS $GLX_CFLAGS $CLUTTER_DEPS_CFLAGS"
CLUTTER_LIBS="$SDL_LIBS $EGL_LIBS $GLX_LIBS $CLUTTER_DEPS_LIBS"
AC_SUBST(CLUTTER_CFLAGS)

View file

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

View file

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