Add Actor::create_pango_layout()
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 2 Feb 2009 09:01:41 +0000 (09:01 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 2 Feb 2009 12:07:28 +0000 (12:07 +0000)
Final bit of integration between ClutterActor and Pango: a simple
method for creating a PangoLayout, pre-filled with text and ready
to be rendered using cogl_pango_render_layout().

This should make writing new Actors rendering custom text in their
paint() implementation easy and reliable.

clutter/clutter-actor.c
clutter/clutter-actor.h
doc/reference/clutter/clutter-sections.txt

index dfc4b29..75e927f 100644 (file)
@@ -8095,6 +8095,44 @@ clutter_actor_create_pango_context (ClutterActor *self)
   return retval;
 }
 
+/**
+ * clutter_actor_create_pango_layout:
+ * @self: a #ClutterActor
+ * @text: the text to set on the #PangoLayout, or %NULL
+ *
+ * Creates a new #PangoLayout from the same #PangoContext used
+ * by the #ClutterActor. The #PangoLayout is already configured
+ * with the font map, resolution and font options, and the
+ * given @text.
+ *
+ * If you want to keep around a #PangoLayout created by this
+ * function you will have to connect to the #ClutterBackend::font-changed
+ * and #ClutterBackend::resolution-changed signals, and call
+ * pango_layout_context_changed() in response to them.
+ *
+ * Return value: the newly created #PangoLayout. Use g_object_unref()
+ *   when done
+ *
+ * Since: 1.0
+ */
+PangoLayout *
+clutter_actor_create_pango_layout (ClutterActor *self,
+                                   const gchar  *text)
+{
+  PangoContext *context;
+  PangoLayout *layout;
+
+  g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+
+  context = clutter_actor_get_pango_context (self);
+  layout = pango_layout_new (context);
+
+  if (text)
+    pango_layout_set_text (layout, text, -1);
+
+  return layout;
+}
+
 /* Allows overriding the parent traversed when querying an actors paint
  * opacity. Used by ClutterClone. */
 void
index 571bac1..26167da 100644 (file)
@@ -576,6 +576,8 @@ void          clutter_actor_grab_key_focus            (ClutterActor        *self
 
 PangoContext *clutter_actor_get_pango_context         (ClutterActor        *self);
 PangoContext *clutter_actor_create_pango_context      (ClutterActor        *self);
+PangoLayout * clutter_actor_create_pango_layout       (ClutterActor        *self,
+                                                       const gchar         *text);
 
 G_END_DECLS
 
index 35b9e9c..9c14ef2 100644 (file)
@@ -451,6 +451,7 @@ clutter_actor_get_transformed_sizeu
 clutter_actor_grab_key_focus
 clutter_actor_get_pango_context
 clutter_actor_create_pango_context
+clutter_actor_create_pango_layout
 
 <SUBSECTION Standard>
 CLUTTER_TYPE_GEOMETRY