2007-11-30 Emmanuele Bassi <ebassi@openedhand.com>
+ * clutter/clutter-actor.c (parse_units),
+ (clutter_actor_parse_custom_node): Do not allow using percentages
+ of the stage on the stage itself, as it makes little to no
+ sense.
+
+ * clutter/clutter-script.c:
+ (clutter_script_construct_object): Rearrange code.
+
+ * tests/test-script.json: Do not set the size of the stage, to
+ test for the stage size percentage.
+
+2007-11-30 Emmanuele Bassi <ebassi@openedhand.com>
+
* clutter/clutter-model.h: Complete the documentation of
the ClutterModelClass structure members.
} ParseDimension;
static ClutterUnit
-parse_units (ParseDimension dimension,
+parse_units (ClutterActor *self,
+ ParseDimension dimension,
JsonNode *node)
{
GValue value = { 0, };
if (end[0] == '%' && end[1] == '\0')
{
+ if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)
+ {
+ g_warning ("Unable to set percentage of %s on a top-level "
+ "actor of type `%s'",
+ (dimension == PARSE_X || dimension == PARSE_WIDTH) ? "width"
+ : "height",
+ g_type_name (G_OBJECT_TYPE (self)));
+ retval = 0;
+ goto out;
+ }
+
if (dimension == PARSE_X || dimension == PARSE_WIDTH)
retval = CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE (val);
else
}
else if (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE))
{
- gint val = CLAMP (g_value_get_double (&value) * 100, 0, 100);
+ gint val;
+
+ if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)
+ {
+ g_warning ("Unable to set percentage of %s on a top-level "
+ "actor of type `%s'",
+ (dimension == PARSE_X || dimension == PARSE_WIDTH) ? "width"
+ : "height",
+ g_type_name (G_OBJECT_TYPE (self)));
+ retval = 0;
+ goto out;
+ }
+
+ val = CLAMP (g_value_get_double (&value) * 100, 0, 100);
if (dimension == PARSE_X || dimension == PARSE_WIDTH)
retval = CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE (val);
const gchar *name,
JsonNode *node)
{
+ ClutterActor *actor = CLUTTER_ACTOR (scriptable);
gboolean retval = FALSE;
if ((name[0] == 'x' && name[1] == '\0') ||
else
dimension = PARSE_HEIGHT;
- units = parse_units (dimension, node);
+ units = parse_units (actor, dimension, node);
/* convert back to pixels */
g_value_init (value, G_TYPE_INT);
g_array_free (construct_params, TRUE);
}
+ /* then we get the rest of the parameters, asking the object itself
+ * to translate them for us, if we cannot do that
+ */
+ oinfo->properties = clutter_script_translate_parameters (script,
+ object,
+ oinfo->id,
+ oinfo->properties,
+ ¶ms);
+
/* shortcut, to avoid typechecking every time */
if (CLUTTER_IS_SCRIPTABLE (object))
{
set_custom_property = TRUE;
}
- /* then we get the rest of the parameters, asking the object itself
- * to translate them for us, if we cannot do that
- */
- oinfo->properties = clutter_script_translate_parameters (script,
- object,
- oinfo->id,
- oinfo->properties,
- ¶ms);
-
/* consume all the properties we could translate in this pass */
for (i = 0; i < params->len; i++)
{