+2007-06-14 Matthew Allum <mallum@openedhand.com>
+
+ * clutter/clutter-actor.c:
+ * clutter/clutter-actor.h:
+ * clutter/clutter-group.c:
+ * clutter/clutter-label.c:
+ * clutter/egl/clutter-stage-egl.c:
+ * clutter/glx/clutter-stage-glx.c:
+ * clutter/sdl/clutter-stage-sdl.c:
+ Rename clutter_actor_allocate_coords -> clutter_actor_query_coords
+
+ Change repaints to G_PRIORITY_DEFAULT + 10.
+ (timelines are G_PRIORITY_DEFAULT + 30, events G_PRIORITY_DEFAULT)
+
+ * clutter/glx/clutter-event-glx.c:
+ Handle shift modifier in keycode -> keysym translation.
+
+ * tests/test-actors.c:
+ Remove (broken) screen saver code.
+ Add scaling behaviour, clean code a little.
+
2007-06-13 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c:
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- /* FIXME: we should probably call allocate_cords on the actor to make
+ /* FIXME: we should probably call query_cords on the actor to make
* sure untransformed box is up to date.
*/
priv = self->priv;
}
/**
- * clutter_actor_allocate_coords:
+ * clutter_actor_query_coords:
* @self: A #ClutterActor
* @box: A location to store the actors #ClutterActorBox co-ordinates
*
- * Requests the allocated co-ordinates for the #ClutterActor relative
- * to any parent.
+ * Requests the queryd un transformed co-ordinates for the #ClutterActor
+ * relative to any parent.
*
* This function should not be called directly by applications instead
* the various position/geometry methods should be used.
**/
void
-clutter_actor_allocate_coords (ClutterActor *self,
- ClutterActorBox *box)
+clutter_actor_query_coords (ClutterActor *self,
+ ClutterActorBox *box)
{
ClutterActorClass *klass;
box->x2 = self->priv->coords.x2;
box->y2 = self->priv->coords.y2;
- if (klass->allocate_coords)
+ if (klass->query_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);
+ klass->query_coords(self, box);
self->priv->coords.x1 = box->x1;
self->priv->coords.y1 = box->y1;
{
CLUTTER_TIMESTAMP (SCHEDULER,
"Adding ideler for actor: %p", self);
- ctx->update_idle = g_idle_add_full (-100 , /* very high priority */
+ ctx->update_idle = g_idle_add_full (G_PRIORITY_DEFAULT + 10,
redraw_update_idle,
NULL, NULL);
}
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
geometry->x = CLUTTER_UNITS_TO_INT (box.x1);
geometry->y = CLUTTER_UNITS_TO_INT (box.y1);
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
if (x1)
*x1 = CLUTTER_UNITS_TO_INT (box.x1);
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
box.x2 += (CLUTTER_UNITS_FROM_INT (x) - box.x1);
box.y2 += (CLUTTER_UNITS_FROM_INT (y) - box.y1);
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
box.x2 += dxu;
box.y2 += dyu;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
box.x2 = box.x1 + CLUTTER_UNITS_FROM_INT (width);
box.y2 = box.y1 + CLUTTER_UNITS_FROM_INT (height);
g_return_if_fail (CLUTTER_IS_ACTOR (self));
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
parent = self->priv->parent_actor;
ClutterActorBox box;
ClutterActor *parent;
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
if (width)
*width = box.x2 - box.x1;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
return CLUTTER_UNITS_TO_INT (box.x2 - box.x1);
}
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
return CLUTTER_UNITS_TO_INT (box.y2 - box.y1);
}
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
return CLUTTER_UNITS_TO_INT (box.x1);
}
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
return CLUTTER_UNITS_TO_INT (box.y1);
}
clutter_actor_get_abs_size_units (self, &sw, &sh);
- clutter_actor_allocate_coords (self, &box);
+ clutter_actor_query_coords (self, &box);
x = box.x1;
y = box.y1;
void (* paint) (ClutterActor *actor);
void (* request_coords) (ClutterActor *actor,
ClutterActorBox *box);
- void (* allocate_coords) (ClutterActor *actor,
+ void (* query_coords) (ClutterActor *actor,
ClutterActorBox *box);
void (* set_depth) (ClutterActor *actor,
gint depth);
void clutter_actor_destroy (ClutterActor *self);
void clutter_actor_request_coords (ClutterActor *self,
ClutterActorBox *box);
-void clutter_actor_allocate_coords (ClutterActor *self,
+void clutter_actor_query_coords (ClutterActor *self,
ClutterActorBox *box);
void clutter_actor_set_geometry (ClutterActor *self,
const ClutterGeometry *geometry);
{
ClutterActorBox cbox;
- clutter_actor_allocate_coords (self, &cbox);
+ clutter_actor_query_coords (self, &cbox);
/* Only positioning works.
* Sizing requests fail, use scale() instead
}
static void
-clutter_group_allocate_coords (ClutterActor *self,
- ClutterActorBox *box)
+clutter_group_query_coords (ClutterActor *self,
+ ClutterActorBox *box)
{
ClutterGroupPrivate *priv;
GList *child_item;
{
ClutterActorBox cbox;
- clutter_actor_allocate_coords (child, &cbox);
+ clutter_actor_query_coords (child, &cbox);
/* Ignore any children with offscreen ( negaive )
* positions.
actor_class->show_all = clutter_group_real_show_all;
actor_class->hide_all = clutter_group_real_hide_all;
actor_class->request_coords = clutter_group_request_coords;
- actor_class->allocate_coords = clutter_group_allocate_coords;
+ actor_class->query_coords = clutter_group_query_coords;
/**
* ClutterGroup::add:
}
static void
-clutter_label_allocate_coords (ClutterActor *self,
- ClutterActorBox *box)
+clutter_label_query_coords (ClutterActor *self,
+ ClutterActorBox *box)
{
ClutterLabel *label = CLUTTER_LABEL(self);
ClutterLabelPrivate *priv;
actor_class->paint = clutter_label_paint;
actor_class->request_coords = clutter_label_request_coords;
- actor_class->allocate_coords = clutter_label_allocate_coords;
+ actor_class->query_coords = clutter_label_query_coords;
gobject_class->finalize = clutter_label_finalize;
gobject_class->dispose = clutter_label_dispose;
}
static void
-clutter_stage_egl_allocate_coords (ClutterActor *self,
+clutter_stage_egl_query_coords (ClutterActor *self,
ClutterActorBox *box)
{
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self);
actor_class->realize = clutter_stage_egl_realize;
actor_class->unrealize = clutter_stage_egl_unrealize;
actor_class->request_coords = clutter_stage_egl_request_coords;
- actor_class->allocate_coords = clutter_stage_egl_allocate_coords;
+ actor_class->query_coords = clutter_stage_egl_query_coords;
stage_class->set_fullscreen = clutter_stage_egl_set_fullscreen;
stage_class->set_cursor_visible = clutter_stage_egl_set_cursor_visible;
event->key.time = xevent->xkey.time;
event->key.modifier_state = (ClutterModifierType) xevent->xkey.state;
event->key.hardware_keycode = xevent->xkey.keycode;
- event->key.keyval = XKeycodeToKeysym (xevent->xkey.display,
- xevent->xkey.keycode,
- 0); /* FIXME: index with modifiers */
+
+ /* FIXME: We need to handle other modifiers rather than just shift */
+ event->key.keyval
+ = XKeycodeToKeysym (xevent->xkey.display,
+ xevent->xkey.keycode,
+ (event->key.modifier_state & CLUTTER_SHIFT_MASK)
+ ? 1 : 0);
}
static gboolean
}
static void
-clutter_stage_glx_allocate_coords (ClutterActor *self,
- ClutterActorBox *box)
+clutter_stage_glx_query_coords (ClutterActor *self,
+ ClutterActorBox *box)
{
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (self);
actor_class->realize = clutter_stage_glx_realize;
actor_class->unrealize = clutter_stage_glx_unrealize;
actor_class->request_coords = clutter_stage_glx_request_coords;
- actor_class->allocate_coords = clutter_stage_glx_allocate_coords;
+ actor_class->query_coords = clutter_stage_glx_query_coords;
stage_class->set_fullscreen = clutter_stage_glx_set_fullscreen;
stage_class->set_cursor_visible = clutter_stage_glx_set_cursor_visible;
}
static void
-clutter_stage_sdl_allocate_coords (ClutterActor *self,
+clutter_stage_sdl_query_coords (ClutterActor *self,
ClutterActorBox *box)
{
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self);
actor_class->realize = clutter_stage_sdl_realize;
actor_class->unrealize = clutter_stage_sdl_unrealize;
actor_class->request_coords = clutter_stage_sdl_request_coords;
- actor_class->allocate_coords = clutter_stage_sdl_allocate_coords;
+ actor_class->query_coords = clutter_stage_sdl_query_coords;
stage_class->set_fullscreen = clutter_stage_sdl_set_fullscreen;
stage_class->set_cursor_visible = clutter_stage_sdl_set_cursor_visible;
#include <clutter/clutter.h>
-#ifdef CLUTTER_FLAVOUR_GLX
-#include <clutter/clutter-glx.h>
-#endif
+
#include <math.h>
#include <errno.h>
#include <stdlib.h>
typedef struct SuperOH
{
- ClutterActor **hand, *bgtex;
- ClutterActor *group;
- GdkPixbuf *bgpixb;
+ ClutterActor **hand, *bgtex;
+ ClutterActor *group;
+ GdkPixbuf *bgpixb;
} SuperOH;
static gint
get_radius (void)
{
- return (CLUTTER_STAGE_WIDTH() + CLUTTER_STAGE_HEIGHT()) / n_hands;
-}
-
-void
-screensaver_setup (void)
-{
-#ifdef CLUTTER_FLAVOUR_GLX
- const gchar *preview_xid;
- gboolean foreign_success = FALSE;
- ClutterActor *stage;
-
- stage = clutter_stage_get_default ();
-
- preview_xid = g_getenv ("XSCREENSAVER_WINDOW");
-
- if (preview_xid && *preview_xid)
- {
- char *end;
- Window remote_xwin = (Window) strtoul (preview_xid, &end, 0);
-
- if ((remote_xwin != None) && (end != NULL) &&
- ((*end == ' ') || (*end == '\0')) &&
- ((remote_xwin < G_MAXULONG) || (errno != ERANGE)))
- {
-
- foreign_success =
- clutter_glx_stage_set_foreign (CLUTTER_STAGE (stage), remote_xwin);
- }
- }
-
- if (!foreign_success)
- clutter_actor_set_size (stage, 800, 600);
-#endif
+ return (CLUTTER_STAGE_HEIGHT() + CLUTTER_STAGE_HEIGHT()) / n_hands ;
}
/* input handler */
if (e)
clutter_actor_hide (e);
+
}
else if (event->type == CLUTTER_KEY_RELEASE)
{
ClutterActor *stage = clutter_stage_get_default ();
gint i;
-#if TRAILS
- oh->bgpixb = clutter_stage_snapshot (CLUTTER_STAGE (stage),
- 0, 0,
- CLUTTER_STAGE_WIDTH(),
- CLUTTER_STAGE_HEIGHT());
- clutter_texture_set_pixbuf (CLUTTER_TEXTURE (oh->bgtex), oh->bgpixb);
- g_object_unref (G_OBJECT (oh->bgpixb));
-#endif
-
/* Rotate everything clockwise about stage center*/
clutter_actor_rotate_z (CLUTTER_ACTOR (oh->group),
frame_num,
CLUTTER_STAGE_WIDTH() / 2,
CLUTTER_STAGE_HEIGHT() / 2);
+
for (i = 0; i < n_hands; i++)
{
- /* rotate each hand around there centers */
- clutter_actor_rotate_z (oh->hand[i],
- - 6.0 * frame_num,
- clutter_actor_get_width (oh->hand[i]) / 2,
- clutter_actor_get_height (oh->hand[i]) / 2);
- }
+ gdouble scale_x, scale_y;
- /*
- clutter_actor_rotate_x (CLUTTER_ACTOR(oh->group),
- 75.0,
- CLUTTER_STAGE_HEIGHT()/2, 0);
- */
-}
+ clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y);
+
+ /* Rotate each hand around there centers - to get this we need
+ * to take into account any scaling.
+ */
+ clutter_actor_rotate_z
+ (oh->hand[i],
+ - 6.0 * frame_num,
+ (clutter_actor_get_width (oh->hand[i]) / 2) * scale_x,
+ (clutter_actor_get_height (oh->hand[i]) / 2) * scale_y);
+ }
+}
int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
- ClutterActor *stage;
+ ClutterAlpha *alpha;
+ ClutterBehaviour *scaler_1, *scaler_2;
+ ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
GdkPixbuf *pixbuf;
SuperOH *oh;
GError *error;
error = NULL;
+
clutter_init_with_args (&argc, &argv,
NULL,
super_oh_entries,
}
stage = clutter_stage_get_default ();
+ clutter_actor_set_size (stage, 800, 600);
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
if (!pixbuf)
g_error("pixbuf load failed");
- /* Set our stage (window) size */
- // clutter_actor_set_size (stage, WINWIDTH, WINHEIGHT);
-
- /* and its background color */
-
- screensaver_setup ();
-
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
oh = g_new(SuperOH, 1);
-#if TRAILS
- oh->bgtex = clutter_texture_new();
- clutter_actor_set_size (oh->bgtex,
- CLUTTER_STAGE_WIDTH(), CLUTTER_STAGE_HEIGHT());
- clutter_actor_set_opacity (oh->bgtex, 0x99);
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), oh->bgtex);
-#endif
+ /* Create a timeline to manage animation */
+ timeline = clutter_timeline_new (360, 120); /* num frames, fps */
+ g_object_set(timeline, "loop", TRUE, 0); /* have it loop */
+
+ /* fire a callback for frame change */
+ g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh);
+
+ /* Set up some behaviours to handle scaling */
+ alpha = clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE, NULL, NULL);
+
+ scaler_1 = clutter_behaviour_scale_new (alpha,
+ 0.5,
+ 1.0,
+ CLUTTER_GRAVITY_CENTER);
+
+ scaler_2 = clutter_behaviour_scale_new (alpha,
+ 1.0,
+ 0.5,
+ CLUTTER_GRAVITY_CENTER);
/* create a new group to hold multiple actors in a group */
oh->group = clutter_group_new();
/* Add to our group group */
clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);
- }
-
-#if 0
- {
- clutter_actor_set_scale (oh->group, .1, 0.1);
- guint w, h;
- clutter_actor_get_abs_size (CLUTTER_ACTOR(oh->hand[0]), &w, &h);
- g_print ("%ix%i\n", w, h);
- g_print ("%ix%i\n",
- clutter_actor_get_width(oh->hand[0]),
- clutter_actor_get_height(oh->hand[0]));
- }
-#endif
+ if (i % 2)
+ clutter_behaviour_apply (scaler_1, oh->hand[i]);
+ else
+ clutter_behaviour_apply (scaler_2, oh->hand[i]);
+ }
clutter_actor_show_all (oh->group);
G_CALLBACK (input_cb),
oh);
- /* Create a timeline to manage animation */
- timeline = clutter_timeline_new (360, 90); /* num frames, fps */
- g_object_set(timeline, "loop", TRUE, 0); /* have it loop */
-
- /* fire a callback for frame change */
- g_signal_connect (timeline, "new-frame",
- G_CALLBACK (frame_cb), oh);
-
/* and start it */
clutter_timeline_start (timeline);