mirror of
https://github.com/brl/mutter.git
synced 2025-02-02 14:53:03 +00:00
content: Make vfuncs optional
The virtual functions on the ClutterContent interface should provide hooks for application code, not be the actual implementation.
This commit is contained in:
parent
f4d8fb054a
commit
2f0d29ad75
@ -70,57 +70,17 @@ static void
|
|||||||
clutter_content_real_attached (ClutterContent *content,
|
clutter_content_real_attached (ClutterContent *content,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
GObject *obj = G_OBJECT (content);
|
|
||||||
GHashTable *actors;
|
|
||||||
|
|
||||||
actors = g_object_get_qdata (obj, quark_content_actors);
|
|
||||||
if (actors == NULL)
|
|
||||||
{
|
|
||||||
actors = g_hash_table_new (NULL, NULL);
|
|
||||||
g_object_set_qdata_full (obj, quark_content_actors,
|
|
||||||
actors,
|
|
||||||
(GDestroyNotify) g_hash_table_unref);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_insert (actors, actor, actor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_content_real_detached (ClutterContent *content,
|
clutter_content_real_detached (ClutterContent *content,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
GObject *obj = G_OBJECT (content);
|
|
||||||
GHashTable *actors;
|
|
||||||
|
|
||||||
actors = g_object_get_qdata (obj, quark_content_actors);
|
|
||||||
g_assert (actors != NULL);
|
|
||||||
|
|
||||||
g_hash_table_remove (actors, actor);
|
|
||||||
|
|
||||||
if (g_hash_table_size (actors) == 0)
|
|
||||||
g_object_set_qdata (obj, quark_content_actors, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_content_real_invalidate (ClutterContent *content)
|
clutter_content_real_invalidate (ClutterContent *content)
|
||||||
{
|
{
|
||||||
GHashTable *actors;
|
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer key_p, value_p;
|
|
||||||
|
|
||||||
actors = g_object_get_qdata (G_OBJECT (content), quark_content_actors);
|
|
||||||
if (actors == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, actors);
|
|
||||||
while (g_hash_table_iter_next (&iter, &key_p, &value_p))
|
|
||||||
{
|
|
||||||
ClutterActor *actor = key_p;
|
|
||||||
|
|
||||||
g_assert (actor != NULL);
|
|
||||||
|
|
||||||
clutter_actor_queue_redraw (actor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -157,8 +117,26 @@ clutter_content_default_init (ClutterContentInterface *iface)
|
|||||||
void
|
void
|
||||||
clutter_content_invalidate (ClutterContent *content)
|
clutter_content_invalidate (ClutterContent *content)
|
||||||
{
|
{
|
||||||
|
GHashTable *actors;
|
||||||
|
GHashTableIter iter;
|
||||||
|
gpointer key_p, value_p;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_CONTENT (content));
|
g_return_if_fail (CLUTTER_IS_CONTENT (content));
|
||||||
|
|
||||||
|
actors = g_object_get_qdata (G_OBJECT (content), quark_content_actors);
|
||||||
|
if (actors == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_hash_table_iter_init (&iter, actors);
|
||||||
|
while (g_hash_table_iter_next (&iter, &key_p, &value_p))
|
||||||
|
{
|
||||||
|
ClutterActor *actor = key_p;
|
||||||
|
|
||||||
|
g_assert (actor != NULL);
|
||||||
|
|
||||||
|
clutter_actor_queue_redraw (actor);
|
||||||
|
}
|
||||||
|
|
||||||
CLUTTER_CONTENT_GET_IFACE (content)->invalidate (content);
|
CLUTTER_CONTENT_GET_IFACE (content)->invalidate (content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +158,20 @@ void
|
|||||||
_clutter_content_attached (ClutterContent *content,
|
_clutter_content_attached (ClutterContent *content,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
|
GObject *obj = G_OBJECT (content);
|
||||||
|
GHashTable *actors;
|
||||||
|
|
||||||
|
actors = g_object_get_qdata (obj, quark_content_actors);
|
||||||
|
if (actors == NULL)
|
||||||
|
{
|
||||||
|
actors = g_hash_table_new (NULL, NULL);
|
||||||
|
g_object_set_qdata_full (obj, quark_content_actors,
|
||||||
|
actors,
|
||||||
|
(GDestroyNotify) g_hash_table_unref);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_insert (actors, actor, actor);
|
||||||
|
|
||||||
CLUTTER_CONTENT_GET_IFACE (content)->attached (content, actor);
|
CLUTTER_CONTENT_GET_IFACE (content)->attached (content, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +192,17 @@ void
|
|||||||
_clutter_content_detached (ClutterContent *content,
|
_clutter_content_detached (ClutterContent *content,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
|
GObject *obj = G_OBJECT (content);
|
||||||
|
GHashTable *actors;
|
||||||
|
|
||||||
|
actors = g_object_get_qdata (obj, quark_content_actors);
|
||||||
|
g_assert (actors != NULL);
|
||||||
|
|
||||||
|
g_hash_table_remove (actors, actor);
|
||||||
|
|
||||||
|
if (g_hash_table_size (actors) == 0)
|
||||||
|
g_object_set_qdata (obj, quark_content_actors, NULL);
|
||||||
|
|
||||||
CLUTTER_CONTENT_GET_IFACE (content)->detached (content, actor);
|
CLUTTER_CONTENT_GET_IFACE (content)->detached (content, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* An OpenGL based 'interactive canvas' library.
|
* An OpenGL based 'interactive canvas' library.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Intel Corporation.
|
* Copyright (C) 2012 Intel Corporation.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -56,14 +56,11 @@ typedef struct _ClutterContentIface ClutterContentIface;
|
|||||||
* @paint_content: virtual function; called each time the content needs to
|
* @paint_content: virtual function; called each time the content needs to
|
||||||
* paint itself
|
* paint itself
|
||||||
* @attached: virtual function; called each time a #ClutterContent is attached
|
* @attached: virtual function; called each time a #ClutterContent is attached
|
||||||
* to a #ClutterActor. If overridden, the subclass must chain up to the
|
* to a #ClutterActor.
|
||||||
* parent class implementation.
|
|
||||||
* @detached: virtual function; called each time a #ClutterContent is detached
|
* @detached: virtual function; called each time a #ClutterContent is detached
|
||||||
* from a #ClutterActor. If overridden, the subclass must chain up to the
|
* from a #ClutterActor.
|
||||||
* parent class implementation.
|
|
||||||
* @invalidate: virtual function; called each time a #ClutterContent state
|
* @invalidate: virtual function; called each time a #ClutterContent state
|
||||||
* is changed. If overridden, the subclass must chain up to the parent
|
* is changed.
|
||||||
* class implementation.
|
|
||||||
*
|
*
|
||||||
* The <structname>ClutterContentIface</structname> structure contains only
|
* The <structname>ClutterContentIface</structname> structure contains only
|
||||||
* private data.
|
* private data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user