From 494629d4b9eac31afa3910ef130404030656bc4e Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Fri, 4 Feb 2011 12:33:53 +0100 Subject: [PATCH] clutter-text: new clutter_text_get_layout_offsets API This new function can be used to retrieve the coordinates where the ClutterText will draw the PangoLayout representing the text. http://bugzilla.clutter-project.org/show_bug.cgi?id=2553 --- clutter/clutter-text.c | 38 +++++++++++++++++++++++++++++- clutter/clutter-text.h | 4 ++++ doc/reference/clutter/clutter-sections.txt | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 1606284..85912cc 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -168,6 +168,10 @@ struct _ClutterTextPrivate */ gint text_x; + /* the y position of the PangoLayout, fixed to 0 by + * default for now */ + gint text_y; + /* the length of the text, in bytes */ gint n_bytes; @@ -2037,7 +2041,7 @@ clutter_text_paint (ClutterActor *self) priv->text_color.green, priv->text_color.blue, real_opacity); - cogl_pango_render_layout (layout, text_x, 0, &color, 0); + cogl_pango_render_layout (layout, text_x, priv->text_y, &color, 0); selection_paint (text); @@ -3486,6 +3490,8 @@ clutter_text_init (ClutterText *self) priv->max_length = 0; + priv->text_y = 0; + priv->cursor_size = DEFAULT_CURSOR_SIZE; memset (&priv->cursor_pos, 0, sizeof (ClutterGeometry)); @@ -5478,3 +5484,33 @@ clutter_text_set_preedit_string (ClutterText *self, clutter_text_dirty_cache (self); clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); } + + +/** + * clutter_text_get_layout_offsets: + * @self: a #ClutterText + * @x: (out): location to store X offset of layout, or %NULL + * @y: (out): location to store Y offset of layout, or %NULL + * + * Obtains the coordinates where the #ClutterText will draw the #PangoLayout + * representing the text. + * + * Since: 1.7 + **/ +void +clutter_text_get_layout_offsets (ClutterText *self, + gint *x, + gint *y) +{ + ClutterTextPrivate *priv; + + g_return_if_fail (CLUTTER_IS_TEXT (self)); + + priv = self->priv; + + if (x != NULL) + *x = priv->text_x; + + if (y != NULL) + *y = priv->text_y; +} diff --git a/clutter/clutter-text.h b/clutter/clutter-text.h index eef7d76..c127fe7 100644 --- a/clutter/clutter-text.h +++ b/clutter/clutter-text.h @@ -217,6 +217,10 @@ void clutter_text_set_preedit_string (ClutterText *s PangoAttrList *preedit_attrs, guint cursor_pos); +void clutter_text_get_layout_offsets (ClutterText *self, + gint *x, + gint *y); + G_END_DECLS #endif /* __CLUTTER_TEXT_H__ */ diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 414b0e0..44fd85d 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1826,6 +1826,7 @@ clutter_text_get_cursor_size clutter_text_activate clutter_text_position_to_coords clutter_text_set_preedit_string +clutter_text_get_layout_offsets CLUTTER_IS_TEXT -- 2.7.4