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.
This commit is contained in:
Matthew Allum 2006-06-20 20:29:45 +00:00
parent 13ce0e3709
commit 35ee56c50d
8 changed files with 198 additions and 102 deletions

View File

@ -1,3 +1,18 @@
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> 2006-06-15 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-stage.c: * clutter/clutter-stage.c:

2
TODO
View File

@ -5,6 +5,7 @@ Posiible New Features
== ==
- Gradients - Gradients
- better pangi integration.
- Audio only object implementing ClutterMedia Interface. - Audio only object implementing ClutterMedia Interface.
- Some kind of glitz/cairo integration - a GlitzDrawable Actor ? - Some kind of glitz/cairo integration - a GlitzDrawable Actor ?
- Improve clutter label usage as to expose more pango functionality. - Improve clutter label usage as to expose more pango functionality.
@ -16,6 +17,7 @@ Optimisations
- Display lists. - Display lists.
- labels being more conservative on texture creation. - labels being more conservative on texture creation.
o blitting to textures less
- Custom source rather than idle handler for paints ? - Custom source rather than idle handler for paints ?
Other Other

View File

@ -57,8 +57,6 @@ clutter_group_paint (ClutterActor *actor)
ClutterGroup *self = CLUTTER_GROUP(actor); ClutterGroup *self = CLUTTER_GROUP(actor);
GList *child_item; GList *child_item;
child_item = self->priv->children;
glPushMatrix(); glPushMatrix();
/* Translate if parent ( i.e not stage window ). /* Translate if parent ( i.e not stage window ).
@ -74,7 +72,6 @@ clutter_group_paint (ClutterActor *actor)
} }
#if 0
for (child_item = self->priv->children; for (child_item = self->priv->children;
child_item != NULL; child_item != NULL;
child_item = child_item->next) child_item = child_item->next)
@ -86,21 +83,6 @@ clutter_group_paint (ClutterActor *actor)
if (CLUTTER_ACTOR_IS_MAPPED (child)) if (CLUTTER_ACTOR_IS_MAPPED (child))
clutter_actor_paint (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(); glPopMatrix();
} }
@ -109,10 +91,60 @@ static void
clutter_group_request_coords (ClutterActor *self, clutter_group_request_coords (ClutterActor *self,
ClutterActorBox *box) ClutterActorBox *box)
{ {
/* FIXME: what to do here ? ClutterGroup *group = CLUTTER_GROUP(self);
* o clip if smaller ? guint cwidth, cheight, width ,height;
* o scale each actor ? 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 static void
@ -132,7 +164,7 @@ clutter_group_allocate_coords (ClutterActor *self,
{ {
ClutterActor *child = CLUTTER_ACTOR(child_item->data); ClutterActor *child = CLUTTER_ACTOR(child_item->data);
if (CLUTTER_ACTOR_IS_VISIBLE (child)) /* if (CLUTTER_ACTOR_IS_VISIBLE (child)) */
{ {
ClutterActorBox cbox; ClutterActorBox cbox;

View File

@ -99,7 +99,10 @@ clutter_label_make_pixbuf (ClutterLabel *label)
&h); &h);
if (w == 0 || h == 0) if (w == 0 || h == 0)
{
CLUTTER_DBG("aborting w:%i , h:%i", w, h);
return; return;
}
ft_bitmap.rows = h; ft_bitmap.rows = h;
ft_bitmap.width = w; ft_bitmap.width = w;
@ -135,24 +138,20 @@ clutter_label_make_pixbuf (ClutterLabel *label)
g_free (ft_bitmap.buffer); g_free (ft_bitmap.buffer);
CLUTTER_DBG("Calling set_pixbuf with text : '%s' , pixb %ix%i", CLUTTER_DBG("Calling set_pixbuf with text : '%s' , pixb %ix%i"
priv->text, w, h); " 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); clutter_texture_set_pixbuf (CLUTTER_TEXTURE (label), pixbuf);
/* Texture has the ref now */ /* Texture has the ref now */
g_object_unref (pixbuf); g_object_unref (pixbuf);
} }
static void
clutter_label_allocate_coords (ClutterActor *actor,
ClutterActorBox *box)
{
}
static void static void
clutter_label_set_property (GObject *object, clutter_label_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -308,9 +307,9 @@ clutter_label_init (ClutterLabel *self)
self->priv = priv = CLUTTER_LABEL_GET_PRIVATE (self); self->priv = priv = CLUTTER_LABEL_GET_PRIVATE (self);
priv->fgcol.red = 255; priv->fgcol.red = 0;
priv->fgcol.green = 255; priv->fgcol.green = 0;
priv->fgcol.blue = 255; priv->fgcol.blue = 0;
priv->fgcol.alpha = 255; priv->fgcol.alpha = 255;
priv->text = NULL; priv->text = NULL;
@ -339,16 +338,28 @@ clutter_label_init (ClutterLabel *self)
* *
* Return value: a #ClutterLabel * Return value: a #ClutterLabel
*/ */
ClutterActor * ClutterActor*
clutter_label_new_with_text (const gchar *font_name, clutter_label_new_with_text (const gchar *font_name,
const gchar *text) const gchar *text)
{ {
ClutterActor *label;
CLUTTER_MARK(); CLUTTER_MARK();
return g_object_new (CLUTTER_TYPE_LABEL, label = clutter_label_new ();
"font-name", font_name, clutter_label_set_font_name (CLUTTER_LABEL(label), font_name);
"text", text, clutter_label_set_text (CLUTTER_LABEL(label), text);
NULL);
/* 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;
} }
/** /**
@ -557,6 +568,7 @@ clutter_label_set_color (ClutterLabel *label,
clutter_actor_queue_redraw (actor); clutter_actor_queue_redraw (actor);
g_object_notify (G_OBJECT (label), "color"); g_object_notify (G_OBJECT (label), "color");
} }
/** /**

View File

@ -300,7 +300,6 @@ clutter_redraw (void)
} }
if (clutter_want_fps ()) if (clutter_want_fps ())
{ {
timer_n_frames++; timer_n_frames++;

View File

@ -348,6 +348,7 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
g_return_if_fail (priv->pixbuf != NULL); g_return_if_fail (priv->pixbuf != NULL);
CLUTTER_MARK(); CLUTTER_MARK();
if (!priv->tiled) if (!priv->tiled)
@ -415,6 +416,8 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
CLUTTER_DBG("syncing for multiple tiles for %ix%i pixbuf", CLUTTER_DBG("syncing for multiple tiles for %ix%i pixbuf",
priv->width, priv->height); priv->width, priv->height);
g_return_if_fail (priv->x_tiles != NULL && priv->y_tiles != NULL);
if (priv->tiles == NULL) if (priv->tiles == NULL)
{ {
priv->tiles = g_new (GLuint, priv->n_x_tiles * priv->n_y_tiles); priv->tiles = g_new (GLuint, priv->n_x_tiles * priv->n_y_tiles);
@ -466,6 +469,7 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
pixtmp, pixtmp,
0,0); 0,0);
#ifdef CLUTTER_DUMP_TILES #ifdef CLUTTER_DUMP_TILES
{ {
gchar *filename; gchar *filename;
@ -576,6 +580,7 @@ clutter_texture_paint (ClutterActor *self)
{ {
ClutterTexture *texture = CLUTTER_TEXTURE(self); ClutterTexture *texture = CLUTTER_TEXTURE(self);
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
guint8 opacity;
CLUTTER_DBG("@@@ for '%s' @@@", CLUTTER_DBG("@@@ for '%s' @@@",
clutter_actor_get_name(self) ? clutter_actor_get_name(self) ?
@ -586,7 +591,10 @@ clutter_texture_paint (ClutterActor *self)
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 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); clutter_actor_get_coords (self, &x1, &y1, &x2, &y2);
texture_render_to_gl_quad (texture, x1, y1, x2, y2); texture_render_to_gl_quad (texture, x1, y1, x2, y2);
@ -1050,6 +1058,13 @@ clutter_texture_get_base_size (ClutterTexture *texture,
gint *width, gint *width,
gint *height) 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) if (width)
*width = texture->priv->width; *width = texture->priv->width;

View File

@ -232,6 +232,7 @@ set_position (ClutterMedia *media,
{ {
ClutterVideoTexture *video_texture = CLUTTER_VIDEO_TEXTURE(media); ClutterVideoTexture *video_texture = CLUTTER_VIDEO_TEXTURE(media);
ClutterVideoTexturePrivate *priv; ClutterVideoTexturePrivate *priv;
GstState state, pending;
g_return_if_fail (CLUTTER_IS_VIDEO_TEXTURE (video_texture)); g_return_if_fail (CLUTTER_IS_VIDEO_TEXTURE (video_texture));
@ -240,6 +241,13 @@ set_position (ClutterMedia *media,
if (!priv->playbin) if (!priv->playbin)
return; 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, gst_element_seek (priv->playbin,
1.0, 1.0,
GST_FORMAT_TIME, GST_FORMAT_TIME,
@ -247,6 +255,8 @@ set_position (ClutterMedia *media,
GST_SEEK_TYPE_SET, GST_SEEK_TYPE_SET,
position * GST_SECOND, position * GST_SECOND,
0, 0); 0, 0);
gst_element_set_state (priv->playbin, state);
} }
static int static int

View File

@ -1,54 +1,40 @@
#include <clutter/clutter.h> #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)
{
ClutterActor *actor;
actor = CLUTTER_ACTOR(data);
if (opacity > 0)
{
clutter_actor_set_opacity (actor, opacity);
opacity -= 2;
}
else opacity = 0xff;
return TRUE;
}
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;
}
void void
frame_cb (ClutterTimeline *timeline, rect_cb (ClutterTimeline *timeline,
gint frame_num,
gpointer data)
{
ClutterActor *rect = CLUTTER_ACTOR(data);
gint x, y;
static gint direction = 1;
x = clutter_actor_get_x (rect);
y = clutter_actor_get_y (rect);
if (x > (CLUTTER_STAGE_WIDTH() - 200))
direction = -1;
if (x < 100)
direction = 1;
x += direction;
clutter_actor_set_position (rect, x, y);
}
void
text_cb (ClutterTimeline *timeline,
gint frame_num, gint frame_num,
gpointer data) gpointer data)
{ {
ClutterLabel *label; ClutterLabel *label;
gchar buf[32]; gchar buf[32];
gint opacity;
label = CLUTTER_LABEL(data); label = CLUTTER_LABEL(data);
@ -57,7 +43,7 @@ frame_cb (ClutterTimeline *timeline,
g_snprintf(buf, 32, "--> %i <--", frame_num); g_snprintf(buf, 32, "--> %i <--", frame_num);
clutter_label_set_text (label, buf); 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), clutter_actor_rotate_z (CLUTTER_ACTOR(label),
frame_num, frame_num,
@ -65,12 +51,22 @@ frame_cb (ClutterTimeline *timeline,
clutter_actor_get_height (CLUTTER_ACTOR(label))/2); clutter_actor_get_height (CLUTTER_ACTOR(label))/2);
} }
void
para_cb (ClutterTimeline *timeline,
gint frame_num,
gpointer data)
{
}
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
ClutterActor *texture, *label; ClutterActor *texture, *label, *rect, *para;
ClutterActor *stage; ClutterActor *stage;
ClutterTimeline *timeline; ClutterTimeline *timeline;
ClutterColor rect_col = { 0xff, 0x0, 0x0, 0xff };
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
@ -84,17 +80,22 @@ main (int argc, char *argv[])
texture = clutter_texture_new_from_pixbuf (pixbuf); 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");
printf("***********foo***********\n");
clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99); clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99);
clutter_actor_set_position (CLUTTER_ACTOR(label), 100, 200); clutter_actor_set_position (CLUTTER_ACTOR(label), 550, 100);
rect = clutter_rectangle_new_with_color(&rect_col);
clutter_actor_set_size(rect, 100, 100);
clutter_actor_set_position(rect, 100, 100);
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), texture);
clutter_group_add (CLUTTER_GROUP (stage), label); 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); clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600);
@ -102,7 +103,17 @@ main (int argc, char *argv[])
timeline = clutter_timeline_new (360, 200); timeline = clutter_timeline_new (360, 200);
g_object_set (timeline, "loop", TRUE, 0); 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_timeline_start (timeline);
clutter_main(); clutter_main();