From 78628edf2f6f02db3d283169d93ae2d21e63a1ec Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 23 Dec 2008 14:06:55 +0000 Subject: [PATCH] Add a per-actor PangoContext Rendering text inside an actor is pretty much impossible without using internal API to create the various pieces like the PangoContext and the font map. Each actor should have the ability to create a PangoContext, which is the only object needed to generate layouts and change the various Pango settings. This commit adds a clutter_actor_get_pango_context() function that creates a PangoContext inside the ClutterActor private data and allows the creation of PangoLayouts when needed. If the actor already has a PangoContext, the same instance is returned. The PangoContext is created only on demand. --- clutter/clutter-actor.c | 25 +++++++++++++++++++++++-- clutter/clutter-actor.h | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 6a30c1c..992ffde 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -221,7 +221,9 @@ struct _ClutterActorPrivate /* cached allocation is invalid (request has changed, probably) */ guint needs_allocation : 1; - guint has_clip : 1; + guint show_on_set_parent : 1; + guint has_clip : 1; + ClutterUnit clip[4]; /* Rotation angles */ @@ -260,7 +262,7 @@ struct _ClutterActorPrivate ShaderData *shader_data; - gboolean show_on_set_parent; + PangoContext *pango_context; }; enum @@ -7589,3 +7591,22 @@ clutter_actor_grab_key_focus (ClutterActor *self) if (parent && CLUTTER_IS_STAGE (parent)) clutter_stage_set_key_focus (CLUTTER_STAGE (parent), self); } + +PangoContext * +clutter_actor_get_pango_context (ClutterActor *self) +{ + ClutterActorPrivate *priv; + ClutterMainContext *ctx; + + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL); + + priv = self->priv; + + if (priv->pango_context) + return priv->pango_context; + + ctx = CLUTTER_CONTEXT (); + priv->pango_context = _clutter_context_create_pango_context (ctx); + + return priv->pango_context; +} diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 1874e28..9461e9f 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -31,6 +31,8 @@ /* clutter-actor.h */ #include +#include + #include #include #include @@ -563,6 +565,8 @@ gboolean clutter_actor_get_paint_visibility (ClutterActor *self); void clutter_actor_grab_key_focus (ClutterActor *self); +PangoContext *clutter_actor_get_pango_context (ClutterActor *self); + G_END_DECLS #endif /* _HAVE_CLUTTER_ACTOR_H */ -- 2.7.4