+2006-06-20 Matthew Allum <mallum@openedhand.com>
+
+ * TODO:
+ Update.
+ * clutter/clutter-group.c:
+ Attempt better group sizing code.
+ * clutter/clutter-label.c:
+ Minor tweaks.
+ * clutter/clutter-texture.c:
+ More debug info, make sure texture is realised for base_size()
+ * clutter/clutter-video-texture.c:
+ Seeking fixes
+ * examples/test.c: (main):
+ Populate with more randomness.
+
2006-06-15 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-stage.c:
==
- Gradients
+ - better pangi integration.
- Audio only object implementing ClutterMedia Interface.
- Some kind of glitz/cairo integration - a GlitzDrawable Actor ?
- Improve clutter label usage as to expose more pango functionality.
- Display lists.
- labels being more conservative on texture creation.
+ o blitting to textures less
- Custom source rather than idle handler for paints ?
Other
clutter_group_paint (ClutterActor *actor)
{
ClutterGroup *self = CLUTTER_GROUP(actor);
- GList *child_item;
-
- child_item = self->priv->children;
+ GList *child_item;
glPushMatrix();
}
-#if 0
for (child_item = self->priv->children;
child_item != NULL;
child_item = child_item->next)
if (CLUTTER_ACTOR_IS_MAPPED (child))
clutter_actor_paint (child);
}
-#endif
-
- if (child_item)
- {
- do
- {
- ClutterActor *child = CLUTTER_ACTOR(child_item->data);
-
- if (CLUTTER_ACTOR_IS_MAPPED (child))
- {
- clutter_actor_paint(child);
- }
- }
- while ((child_item = g_list_next(child_item)) != NULL);
- }
glPopMatrix();
}
clutter_group_request_coords (ClutterActor *self,
ClutterActorBox *box)
{
- /* FIXME: what to do here ?
- * o clip if smaller ?
- * o scale each actor ?
- */
+ ClutterGroup *group = CLUTTER_GROUP(self);
+ guint cwidth, cheight, width ,height;
+ ClutterActorBox cbox;
+
+ clutter_actor_allocate_coords (self, &cbox);
+
+ cwidth = cbox.x2 - cbox.x1;
+ cheight = cbox.y2 - cbox.y1;
+
+ /* g_print("cbox x2: %i x1 %i\n", cbox.x2, cbox.x1); */
+
+ width = box->x2 - box->x1;
+ height = box->y2 - box->y1;
+
+ /* FIXME: below needs work */
+ if (cwidth != width || cheight != height)
+ {
+ GList *child_item;
+
+ for (child_item = group->priv->children;
+ child_item != NULL;
+ child_item = child_item->next)
+ {
+ ClutterActor *child = child_item->data;
+ ClutterActorBox tbox;
+ gint nx, ny;
+ gint twidth, theight, nwidth, nheight;
+
+ g_assert (child != NULL);
+
+ clutter_actor_allocate_coords (child, &tbox);
+
+ twidth = tbox.x2 - tbox.x1;
+ theight = tbox.y2 - tbox.y1;
+
+ /* g_print("getting ps %ix%i\n", tbox.x1, tbox.y1); */
+
+ nwidth = ( width * twidth ) / cwidth;
+ nheight = ( height * theight ) / cheight;
+
+ nx = ( nwidth * tbox.x1 ) / twidth ;
+
+ /* g_print("n: %i t %i x1: %i\n", nwidth, twidth, tbox.x1); */
+
+ ny = ( nheight * tbox.y1 ) / theight;
+
+ /* g_print("n: %i t %i x1: %i\n", nheight, theight, tbox.y1); */
+
+ clutter_actor_set_position (child, nx, ny);
+ clutter_actor_set_size (child, nwidth, height);
+
+ /* g_print("size to +%i+%x %ix%i\n", nx, ny, nwidth, nheight); */
+ }
+ }
}
static void
{
ClutterActor *child = CLUTTER_ACTOR(child_item->data);
- if (CLUTTER_ACTOR_IS_VISIBLE (child))
+ /* if (CLUTTER_ACTOR_IS_VISIBLE (child)) */
{
ClutterActorBox cbox;
&h);
if (w == 0 || h == 0)
- return;
+ {
+ CLUTTER_DBG("aborting w:%i , h:%i", w, h);
+ return;
+ }
ft_bitmap.rows = h;
ft_bitmap.width = w;
g_free (ft_bitmap.buffer);
- CLUTTER_DBG("Calling set_pixbuf with text : '%s' , pixb %ix%i",
- priv->text, w, h);
+ CLUTTER_DBG("Calling set_pixbuf with text : '%s' , pixb %ix%i"
+ " rendered with color %i,%i,%i,%i",
+ priv->text, w, h,
+ priv->fgcol.red,
+ priv->fgcol.green,
+ priv->fgcol.blue,
+ priv->fgcol.alpha);
+
clutter_texture_set_pixbuf (CLUTTER_TEXTURE (label), pixbuf);
/* Texture has the ref now */
}
static void
-clutter_label_allocate_coords (ClutterActor *actor,
- ClutterActorBox *box)
-{
-
-
-
-}
-
-
-static void
clutter_label_set_property (GObject *object,
guint prop_id,
const GValue *value,
self->priv = priv = CLUTTER_LABEL_GET_PRIVATE (self);
- priv->fgcol.red = 255;
- priv->fgcol.green = 255;
- priv->fgcol.blue = 255;
+ priv->fgcol.red = 0;
+ priv->fgcol.green = 0;
+ priv->fgcol.blue = 0;
priv->fgcol.alpha = 255;
priv->text = NULL;
*
* Return value: a #ClutterLabel
*/
-ClutterActor *
+ClutterActor*
clutter_label_new_with_text (const gchar *font_name,
const gchar *text)
{
+ ClutterActor *label;
+
CLUTTER_MARK();
- return g_object_new (CLUTTER_TYPE_LABEL,
- "font-name", font_name,
- "text", text,
- NULL);
+ label = clutter_label_new ();
+ clutter_label_set_font_name (CLUTTER_LABEL(label), font_name);
+ clutter_label_set_text (CLUTTER_LABEL(label), text);
+
+ /* FIXME: Why does calling like;
+ * return g_object_new (CLUTTER_TYPE_LABEL,
+ * "font-name", font_name,
+ * "text", text,
+ * NULL);
+ * mean text does not get rendered without color being set
+ * ( seems to need extra clutter_label_make_pixbuf() call )
+ */
+
+ return label;
}
/**
priv->fgcol.alpha = color->alpha;
clutter_label_make_pixbuf (label);
-
+
actor = CLUTTER_ACTOR (label);
clutter_actor_set_opacity (actor, priv->fgcol.alpha);
clutter_actor_queue_redraw (actor);
g_object_notify (G_OBJECT (label), "color");
+
}
/**
}
-
if (clutter_want_fps ())
{
timer_n_frames++;
g_return_if_fail (priv->pixbuf != NULL);
+
CLUTTER_MARK();
if (!priv->tiled)
CLUTTER_DBG("syncing for multiple tiles for %ix%i pixbuf",
priv->width, priv->height);
+ g_return_if_fail (priv->x_tiles != NULL && priv->y_tiles != NULL);
+
if (priv->tiles == NULL)
{
priv->tiles = g_new (GLuint, priv->n_x_tiles * priv->n_y_tiles);
pixtmp,
0,0);
+
#ifdef CLUTTER_DUMP_TILES
{
gchar *filename;
{
ClutterTexture *texture = CLUTTER_TEXTURE(self);
gint x1, y1, x2, y2;
+ guint8 opacity;
CLUTTER_DBG("@@@ for '%s' @@@",
clutter_actor_get_name(self) ?
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4ub(255, 255, 255, clutter_actor_get_opacity(self));
+ opacity = clutter_actor_get_opacity(self);
+
+ CLUTTER_DBG("setting opacity to %i\n", opacity);
+ glColor4ub(255, 255, 255, opacity);
clutter_actor_get_coords (self, &x1, &y1, &x2, &y2);
texture_render_to_gl_quad (texture, x1, y1, x2, y2);
gint *width,
gint *height)
{
+ /* Attempt to realize, mainly for subclasses ( such as labels )
+ * which maynot create pixbuf data and thus base size until
+ * realization happens.
+ */
+ if (!CLUTTER_ACTOR_IS_REALIZED(CLUTTER_ACTOR(texture)))
+ clutter_actor_realize (CLUTTER_ACTOR(texture));
+
if (width)
*width = texture->priv->width;
{
ClutterVideoTexture *video_texture = CLUTTER_VIDEO_TEXTURE(media);
ClutterVideoTexturePrivate *priv;
+ GstState state, pending;
g_return_if_fail (CLUTTER_IS_VIDEO_TEXTURE (video_texture));
if (!priv->playbin)
return;
+ gst_element_get_state (priv->playbin, &state, &pending, 0);
+
+ if (pending)
+ state = pending;
+
+ gst_element_set_state (priv->playbin, GST_STATE_PAUSED);
+
gst_element_seek (priv->playbin,
1.0,
GST_FORMAT_TIME,
GST_SEEK_TYPE_SET,
position * GST_SECOND,
0, 0);
+
+ gst_element_set_state (priv->playbin, state);
}
static int
#include <clutter/clutter.h>
-guint8 opacity = 255;
+#define PARA_TEXT "This is a paragraph of text to check both" \
+ "word wrapping and basic clipping."
-gboolean
-timeout_cb (gpointer data)
+void
+rect_cb (ClutterTimeline *timeline,
+ gint frame_num,
+ gpointer data)
{
- ClutterActor *actor;
+ ClutterActor *rect = CLUTTER_ACTOR(data);
+ gint x, y;
+ static gint direction = 1;
- actor = CLUTTER_ACTOR(data);
+ x = clutter_actor_get_x (rect);
+ y = clutter_actor_get_y (rect);
- if (opacity > 0)
- {
- clutter_actor_set_opacity (actor, opacity);
- opacity -= 2;
- }
- else opacity = 0xff;
+ if (x > (CLUTTER_STAGE_WIDTH() - 200))
+ direction = -1;
+
+ if (x < 100)
+ direction = 1;
- return TRUE;
-}
+ x += direction;
-gboolean
-timeout_text_cb (gpointer data)
-{
- ClutterLabel *label;
- gchar buf[32];
-
- label = CLUTTER_LABEL(data);
-
- g_snprintf(buf, 32, "--> %i <--", opacity);
-
- if (opacity > 0)
- {
- clutter_label_set_text(label, buf);
- clutter_actor_set_opacity (CLUTTER_ACTOR(label), opacity);
- opacity -= 2;
- }
- else opacity = 0xff;
-
-
-
- return TRUE;
+ clutter_actor_set_position (rect, x, y);
}
+
void
-frame_cb (ClutterTimeline *timeline,
- gint frame_num,
- gpointer data)
+text_cb (ClutterTimeline *timeline,
+ gint frame_num,
+ gpointer data)
{
ClutterLabel *label;
gchar buf[32];
+ gint opacity;
label = CLUTTER_LABEL(data);
g_snprintf(buf, 32, "--> %i <--", frame_num);
clutter_label_set_text (label, buf);
- clutter_actor_set_opacity (CLUTTER_ACTOR(label), opacity);
+ // clutter_actor_set_opacity (CLUTTER_ACTOR(label), opacity);
clutter_actor_rotate_z (CLUTTER_ACTOR(label),
frame_num,
clutter_actor_get_height (CLUTTER_ACTOR(label))/2);
}
+void
+para_cb (ClutterTimeline *timeline,
+ gint frame_num,
+ gpointer data)
+{
+
+
+}
+
int
main (int argc, char *argv[])
{
- ClutterActor *texture, *label;
- ClutterActor *stage;
+ ClutterActor *texture, *label, *rect, *para;
+ ClutterActor *stage;
ClutterTimeline *timeline;
+ ClutterColor rect_col = { 0xff, 0x0, 0x0, 0xff };
GdkPixbuf *pixbuf;
clutter_init (&argc, &argv);
texture = clutter_texture_new_from_pixbuf (pixbuf);
- printf("***********foo***********\n");
+ label = clutter_label_new_with_text("Sans Bold 32", "hello");
- label = clutter_label_new_with_text("Sans Bold 72", "Clutter\nOpened\nHand");
+ clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99);
+ clutter_actor_set_position (CLUTTER_ACTOR(label), 550, 100);
- printf("***********foo***********\n");
+ rect = clutter_rectangle_new_with_color(&rect_col);
+ clutter_actor_set_size(rect, 100, 100);
+ clutter_actor_set_position(rect, 100, 100);
- clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99);
- clutter_actor_set_position (CLUTTER_ACTOR(label), 100, 200);
+ para = clutter_label_new_with_text ("Sans 24", PARA_TEXT);
+ clutter_actor_set_position(para, 10, 10);
clutter_group_add (CLUTTER_GROUP (stage), texture);
clutter_group_add (CLUTTER_GROUP (stage), label);
+ clutter_group_add (CLUTTER_GROUP (stage), rect);
+ clutter_group_add (CLUTTER_GROUP (stage), para);
clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600);
timeline = clutter_timeline_new (360, 200);
g_object_set (timeline, "loop", TRUE, 0);
- g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), label);
+ g_signal_connect (timeline, "new-frame", G_CALLBACK (text_cb), label);
+ clutter_timeline_start (timeline);
+
+ timeline = clutter_timeline_new (1, 30);
+ g_object_set (timeline, "loop", TRUE, 0);
+ g_signal_connect (timeline, "new-frame", G_CALLBACK (rect_cb), rect);
+ clutter_timeline_start (timeline);
+
+ timeline = clutter_timeline_new (1, 10);
+ g_object_set (timeline, "loop", TRUE, 0);
+ g_signal_connect (timeline, "new-frame", G_CALLBACK (para_cb), rect);
clutter_timeline_start (timeline);
clutter_main();