mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 03:22:04 +00:00
Make ::find_child_by_id() a method of ClutterContainer
Finding a child by its ID is a method that should be used by every container and not only by ClutterGroup. This is needed to actually fix the picking in ClutterStage.
This commit is contained in:
parent
b5cc246f59
commit
d9b421de40
@ -377,3 +377,25 @@ clutter_container_foreach (ClutterContainer *container,
|
||||
CLUTTER_CONTAINER_GET_IFACE (container)->foreach (container, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_container_find_child_by_id:
|
||||
* @container: a #ClutterContainer
|
||||
* @child_id: the unique id of an actor
|
||||
*
|
||||
* Finds a child actor of a container by its unique ID. Search recurses
|
||||
* into any child container.
|
||||
*
|
||||
* Return value: The child actor with the requested id, or %NULL if no
|
||||
* actor with that id was found
|
||||
*
|
||||
* Since: 0.6
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_container_find_child_by_id (ClutterContainer *container,
|
||||
guint child_id)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_CONTAINER (container), NULL);
|
||||
|
||||
return CLUTTER_CONTAINER_GET_IFACE (container)->find_child_by_id (container,
|
||||
child_id);
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ typedef struct _ClutterContainerIface ClutterContainerIface;
|
||||
* @add: virtual function for adding an actor to the container
|
||||
* @remove: virtual function for removing an actor from the container
|
||||
* @foreach: virtual function for iterating over the container's children
|
||||
* @find_child_by_id: virtual function for searching a container children
|
||||
* using its unique id. Should recurse through its children. This function
|
||||
* is used when "picking" actors (e.g. by clutter_stage_get_actor_at_pos())
|
||||
* @actor_added: signal class handler for ClutterContainer::actor_added
|
||||
* @actor_removed: signal class handler for ClutterContainer::actor_removed
|
||||
*
|
||||
@ -59,14 +62,16 @@ struct _ClutterContainerIface
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/*< public >*/
|
||||
void (* add) (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void (* remove) (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void (* foreach) (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
void (* add) (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void (* remove) (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void (* foreach) (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data);
|
||||
ClutterActor *(* find_child_by_id) (ClutterContainer *container,
|
||||
guint child_id);
|
||||
|
||||
/* signals */
|
||||
void (* actor_added) (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
@ -74,28 +79,31 @@ struct _ClutterContainerIface
|
||||
ClutterActor *actor);
|
||||
};
|
||||
|
||||
GType clutter_container_get_type (void) G_GNUC_CONST;
|
||||
GType clutter_container_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void clutter_container_add (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void clutter_container_add_actor (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void clutter_container_add_valist (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
va_list var_args);
|
||||
void clutter_container_remove (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void clutter_container_remove_actor (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void clutter_container_remove_valist (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
va_list var_args);
|
||||
GList * clutter_container_get_children (ClutterContainer *container);
|
||||
void clutter_container_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data);
|
||||
ClutterActor *clutter_container_find_child_by_id (ClutterContainer *container,
|
||||
guint child_id);
|
||||
|
||||
void clutter_container_add (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void clutter_container_add_actor (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void clutter_container_add_valist (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
va_list var_args);
|
||||
void clutter_container_remove (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void clutter_container_remove_actor (ClutterContainer *container,
|
||||
ClutterActor *actor);
|
||||
void clutter_container_remove_valist (ClutterContainer *container,
|
||||
ClutterActor *first_actor,
|
||||
va_list var_args);
|
||||
GList *clutter_container_get_children (ClutterContainer *container);
|
||||
void clutter_container_foreach (ClutterContainer *container,
|
||||
ClutterCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -282,12 +282,48 @@ clutter_group_real_foreach (ClutterContainer *container,
|
||||
(* callback) (CLUTTER_ACTOR (l->data), user_data);
|
||||
}
|
||||
|
||||
static ClutterActor *
|
||||
clutter_group_real_find_child_by_id (ClutterContainer *container,
|
||||
guint child_id)
|
||||
{
|
||||
ClutterGroup *self = CLUTTER_GROUP (container);
|
||||
ClutterGroupPrivate *priv = self->priv;
|
||||
ClutterActor *actor = NULL;
|
||||
GList *l;
|
||||
|
||||
if (clutter_actor_get_id (CLUTTER_ACTOR (self)) == child_id)
|
||||
return CLUTTER_ACTOR (self);
|
||||
|
||||
for (l = priv->children; l; l = l->next)
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
|
||||
if (clutter_actor_get_id (child) == child_id)
|
||||
{
|
||||
actor = child;
|
||||
break;
|
||||
}
|
||||
|
||||
if (CLUTTER_IS_CONTAINER (child))
|
||||
{
|
||||
ClutterContainer *c = CLUTTER_CONTAINER (child);
|
||||
|
||||
actor = clutter_container_find_child_by_id (c, child_id);
|
||||
if (actor)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_container_iface_init (ClutterContainerIface *iface)
|
||||
{
|
||||
iface->add = clutter_group_real_add;
|
||||
iface->remove = clutter_group_real_remove;
|
||||
iface->foreach = clutter_group_real_foreach;
|
||||
iface->find_child_by_id = clutter_group_real_find_child_by_id;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -534,38 +570,16 @@ clutter_group_get_nth_child (ClutterGroup *self,
|
||||
* into any child groups.
|
||||
*
|
||||
* Returns: the #ClutterActor if found, or NULL.
|
||||
*
|
||||
* Deprecated: 0.6: Use clutter_container_find_child_by_id() instead.
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_group_find_child_by_id (ClutterGroup *self,
|
||||
guint id)
|
||||
{
|
||||
ClutterActor *actor = NULL;
|
||||
GList *l;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GROUP (self), NULL);
|
||||
|
||||
if (clutter_actor_get_id (CLUTTER_ACTOR (self)) == id)
|
||||
return CLUTTER_ACTOR (self);
|
||||
|
||||
for (l = self->priv->children; l; l = l->next)
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
|
||||
if (clutter_actor_get_id (child) == id)
|
||||
{
|
||||
actor = child;
|
||||
break;
|
||||
}
|
||||
|
||||
if (CLUTTER_IS_GROUP (child))
|
||||
{
|
||||
actor = clutter_group_find_child_by_id (CLUTTER_GROUP (child), id);
|
||||
if (actor)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return actor;
|
||||
return clutter_container_find_child_by_id (CLUTTER_CONTAINER (self), id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -577,7 +591,7 @@ clutter_group_find_child_by_id (ClutterGroup *self,
|
||||
* FIXME
|
||||
*/
|
||||
void
|
||||
clutter_group_raise (ClutterGroup *self,
|
||||
clutter_group_raise (ClutterGroup *self,
|
||||
ClutterActor *actor,
|
||||
ClutterActor *sibling)
|
||||
{
|
||||
|
@ -86,8 +86,6 @@ struct _ClutterGroupClass
|
||||
|
||||
GType clutter_group_get_type (void) G_GNUC_CONST;
|
||||
ClutterActor *clutter_group_new (void);
|
||||
ClutterActor *clutter_group_find_child_by_id (ClutterGroup *self,
|
||||
guint id);
|
||||
ClutterActor *clutter_group_get_nth_child (ClutterGroup *self,
|
||||
gint index_);
|
||||
gint clutter_group_get_n_children (ClutterGroup *self);
|
||||
@ -104,6 +102,8 @@ void clutter_group_add_many_valist (ClutterGroup *group,
|
||||
va_list var_args);
|
||||
void clutter_group_remove (ClutterGroup *group,
|
||||
ClutterActor *actor);
|
||||
ClutterActor *clutter_group_find_child_by_id (ClutterGroup *self,
|
||||
guint id);
|
||||
#endif /* CLUTTER_DISABLE_DEPRECATED */
|
||||
|
||||
void clutter_group_raise (ClutterGroup *self,
|
||||
|
@ -25,7 +25,7 @@ SCANGOBJ_OPTIONS=--type-init-func="clutter_base_init()"
|
||||
|
||||
# Extra options to supply to gtkdoc-scan.
|
||||
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||
SCAN_OPTIONS=
|
||||
SCAN_OPTIONS=--deprecated-guards="CLUTTER_DISABLE_DEPRECATED"
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb.
|
||||
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||
|
@ -218,6 +218,7 @@ clutter_container_remove
|
||||
clutter_container_remove_valist
|
||||
clutter_container_get_children
|
||||
clutter_container_foreach
|
||||
clutter_container_find_child_by_id
|
||||
<SUBSECTION Standard>
|
||||
ClutterContainer
|
||||
CLUTTER_TYPE_CONTAINER
|
||||
|
Loading…
Reference in New Issue
Block a user