Add ClutterActor::create_pango_context()
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 5 Jan 2009 15:29:10 +0000 (15:29 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 5 Jan 2009 15:29:10 +0000 (15:29 +0000)
Sometimes an actor needs to set specific font rendering options on
the PangoContext without changing settings for every other text-rendering
actor.

In order to do this, we need a new public method to create a Pango
context object -- preset with all the default settings -- owned by the
developer and not shared with the rest of Clutter.

This new method is called clutter_actor_create_pango_context(); while
it does not strictly depend on a ClutterActor, it is a good idea to
have it inside the ClutterActor API to map the current get_pango_context()
method and in case we start storing screen-specific data to the Actor
itself during the 1.x API cycle.

clutter/clutter-actor.c
clutter/clutter-actor.h

index b4068b5..49da274 100644 (file)
@@ -7606,8 +7606,9 @@ clutter_actor_grab_key_focus (ClutterActor *self)
  * is already configured using the appropriate font map, resolution
  * and font options.
  *
- * The returned #PangoContext will be updated each time the options
- * stored by the default #ClutterBackend change.
+ * Unlike clutter_actor_create_pango_context(), this context is owend
+ * by the #ClutterActor and it will be updated each time the options
+ * stored by the #ClutterBackend change.
  *
  * You can use the returned #PangoContext to create a #PangoLayout
  * and render text using cogl_pango_render_layout() to reuse the
@@ -7633,8 +7634,37 @@ clutter_actor_get_pango_context (ClutterActor *self)
     return priv->pango_context;
 
   ctx = CLUTTER_CONTEXT ();
-  priv->pango_context = _clutter_context_create_pango_context (ctx);
+  priv->pango_context = _clutter_context_get_pango_context (ctx);
   g_object_ref (priv->pango_context);
 
   return priv->pango_context;
 }
+
+/**
+ * clutter_actor_create_pango_context:
+ * @self: a #ClutterActor
+ *
+ * Creates a #PangoContext for the given actor. The #PangoContext
+ * is already configured using the appropriate font map, resolution
+ * and font options.
+ *
+ * See also clutter_actor_get_pango_context().
+ *
+ * Return value: the newly created #PangoContext. Use g_object_ref()
+ *   on the returned value to deallocate its resources
+ *
+ * Since: 1.0
+ */
+PangoContext *
+clutter_actor_create_pango_context (ClutterActor *self)
+{
+  ClutterMainContext *ctx;
+  PangoContext *retval;
+
+  g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
+
+  ctx = CLUTTER_CONTEXT ();
+  retval = _clutter_context_create_pango_context (ctx);
+
+  return retval;
+}
index 9461e9f..af962ca 100644 (file)
@@ -422,6 +422,8 @@ void                  clutter_actor_set_opacity               (ClutterActor
                                                                guint8                 opacity);
 guint8                clutter_actor_get_opacity               (ClutterActor          *self);
 guint8                clutter_actor_get_paint_opacity         (ClutterActor          *self);
+gboolean              clutter_actor_get_paint_visibility      (ClutterActor          *self);
+
 
 void                  clutter_actor_set_name                  (ClutterActor          *self,
                                                                const gchar           *name);
@@ -547,25 +549,24 @@ gboolean clutter_actor_is_rotated                     (ClutterActor   *self);
 gboolean clutter_actor_is_scaled                      (ClutterActor   *self);
 gboolean clutter_actor_should_pick_paint              (ClutterActor   *self);
 
-void     clutter_actor_box_get_from_vertices          (ClutterVertex    vtx[4],
-                                                      ClutterActorBox *box);
-
-void clutter_actor_get_abs_allocation_vertices       (ClutterActor  *self,
-                                                      ClutterVertex  verts[4]);
+void     clutter_actor_box_get_from_vertices          (ClutterVertex        vtx[4],
+                                                      ClutterActorBox     *box);
 
-void clutter_actor_apply_transform_to_point          (ClutterActor        *self,
-                                                      const ClutterVertex *point,
-                                                      ClutterVertex       *vertex);
-void clutter_actor_apply_relative_transform_to_point (ClutterActor        *self,
-                                                      ClutterActor        *ancestor,
-                                                      const ClutterVertex *point,
-                                                      ClutterVertex       *vertex);
+void clutter_actor_get_abs_allocation_vertices        (ClutterActor        *self,
+                                                       ClutterVertex        verts[4]);
 
-gboolean clutter_actor_get_paint_visibility           (ClutterActor *self);
+void clutter_actor_apply_transform_to_point           (ClutterActor        *self,
+                                                       const ClutterVertex *point,
+                                                       ClutterVertex       *vertex);
+void clutter_actor_apply_relative_transform_to_point  (ClutterActor        *self,
+                                                       ClutterActor        *ancestor,
+                                                       const ClutterVertex *point,
+                                                       ClutterVertex       *vertex);
 
-void clutter_actor_grab_key_focus (ClutterActor *self);
+void          clutter_actor_grab_key_focus            (ClutterActor        *self);
 
-PangoContext *clutter_actor_get_pango_context    (ClutterActor *self);
+PangoContext *clutter_actor_get_pango_context         (ClutterActor        *self);
+PangoContext *clutter_actor_create_pango_context      (ClutterActor        *self);
 
 G_END_DECLS