2.0: Remove ClutterGeometry
This commit is contained in:
@ -348,63 +348,63 @@ _clutter_script_parse_knot (ClutterScript *script,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_geometry_from_array (JsonArray *array,
|
||||
ClutterGeometry *geometry)
|
||||
parse_rect_from_array (JsonArray *array,
|
||||
ClutterRect *rect)
|
||||
{
|
||||
if (json_array_get_length (array) != 4)
|
||||
return FALSE;
|
||||
|
||||
geometry->x = json_array_get_int_element (array, 0);
|
||||
geometry->y = json_array_get_int_element (array, 1);
|
||||
geometry->width = json_array_get_int_element (array, 2);
|
||||
geometry->height = json_array_get_int_element (array, 3);
|
||||
rect->origin.x = json_array_get_double_element (array, 0);
|
||||
rect->origin.y = json_array_get_double_element (array, 1);
|
||||
rect->size.width = json_array_get_double_element (array, 2);
|
||||
rect->size.height = json_array_get_double_element (array, 3);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_geometry_from_object (JsonObject *object,
|
||||
ClutterGeometry *geometry)
|
||||
parse_rect_from_object (JsonObject *object,
|
||||
ClutterRect *rect)
|
||||
{
|
||||
if (json_object_has_member (object, "x"))
|
||||
geometry->x = json_object_get_int_member (object, "x");
|
||||
rect->origin.x = json_object_get_double_member (object, "x");
|
||||
else
|
||||
geometry->x = 0;
|
||||
rect->origin.x = 0;
|
||||
|
||||
if (json_object_has_member (object, "y"))
|
||||
geometry->y = json_object_get_int_member (object, "y");
|
||||
rect->origin.y = json_object_get_double_member (object, "y");
|
||||
else
|
||||
geometry->y = 0;
|
||||
rect->origin.y = 0;
|
||||
|
||||
if (json_object_has_member (object, "width"))
|
||||
geometry->width = json_object_get_int_member (object, "width");
|
||||
rect->size.width = json_object_get_double_member (object, "width");
|
||||
else
|
||||
geometry->width = 0;
|
||||
rect->size.width = 0;
|
||||
|
||||
if (json_object_has_member (object, "height"))
|
||||
geometry->height = json_object_get_int_member (object, "height");
|
||||
rect->size.height = json_object_get_double_member (object, "height");
|
||||
else
|
||||
geometry->height = 0;
|
||||
rect->size.height = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_script_parse_geometry (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
ClutterGeometry *geometry)
|
||||
_clutter_script_parse_rect (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
ClutterRect *rect)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE);
|
||||
g_return_val_if_fail (node != NULL, FALSE);
|
||||
g_return_val_if_fail (geometry != NULL, FALSE);
|
||||
g_return_val_if_fail (rect != NULL, FALSE);
|
||||
|
||||
switch (JSON_NODE_TYPE (node))
|
||||
{
|
||||
case JSON_NODE_ARRAY:
|
||||
return parse_geometry_from_array (json_node_get_array (node), geometry);
|
||||
return parse_rect_from_array (json_node_get_array (node), rect);
|
||||
|
||||
case JSON_NODE_OBJECT:
|
||||
return parse_geometry_from_object (json_node_get_object (node), geometry);
|
||||
return parse_rect_from_object (json_node_get_object (node), rect);
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -1089,21 +1089,21 @@ _clutter_script_parse_node (ClutterScript *script,
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (p_type == CLUTTER_TYPE_GEOMETRY)
|
||||
else if (p_type == CLUTTER_TYPE_RECT)
|
||||
{
|
||||
ClutterGeometry geom = { 0, };
|
||||
ClutterRect rect = CLUTTER_RECT_INIT_ZERO;
|
||||
|
||||
/* geometry := {
|
||||
* "x" : (int),
|
||||
* "y" : (int),
|
||||
* "width" : (int),
|
||||
* "height" : (int)
|
||||
/* rect := {
|
||||
* "x" : (double),
|
||||
* "y" : (double),
|
||||
* "width" : (double),
|
||||
* "height" : (double)
|
||||
* }
|
||||
*/
|
||||
|
||||
if (_clutter_script_parse_geometry (script, node, &geom))
|
||||
if (_clutter_script_parse_rect (script, node, &rect))
|
||||
{
|
||||
g_value_set_boxed (value, &geom);
|
||||
g_value_set_boxed (value, &rect);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -1178,15 +1178,15 @@ _clutter_script_parse_node (ClutterScript *script,
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_GEOMETRY))
|
||||
else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_RECT))
|
||||
{
|
||||
ClutterGeometry geom = { 0, };
|
||||
ClutterRect rect = CLUTTER_RECT_INIT_ZERO;
|
||||
|
||||
/* geometry := [ (int), (int), (int), (int) ] */
|
||||
/* rect := [ (double), (double), (double), (double) ] */
|
||||
|
||||
if (_clutter_script_parse_geometry (script, node, &geom))
|
||||
if (_clutter_script_parse_rect (script, node, &rect))
|
||||
{
|
||||
g_value_set_boxed (value, &geom);
|
||||
g_value_set_boxed (value, &rect);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user