From 982a678053a518e94928e5d7a344c4c5525dec15 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 5 Jan 2009 15:29:10 +0000 Subject: [PATCH] Add ClutterActor::create_pango_context() 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 | 36 +++++++++++++++++++++++++++++++++--- clutter/clutter-actor.h | 31 ++++++++++++++++--------------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index b4068b5d2..49da27403 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -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; +} diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 9461e9fa3..af962caf1 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -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_box_get_from_vertices (ClutterVertex vtx[4], + ClutterActorBox *box); -void clutter_actor_get_abs_allocation_vertices (ClutterActor *self, - ClutterVertex verts[4]); +void clutter_actor_get_abs_allocation_vertices (ClutterActor *self, + ClutterVertex verts[4]); -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_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); -gboolean clutter_actor_get_paint_visibility (ClutterActor *self); +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