mirror of
https://github.com/brl/mutter.git
synced 2025-04-17 23:59:38 +00:00
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
@ -71,12 +71,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "clutter-main.h"
|
|
||||||
#include "clutter-actor.h"
|
#include "clutter-actor.h"
|
||||||
#include "clutter-behaviour.h"
|
#include "clutter-behaviour.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-main.h"
|
||||||
#include "clutter-marshal.h"
|
#include "clutter-marshal.h"
|
||||||
|
#include "clutter-private.h"
|
||||||
|
#include "clutter-scriptable.h"
|
||||||
|
#include "clutter-script-private.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_knot_copy:
|
* clutter_knot_copy:
|
||||||
@ -157,9 +159,13 @@ clutter_knot_get_type (void)
|
|||||||
return our_type;
|
return our_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (ClutterBehaviour,
|
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
||||||
clutter_behaviour,
|
|
||||||
G_TYPE_OBJECT);
|
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterBehaviour,
|
||||||
|
clutter_behaviour,
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
||||||
|
clutter_scriptable_iface_init));
|
||||||
|
|
||||||
struct _ClutterBehaviourPrivate
|
struct _ClutterBehaviourPrivate
|
||||||
{
|
{
|
||||||
@ -188,6 +194,36 @@ static guint behave_signals[LAST_SIGNAL] = { 0 };
|
|||||||
CLUTTER_TYPE_BEHAVIOUR, \
|
CLUTTER_TYPE_BEHAVIOUR, \
|
||||||
ClutterBehaviourPrivate))
|
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
|
static void
|
||||||
clutter_behaviour_dispose (GObject *gobject)
|
clutter_behaviour_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
|
@ -816,8 +816,8 @@ resolve_alpha_func (const gchar *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GObject *
|
GObject *
|
||||||
clutter_script_parse_alpha (ClutterScript *script,
|
_clutter_script_parse_alpha (ClutterScript *script,
|
||||||
JsonNode *node)
|
JsonNode *node)
|
||||||
{
|
{
|
||||||
GObject *retval = NULL;
|
GObject *retval = NULL;
|
||||||
JsonObject *object;
|
JsonObject *object;
|
||||||
@ -1068,21 +1068,6 @@ clutter_script_parse_node (ClutterScript *script,
|
|||||||
|
|
||||||
if (g_type_is_a (p_type, G_TYPE_OBJECT))
|
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
|
/* default GObject handling: we get the id and
|
||||||
* retrieve the ObjectInfo for it; since the object
|
* retrieve the ObjectInfo for it; since the object
|
||||||
* definitions are parsed leaf-first we are guaranteed
|
* 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,
|
gboolean clutter_script_parse_color (ClutterScript *script,
|
||||||
JsonNode *node,
|
JsonNode *node,
|
||||||
ClutterColor *color);
|
ClutterColor *color);
|
||||||
GObject *clutter_script_parse_alpha (ClutterScript *script,
|
GObject *_clutter_script_parse_alpha (ClutterScript *script,
|
||||||
JsonNode *node);
|
JsonNode *node);
|
||||||
|
|
||||||
void _clutter_script_construct_object (ClutterScript *script,
|
void _clutter_script_construct_object (ClutterScript *script,
|
||||||
ObjectInfo *oinfo);
|
ObjectInfo *oinfo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user