behaviour: Implement the implicit alpha parsing
ClutterBehaviour should implement the Scriptable interface and parse ClutterAlpha when implicitly defined, instead of having this ad hoc code inside ClutterScriptParser itself. After all, only ClutterBehaviour supports Alpha defined implicitly.
This commit is contained in:
parent
f1ed8be066
commit
cb60c038ac
3 changed files with 45 additions and 24 deletions
|
@ -71,12 +71,14 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-behaviour.h"
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-marshal.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-scriptable.h"
|
||||
#include "clutter-script-private.h"
|
||||
|
||||
/**
|
||||
* clutter_knot_copy:
|
||||
|
@ -157,9 +159,13 @@ clutter_knot_get_type (void)
|
|||
return our_type;
|
||||
}
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (ClutterBehaviour,
|
||||
clutter_behaviour,
|
||||
G_TYPE_OBJECT);
|
||||
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterBehaviour,
|
||||
clutter_behaviour,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||
clutter_scriptable_iface_init));
|
||||
|
||||
struct _ClutterBehaviourPrivate
|
||||
{
|
||||
|
@ -188,6 +194,36 @@ static guint behave_signals[LAST_SIGNAL] = { 0 };
|
|||
CLUTTER_TYPE_BEHAVIOUR, \
|
||||
ClutterBehaviourPrivate))
|
||||
|
||||
static gboolean
|
||||
clutter_behaviour_parse_custom_node (ClutterScriptable *scriptable,
|
||||
ClutterScript *script,
|
||||
GValue *value,
|
||||
const gchar *name,
|
||||
JsonNode *node)
|
||||
{
|
||||
if (strncmp (name, "alpha", 5) == 0)
|
||||
{
|
||||
GObject *alpha;
|
||||
|
||||
alpha = _clutter_script_parse_alpha (script, node);
|
||||
if (alpha != NULL)
|
||||
{
|
||||
g_value_init (value, CLUTTER_TYPE_ALPHA);
|
||||
g_value_set_object (value, alpha);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
||||
{
|
||||
iface->parse_custom_node = clutter_behaviour_parse_custom_node;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_behaviour_dispose (GObject *gobject)
|
||||
{
|
||||
|
|
|
@ -816,8 +816,8 @@ resolve_alpha_func (const gchar *name)
|
|||
}
|
||||
|
||||
GObject *
|
||||
clutter_script_parse_alpha (ClutterScript *script,
|
||||
JsonNode *node)
|
||||
_clutter_script_parse_alpha (ClutterScript *script,
|
||||
JsonNode *node)
|
||||
{
|
||||
GObject *retval = NULL;
|
||||
JsonObject *object;
|
||||
|
@ -1068,21 +1068,6 @@ clutter_script_parse_node (ClutterScript *script,
|
|||
|
||||
if (g_type_is_a (p_type, G_TYPE_OBJECT))
|
||||
{
|
||||
/* ClutterAlpha are handled a little bit
|
||||
* differently, since they can be implicit
|
||||
*/
|
||||
if (g_type_is_a (p_type, CLUTTER_TYPE_ALPHA))
|
||||
{
|
||||
GObject *alpha;
|
||||
|
||||
alpha = clutter_script_parse_alpha (script, node);
|
||||
if (alpha)
|
||||
{
|
||||
g_value_set_object (value, alpha);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* default GObject handling: we get the id and
|
||||
* retrieve the ObjectInfo for it; since the object
|
||||
* definitions are parsed leaf-first we are guaranteed
|
||||
|
|
|
@ -121,8 +121,8 @@ gboolean clutter_script_parse_geometry (ClutterScript *script,
|
|||
gboolean clutter_script_parse_color (ClutterScript *script,
|
||||
JsonNode *node,
|
||||
ClutterColor *color);
|
||||
GObject *clutter_script_parse_alpha (ClutterScript *script,
|
||||
JsonNode *node);
|
||||
GObject *_clutter_script_parse_alpha (ClutterScript *script,
|
||||
JsonNode *node);
|
||||
|
||||
void _clutter_script_construct_object (ClutterScript *script,
|
||||
ObjectInfo *oinfo);
|
||||
|
|
Loading…
Add table
Reference in a new issue