clutter/content: Add clutter_content_invalidate_size()

ClutterContent has the ability to dictate the layout of any
given actor, through the CLUTTER_REQUEST_CONTENT_SIZE request
mode.

However, there is no way for ClutterContent implementations
to notify their attached actors that the content size changed.

Add a new optional ClutterContent.invalidate_size() vfunc and
clutter_content_invalidate_size().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/405
This commit is contained in:
Georges Basile Stavracas Neto 2018-12-26 23:17:29 -02:00
parent 5a71ed4411
commit 0f0b411f6e
2 changed files with 51 additions and 0 deletions

View File

@ -38,6 +38,7 @@
#include "clutter-build-config.h"
#include "clutter-actor-private.h"
#include "clutter-content-private.h"
#include "clutter-debug.h"
@ -91,6 +92,11 @@ clutter_content_real_invalidate (ClutterContent *content)
{
}
static void
clutter_content_real_invalidate_size (ClutterContent *content)
{
}
static void
clutter_content_real_paint_content (ClutterContent *content,
ClutterActor *actor,
@ -108,6 +114,7 @@ clutter_content_default_init (ClutterContentInterface *iface)
iface->attached = clutter_content_real_attached;
iface->detached = clutter_content_real_detached;
iface->invalidate = clutter_content_real_invalidate;
iface->invalidate_size = clutter_content_real_invalidate_size;
/**
* ClutterContent::attached:
@ -188,6 +195,45 @@ clutter_content_invalidate (ClutterContent *content)
}
}
/**
* clutter_content_invalidate_size:
* @content: a #ClutterContent
*
* Signals that @content's size changed. Attached actors with request mode
* set to %CLUTTER_REQUEST_CONTENT_SIZE will have a relayout queued.
*
* Attached actors with other request modes are not redrawn. To redraw them
* too, use clutter_content_invalidate().
*/
void
clutter_content_invalidate_size (ClutterContent *content)
{
ClutterActor *actor;
GHashTable *actors;
GHashTableIter iter;
g_return_if_fail (CLUTTER_IS_CONTENT (content));
CLUTTER_CONTENT_GET_IFACE (content)->invalidate_size (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, (gpointer *) &actor, NULL))
{
ClutterRequestMode request_mode;
g_assert (actor != NULL);
request_mode = clutter_actor_get_request_mode (actor);
if (request_mode == CLUTTER_REQUEST_CONTENT_SIZE)
_clutter_actor_queue_only_relayout (actor);
}
}
/*< private >
* _clutter_content_attached:
* @content: a #ClutterContent

View File

@ -86,6 +86,8 @@ struct _ClutterContentIface
ClutterActor *actor);
void (* invalidate) (ClutterContent *content);
void (* invalidate_size) (ClutterContent *content);
};
CLUTTER_EXPORT
@ -98,6 +100,9 @@ gboolean clutter_content_get_preferred_size (ClutterContent *content
CLUTTER_EXPORT
void clutter_content_invalidate (ClutterContent *content);
CLUTTER_EXPORT
void clutter_content_invalidate_size (ClutterContent *content);
G_END_DECLS
#endif /* __CLUTTER_CONTENT_H__ */