mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
[text] Expose position_to_coords()
The clutter_text_position_to_coords() is useful for ClutterText subclasses. See bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1521 Based on a patch by: Raymond Liu <raymond.liu@intel.com>
This commit is contained in:
parent
ca23838752
commit
21e3901d62
@ -477,7 +477,7 @@ clutter_text_coords_to_position (ClutterText *text,
|
|||||||
return index_ + trailing;
|
return index_ + trailing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* clutter_text_position_to_coords:
|
* clutter_text_position_to_coords:
|
||||||
* @self: a #ClutterText
|
* @self: a #ClutterText
|
||||||
* @position: position in characters
|
* @position: position in characters
|
||||||
@ -488,19 +488,28 @@ clutter_text_coords_to_position (ClutterText *text,
|
|||||||
* Retrieves the coordinates of the given @position.
|
* Retrieves the coordinates of the given @position.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the conversion was successful
|
* Return value: %TRUE if the conversion was successful
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
*/
|
*/
|
||||||
static gboolean
|
gboolean
|
||||||
clutter_text_position_to_coords (ClutterText *self,
|
clutter_text_position_to_coords (ClutterText *self,
|
||||||
gint position,
|
gint position,
|
||||||
ClutterUnit *x,
|
ClutterUnit *x,
|
||||||
ClutterUnit *y,
|
ClutterUnit *y,
|
||||||
ClutterUnit *line_height)
|
ClutterUnit *line_height)
|
||||||
{
|
{
|
||||||
ClutterTextPrivate *priv = self->priv;
|
ClutterTextPrivate *priv;
|
||||||
PangoRectangle rect;
|
PangoRectangle rect;
|
||||||
gint password_char_bytes = 1;
|
gint password_char_bytes = 1;
|
||||||
gint index_;
|
gint index_;
|
||||||
|
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_TEXT (self), FALSE);
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (position < -1 || position > priv->n_chars)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (priv->password_char != 0)
|
if (priv->password_char != 0)
|
||||||
password_char_bytes = g_unichar_to_utf8 (priv->password_char, NULL);
|
password_char_bytes = g_unichar_to_utf8 (priv->password_char, NULL);
|
||||||
|
|
||||||
@ -527,7 +536,13 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
&rect, NULL);
|
&rect, NULL);
|
||||||
|
|
||||||
if (x)
|
if (x)
|
||||||
*x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
|
{
|
||||||
|
*x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
|
||||||
|
|
||||||
|
/* Take any offset due to scrolling into account */
|
||||||
|
if (priv->single_line_mode)
|
||||||
|
*x += priv->text_x;
|
||||||
|
}
|
||||||
|
|
||||||
if (y)
|
if (y)
|
||||||
*y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
|
*y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
|
||||||
@ -535,16 +550,6 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
if (line_height)
|
if (line_height)
|
||||||
*line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height);
|
*line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height);
|
||||||
|
|
||||||
if (self->priv->single_line_mode)
|
|
||||||
{
|
|
||||||
/* Take any offset due to scrolling into account */
|
|
||||||
if (x)
|
|
||||||
*x += self->priv->text_x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: should return false if coords were outside text */
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +198,11 @@ void clutter_text_set_single_line_mode (ClutterText *sel
|
|||||||
gboolean clutter_text_get_single_line_mode (ClutterText *self);
|
gboolean clutter_text_get_single_line_mode (ClutterText *self);
|
||||||
|
|
||||||
gboolean clutter_text_activate (ClutterText *self);
|
gboolean clutter_text_activate (ClutterText *self);
|
||||||
|
gboolean clutter_text_position_to_coords (ClutterText *self,
|
||||||
|
gint position,
|
||||||
|
gfloat *x,
|
||||||
|
gfloat *y,
|
||||||
|
gfloat *line_height);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -1599,6 +1599,7 @@ clutter_text_get_cursor_size
|
|||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
clutter_text_activate
|
clutter_text_activate
|
||||||
|
clutter_text_position_to_coords
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
CLUTTER_IS_TEXT
|
CLUTTER_IS_TEXT
|
||||||
|
Loading…
Reference in New Issue
Block a user