mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
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:
parent
13ce0e3709
commit
35ee56c50d
15
ChangeLog
15
ChangeLog
@ -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>
|
||||
|
||||
* clutter/clutter-stage.c:
|
||||
|
2
TODO
2
TODO
@ -5,6 +5,7 @@ Posiible New Features
|
||||
==
|
||||
|
||||
- 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.
|
||||
@ -16,6 +17,7 @@ Optimisations
|
||||
|
||||
- Display lists.
|
||||
- labels being more conservative on texture creation.
|
||||
o blitting to textures less
|
||||
- Custom source rather than idle handler for paints ?
|
||||
|
||||
Other
|
||||
|
@ -57,8 +57,6 @@ clutter_group_paint (ClutterActor *actor)
|
||||
ClutterGroup *self = CLUTTER_GROUP(actor);
|
||||
GList *child_item;
|
||||
|
||||
child_item = self->priv->children;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
/* 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;
|
||||
child_item != NULL;
|
||||
child_item = child_item->next)
|
||||
@ -86,21 +83,6 @@ clutter_group_paint (ClutterActor *actor)
|
||||
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();
|
||||
}
|
||||
@ -109,10 +91,60 @@ static void
|
||||
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
|
||||
@ -132,7 +164,7 @@ clutter_group_allocate_coords (ClutterActor *self,
|
||||
{
|
||||
ClutterActor *child = CLUTTER_ACTOR(child_item->data);
|
||||
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
/* if (CLUTTER_ACTOR_IS_VISIBLE (child)) */
|
||||
{
|
||||
ClutterActorBox cbox;
|
||||
|
||||
|
@ -99,7 +99,10 @@ clutter_label_make_pixbuf (ClutterLabel *label)
|
||||
&h);
|
||||
|
||||
if (w == 0 || h == 0)
|
||||
{
|
||||
CLUTTER_DBG("aborting w:%i , h:%i", w, h);
|
||||
return;
|
||||
}
|
||||
|
||||
ft_bitmap.rows = h;
|
||||
ft_bitmap.width = w;
|
||||
@ -135,24 +138,20 @@ clutter_label_make_pixbuf (ClutterLabel *label)
|
||||
|
||||
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 */
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_label_allocate_coords (ClutterActor *actor,
|
||||
ClutterActorBox *box)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
clutter_label_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -308,9 +307,9 @@ clutter_label_init (ClutterLabel *self)
|
||||
|
||||
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;
|
||||
@ -343,12 +342,24 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -557,6 +568,7 @@ clutter_label_set_color (ClutterLabel *label,
|
||||
clutter_actor_queue_redraw (actor);
|
||||
|
||||
g_object_notify (G_OBJECT (label), "color");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,7 +300,6 @@ clutter_redraw (void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (clutter_want_fps ())
|
||||
{
|
||||
timer_n_frames++;
|
||||
|
@ -348,6 +348,7 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
|
||||
|
||||
g_return_if_fail (priv->pixbuf != NULL);
|
||||
|
||||
|
||||
CLUTTER_MARK();
|
||||
|
||||
if (!priv->tiled)
|
||||
@ -415,6 +416,8 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
|
||||
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);
|
||||
@ -466,6 +469,7 @@ clutter_texture_sync_pixbuf (ClutterTexture *texture)
|
||||
pixtmp,
|
||||
0,0);
|
||||
|
||||
|
||||
#ifdef CLUTTER_DUMP_TILES
|
||||
{
|
||||
gchar *filename;
|
||||
@ -576,6 +580,7 @@ clutter_texture_paint (ClutterActor *self)
|
||||
{
|
||||
ClutterTexture *texture = CLUTTER_TEXTURE(self);
|
||||
gint x1, y1, x2, y2;
|
||||
guint8 opacity;
|
||||
|
||||
CLUTTER_DBG("@@@ for '%s' @@@",
|
||||
clutter_actor_get_name(self) ?
|
||||
@ -586,7 +591,10 @@ clutter_texture_paint (ClutterActor *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);
|
||||
@ -1050,6 +1058,13 @@ clutter_texture_get_base_size (ClutterTexture *texture,
|
||||
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;
|
||||
|
||||
|
@ -232,6 +232,7 @@ set_position (ClutterMedia *media,
|
||||
{
|
||||
ClutterVideoTexture *video_texture = CLUTTER_VIDEO_TEXTURE(media);
|
||||
ClutterVideoTexturePrivate *priv;
|
||||
GstState state, pending;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_VIDEO_TEXTURE (video_texture));
|
||||
|
||||
@ -240,6 +241,13 @@ set_position (ClutterMedia *media,
|
||||
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,
|
||||
@ -247,6 +255,8 @@ set_position (ClutterMedia *media,
|
||||
GST_SEEK_TYPE_SET,
|
||||
position * GST_SECOND,
|
||||
0, 0);
|
||||
|
||||
gst_element_set_state (priv->playbin, state);
|
||||
}
|
||||
|
||||
static int
|
||||
|
113
examples/test.c
113
examples/test.c
@ -1,54 +1,40 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
guint8 opacity = 255;
|
||||
|
||||
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;
|
||||
}
|
||||
#define PARA_TEXT "This is a paragraph of text to check both" \
|
||||
"word wrapping and basic clipping."
|
||||
|
||||
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,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterLabel *label;
|
||||
gchar buf[32];
|
||||
gint opacity;
|
||||
|
||||
label = CLUTTER_LABEL(data);
|
||||
|
||||
@ -57,7 +43,7 @@ frame_cb (ClutterTimeline *timeline,
|
||||
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,
|
||||
@ -65,12 +51,22 @@ frame_cb (ClutterTimeline *timeline,
|
||||
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 *texture, *label, *rect, *para;
|
||||
ClutterActor *stage;
|
||||
ClutterTimeline *timeline;
|
||||
ClutterColor rect_col = { 0xff, 0x0, 0x0, 0xff };
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
@ -84,17 +80,22 @@ main (int argc, char *argv[])
|
||||
|
||||
texture = clutter_texture_new_from_pixbuf (pixbuf);
|
||||
|
||||
printf("***********foo***********\n");
|
||||
|
||||
label = clutter_label_new_with_text("Sans Bold 72", "Clutter\nOpened\nHand");
|
||||
|
||||
printf("***********foo***********\n");
|
||||
label = clutter_label_new_with_text("Sans Bold 32", "hello");
|
||||
|
||||
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), label);
|
||||
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
||||
clutter_group_add (CLUTTER_GROUP (stage), para);
|
||||
|
||||
clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600);
|
||||
|
||||
@ -102,7 +103,17 @@ main (int argc, char *argv[])
|
||||
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user