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.
This commit is contained in:
Emmanuele Bassi 2009-02-02 09:01:41 +00:00
parent 52d04b5750
commit 801e535e94
3 changed files with 41 additions and 0 deletions

View 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

View 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

View 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