From: Emmanuele Bassi Date: Mon, 2 Feb 2009 09:01:41 +0000 (+0000) Subject: Add Actor::create_pango_layout() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=801e535e947e32fea5fe2859e94c58f7b7c8af4f;p=profile%2Fivi%2Fclutter.git Add Actor::create_pango_layout() 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. --- diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index dfc4b29..75e927f 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -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 diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 571bac1..26167da 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -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 diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 35b9e9c..9c14ef2 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -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 CLUTTER_TYPE_GEOMETRY