clutter: Make json-glib a debug only dependency
Currently, json-glib is used for two things: - For loading scripts, nothing seems to use that in real life other than some tests - For debugging paint nodes For now, the PR drops the first use case and only require json-glib if it is a debug build Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3354>
This commit is contained in:
parent
4bc73ba9f4
commit
8a3181f741
38 changed files with 51 additions and 5376 deletions
|
@ -380,44 +380,6 @@
|
|||
* In general, it is strongly encouraged to use delegation and composition
|
||||
* instead of direct subclassing.
|
||||
*
|
||||
* ## ClutterActor custom properties for ClutterScript
|
||||
*
|
||||
* #ClutterActor defines a custom "rotation" property which allows a short-hand
|
||||
* description of the rotations to be applied to an actor.
|
||||
*
|
||||
* The syntax of the "rotation" property is the following:
|
||||
*
|
||||
* ```
|
||||
* "rotation" : [ { "<axis>" : [ <angle>, [ <center-point> ] ] } ]
|
||||
* ```
|
||||
*
|
||||
* where:
|
||||
*
|
||||
* - axis is the name of an enumeration value of type #ClutterRotateAxis
|
||||
* - angle is a floating point value representing the rotation angle on the given axis in degrees
|
||||
* - center-point is an optional array, and if present it must contain the center of rotation as described by two coordinates:
|
||||
* - Y and Z for "x-axis"
|
||||
* - X and Z for "y-axis"
|
||||
* - X and Y for "z-axis".
|
||||
*
|
||||
* #ClutterActor also defines a scriptable "margin" property which follows the CSS "margin" shorthand.
|
||||
*
|
||||
* ```
|
||||
* // 4 values
|
||||
* "margin" : [ top, right, bottom, left ]
|
||||
* // 3 values
|
||||
* "margin" : [ top, left/right, bottom ]
|
||||
* // 2 values
|
||||
* "margin" : [ top/bottom, left/right ]
|
||||
* // 1 value
|
||||
* "margin" : [ top/right/bottom/left ]
|
||||
* ```
|
||||
*
|
||||
* #ClutterActor will also parse every positional and dimensional
|
||||
* property defined as a string through clutter_units_from_string(); you
|
||||
* should read the documentation for the #ClutterUnits parser format for
|
||||
* the valid units and syntax.
|
||||
*
|
||||
* ## Custom animatable properties
|
||||
*
|
||||
* #ClutterActor allows accessing properties of #ClutterAction,
|
||||
|
@ -555,8 +517,6 @@
|
|||
#include "clutter/clutter-pick-context-private.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
#include "clutter/clutter-property-transition.h"
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-script-private.h"
|
||||
#include "clutter/clutter-stage-private.h"
|
||||
#include "clutter/clutter-stage-view-private.h"
|
||||
#include "clutter/clutter-timeline.h"
|
||||
|
@ -941,7 +901,6 @@ typedef struct _TransitionClosure
|
|||
gulong completed_id;
|
||||
} TransitionClosure;
|
||||
|
||||
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||
static void clutter_animatable_iface_init (ClutterAnimatableInterface *iface);
|
||||
static void atk_implementor_iface_init (AtkImplementorIface *iface);
|
||||
|
||||
|
@ -1026,8 +985,6 @@ G_DEFINE_TYPE_WITH_CODE (ClutterActor,
|
|||
clutter_actor,
|
||||
G_TYPE_INITIALLY_UNOWNED,
|
||||
G_ADD_PRIVATE (ClutterActor)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||
clutter_scriptable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_ANIMATABLE,
|
||||
clutter_animatable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMPLEMENTOR,
|
||||
|
@ -11951,474 +11908,6 @@ clutter_actor_store_content_box (ClutterActor *self,
|
|||
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CONTENT_BOX]);
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PARSE_X,
|
||||
PARSE_Y,
|
||||
PARSE_WIDTH,
|
||||
PARSE_HEIGHT,
|
||||
} ParseDimension;
|
||||
|
||||
static gfloat
|
||||
parse_units (ClutterActor *self,
|
||||
ParseDimension dimension,
|
||||
JsonNode *node)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
gfloat retval = 0;
|
||||
|
||||
if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE)
|
||||
return 0;
|
||||
|
||||
json_node_get_value (node, &value);
|
||||
|
||||
if (G_VALUE_HOLDS (&value, G_TYPE_INT64))
|
||||
{
|
||||
retval = (gfloat) g_value_get_int64 (&value);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE))
|
||||
{
|
||||
retval = g_value_get_double (&value);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (&value, G_TYPE_STRING))
|
||||
{
|
||||
ClutterUnits units;
|
||||
gboolean res;
|
||||
|
||||
res = clutter_units_from_string (&units, g_value_get_string (&value));
|
||||
if (res)
|
||||
retval = clutter_units_to_pixels (&units);
|
||||
else
|
||||
{
|
||||
g_warning ("Invalid value '%s': integers, strings or floating point "
|
||||
"values can be used for the x, y, width and height "
|
||||
"properties. Valid modifiers for strings are 'px', 'mm', "
|
||||
"'pt' and 'em'.",
|
||||
g_value_get_string (&value));
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Invalid value of type '%s': integers, strings of floating "
|
||||
"point values can be used for the x, y, width, and height "
|
||||
"properties.",
|
||||
g_type_name (G_VALUE_TYPE (&value)));
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ClutterRotateAxis axis;
|
||||
|
||||
gdouble angle;
|
||||
|
||||
gfloat center_x;
|
||||
gfloat center_y;
|
||||
gfloat center_z;
|
||||
} RotationInfo;
|
||||
|
||||
static inline gboolean
|
||||
parse_rotation_array (ClutterActor *actor,
|
||||
JsonArray *array,
|
||||
RotationInfo *info)
|
||||
{
|
||||
JsonNode *element;
|
||||
|
||||
if (json_array_get_length (array) != 2)
|
||||
return FALSE;
|
||||
|
||||
/* angle */
|
||||
element = json_array_get_element (array, 0);
|
||||
if (JSON_NODE_TYPE (element) == JSON_NODE_VALUE)
|
||||
info->angle = json_node_get_double (element);
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
/* center */
|
||||
element = json_array_get_element (array, 1);
|
||||
if (JSON_NODE_TYPE (element) == JSON_NODE_ARRAY)
|
||||
{
|
||||
JsonArray *center = json_node_get_array (element);
|
||||
|
||||
if (json_array_get_length (center) != 2)
|
||||
return FALSE;
|
||||
|
||||
switch (info->axis)
|
||||
{
|
||||
case CLUTTER_X_AXIS:
|
||||
info->center_y = parse_units (actor, PARSE_Y,
|
||||
json_array_get_element (center, 0));
|
||||
info->center_z = parse_units (actor, PARSE_Y,
|
||||
json_array_get_element (center, 1));
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_Y_AXIS:
|
||||
info->center_x = parse_units (actor, PARSE_X,
|
||||
json_array_get_element (center, 0));
|
||||
info->center_z = parse_units (actor, PARSE_X,
|
||||
json_array_get_element (center, 1));
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_Z_AXIS:
|
||||
info->center_x = parse_units (actor, PARSE_X,
|
||||
json_array_get_element (center, 0));
|
||||
info->center_y = parse_units (actor, PARSE_Y,
|
||||
json_array_get_element (center, 1));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_rotation (ClutterActor *actor,
|
||||
JsonNode *node,
|
||||
RotationInfo *info)
|
||||
{
|
||||
JsonArray *array;
|
||||
guint len, i;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (JSON_NODE_TYPE (node) != JSON_NODE_ARRAY)
|
||||
{
|
||||
g_warning ("Invalid node of type '%s' found, expecting an array",
|
||||
json_node_type_name (node));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
array = json_node_get_array (node);
|
||||
len = json_array_get_length (array);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
JsonNode *element = json_array_get_element (array, i);
|
||||
JsonObject *object;
|
||||
JsonNode *member;
|
||||
|
||||
if (JSON_NODE_TYPE (element) != JSON_NODE_OBJECT)
|
||||
{
|
||||
g_warning ("Invalid node of type '%s' found, expecting an object",
|
||||
json_node_type_name (element));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
object = json_node_get_object (element);
|
||||
|
||||
if (json_object_has_member (object, "x-axis"))
|
||||
{
|
||||
member = json_object_get_member (object, "x-axis");
|
||||
|
||||
info->axis = CLUTTER_X_AXIS;
|
||||
|
||||
if (JSON_NODE_TYPE (member) == JSON_NODE_VALUE)
|
||||
{
|
||||
info->angle = json_node_get_double (member);
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||
retval = parse_rotation_array (actor,
|
||||
json_node_get_array (member),
|
||||
info);
|
||||
else
|
||||
retval = FALSE;
|
||||
}
|
||||
else if (json_object_has_member (object, "y-axis"))
|
||||
{
|
||||
member = json_object_get_member (object, "y-axis");
|
||||
|
||||
info->axis = CLUTTER_Y_AXIS;
|
||||
|
||||
if (JSON_NODE_TYPE (member) == JSON_NODE_VALUE)
|
||||
{
|
||||
info->angle = json_node_get_double (member);
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||
retval = parse_rotation_array (actor,
|
||||
json_node_get_array (member),
|
||||
info);
|
||||
else
|
||||
retval = FALSE;
|
||||
}
|
||||
else if (json_object_has_member (object, "z-axis"))
|
||||
{
|
||||
member = json_object_get_member (object, "z-axis");
|
||||
|
||||
info->axis = CLUTTER_Z_AXIS;
|
||||
|
||||
if (JSON_NODE_TYPE (member) == JSON_NODE_VALUE)
|
||||
{
|
||||
info->angle = json_node_get_double (member);
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||
retval = parse_rotation_array (actor,
|
||||
json_node_get_array (member),
|
||||
info);
|
||||
else
|
||||
retval = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
parse_actor_metas (ClutterScript *script,
|
||||
ClutterActor *actor,
|
||||
JsonNode *node)
|
||||
{
|
||||
GList *elements, *l;
|
||||
GSList *retval = NULL;
|
||||
|
||||
if (!JSON_NODE_HOLDS_ARRAY (node))
|
||||
return NULL;
|
||||
|
||||
elements = json_array_get_elements (json_node_get_array (node));
|
||||
|
||||
for (l = elements; l != NULL; l = l->next)
|
||||
{
|
||||
JsonNode *element = l->data;
|
||||
const gchar *id_ = _clutter_script_get_id_from_node (element);
|
||||
GObject *meta;
|
||||
|
||||
if (id_ == NULL || *id_ == '\0')
|
||||
continue;
|
||||
|
||||
meta = clutter_script_get_object (script, id_);
|
||||
if (meta == NULL)
|
||||
continue;
|
||||
|
||||
retval = g_slist_prepend (retval, meta);
|
||||
}
|
||||
|
||||
g_list_free (elements);
|
||||
|
||||
return g_slist_reverse (retval);
|
||||
}
|
||||
|
||||
static ClutterMargin *
|
||||
parse_margin (ClutterActor *self,
|
||||
JsonNode *node)
|
||||
{
|
||||
ClutterMargin *margin;
|
||||
JsonArray *array;
|
||||
|
||||
if (!JSON_NODE_HOLDS_ARRAY (node))
|
||||
{
|
||||
g_warning ("The margin property must be an array of 1 to 4 elements");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
margin = clutter_margin_new ();
|
||||
array = json_node_get_array (node);
|
||||
switch (json_array_get_length (array))
|
||||
{
|
||||
case 1:
|
||||
margin->top = margin->right = margin->bottom = margin->left =
|
||||
parse_units (self, 0, json_array_get_element (array, 0));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
margin->top = margin->bottom =
|
||||
parse_units (self, 0, json_array_get_element (array, 0));
|
||||
margin->right = margin->left =
|
||||
parse_units (self, 0, json_array_get_element (array, 1));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
margin->top =
|
||||
parse_units (self, 0, json_array_get_element (array, 0));
|
||||
margin->right = margin->left =
|
||||
parse_units (self, 0, json_array_get_element (array, 1));
|
||||
margin->bottom =
|
||||
parse_units (self, 0, json_array_get_element (array, 2));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
margin->top =
|
||||
parse_units (self, 0, json_array_get_element (array, 0));
|
||||
margin->right =
|
||||
parse_units (self, 0, json_array_get_element (array, 1));
|
||||
margin->bottom =
|
||||
parse_units (self, 0, json_array_get_element (array, 2));
|
||||
margin->left =
|
||||
parse_units (self, 0, json_array_get_element (array, 3));
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("The margin property must be an array of 1 to 4 elements");
|
||||
clutter_margin_free (margin);
|
||||
return NULL;
|
||||
}
|
||||
return margin;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_actor_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
ClutterActor *actor = CLUTTER_ACTOR (scriptable);
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if ((name[0] == 'x' && name[1] == '\0') ||
|
||||
(name[0] == 'y' && name[1] == '\0') ||
|
||||
(strcmp (name, "width") == 0) ||
|
||||
(strcmp (name, "height") == 0))
|
||||
{
|
||||
ParseDimension dimension;
|
||||
gfloat units;
|
||||
|
||||
if (name[0] == 'x')
|
||||
dimension = PARSE_X;
|
||||
else if (name[0] == 'y')
|
||||
dimension = PARSE_Y;
|
||||
else if (name[0] == 'w')
|
||||
dimension = PARSE_WIDTH;
|
||||
else if (name[0] == 'h')
|
||||
dimension = PARSE_HEIGHT;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
units = parse_units (actor, dimension, node);
|
||||
|
||||
/* convert back to pixels: all properties are pixel-based */
|
||||
g_value_init (value, G_TYPE_FLOAT);
|
||||
g_value_set_float (value, units);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (strcmp (name, "rotation") == 0)
|
||||
{
|
||||
RotationInfo *info;
|
||||
|
||||
info = g_new0 (RotationInfo, 1);
|
||||
retval = parse_rotation (actor, node, info);
|
||||
|
||||
if (retval)
|
||||
{
|
||||
g_value_init (value, G_TYPE_POINTER);
|
||||
g_value_set_pointer (value, info);
|
||||
}
|
||||
else
|
||||
g_free (info);
|
||||
}
|
||||
else if (strcmp (name, "actions") == 0 ||
|
||||
strcmp (name, "constraints") == 0 ||
|
||||
strcmp (name, "effects") == 0)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
l = parse_actor_metas (script, actor, node);
|
||||
|
||||
g_value_init (value, G_TYPE_POINTER);
|
||||
g_value_set_pointer (value, l);
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (strcmp (name, "margin") == 0)
|
||||
{
|
||||
ClutterMargin *margin = parse_margin (actor, node);
|
||||
|
||||
if (margin)
|
||||
{
|
||||
g_value_init (value, CLUTTER_TYPE_MARGIN);
|
||||
g_value_set_boxed (value, margin);
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_actor_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value)
|
||||
{
|
||||
ClutterActor *actor = CLUTTER_ACTOR (scriptable);
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (CLUTTER_HAS_DEBUG (SCRIPT)))
|
||||
{
|
||||
gchar *tmp = g_strdup_value_contents (value);
|
||||
|
||||
CLUTTER_NOTE (SCRIPT,
|
||||
"in ClutterActor::set_custom_property('%s') = %s",
|
||||
name,
|
||||
tmp);
|
||||
|
||||
g_free (tmp);
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
if (strcmp (name, "rotation") == 0)
|
||||
{
|
||||
RotationInfo *info;
|
||||
|
||||
if (!G_VALUE_HOLDS (value, G_TYPE_POINTER))
|
||||
return;
|
||||
|
||||
info = g_value_get_pointer (value);
|
||||
|
||||
clutter_actor_set_rotation_angle (actor, info->axis, info->angle);
|
||||
|
||||
g_free (info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp (name, "actions") == 0 ||
|
||||
strcmp (name, "constraints") == 0 ||
|
||||
strcmp (name, "effects") == 0)
|
||||
{
|
||||
GSList *metas, *l;
|
||||
|
||||
if (!G_VALUE_HOLDS (value, G_TYPE_POINTER))
|
||||
return;
|
||||
|
||||
metas = g_value_get_pointer (value);
|
||||
for (l = metas; l != NULL; l = l->next)
|
||||
{
|
||||
if (name[0] == 'a')
|
||||
clutter_actor_add_action (actor, l->data);
|
||||
|
||||
if (name[0] == 'c')
|
||||
clutter_actor_add_constraint (actor, l->data);
|
||||
|
||||
if (name[0] == 'e')
|
||||
clutter_actor_add_effect (actor, l->data);
|
||||
}
|
||||
|
||||
g_slist_free (metas);
|
||||
|
||||
return;
|
||||
}
|
||||
if (strcmp (name, "margin") == 0)
|
||||
{
|
||||
clutter_actor_set_margin (actor, g_value_get_boxed (value));
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set_property (G_OBJECT (scriptable), name, value);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
||||
{
|
||||
iface->parse_custom_node = clutter_actor_parse_custom_node;
|
||||
iface->set_custom_property = clutter_actor_set_custom_property;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_layout_from_animation_property (ClutterActor *actor,
|
||||
const gchar *name,
|
||||
|
|
|
@ -57,8 +57,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathConstraint, g_object_unref)
|
|||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPath, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPropertyTransition, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRotateAction, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScriptable, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScript, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScrollActor, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSettings, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterShaderEffect, g_object_unref)
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
#include "clutter/clutter-interval.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
#include "clutter/clutter-units.h"
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-script-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -87,14 +85,10 @@ struct _ClutterIntervalPrivate
|
|||
GValue *values;
|
||||
};
|
||||
|
||||
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterInterval,
|
||||
clutter_interval,
|
||||
G_TYPE_INITIALLY_UNOWNED,
|
||||
G_ADD_PRIVATE (ClutterInterval)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||
clutter_scriptable_iface_init));
|
||||
G_ADD_PRIVATE (ClutterInterval));
|
||||
|
||||
|
||||
static gboolean
|
||||
|
@ -466,47 +460,6 @@ clutter_interval_get_property (GObject *gobject,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_interval_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
ClutterIntervalPrivate *priv = CLUTTER_INTERVAL (scriptable)->priv;
|
||||
|
||||
if ((strcmp (name, "initial") == 0) || (strcmp (name, "final") == 0))
|
||||
{
|
||||
g_value_init (value, priv->value_type);
|
||||
return _clutter_script_parse_node (script, value, name, node, NULL);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_interval_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value)
|
||||
{
|
||||
ClutterInterval *self = CLUTTER_INTERVAL (scriptable);
|
||||
|
||||
if (strcmp (name, "initial") == 0)
|
||||
clutter_interval_set_initial_value (self, value);
|
||||
else if (strcmp (name, "final") == 0)
|
||||
clutter_interval_set_final_value (self, value);
|
||||
else
|
||||
g_object_set_property (G_OBJECT (scriptable), name, value);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
||||
{
|
||||
iface->parse_custom_node = clutter_interval_parse_custom_node;
|
||||
iface->set_custom_property = clutter_interval_set_custom_property;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_interval_class_init (ClutterIntervalClass *klass)
|
||||
{
|
||||
|
|
|
@ -86,47 +86,6 @@
|
|||
* Where `manager` is the #ClutterLayoutManager, `container` is the
|
||||
* #ClutterActor using the #ClutterLayoutManager, and `actor` is
|
||||
* the #ClutterActor child of the #ClutterActor.
|
||||
*
|
||||
* ## Using ClutterLayoutManager with ClutterScript
|
||||
*
|
||||
* #ClutterLayoutManager instances can be created in the same way
|
||||
* as other objects in #ClutterScript; properties can be set using the
|
||||
* common syntax.
|
||||
*
|
||||
* Layout properties can be set on children of a container with
|
||||
* a #ClutterLayoutManager using the `layout::` modifier on the property
|
||||
* name, for instance:
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "type" : "ClutterActor",
|
||||
* "layout-manager" : { "type" : "ClutterGridLayout" },
|
||||
* "children" : [
|
||||
* {
|
||||
* "type" : "ClutterText",
|
||||
* "text" : "Some text",
|
||||
*
|
||||
* "layout::row" : 0,
|
||||
* "layout::column" : 0,
|
||||
* "layout::x-align" : "left",
|
||||
* "layout::y-align" : "center",
|
||||
* "layout::x-expand" : true,
|
||||
* "layout::y-expand" : true
|
||||
* },
|
||||
* {
|
||||
* "type" : "ClutterText",
|
||||
* "text" : "Some more text",
|
||||
*
|
||||
* "layout::row" : 0,
|
||||
* "layout::column" : 1,
|
||||
* "layout::x-align" : "right",
|
||||
* "layout::y-align" : "center",
|
||||
* "layout::x-expand" : true,
|
||||
* "layout::y-expand" : true
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
|
||||
#include "clutter/clutter-build-config.h"
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
#include <json-glib/json-glib.h>
|
||||
#endif
|
||||
|
||||
#include "clutter/clutter-backend.h"
|
||||
#include "clutter/clutter-paint-context.h"
|
||||
|
@ -72,7 +75,9 @@ struct _ClutterPaintNodeClass
|
|||
void (* post_draw) (ClutterPaintNode *node,
|
||||
ClutterPaintContext *paint_context);
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
JsonNode*(* serialize) (ClutterPaintNode *node);
|
||||
#endif
|
||||
|
||||
CoglFramebuffer *(* get_framebuffer) (ClutterPaintNode *node);
|
||||
};
|
||||
|
|
|
@ -50,9 +50,12 @@
|
|||
#include "clutter/clutter-build-config.h"
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
#include <pango/pango.h>
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
#include <json-glib/json-glib.h>
|
||||
#endif
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
#include "clutter/clutter-paint-node-private.h"
|
||||
#include "clutter/clutter-debug.h"
|
||||
|
|
|
@ -280,6 +280,7 @@ clutter_dummy_node_pre_draw (ClutterPaintNode *node,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_dummy_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -303,6 +304,7 @@ clutter_dummy_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static CoglFramebuffer *
|
||||
clutter_dummy_node_get_framebuffer (ClutterPaintNode *node)
|
||||
|
@ -328,7 +330,9 @@ clutter_dummy_node_class_init (ClutterDummyNodeClass *klass)
|
|||
ClutterPaintNodeClass *node_class = CLUTTER_PAINT_NODE_CLASS (klass);
|
||||
|
||||
node_class->pre_draw = clutter_dummy_node_pre_draw;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_dummy_node_serialize;
|
||||
#endif
|
||||
node_class->get_framebuffer = clutter_dummy_node_get_framebuffer;
|
||||
node_class->finalize = clutter_dummy_node_finalize;
|
||||
}
|
||||
|
@ -488,6 +492,7 @@ clutter_pipeline_node_post_draw (ClutterPaintNode *node,
|
|||
{
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_pipeline_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -527,6 +532,7 @@ clutter_pipeline_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_pipeline_node_class_init (ClutterPipelineNodeClass *klass)
|
||||
|
@ -538,7 +544,9 @@ clutter_pipeline_node_class_init (ClutterPipelineNodeClass *klass)
|
|||
node_class->draw = clutter_pipeline_node_draw;
|
||||
node_class->post_draw = clutter_pipeline_node_post_draw;
|
||||
node_class->finalize = clutter_pipeline_node_finalize;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_pipeline_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -865,6 +873,7 @@ clutter_text_node_draw (ClutterPaintNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_text_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -905,6 +914,7 @@ clutter_text_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_text_node_class_init (ClutterTextNodeClass *klass)
|
||||
|
@ -914,7 +924,9 @@ clutter_text_node_class_init (ClutterTextNodeClass *klass)
|
|||
node_class->pre_draw = clutter_text_node_pre_draw;
|
||||
node_class->draw = clutter_text_node_draw;
|
||||
node_class->finalize = clutter_text_node_finalize;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_text_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1151,6 +1163,7 @@ clutter_actor_node_post_draw (ClutterPaintNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_actor_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -1169,6 +1182,7 @@ clutter_actor_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return json_builder_get_root (builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_actor_node_class_init (ClutterActorNodeClass *klass)
|
||||
|
@ -1179,7 +1193,9 @@ clutter_actor_node_class_init (ClutterActorNodeClass *klass)
|
|||
node_class->pre_draw = clutter_actor_node_pre_draw;
|
||||
node_class->draw = clutter_actor_node_draw;
|
||||
node_class->post_draw = clutter_actor_node_post_draw;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_actor_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1235,6 +1251,7 @@ struct _ClutterEffectNodeClass
|
|||
|
||||
G_DEFINE_TYPE (ClutterEffectNode, clutter_effect_node, CLUTTER_TYPE_PAINT_NODE)
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_effect_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -1264,14 +1281,18 @@ clutter_effect_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return json_builder_get_root (builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_effect_node_class_init (ClutterEffectNodeClass *klass)
|
||||
{
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
|
||||
ClutterPaintNodeClass *node_class;
|
||||
|
||||
node_class = CLUTTER_PAINT_NODE_CLASS (klass);
|
||||
node_class->serialize = clutter_effect_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1434,6 +1455,7 @@ clutter_layer_node_finalize (ClutterPaintNode *node)
|
|||
CLUTTER_PAINT_NODE_CLASS (clutter_layer_node_parent_class)->finalize (node);
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_layer_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -1452,6 +1474,7 @@ clutter_layer_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return json_builder_get_root (builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_layer_node_class_init (ClutterLayerNodeClass *klass)
|
||||
|
@ -1462,7 +1485,9 @@ clutter_layer_node_class_init (ClutterLayerNodeClass *klass)
|
|||
node_class->pre_draw = clutter_layer_node_pre_draw;
|
||||
node_class->post_draw = clutter_layer_node_post_draw;
|
||||
node_class->finalize = clutter_layer_node_finalize;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_layer_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1591,6 +1616,7 @@ clutter_blit_node_finalize (ClutterPaintNode *node)
|
|||
CLUTTER_PAINT_NODE_CLASS (clutter_blit_node_parent_class)->finalize (node);
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_blit_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -1608,6 +1634,7 @@ clutter_blit_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return json_builder_get_root (builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_blit_node_class_init (ClutterBlitNodeClass *klass)
|
||||
|
@ -1618,7 +1645,9 @@ clutter_blit_node_class_init (ClutterBlitNodeClass *klass)
|
|||
node_class->pre_draw = clutter_blit_node_pre_draw;
|
||||
node_class->draw = clutter_blit_node_draw;
|
||||
node_class->finalize = clutter_blit_node_finalize;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_blit_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1725,6 +1754,7 @@ clutter_blur_node_finalize (ClutterPaintNode *node)
|
|||
CLUTTER_PAINT_NODE_CLASS (clutter_blur_node_parent_class)->finalize (node);
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static JsonNode *
|
||||
clutter_blur_node_serialize (ClutterPaintNode *node)
|
||||
{
|
||||
|
@ -1742,6 +1772,7 @@ clutter_blur_node_serialize (ClutterPaintNode *node)
|
|||
|
||||
return json_builder_get_root (builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_blur_node_class_init (ClutterBlurNodeClass *klass)
|
||||
|
@ -1751,7 +1782,9 @@ clutter_blur_node_class_init (ClutterBlurNodeClass *klass)
|
|||
node_class = CLUTTER_PAINT_NODE_CLASS (klass);
|
||||
node_class->post_draw = clutter_blur_node_post_draw;
|
||||
node_class->finalize = clutter_blur_node_finalize;
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
node_class->serialize = clutter_blur_node_serialize;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
#include "clutter/clutter-color.h"
|
||||
#include "clutter/clutter-types.h"
|
||||
#include "clutter/clutter-script.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_SCRIPT_PARSER (_clutter_script_parser_get_type ())
|
||||
#define CLUTTER_SCRIPT_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SCRIPT_PARSER, ClutterScriptParser))
|
||||
#define CLUTTER_IS_SCRIPT_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SCRIPT_PARSER))
|
||||
|
||||
typedef struct _ClutterScriptParser ClutterScriptParser;
|
||||
typedef struct _JsonParserClass ClutterScriptParserClass;
|
||||
|
||||
struct _ClutterScriptParser
|
||||
{
|
||||
JsonParser parent_instance;
|
||||
|
||||
/* back reference */
|
||||
ClutterScript *script;
|
||||
};
|
||||
|
||||
typedef GType (* GTypeGetFunc) (void);
|
||||
|
||||
typedef struct {
|
||||
gchar *id;
|
||||
gchar *class_name;
|
||||
gchar *type_func;
|
||||
|
||||
GList *properties;
|
||||
GList *children;
|
||||
GList *signals;
|
||||
|
||||
GType gtype;
|
||||
GObject *object;
|
||||
|
||||
guint merge_id;
|
||||
|
||||
guint is_actor : 1;
|
||||
guint is_stage : 1;
|
||||
guint is_stage_default : 1;
|
||||
guint has_unresolved : 1;
|
||||
guint is_unmerged : 1;
|
||||
} ObjectInfo;
|
||||
|
||||
void object_info_free (gpointer data);
|
||||
|
||||
typedef struct {
|
||||
gchar *name;
|
||||
JsonNode *node;
|
||||
GParamSpec *pspec;
|
||||
|
||||
guint is_layout : 1;
|
||||
} PropertyInfo;
|
||||
|
||||
typedef struct {
|
||||
gchar *name;
|
||||
gchar *handler;
|
||||
gchar *object;
|
||||
gchar *state;
|
||||
gchar *target;
|
||||
|
||||
GConnectFlags flags;
|
||||
|
||||
guint is_handler : 1;
|
||||
guint warp_to : 1;
|
||||
} SignalInfo;
|
||||
|
||||
void property_info_free (gpointer data);
|
||||
|
||||
GType _clutter_script_parser_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean _clutter_script_parse_node (ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node,
|
||||
GParamSpec *pspec);
|
||||
|
||||
GType _clutter_script_get_type_from_symbol (const gchar *symbol);
|
||||
GType _clutter_script_get_type_from_class (const gchar *name);
|
||||
|
||||
gboolean _clutter_script_enum_from_string (GType gtype,
|
||||
const gchar *string,
|
||||
gint *enum_value);
|
||||
gboolean _clutter_script_flags_from_string (GType gtype,
|
||||
const gchar *string,
|
||||
gint *flags_value);
|
||||
|
||||
gboolean _clutter_script_parse_knot (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
ClutterKnot *knot);
|
||||
gboolean _clutter_script_parse_rect (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
graphene_rect_t *rect);
|
||||
gboolean _clutter_script_parse_color (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
ClutterColor *color);
|
||||
gboolean _clutter_script_parse_point (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
graphene_point_t *point);
|
||||
gboolean _clutter_script_parse_size (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
graphene_size_t *size);
|
||||
|
||||
gboolean _clutter_script_parse_translatable_string (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
char **str);
|
||||
|
||||
void _clutter_script_construct_object (ClutterScript *script,
|
||||
ObjectInfo *oinfo);
|
||||
void _clutter_script_apply_properties (ClutterScript *script,
|
||||
ObjectInfo *oinfo);
|
||||
|
||||
gchar *_clutter_script_generate_fake_id (ClutterScript *script);
|
||||
|
||||
void _clutter_script_warn_missing_attribute (ClutterScript *script,
|
||||
const gchar *id,
|
||||
const gchar *attribute);
|
||||
|
||||
void _clutter_script_warn_invalid_value (ClutterScript *script,
|
||||
const gchar *attribute,
|
||||
const gchar *expected,
|
||||
JsonNode *node);
|
||||
|
||||
ObjectInfo *_clutter_script_get_object_info (ClutterScript *script,
|
||||
const gchar *script_id);
|
||||
|
||||
guint _clutter_script_get_last_merge_id (ClutterScript *script);
|
||||
|
||||
void _clutter_script_add_object_info (ClutterScript *script,
|
||||
ObjectInfo *oinfo);
|
||||
|
||||
const gchar *_clutter_script_get_id_from_node (JsonNode *node);
|
||||
|
||||
G_END_DECLS
|
File diff suppressed because it is too large
Load diff
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "clutter/clutter-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_SCRIPT (clutter_script_get_type ())
|
||||
#define CLUTTER_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SCRIPT, ClutterScript))
|
||||
#define CLUTTER_IS_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SCRIPT))
|
||||
#define CLUTTER_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_SCRIPT, ClutterScriptClass))
|
||||
#define CLUTTER_IS_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_SCRIPT))
|
||||
#define CLUTTER_SCRIPT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_SCRIPT, ClutterScriptClass))
|
||||
|
||||
typedef struct _ClutterScript ClutterScript;
|
||||
typedef struct _ClutterScriptPrivate ClutterScriptPrivate;
|
||||
typedef struct _ClutterScriptClass ClutterScriptClass;
|
||||
|
||||
/**
|
||||
* ClutterScriptConnectFunc:
|
||||
* @script: a #ClutterScript
|
||||
* @object: the object to connect
|
||||
* @signal_name: the name of the signal
|
||||
* @handler_name: the name of the signal handler
|
||||
* @connect_object: the object to connect the signal to, or %NULL
|
||||
* @flags: signal connection flags
|
||||
* @user_data: user data to pass to the signal handler
|
||||
*
|
||||
* This is the signature of a function used to connect signals. It is used
|
||||
* by the clutter_script_connect_signals_full() function. It is mainly
|
||||
* intended for interpreted language bindings, but could be useful where the
|
||||
* programmer wants more control over the signal connection process.
|
||||
*/
|
||||
typedef void (* ClutterScriptConnectFunc) (ClutterScript *script,
|
||||
GObject *object,
|
||||
const gchar *signal_name,
|
||||
const gchar *handler_name,
|
||||
GObject *connect_object,
|
||||
GConnectFlags flags,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* ClutterScriptError:
|
||||
* @CLUTTER_SCRIPT_ERROR_INVALID_TYPE_FUNCTION: Type function not found
|
||||
* or invalid
|
||||
* @CLUTTER_SCRIPT_ERROR_INVALID_PROPERTY: Property not found or invalid
|
||||
* @CLUTTER_SCRIPT_ERROR_INVALID_VALUE: Invalid value
|
||||
*
|
||||
* #ClutterScript error enumeration.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CLUTTER_SCRIPT_ERROR_INVALID_TYPE_FUNCTION,
|
||||
CLUTTER_SCRIPT_ERROR_INVALID_PROPERTY,
|
||||
CLUTTER_SCRIPT_ERROR_INVALID_VALUE
|
||||
} ClutterScriptError;
|
||||
|
||||
/**
|
||||
* CLUTTER_SCRIPT_ERROR:
|
||||
*
|
||||
* Error domain for the #ClutterScript errors
|
||||
*/
|
||||
#define CLUTTER_SCRIPT_ERROR (clutter_script_error_quark ())
|
||||
CLUTTER_EXPORT
|
||||
GQuark clutter_script_error_quark (void);
|
||||
|
||||
struct _ClutterScript
|
||||
{
|
||||
/*< private >*/
|
||||
GObject parent_instance;
|
||||
|
||||
ClutterScriptPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* ClutterScriptClass:
|
||||
* @get_type_from_name: virtual function used to map a type name
|
||||
* to a #GType. This function should only be overridden by
|
||||
* language bindings in order to map native types to #GType.
|
||||
* The default implementation is equivalent to g_type_from_name()
|
||||
*
|
||||
* The #ClutterScriptClass structure contains only private data
|
||||
*/
|
||||
struct _ClutterScriptClass
|
||||
{
|
||||
/*< private >*/
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
GType (* get_type_from_name) (ClutterScript *script,
|
||||
const gchar *type_name);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_script_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterScript * clutter_script_new (void);
|
||||
CLUTTER_EXPORT
|
||||
guint clutter_script_load_from_file (ClutterScript *script,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
CLUTTER_EXPORT
|
||||
guint clutter_script_load_from_data (ClutterScript *script,
|
||||
const gchar *data,
|
||||
gssize length,
|
||||
GError **error);
|
||||
CLUTTER_EXPORT
|
||||
guint clutter_script_load_from_resource (ClutterScript *script,
|
||||
const gchar *resource_path,
|
||||
GError **error);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GObject * clutter_script_get_object (ClutterScript *script,
|
||||
const gchar *name);
|
||||
CLUTTER_EXPORT
|
||||
gint clutter_script_get_objects (ClutterScript *script,
|
||||
const gchar *first_name,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
CLUTTER_EXPORT
|
||||
GList * clutter_script_list_objects (ClutterScript *script);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_unmerge_objects (ClutterScript *script,
|
||||
guint merge_id);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_ensure_objects (ClutterScript *script);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_connect_signals (ClutterScript *script,
|
||||
gpointer user_data);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_connect_signals_full (ClutterScript *script,
|
||||
ClutterScriptConnectFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_add_search_paths (ClutterScript *script,
|
||||
const gchar * const paths[],
|
||||
gsize n_paths);
|
||||
CLUTTER_EXPORT
|
||||
gchar * clutter_script_lookup_filename (ClutterScript *script,
|
||||
const gchar *filename) G_GNUC_MALLOC;
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_script_get_type_from_name (ClutterScript *script,
|
||||
const gchar *type_name);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_script_set_translation_domain (ClutterScript *script,
|
||||
const gchar *domain);
|
||||
CLUTTER_EXPORT
|
||||
const gchar * clutter_script_get_translation_domain (ClutterScript *script);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
const gchar * clutter_get_script_id (GObject *gobject);
|
||||
|
||||
G_END_DECLS
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
* Emmanuele Bassi <ebassi@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* ClutterScriptable:
|
||||
*
|
||||
* Override the UI definition parsing
|
||||
*
|
||||
* The #ClutterScriptable interface exposes the UI definition parsing
|
||||
* process to external classes. By implementing this interface, a class can
|
||||
* override the UI definition parsing and transform complex data types into
|
||||
* [class@GObject.Object] properties, or allow custom properties.
|
||||
*/
|
||||
|
||||
#include "clutter/clutter-build-config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-script-private.h"
|
||||
|
||||
#include "clutter/clutter-private.h"
|
||||
#include "clutter/clutter-debug.h"
|
||||
|
||||
typedef ClutterScriptableIface ClutterScriptableInterface;
|
||||
|
||||
G_DEFINE_INTERFACE (ClutterScriptable, clutter_scriptable, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
clutter_scriptable_default_init (ClutterScriptableInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_scriptable_set_id:
|
||||
* @scriptable: a #ClutterScriptable
|
||||
* @id_: the #ClutterScript id of the object
|
||||
*
|
||||
* Sets @id_ as the unique Clutter script it for this instance of
|
||||
* #ClutterScriptableIface.
|
||||
*
|
||||
* This name can be used by user interface designer applications to
|
||||
* define a unique name for an object constructable using the UI
|
||||
* definition language parsed by [class@Script].
|
||||
*/
|
||||
void
|
||||
clutter_scriptable_set_id (ClutterScriptable *scriptable,
|
||||
const gchar *id_)
|
||||
{
|
||||
ClutterScriptableIface *iface;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable));
|
||||
g_return_if_fail (id_ != NULL);
|
||||
|
||||
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
|
||||
if (iface->set_id)
|
||||
iface->set_id (scriptable, id_);
|
||||
else
|
||||
g_object_set_data_full (G_OBJECT (scriptable),
|
||||
"clutter-script-id",
|
||||
g_strdup (id_),
|
||||
g_free);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_scriptable_get_id:
|
||||
* @scriptable: a #ClutterScriptable
|
||||
*
|
||||
* Retrieves the id of @scriptable set using [method@Clutter.Scriptable.set_id].
|
||||
*
|
||||
* Return value: the id of the object. The returned string is owned by
|
||||
* the scriptable object and should never be modified of freed
|
||||
*/
|
||||
const gchar *
|
||||
clutter_scriptable_get_id (ClutterScriptable *scriptable)
|
||||
{
|
||||
ClutterScriptableIface *iface;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable), NULL);
|
||||
|
||||
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
|
||||
if (iface->get_id)
|
||||
return iface->get_id (scriptable);
|
||||
else
|
||||
return g_object_get_data (G_OBJECT (scriptable), "clutter-script-id");
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_scriptable_parse_custom_node:
|
||||
* @scriptable: a #ClutterScriptable
|
||||
* @script: the #ClutterScript creating the scriptable instance
|
||||
* @value: the generic value to be set
|
||||
* @name: the name of the node
|
||||
* @node: the JSON node to be parsed
|
||||
*
|
||||
* Parses the passed JSON node. The implementation must set the type
|
||||
* of the passed [struct@GObject.Value] pointer using g_value_init().
|
||||
*
|
||||
* Return value: %TRUE if the node was successfully parsed, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
clutter_scriptable_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
ClutterScriptableIface *iface;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable), FALSE);
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (node != NULL, FALSE);
|
||||
|
||||
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
|
||||
if (iface->parse_custom_node)
|
||||
return iface->parse_custom_node (scriptable, script, value, name, node);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_scriptable_set_custom_property:
|
||||
* @scriptable: a #ClutterScriptable
|
||||
* @script: the #ClutterScript creating the scriptable instance
|
||||
* @name: the name of the property
|
||||
* @value: the value of the property
|
||||
*
|
||||
* Overrides the common properties setting. The underlying virtual
|
||||
* function should be used when implementing custom properties.
|
||||
*/
|
||||
void
|
||||
clutter_scriptable_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value)
|
||||
{
|
||||
ClutterScriptableIface *iface;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable));
|
||||
g_return_if_fail (CLUTTER_IS_SCRIPT (script));
|
||||
g_return_if_fail (name != NULL);
|
||||
g_return_if_fail (value != NULL);
|
||||
|
||||
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
|
||||
if (iface->set_custom_property)
|
||||
iface->set_custom_property (scriptable, script, name, value);
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
* Emmanuele Bassi <ebassi@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
#include "clutter/clutter-script.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_SCRIPTABLE (clutter_scriptable_get_type ())
|
||||
#define CLUTTER_SCRIPTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SCRIPTABLE, ClutterScriptable))
|
||||
#define CLUTTER_IS_SCRIPTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SCRIPTABLE))
|
||||
#define CLUTTER_SCRIPTABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_SCRIPTABLE, ClutterScriptableIface))
|
||||
|
||||
typedef struct _ClutterScriptable ClutterScriptable;
|
||||
typedef struct _ClutterScriptableIface ClutterScriptableIface;
|
||||
|
||||
/**
|
||||
* ClutterScriptableIface:
|
||||
* @set_id: virtual function for setting the id of a scriptable object
|
||||
* @get_id: virtual function for getting the id of a scriptable object
|
||||
* @parse_custom_node: virtual function for parsing complex data containers
|
||||
* into GObject properties
|
||||
* @set_custom_property: virtual function for setting a custom property
|
||||
*
|
||||
* Interface for implementing "scriptable" objects. An object implementing
|
||||
* this interface can override the parsing and properties setting sequence
|
||||
* when loading a UI definition data with #ClutterScript
|
||||
*/
|
||||
struct _ClutterScriptableIface
|
||||
{
|
||||
/*< private >*/
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/*< public >*/
|
||||
void (* set_id) (ClutterScriptable *scriptable,
|
||||
const gchar *id_);
|
||||
const gchar *(* get_id) (ClutterScriptable *scriptable);
|
||||
|
||||
gboolean (* parse_custom_node) (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node);
|
||||
void (* set_custom_property) (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_scriptable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_scriptable_set_id (ClutterScriptable *scriptable,
|
||||
const gchar *id_);
|
||||
CLUTTER_EXPORT
|
||||
const gchar * clutter_scriptable_get_id (ClutterScriptable *scriptable);
|
||||
CLUTTER_EXPORT
|
||||
gboolean clutter_scriptable_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_scriptable_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value);
|
||||
|
||||
G_END_DECLS
|
|
@ -59,7 +59,6 @@
|
|||
#include "clutter/clutter-text-buffer.h"
|
||||
#include "clutter/clutter-units.h"
|
||||
#include "clutter/clutter-paint-volume-private.h"
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-input-focus.h"
|
||||
|
||||
/* cursor width in pixels */
|
||||
|
@ -282,7 +281,6 @@ static const ClutterColor default_text_color = { 0, 0, 0, 255 };
|
|||
static const ClutterColor default_selected_text_color = { 0, 0, 0, 255 };
|
||||
|
||||
static ClutterAnimatableInterface *parent_animatable_iface = NULL;
|
||||
static ClutterScriptableIface *parent_scriptable_iface = NULL;
|
||||
|
||||
/* ClutterTextInputFocus */
|
||||
#define CLUTTER_TYPE_TEXT_INPUT_FOCUS (clutter_text_input_focus_get_type ())
|
||||
|
@ -437,15 +435,12 @@ clutter_text_input_focus_new (ClutterText *text)
|
|||
}
|
||||
|
||||
/* ClutterText */
|
||||
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||
static void clutter_animatable_iface_init (ClutterAnimatableInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterText,
|
||||
clutter_text,
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
G_ADD_PRIVATE (ClutterText)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||
clutter_scriptable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_ANIMATABLE,
|
||||
clutter_animatable_iface_init));
|
||||
|
||||
|
@ -3566,27 +3561,6 @@ clutter_text_add_move_binding (ClutterBindingPool *pool,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_text_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
if (strncmp (name, "font-description", 16) == 0)
|
||||
{
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, json_node_get_string (node));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return parent_scriptable_iface->parse_custom_node (scriptable, script,
|
||||
value,
|
||||
name,
|
||||
node);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_set_color_internal (ClutterText *self,
|
||||
GParamSpec *pspec,
|
||||
|
@ -3737,34 +3711,6 @@ clutter_text_set_color_animated (ClutterText *self,
|
|||
clutter_timeline_start (CLUTTER_TIMELINE (transition));
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value)
|
||||
{
|
||||
if (strncmp (name, "font-description", 16) == 0)
|
||||
{
|
||||
g_assert (G_VALUE_HOLDS (value, G_TYPE_STRING));
|
||||
if (g_value_get_string (value) != NULL)
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (scriptable),
|
||||
g_value_get_string (value));
|
||||
}
|
||||
else
|
||||
parent_scriptable_iface->set_custom_property (scriptable, script,
|
||||
name,
|
||||
value);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
||||
{
|
||||
parent_scriptable_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->parse_custom_node = clutter_text_parse_custom_node;
|
||||
iface->set_custom_property = clutter_text_set_custom_property;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_set_final_state (ClutterAnimatable *animatable,
|
||||
const char *property_name,
|
||||
|
|
|
@ -72,25 +72,6 @@
|
|||
*
|
||||
* Timelines are used in the Clutter animation framework by classes like
|
||||
* [class@Transition].
|
||||
*
|
||||
* ## Defining Timelines in ClutterScript
|
||||
*
|
||||
* A #ClutterTimeline can be described in [class@Script] like any
|
||||
* other object. Additionally, it is possible to define markers directly
|
||||
* inside the JSON definition by using the `markers` JSON object member,
|
||||
* such as:
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "type" : "ClutterTimeline",
|
||||
* "duration" : 1000,
|
||||
* "markers" : [
|
||||
* { "name" : "quarter", "time" : 250 },
|
||||
* { "name" : "half-time", "time" : 500 },
|
||||
* { "name" : "three-quarters", "time" : 750 }
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
|
||||
#include "clutter/clutter-build-config.h"
|
||||
|
@ -106,7 +87,6 @@
|
|||
#include "clutter/clutter-marshal.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-timeline-private.h"
|
||||
|
||||
struct _ClutterTimelinePrivate
|
||||
|
@ -215,12 +195,9 @@ static guint timeline_signals[LAST_SIGNAL] = { 0, };
|
|||
|
||||
static void update_frame_clock (ClutterTimeline *timeline);
|
||||
|
||||
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterTimeline, clutter_timeline, G_TYPE_OBJECT,
|
||||
G_ADD_PRIVATE (ClutterTimeline)
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||
clutter_scriptable_iface_init))
|
||||
G_ADD_PRIVATE (ClutterTimeline))
|
||||
|
||||
static TimelineMarker *
|
||||
timeline_marker_new_time (const gchar *name,
|
||||
|
@ -497,135 +474,12 @@ clutter_timeline_set_actor (ClutterTimeline *timeline,
|
|||
update_frame_clock (timeline);
|
||||
}
|
||||
|
||||
/* Scriptable */
|
||||
typedef struct _ParseClosure {
|
||||
ClutterTimeline *timeline;
|
||||
ClutterScript *script;
|
||||
GValue *value;
|
||||
gboolean result;
|
||||
} ParseClosure;
|
||||
|
||||
static void
|
||||
parse_timeline_markers (JsonArray *array,
|
||||
guint index_,
|
||||
JsonNode *element,
|
||||
gpointer data)
|
||||
{
|
||||
ParseClosure *clos = data;
|
||||
JsonObject *object;
|
||||
TimelineMarker *marker;
|
||||
GList *markers;
|
||||
|
||||
if (JSON_NODE_TYPE (element) != JSON_NODE_OBJECT)
|
||||
{
|
||||
g_warning ("The 'markers' member of a ClutterTimeline description "
|
||||
"should be an array of objects, but the element %d of the "
|
||||
"array is of type '%s'. The element will be ignored.",
|
||||
index_,
|
||||
json_node_type_name (element));
|
||||
return;
|
||||
}
|
||||
|
||||
object = json_node_get_object (element);
|
||||
|
||||
if (!(json_object_has_member (object, "name") &&
|
||||
(json_object_has_member (object, "time") ||
|
||||
json_object_has_member (object, "progress"))))
|
||||
{
|
||||
g_warning ("The marker definition in a ClutterTimeline description "
|
||||
"must be an object with the 'name' and either the 'time' "
|
||||
"or the 'progress' members, but the element %d of the "
|
||||
"'markers' array does not have any of them.",
|
||||
index_);
|
||||
return;
|
||||
}
|
||||
|
||||
if (G_IS_VALUE (clos->value))
|
||||
markers = g_value_get_pointer (clos->value);
|
||||
else
|
||||
{
|
||||
g_value_init (clos->value, G_TYPE_POINTER);
|
||||
markers = NULL;
|
||||
}
|
||||
|
||||
if (json_object_has_member (object, "time"))
|
||||
marker = timeline_marker_new_time (json_object_get_string_member (object, "name"),
|
||||
json_object_get_int_member (object, "time"));
|
||||
else
|
||||
marker = timeline_marker_new_progress (json_object_get_string_member (object, "name"),
|
||||
json_object_get_double_member (object, "progress"));
|
||||
|
||||
markers = g_list_prepend (markers, marker);
|
||||
|
||||
g_value_set_pointer (clos->value, markers);
|
||||
|
||||
clos->result = TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_timeline_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
ParseClosure clos;
|
||||
|
||||
if (strcmp (name, "markers") != 0)
|
||||
return FALSE;
|
||||
|
||||
if (JSON_NODE_TYPE (node) != JSON_NODE_ARRAY)
|
||||
return FALSE;
|
||||
|
||||
clos.timeline = CLUTTER_TIMELINE (scriptable);
|
||||
clos.script = script;
|
||||
clos.value = value;
|
||||
clos.result = FALSE;
|
||||
|
||||
json_array_foreach_element (json_node_get_array (node),
|
||||
parse_timeline_markers,
|
||||
&clos);
|
||||
|
||||
return clos.result;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_timeline_set_custom_property (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
const gchar *name,
|
||||
const GValue *value)
|
||||
{
|
||||
if (strcmp (name, "markers") == 0)
|
||||
{
|
||||
ClutterTimeline *timeline = CLUTTER_TIMELINE (scriptable);
|
||||
GList *markers = g_value_get_pointer (value);
|
||||
GList *m;
|
||||
|
||||
/* the list was created through prepend() */
|
||||
markers = g_list_reverse (markers);
|
||||
|
||||
for (m = markers; m != NULL; m = m->next)
|
||||
clutter_timeline_add_marker_internal (timeline, m->data);
|
||||
|
||||
g_list_free (markers);
|
||||
}
|
||||
else
|
||||
g_object_set_property (G_OBJECT (scriptable), name, value);
|
||||
}
|
||||
|
||||
void
|
||||
clutter_timeline_cancel_delay (ClutterTimeline *timeline)
|
||||
{
|
||||
g_clear_handle_id (&timeline->priv->delay_id, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
||||
{
|
||||
iface->parse_custom_node = clutter_timeline_parse_custom_node;
|
||||
iface->set_custom_property = clutter_timeline_set_custom_property;
|
||||
}
|
||||
|
||||
/* Object */
|
||||
|
||||
static void
|
||||
|
|
|
@ -86,8 +86,6 @@
|
|||
#include "clutter/clutter-path.h"
|
||||
#include "clutter/clutter-property-transition.h"
|
||||
#include "clutter/clutter-rotate-action.h"
|
||||
#include "clutter/clutter-scriptable.h"
|
||||
#include "clutter/clutter-script.h"
|
||||
#include "clutter/clutter-scroll-actor.h"
|
||||
#include "clutter/clutter-settings.h"
|
||||
#include "clutter/clutter-shader-effect.h"
|
||||
|
|
|
@ -64,8 +64,6 @@ clutter_headers = [
|
|||
'clutter-pick-context.h',
|
||||
'clutter-property-transition.h',
|
||||
'clutter-rotate-action.h',
|
||||
'clutter-script.h',
|
||||
'clutter-scriptable.h',
|
||||
'clutter-scroll-actor.h',
|
||||
'clutter-seat.h',
|
||||
'clutter-settings.h',
|
||||
|
@ -155,9 +153,6 @@ clutter_sources = [
|
|||
'clutter-pick-stack.c',
|
||||
'clutter-property-transition.c',
|
||||
'clutter-rotate-action.c',
|
||||
'clutter-script.c',
|
||||
'clutter-script-parser.c',
|
||||
'clutter-scriptable.c',
|
||||
'clutter-scroll-actor.c',
|
||||
'clutter-seat.c',
|
||||
'clutter-settings.c',
|
||||
|
@ -209,7 +204,6 @@ clutter_private_headers = [
|
|||
'clutter-paint-node-private.h',
|
||||
'clutter-paint-volume-private.h',
|
||||
'clutter-private.h',
|
||||
'clutter-script-private.h',
|
||||
'clutter-settings-private.h',
|
||||
'clutter-stage-manager-private.h',
|
||||
'clutter-stage-private.h',
|
||||
|
@ -348,7 +342,6 @@ if have_introspection
|
|||
'GObject-2.0',
|
||||
'cairo-1.0',
|
||||
'Atk-1.0',
|
||||
'Json-1.0',
|
||||
],
|
||||
dependencies: [cogl_deps],
|
||||
extra_args: clutter_introspection_args + ['--c-include=clutter/clutter.h'],
|
||||
|
|
|
@ -33,7 +33,6 @@ clutter_pkg_deps = [
|
|||
glib_dep,
|
||||
gobject_dep,
|
||||
gio_dep,
|
||||
json_glib_dep,
|
||||
pango_dep,
|
||||
harfbuzz_dep,
|
||||
]
|
||||
|
@ -45,6 +44,12 @@ clutter_pkg_private_deps = [
|
|||
pangocairo_dep,
|
||||
]
|
||||
|
||||
if get_option('debug')
|
||||
clutter_pkg_private_deps += [
|
||||
json_glib_dep,
|
||||
]
|
||||
endif
|
||||
|
||||
if have_pango_ft2
|
||||
clutter_pkg_private_deps += [
|
||||
pangoft2_dep,
|
||||
|
|
|
@ -123,7 +123,7 @@ gobject_dep = dependency('gobject-2.0', version: glib_req)
|
|||
gthread_dep = dependency('gobject-2.0', version: glib_req)
|
||||
gmodule_no_export_dep = dependency('gmodule-no-export-2.0', version: glib_req)
|
||||
gnome_settings_daemon_dep = dependency('gnome-settings-daemon', required: false)
|
||||
json_glib_dep = dependency('json-glib-1.0', version: json_glib_req)
|
||||
json_glib_dep = dependency('json-glib-1.0', version: json_glib_req, required: get_option('debug'))
|
||||
xkbcommon_dep = dependency('xkbcommon', version: xkbcommon_req)
|
||||
ice_dep = dependency('ice')
|
||||
atk_dep = dependency('atk', version: atk_req)
|
||||
|
|
|
@ -10,7 +10,6 @@ default_plugin = shared_module('default',
|
|||
c_args: default_plugin_c_args,
|
||||
dependencies: [
|
||||
glib_dep,
|
||||
json_glib_dep,
|
||||
gsettings_desktop_schemas_dep,
|
||||
libmutter_clutter_dep,
|
||||
],
|
||||
|
|
|
@ -25,7 +25,6 @@ mutter_pkg_private_deps = [
|
|||
lcms2_dep,
|
||||
gmodule_no_export_dep,
|
||||
gnome_settings_daemon_dep,
|
||||
json_glib_dep,
|
||||
xkbcommon_dep,
|
||||
gdk_pixbuf_dep,
|
||||
libeis_dep,
|
||||
|
|
|
@ -67,53 +67,7 @@ interval_transform (void)
|
|||
g_object_unref (interval);
|
||||
}
|
||||
|
||||
static void
|
||||
interval_from_script (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterInterval *interval;
|
||||
gchar *test_file;
|
||||
GError *error = NULL;
|
||||
GValue *initial, *final;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST,
|
||||
"scripts",
|
||||
"test-script-interval.json",
|
||||
NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_printerr ("\tError: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-1"));
|
||||
initial = clutter_interval_peek_initial_value (interval);
|
||||
if (!g_test_quiet ())
|
||||
g_test_message ("\tinitial ['%s'] = '%.2f'",
|
||||
g_type_name (G_VALUE_TYPE (initial)),
|
||||
g_value_get_float (initial));
|
||||
g_assert (G_VALUE_HOLDS (initial, G_TYPE_FLOAT));
|
||||
g_assert_cmpfloat (g_value_get_float (initial), ==, 23.3f);
|
||||
final = clutter_interval_peek_final_value (interval);
|
||||
if (!g_test_quiet ())
|
||||
g_test_message ("\tfinal ['%s'] = '%.2f'",
|
||||
g_type_name (G_VALUE_TYPE (final)),
|
||||
g_value_get_float (final));
|
||||
g_assert (G_VALUE_HOLDS (final, G_TYPE_FLOAT));
|
||||
g_assert_cmpfloat (g_value_get_float (final), ==, 42.2f);
|
||||
|
||||
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-2"));
|
||||
initial = clutter_interval_peek_initial_value (interval);
|
||||
g_assert (G_VALUE_HOLDS (initial, CLUTTER_TYPE_COLOR));
|
||||
final = clutter_interval_peek_final_value (interval);
|
||||
g_assert (G_VALUE_HOLDS (final, CLUTTER_TYPE_COLOR));
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
CLUTTER_TEST_SUITE (
|
||||
CLUTTER_TEST_UNIT ("/interval/initial-state", interval_initial_state)
|
||||
CLUTTER_TEST_UNIT ("/interval/transform", interval_transform)
|
||||
CLUTTER_TEST_UNIT ("/interval/from-script", interval_from_script)
|
||||
)
|
||||
|
|
|
@ -39,7 +39,6 @@ clutter_conform_tests_general_tests = [
|
|||
'frame-clock-timeline',
|
||||
'grab',
|
||||
'interval',
|
||||
'script-parser',
|
||||
'timeline',
|
||||
'timeline-interpolate',
|
||||
'timeline-progress',
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "tests/clutter-test-utils.h"
|
||||
|
||||
#define TEST_TYPE_GROUP (test_group_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (TestGroup, test_group, TEST, GROUP, ClutterActor)
|
||||
|
||||
struct _TestGroup
|
||||
{
|
||||
ClutterActor parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (TestGroup, test_group, CLUTTER_TYPE_ACTOR)
|
||||
|
||||
static void
|
||||
test_group_class_init (TestGroupClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_group_init (TestGroup *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
script_child (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
GObject *container, *actor;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-child.json", NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
container = actor = NULL;
|
||||
clutter_script_get_objects (script,
|
||||
"test-group", &container,
|
||||
"test-rect-1", &actor,
|
||||
NULL);
|
||||
g_assert (TEST_IS_GROUP (container));
|
||||
g_assert (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
actor = clutter_script_get_object (script, "test-rect-2");
|
||||
g_assert (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
static void
|
||||
script_single (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterColor color = { 0, };
|
||||
GObject *actor = NULL;
|
||||
GError *error = NULL;
|
||||
ClutterActor *rect;
|
||||
gchar *test_file;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-single.json", NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
actor = clutter_script_get_object (script, "test");
|
||||
g_assert (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
rect = CLUTTER_ACTOR (actor);
|
||||
g_assert_cmpfloat (clutter_actor_get_width (rect), ==, 50.0);
|
||||
g_assert_cmpfloat (clutter_actor_get_y (rect), ==, 100.0);
|
||||
|
||||
clutter_actor_get_background_color (rect, &color);
|
||||
g_assert_cmpint (color.red, ==, 255);
|
||||
g_assert_cmpint (color.green, ==, 0xcc);
|
||||
g_assert_cmpint (color.alpha, ==, 0xff);
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
static void
|
||||
script_object_property (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterLayoutManager *manager;
|
||||
GObject *actor = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-object-property.json", NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
actor = clutter_script_get_object (script, "test");
|
||||
g_assert (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
manager = clutter_actor_get_layout_manager (CLUTTER_ACTOR (actor));
|
||||
g_assert (CLUTTER_IS_BIN_LAYOUT (manager));
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
static void
|
||||
script_named_object (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterLayoutManager *manager;
|
||||
GObject *actor = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-named-object.json", NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
actor = clutter_script_get_object (script, "test");
|
||||
g_assert (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
manager = clutter_actor_get_layout_manager (CLUTTER_ACTOR (actor));
|
||||
g_assert (CLUTTER_IS_BOX_LAYOUT (manager));
|
||||
g_assert (clutter_box_layout_get_orientation (CLUTTER_BOX_LAYOUT (manager)) == CLUTTER_ORIENTATION_VERTICAL);
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
static void
|
||||
script_margin (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterActor *actor;
|
||||
gchar *test_file;
|
||||
GError *error = NULL;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-margin.json", NULL);
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (!g_test_quiet () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-1"));
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 10.0f);
|
||||
|
||||
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-2"));
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 20.0f);
|
||||
|
||||
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-3"));
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 30.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 20.0f);
|
||||
|
||||
actor = CLUTTER_ACTOR (clutter_script_get_object (script, "actor-4"));
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_top (actor), ==, 10.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_right (actor), ==, 20.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_bottom (actor), ==, 30.0f);
|
||||
g_assert_cmpfloat (clutter_actor_get_margin_left (actor), ==, 40.0f);
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
CLUTTER_TEST_SUITE (
|
||||
CLUTTER_TEST_UNIT ("/script/single-object", script_single)
|
||||
CLUTTER_TEST_UNIT ("/script/container-child", script_child)
|
||||
CLUTTER_TEST_UNIT ("/script/named-object", script_named_object)
|
||||
CLUTTER_TEST_UNIT ("/script/object-property", script_object_property)
|
||||
CLUTTER_TEST_UNIT ("/script/actor-margin", script_margin)
|
||||
)
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"type" : "TestGroup",
|
||||
"id" : "test-group",
|
||||
"children" : [
|
||||
{
|
||||
"type" : "ClutterActor",
|
||||
"id" : "test-rect-1",
|
||||
"width" : 100.0,
|
||||
"height" : 100.0,
|
||||
"background-color" : [ 255, 0, 0, 255 ]
|
||||
},
|
||||
{
|
||||
"type" : "ClutterActor",
|
||||
"id" : "test-rect-2",
|
||||
"width" : 100.0,
|
||||
"height" : 100.0,
|
||||
"background-color" : [ 0, 255, 0, 255 ]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id" : "int-1",
|
||||
"type" : "ClutterInterval",
|
||||
"value-type" : "gfloat",
|
||||
"initial" : 23.3,
|
||||
"final" : 42.2
|
||||
},
|
||||
{
|
||||
"id" : "int-2",
|
||||
"type" : "ClutterInterval",
|
||||
"value-type" : "ClutterColor",
|
||||
"initial" : "red",
|
||||
"final" : "blue"
|
||||
}
|
||||
]
|
|
@ -1,22 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id" : "actor-1",
|
||||
"type" : "ClutterActor",
|
||||
"margin" : [ 10 ]
|
||||
},
|
||||
{
|
||||
"id" : "actor-2",
|
||||
"type" : "ClutterActor",
|
||||
"margin" : [ 10, 20 ]
|
||||
},
|
||||
{
|
||||
"id" : "actor-3",
|
||||
"type" : "ClutterActor",
|
||||
"margin" : [ 10, 20, 30 ]
|
||||
},
|
||||
{
|
||||
"id" : "actor-4",
|
||||
"type" : "ClutterActor",
|
||||
"margin" : [ 10, 20, 30, 40]
|
||||
}
|
||||
]
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"id" : "test-model",
|
||||
"type" : "ClutterListModel",
|
||||
"columns" : [
|
||||
[ "text-column", "gchararray" ],
|
||||
[ "int-column", "gint" ],
|
||||
[ "actor-column", "ClutterActor" ]
|
||||
],
|
||||
"rows" : [
|
||||
[ "text-row-1", 1, null ],
|
||||
[ "text-row-2", 2, { "type" : "ClutterActor", "background-color" : "blue" } ],
|
||||
{
|
||||
"int-column" : 3,
|
||||
"actor-column" : { "type" : "ClutterActor", "name" : "actor-row-3" }
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id" : "layout",
|
||||
"type" : "ClutterBoxLayout",
|
||||
"orientation" : "vertical",
|
||||
"spacing" : 12
|
||||
},
|
||||
{
|
||||
"type" : "ClutterStage",
|
||||
"id" : "main-stage",
|
||||
"children" : [
|
||||
{
|
||||
"id" : "test",
|
||||
"type" : "ClutterActor",
|
||||
"layout-manager" : "layout",
|
||||
"children" : [
|
||||
{
|
||||
"id" : "child-1",
|
||||
"type" : "ClutterActor",
|
||||
"width" : "3 em",
|
||||
"height" : "3 em"
|
||||
}
|
||||
],
|
||||
"constraints" : [
|
||||
{
|
||||
"type" : "ClutterAlignConstraint",
|
||||
"name" : "x-align",
|
||||
"factor" : 0.5,
|
||||
"align-axis" : "x-axis",
|
||||
"source" : "main-stage"
|
||||
},
|
||||
{
|
||||
"type" : "ClutterAlignConstraint",
|
||||
"name" : "y-align",
|
||||
"factor" : 0.5,
|
||||
"align-axis" : "y-axis",
|
||||
"source" : "main-stage"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"id" : "test",
|
||||
"type" : "ClutterActor",
|
||||
"layout-manager" : { "id" : "layout", "type" : "ClutterBinLayout" },
|
||||
"children" : [
|
||||
{
|
||||
"id" : "child-1",
|
||||
"type" : "ClutterActor",
|
||||
"width" : "3 em",
|
||||
"height" : "3 em"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"type" : "ClutterActor",
|
||||
"id" : "test",
|
||||
"width" : 50.0,
|
||||
"height" : 100.0,
|
||||
"x" : 100.0,
|
||||
"y" : 100.0,
|
||||
"background-color" : "#ffccdd",
|
||||
"name" : "Test Rectangle"
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
[
|
||||
{ "id" : "actor0", "type" : "ClutterActor" },
|
||||
{
|
||||
"id" : "timeline0",
|
||||
"type" : "ClutterTimeline",
|
||||
"duration" : 1000,
|
||||
"actor" : "actor0",
|
||||
|
||||
"markers" : [
|
||||
{ "name" : "marker0", "time" : 250 },
|
||||
{ "name" : "marker1", "time" : 500 },
|
||||
{ "name" : "marker2", "time" : 750 },
|
||||
{ "name" : "marker3", "progress" : 0.5 }
|
||||
]
|
||||
}
|
||||
]
|
|
@ -316,50 +316,6 @@ timeline_base (void)
|
|||
g_clear_handle_id (&delay_tag, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
timeline_markers_from_script (void)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
ClutterTimeline *timeline;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
gchar **markers;
|
||||
gsize n_markers;
|
||||
|
||||
test_file = g_test_build_filename (G_TEST_DIST,
|
||||
"scripts",
|
||||
"test-script-timeline-markers.json",
|
||||
NULL);
|
||||
if (!clutter_script_load_from_file (script, test_file, &error))
|
||||
g_printerr ("Error: %s", error->message);
|
||||
|
||||
g_assert_no_error (error);
|
||||
|
||||
timeline = CLUTTER_TIMELINE (clutter_script_get_object (script, "timeline0"));
|
||||
|
||||
g_assert (clutter_timeline_has_marker (timeline, "marker0"));
|
||||
g_assert (clutter_timeline_has_marker (timeline, "marker1"));
|
||||
g_assert (!clutter_timeline_has_marker (timeline, "foo"));
|
||||
g_assert (clutter_timeline_has_marker (timeline, "marker2"));
|
||||
g_assert (clutter_timeline_has_marker (timeline, "marker3"));
|
||||
|
||||
markers = clutter_timeline_list_markers (timeline, -1, &n_markers);
|
||||
g_assert_cmpint (n_markers, ==, 4);
|
||||
g_strfreev (markers);
|
||||
|
||||
markers = clutter_timeline_list_markers (timeline, 500, &n_markers);
|
||||
g_assert_cmpint (n_markers, ==, 2);
|
||||
g_assert (markers != NULL);
|
||||
g_assert (g_strv_contains ((const char * const *) markers, "marker1"));
|
||||
g_assert (g_strv_contains ((const char * const *) markers, "marker3"));
|
||||
g_strfreev (markers);
|
||||
|
||||
g_object_unref (script);
|
||||
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
CLUTTER_TEST_SUITE (
|
||||
CLUTTER_TEST_UNIT ("/timeline/base", timeline_base);
|
||||
CLUTTER_TEST_UNIT ("/timeline/markers-from-script", timeline_markers_from_script)
|
||||
)
|
||||
|
|
|
@ -18,7 +18,6 @@ clutter_tests_interactive_link_args = [
|
|||
clutter_tests_interactive_test_sources = [
|
||||
'test-events.c',
|
||||
'test-actors.c',
|
||||
'test-script.c',
|
||||
'test-grab.c',
|
||||
'test-cogl-shader-glsl.c',
|
||||
'test-cogl-tex-tile.c',
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "tests/clutter-test-utils.h"
|
||||
|
||||
static ClutterScript *script = NULL;
|
||||
static guint merge_id = 0;
|
||||
|
||||
int
|
||||
test_script_main (int argc, char *argv[]);
|
||||
|
||||
static const gchar *test_unmerge =
|
||||
"["
|
||||
" {"
|
||||
" \"id\" : \"main-stage\","
|
||||
" \"type\" : \"ClutterStage\","
|
||||
" \"children\" : [ \"blue-button\" ]"
|
||||
" },"
|
||||
" {"
|
||||
" \"id\" : \"blue-button\","
|
||||
" \"type\" : \"ClutterActor\","
|
||||
" \"background-color\" : \"#0000ffff\","
|
||||
" \"x\" : 350,"
|
||||
" \"y\" : 50,"
|
||||
" \"width\" : 100,"
|
||||
" \"height\" : 100,"
|
||||
" \"visible\" : true,"
|
||||
" \"reactive\" : true"
|
||||
" }"
|
||||
"]";
|
||||
|
||||
static const gchar *test_behaviour =
|
||||
"["
|
||||
" {"
|
||||
" \"id\" : \"main-timeline\","
|
||||
" \"type\" : \"ClutterTimeline\","
|
||||
" \"duration\" : 5000,"
|
||||
" \"loop\" : true"
|
||||
" }"
|
||||
"]";
|
||||
|
||||
static gboolean
|
||||
blue_button_press (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("[*] Pressed '%s'\n", clutter_get_script_id (G_OBJECT (actor)));
|
||||
g_print ("[*] Unmerging objects with merge id: %d\n", merge_id);
|
||||
|
||||
clutter_script_unmerge_objects (script, merge_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
red_button_press (ClutterActor *actor,
|
||||
ClutterButtonEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GObject *timeline;
|
||||
|
||||
g_print ("[*] Pressed '%s'\n", clutter_get_script_id (G_OBJECT (actor)));
|
||||
|
||||
timeline = clutter_script_get_object (script, "main-timeline");
|
||||
g_assert (CLUTTER_IS_TIMELINE (timeline));
|
||||
|
||||
if (!clutter_timeline_is_playing (CLUTTER_TIMELINE (timeline)))
|
||||
clutter_timeline_start (CLUTTER_TIMELINE (timeline));
|
||||
else
|
||||
clutter_timeline_pause (CLUTTER_TIMELINE (timeline));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT int
|
||||
test_script_main (int argc, char *argv[])
|
||||
{
|
||||
GObject *stage, *blue_button, *red_button;
|
||||
GError *error = NULL;
|
||||
gchar *file;
|
||||
gint res;
|
||||
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
script = clutter_script_new ();
|
||||
g_assert (CLUTTER_IS_SCRIPT (script));
|
||||
|
||||
clutter_script_load_from_data (script, test_behaviour, -1, &error);
|
||||
if (error)
|
||||
{
|
||||
g_print ("*** Error:\n"
|
||||
"*** %s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (script);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
file = g_build_filename (TESTS_DATADIR, "test-script.json", NULL);
|
||||
clutter_script_load_from_file (script, file, &error);
|
||||
if (error)
|
||||
{
|
||||
g_print ("*** Error:\n"
|
||||
"*** %s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (script);
|
||||
g_free (file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
g_free (file);
|
||||
|
||||
merge_id = clutter_script_load_from_data (script, test_unmerge, -1, &error);
|
||||
if (error)
|
||||
{
|
||||
g_print ("*** Error:\n"
|
||||
"*** %s\n", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (script);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
clutter_script_connect_signals (script, NULL);
|
||||
|
||||
res = clutter_script_get_objects (script,
|
||||
"main-stage", &stage,
|
||||
"red-button", &red_button,
|
||||
"blue-button", &blue_button,
|
||||
NULL);
|
||||
g_assert (res == 3);
|
||||
|
||||
clutter_actor_show (CLUTTER_ACTOR (stage));
|
||||
|
||||
g_signal_connect (red_button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (red_button_press),
|
||||
NULL);
|
||||
|
||||
g_signal_connect (blue_button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (blue_button_press),
|
||||
NULL);
|
||||
|
||||
clutter_test_main ();
|
||||
|
||||
g_object_unref (script);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"My Scene" : {
|
||||
"id" : "main-stage",
|
||||
"type" : "ClutterStage",
|
||||
"title" : { "translatable" : true, "string" : "ClutterScript test" },
|
||||
"color" : "white",
|
||||
"signals" : [
|
||||
{ "name" : "key-press-event", "handler" : "clutter_test_quit" },
|
||||
{ "name" : "destroy", "handler" : "clutter_test_quit" }
|
||||
],
|
||||
"children" : [
|
||||
{
|
||||
"id" : "red-button",
|
||||
"type" : "ClutterActor",
|
||||
"background-color" : "#ff0000ff",
|
||||
"x" : 50, "y" : 50, "width" : 100, "height" : 100,
|
||||
"reactive" : true,
|
||||
"rotation" : [
|
||||
{ "z-axis" : [ 45.0, [ 75, 75 ] ] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id" : "green-button",
|
||||
"type" : "ClutterActor",
|
||||
"background-color" : "#00ff00ff",
|
||||
"border-width" : 5,
|
||||
"border-color" : "#00cc00ff",
|
||||
"position" : [ 200.0, 50.0 ],
|
||||
"size" : { "width" : 100.0, "height" : 100.0 },
|
||||
"depth" : -200.0,
|
||||
"reactive" : true,
|
||||
"signals" : [
|
||||
{ "name" : "button-press-event", "handler" : "clutter_test_quit" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id" : "label",
|
||||
"type" : "ClutterText",
|
||||
"x" : 50,
|
||||
"y" : 200,
|
||||
"text" : { "translatable" : true, "string" : "Clutter Script" },
|
||||
"font-name" : "Sans 24px",
|
||||
"color" : "black",
|
||||
"line-alignment" : "center",
|
||||
"line-wrap" : false,
|
||||
"ellipsize" : "none",
|
||||
"rotation" : [
|
||||
{ "y-axis" : [ 60.0, [ 275, 100 ] ] },
|
||||
{ "z-axis" : [ 45.0, [ 75, 75 ] ] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <gmodule.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "tests/clutter-test-utils.h"
|
||||
|
||||
#define TEST_STATE_SCRIPT_FILE "test-script-signals.json"
|
||||
|
||||
int
|
||||
test_state_script_main (int argc, char *argv[]);
|
||||
|
||||
G_MODULE_EXPORT int
|
||||
test_state_script_main (int argc, char *argv[])
|
||||
{
|
||||
ClutterActor *stage, *button;
|
||||
ClutterScript *script;
|
||||
GError *error = NULL;
|
||||
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
script = clutter_script_new ();
|
||||
clutter_script_load_from_file (script, TEST_STATE_SCRIPT_FILE, &error);
|
||||
if (error != NULL)
|
||||
g_error ("Unable to load '%s': %s\n",
|
||||
TEST_STATE_SCRIPT_FILE,
|
||||
error->message);
|
||||
|
||||
stage = clutter_test_get_stage ();
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script");
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL);
|
||||
clutter_actor_show (stage);
|
||||
|
||||
button = CLUTTER_ACTOR (clutter_script_get_object (script, "button"));
|
||||
clutter_actor_add_child (stage, button);
|
||||
clutter_actor_add_constraint (button, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
|
||||
|
||||
clutter_script_connect_signals (script, NULL);
|
||||
|
||||
clutter_test_main ();
|
||||
|
||||
g_object_unref (script);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -161,7 +161,6 @@ test_client = executable('mutter-test-client',
|
|||
x11_dep,
|
||||
xext_dep,
|
||||
graphene_dep,
|
||||
json_glib_dep,
|
||||
gsettings_desktop_schemas_dep,
|
||||
],
|
||||
install: have_installed_tests,
|
||||
|
|
Loading…
Reference in a new issue