[mutter/gbsneto/more-clutter-api: 20/25] clutter/content: Add clutter_content_invalidate_size()



commit 0f0b411f6ed3b515dd946a4a45abb06edbc72e29
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 26 23:17:29 2018 -0200

    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

 clutter/clutter/clutter-content.c | 46 +++++++++++++++++++++++++++++++++++++++
 clutter/clutter/clutter-content.h |  5 +++++
 2 files changed, 51 insertions(+)
---
diff --git a/clutter/clutter/clutter-content.c b/clutter/clutter/clutter-content.c
index 35419305e..b7aea04c2 100644
--- a/clutter/clutter/clutter-content.c
+++ b/clutter/clutter/clutter-content.c
@@ -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
diff --git a/clutter/clutter/clutter-content.h b/clutter/clutter/clutter-content.h
index 69836d5a1..0b676f6e3 100644
--- a/clutter/clutter/clutter-content.h
+++ b/clutter/clutter/clutter-content.h
@@ -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__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]