[clutter/wip/clutter-1.99: 76/79] 2.0: Remove Geometry from ClutterText::cursor-event
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/clutter-1.99: 76/79] 2.0: Remove Geometry from ClutterText::cursor-event
- Date: Wed, 7 Nov 2012 16:08:12 +0000 (UTC)
commit 0ae4450b04201a9af76b0a4417ecd523bc785c02
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Oct 7 22:41:12 2012 +0100
2.0: Remove Geometry from ClutterText::cursor-event
Instead of passing a Geometry inside a signal handler, we should just
notify that the cursor origin or size has been changed, and let the user
retrieve the cursor's rectangle using a specific method. This allows us
to use ClutterRect.
https://bugzilla.gnome.org/show_bug.cgi?id=682789
clutter/clutter-text.c | 64 ++++++++++++++++++++++-------------------------
clutter/clutter-text.h | 5 ++-
clutter/clutter.symbols | 4 +--
3 files changed, 34 insertions(+), 39 deletions(-)
---
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index cf99361..45d0093 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -168,7 +168,7 @@ struct _ClutterTextPrivate
gint text_y;
/* Where to draw the cursor */
- ClutterGeometry cursor_pos;
+ ClutterRect cursor_pos;
ClutterColor cursor_color;
guint cursor_size;
@@ -974,9 +974,7 @@ clutter_text_ensure_cursor_position (ClutterText *self)
{
ClutterTextPrivate *priv = self->priv;
gfloat x, y, cursor_height;
- ClutterGeometry cursor_pos = { 0, };
- gboolean x_changed, y_changed;
- gboolean width_changed, height_changed;
+ ClutterRect cursor_pos = CLUTTER_RECT_INIT_ZERO;
gint position;
position = priv->position;
@@ -998,21 +996,16 @@ clutter_text_ensure_cursor_position (ClutterText *self)
&x, &y,
&cursor_height);
- cursor_pos.x = x;
- cursor_pos.y = y + 2;
- cursor_pos.width = priv->cursor_size;
- cursor_pos.height = cursor_height - 4;
+ cursor_pos.origin.x = x;
+ cursor_pos.origin.y = y + 2;
+ cursor_pos.size.width = priv->cursor_size;
+ cursor_pos.size.height = cursor_height - 4;
- x_changed = priv->cursor_pos.x != cursor_pos.x;
- y_changed = priv->cursor_pos.y != cursor_pos.y;
- width_changed = priv->cursor_pos.width != cursor_pos.width;
- height_changed = priv->cursor_pos.height != cursor_pos.height;
-
- if (x_changed || y_changed || width_changed || height_changed)
+ if (memcmp (&priv->cursor_pos, &cursor_pos, sizeof (ClutterRect)) != 0)
{
priv->cursor_pos = cursor_pos;
- g_signal_emit (self, text_signals[CURSOR_EVENT], 0, &priv->cursor_pos);
+ g_signal_emit (self, text_signals[CURSOR_EVENT], 0);
}
}
@@ -1588,10 +1581,10 @@ selection_paint (ClutterText *self)
* color->alpha
/ 255);
- cogl_rectangle (priv->cursor_pos.x,
- priv->cursor_pos.y,
- priv->cursor_pos.x + priv->cursor_pos.width,
- priv->cursor_pos.y + priv->cursor_pos.height);
+ cogl_rectangle (priv->cursor_pos.origin.x,
+ priv->cursor_pos.origin.y,
+ priv->cursor_pos.origin.x + priv->cursor_pos.size.width,
+ priv->cursor_pos.origin.y + priv->cursor_pos.size.height);
}
else
{
@@ -2269,7 +2262,7 @@ clutter_text_paint (ClutterActor *self)
if (actor_width < text_width)
{
- gint cursor_x = priv->cursor_pos.x;
+ gint cursor_x = priv->cursor_pos.origin.x;
if (priv->position == -1)
{
@@ -2380,12 +2373,12 @@ clutter_text_get_paint_volume_for_cursor (ClutterText *text,
if (priv->position == priv->selection_bound)
{
- origin.x = priv->cursor_pos.x;
- origin.y = priv->cursor_pos.y;
+ origin.x = priv->cursor_pos.origin.x;
+ origin.y = priv->cursor_pos.origin.y;
origin.z = 0;
clutter_paint_volume_set_origin (volume, &origin);
- clutter_paint_volume_set_width (volume, priv->cursor_pos.width);
- clutter_paint_volume_set_height (volume, priv->cursor_pos.height);
+ clutter_paint_volume_set_width (volume, priv->cursor_pos.size.width);
+ clutter_paint_volume_set_height (volume, priv->cursor_pos.size.height);
}
else
{
@@ -3867,14 +3860,9 @@ clutter_text_class_init (ClutterTextClass *klass)
/**
* ClutterText::cursor-event:
* @self: the #ClutterText that emitted the signal
- * @geometry: the coordinates of the cursor
*
* The ::cursor-event signal is emitted whenever the cursor position
- * changes inside a #ClutterText actor. Inside @geometry it is stored
- * the current position and size of the cursor, relative to the actor
- * itself.
- *
- *
+ * changes inside a #ClutterText actor.
*/
text_signals[CURSOR_EVENT] =
g_signal_new (I_("cursor-event"),
@@ -3882,9 +3870,8 @@ clutter_text_class_init (ClutterTextClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ClutterTextClass, cursor_event),
NULL, NULL,
- _clutter_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- CLUTTER_TYPE_GEOMETRY | G_SIGNAL_TYPE_STATIC_SCOPE);
+ _clutter_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
/**
* ClutterText::activate:
@@ -4062,7 +4049,6 @@ clutter_text_init (ClutterText *self)
priv->text_y = 0;
priv->cursor_size = DEFAULT_CURSOR_SIZE;
- memset (&priv->cursor_pos, 0, sizeof (ClutterGeometry));
priv->settings_changed_id =
g_signal_connect_swapped (clutter_get_default_backend (),
@@ -6123,3 +6109,13 @@ clutter_text_get_layout_offsets (ClutterText *self,
if (y != NULL)
*y = priv->text_y;
}
+
+void
+clutter_text_get_cursor_rect (ClutterText *self,
+ ClutterRect *rect)
+{
+ g_return_if_fail (CLUTTER_IS_TEXT (self));
+ g_return_if_fail (rect != NULL);
+
+ *rect = self->priv->cursor_pos;
+}
diff --git a/clutter/clutter-text.h b/clutter/clutter-text.h
index 0a5e965..0c9f835 100644
--- a/clutter/clutter-text.h
+++ b/clutter/clutter-text.h
@@ -80,8 +80,7 @@ struct _ClutterTextClass
/* signals, not vfuncs */
void (* text_changed) (ClutterText *self);
void (* activate) (ClutterText *self);
- void (* cursor_event) (ClutterText *self,
- const ClutterGeometry *geometry);
+ void (* cursor_event) (ClutterText *self);
/*< private >*/
/* padding for future expansion */
@@ -231,6 +230,8 @@ void clutter_text_set_preedit_string (ClutterText *s
void clutter_text_get_layout_offsets (ClutterText *self,
gint *x,
gint *y);
+void clutter_text_get_cursor_rect (ClutterText *self,
+ ClutterRect *rect);
G_END_DECLS
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 181dc6d..1956d53 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -494,9 +494,6 @@ clutter_gdk_handle_event
clutter_gdk_set_display
clutter_gdk_set_stage_foreign
#endif
-clutter_geometry_get_type
-clutter_geometry_intersects
-clutter_geometry_union
clutter_gesture_action_cancel
clutter_gesture_action_get_device
clutter_gesture_action_get_last_event
@@ -992,6 +989,7 @@ clutter_text_get_chars
clutter_text_get_color
clutter_text_get_cursor_color
clutter_text_get_cursor_position
+clutter_text_get_cursor_rect
clutter_text_get_cursor_size
clutter_text_get_cursor_visible
clutter_text_get_editable
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]