Question

I just started playing around with clutter a bit, and I got a question in regards to setting properties on a ClutterActor.

I want to set the pivot-point property, after searching though the reference, the function which seems the best fit is clutter_container_child_set_property (I couldn't find anything with operated directly on the actor), so I'm trying

ClutterPoint point = {128,64};
clutter_container_child_set_property(CLUTTER_CONTAINER(stage), box, "pivot-point", point);

But I get an error, it expects the point to be of the type GValue , how do I change the clutter point to a gvalue?

Was it helpful?

Solution

clutter_container_set_property probably isn't the right way to go, but stuffing a ClutterPoint in a GValue would look something like this:

GValue value;
g_value_init (&value, CLUTTER_TYPE_POINT);
g_value_set_boxed (&value, &point);

Once you have that you can use g_object_set_property to set the ClutterActor:pivot-point property:

g_object_set_property (G_OBJECT(box), "pivot-point", &value);

Or you could just let GObject handle the GValue stuff for you and use g_object_set:

g_object_set (G_OBJECT(box), "pivot-point", &point, NULL);

If you don't already have the ClutterPoint sitting around for some other reason, the easiest method would be to just use clutter_actor_set_pivot_point:

clutter_actor_set_pivot_point (box, 128, 64);

Of course, if you do already have the ClutterPoint, you can also just use point.x and point.y instead of 128 and 64.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top