mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
Added signal to track cursor movements\nMoved the curor painting function into the class functions so it can be sub-classed
This commit is contained in:
parent
d82c068faf
commit
214a2ead22
13
ChangeLog
13
ChangeLog
@ -1,4 +1,15 @@
|
|||||||
2007-06-01 Tomas Frydrych <tf@openedhand.com>
|
2007-06-01 Neil J. Patel <njp@o-hand.com>
|
||||||
|
|
||||||
|
* clutter/clutter-entry.c: (clutter_entry_ensure_cursor_position),
|
||||||
|
(clutter_entry_clear_cursor_position),
|
||||||
|
(clutter_entry_paint_cursor), (clutter_entry_paint),
|
||||||
|
(clutter_entry_class_init), (clutter_entry_set_text),
|
||||||
|
(clutter_entry_set_position):
|
||||||
|
* clutter/clutter-entry.h:
|
||||||
|
Added a signla to track cursor movements.
|
||||||
|
Moved the sursor painting function so it can be subclassed.
|
||||||
|
|
||||||
|
007-06-01 Tomas Frydrych <tf@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-actor.c:
|
* clutter/clutter-actor.c:
|
||||||
(clutter_actor_get_transformed_point):
|
(clutter_actor_get_transformed_point):
|
||||||
|
@ -39,12 +39,14 @@
|
|||||||
#include "clutter-enum-types.h"
|
#include "clutter-enum-types.h"
|
||||||
#include "clutter-keysyms.h"
|
#include "clutter-keysyms.h"
|
||||||
#include "clutter-main.h"
|
#include "clutter-main.h"
|
||||||
|
#include "clutter-marshal.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-rectangle.h"
|
#include "clutter-rectangle.h"
|
||||||
#include "clutter-units.h"
|
#include "clutter-units.h"
|
||||||
#include "pangoclutter.h"
|
#include "pangoclutter.h"
|
||||||
|
|
||||||
#define DEFAULT_FONT_NAME "Sans 10"
|
#define DEFAULT_FONT_NAME "Sans 10"
|
||||||
|
#define ENTRY_CURSOR_WIDTH 1
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterEntry, clutter_entry, CLUTTER_TYPE_ACTOR);
|
G_DEFINE_TYPE (ClutterEntry, clutter_entry, CLUTTER_TYPE_ACTOR);
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ enum
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TEXT_CHANGED,
|
TEXT_CHANGED,
|
||||||
|
CURSOR_EVENT,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
@ -102,7 +105,7 @@ struct _ClutterEntryPrivate
|
|||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
gint width_chars;
|
gint width_chars;
|
||||||
|
|
||||||
PangoRectangle cursor_pos;
|
ClutterGeometry cursor_pos;
|
||||||
ClutterActor *cursor;
|
ClutterActor *cursor;
|
||||||
gboolean show_cursor;
|
gboolean show_cursor;
|
||||||
};
|
};
|
||||||
@ -238,7 +241,8 @@ static void
|
|||||||
clutter_entry_ensure_cursor_position (ClutterEntry *entry)
|
clutter_entry_ensure_cursor_position (ClutterEntry *entry)
|
||||||
{
|
{
|
||||||
ClutterEntryPrivate *priv;
|
ClutterEntryPrivate *priv;
|
||||||
gint index;
|
gint index;
|
||||||
|
PangoRectangle rect;
|
||||||
|
|
||||||
priv = entry->priv;
|
priv = entry->priv;
|
||||||
|
|
||||||
@ -247,15 +251,43 @@ clutter_entry_ensure_cursor_position (ClutterEntry *entry)
|
|||||||
else
|
else
|
||||||
index = priv->position;
|
index = priv->position;
|
||||||
|
|
||||||
pango_layout_get_cursor_pos (priv->layout, index,
|
if (priv->cursor_pos.width == 0)
|
||||||
&priv->cursor_pos, NULL);
|
{
|
||||||
|
pango_layout_get_cursor_pos (priv->layout, index, &rect, NULL);
|
||||||
|
priv->cursor_pos.x = rect.x / PANGO_SCALE;
|
||||||
|
priv->cursor_pos.y = rect.y / PANGO_SCALE;
|
||||||
|
priv->cursor_pos.width = ENTRY_CURSOR_WIDTH;
|
||||||
|
priv->cursor_pos.height = rect.height / PANGO_SCALE;
|
||||||
|
|
||||||
clutter_actor_set_size (CLUTTER_ACTOR (priv->cursor),
|
g_signal_emit (entry, entry_signals[CURSOR_EVENT], 0, &priv->cursor_pos);
|
||||||
1, priv->cursor_pos.height/ PANGO_SCALE);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clutter_actor_set_position (priv->cursor,
|
static void
|
||||||
priv->cursor_pos.x/ PANGO_SCALE,
|
clutter_entry_clear_cursor_position (ClutterEntry *entry)
|
||||||
priv->cursor_pos.y/ PANGO_SCALE);
|
{
|
||||||
|
entry->priv->cursor_pos.width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_entry_paint_cursor (ClutterEntry *entry)
|
||||||
|
{
|
||||||
|
ClutterEntryPrivate *priv;
|
||||||
|
|
||||||
|
priv = entry->priv;
|
||||||
|
|
||||||
|
if (priv->show_cursor)
|
||||||
|
{
|
||||||
|
clutter_actor_set_size (CLUTTER_ACTOR (priv->cursor),
|
||||||
|
priv->cursor_pos.width,
|
||||||
|
priv->cursor_pos.height);
|
||||||
|
|
||||||
|
clutter_actor_set_position (priv->cursor,
|
||||||
|
priv->cursor_pos.x,
|
||||||
|
priv->cursor_pos.y);
|
||||||
|
|
||||||
|
clutter_actor_paint (priv->cursor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -277,14 +309,14 @@ clutter_entry_paint (ClutterActor *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
clutter_entry_ensure_layout (entry, clutter_actor_get_width(self));
|
clutter_entry_ensure_layout (entry, clutter_actor_get_width(self));
|
||||||
|
clutter_entry_ensure_cursor_position (entry);
|
||||||
priv->fgcol.alpha = clutter_actor_get_opacity(self);
|
priv->fgcol.alpha = clutter_actor_get_opacity(self);
|
||||||
|
|
||||||
pango_clutter_render_layout (priv->layout, 0, 0, &priv->fgcol, 0);
|
pango_clutter_render_layout (priv->layout, 0, 0, &priv->fgcol, 0);
|
||||||
|
|
||||||
if (priv->show_cursor)
|
if (CLUTTER_ENTRY_GET_CLASS (entry)->paint_cursor != NULL)
|
||||||
{
|
{
|
||||||
clutter_entry_ensure_cursor_position (entry);
|
CLUTTER_ENTRY_GET_CLASS (entry)->paint_cursor (entry);
|
||||||
clutter_actor_paint (priv->cursor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +375,8 @@ clutter_entry_class_init (ClutterEntryClass *klass)
|
|||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||||
|
|
||||||
|
klass->paint_cursor = clutter_entry_paint_cursor;
|
||||||
|
|
||||||
actor_class->paint = clutter_entry_paint;
|
actor_class->paint = clutter_entry_paint;
|
||||||
actor_class->request_coords = clutter_entry_request_coords;
|
actor_class->request_coords = clutter_entry_request_coords;
|
||||||
|
|
||||||
@ -384,6 +418,11 @@ clutter_entry_class_init (ClutterEntryClass *klass)
|
|||||||
PANGO_ALIGN_LEFT,
|
PANGO_ALIGN_LEFT,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterEntry:position
|
||||||
|
*
|
||||||
|
* The current input cursor position. -1 is taken to be the end of the text
|
||||||
|
*/
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(gobject_class, PROP_POSITION,
|
(gobject_class, PROP_POSITION,
|
||||||
g_param_spec_int ( "position",
|
g_param_spec_int ( "position",
|
||||||
@ -393,11 +432,16 @@ clutter_entry_class_init (ClutterEntryClass *klass)
|
|||||||
-1,
|
-1,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterEntry:cursor-visible
|
||||||
|
*
|
||||||
|
* Whether the input cursor is visible
|
||||||
|
*/
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(gobject_class, PROP_CURSOR,
|
(gobject_class, PROP_CURSOR,
|
||||||
g_param_spec_boolean ( "cursor-visible",
|
g_param_spec_boolean ( "cursor-visible",
|
||||||
"Cursor Visible",
|
"Cursor Visible",
|
||||||
"Whether the input cursor is visible ",
|
"Whether the input cursor is visible",
|
||||||
TRUE,
|
TRUE,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
@ -417,6 +461,26 @@ clutter_entry_class_init (ClutterEntryClass *klass)
|
|||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterEntry::cursor-event:
|
||||||
|
* @entry: the actor which received the event
|
||||||
|
* @geometry: a #ClutterGeometry
|
||||||
|
*
|
||||||
|
* The ::cursor-event signal is emitted each time the input cursors geometry
|
||||||
|
* changes, this could be a positional or size change. If you would like to
|
||||||
|
* implement your own input cursor, set the cursor-visible property to FALSE,
|
||||||
|
* and connect to this signal to position and size your own cursor.
|
||||||
|
*/
|
||||||
|
entry_signals[CURSOR_EVENT] =
|
||||||
|
g_signal_new ("cursor-event",
|
||||||
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (ClutterEntryClass, cursor_event),
|
||||||
|
NULL, NULL,
|
||||||
|
clutter_marshal_VOID__BOXED,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
CLUTTER_TYPE_GEOMETRY | G_SIGNAL_TYPE_STATIC_SCOPE);
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (ClutterEntryPrivate));
|
g_type_class_add_private (gobject_class, sizeof (ClutterEntryPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,6 +627,7 @@ clutter_entry_set_text (ClutterEntry *entry,
|
|||||||
priv->text = g_strdup (text);
|
priv->text = g_strdup (text);
|
||||||
|
|
||||||
clutter_entry_clear_layout (entry);
|
clutter_entry_clear_layout (entry);
|
||||||
|
clutter_entry_clear_cursor_position (entry);
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(entry)))
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(entry)))
|
||||||
clutter_actor_queue_redraw (CLUTTER_ACTOR(entry));
|
clutter_actor_queue_redraw (CLUTTER_ACTOR(entry));
|
||||||
@ -819,6 +884,8 @@ clutter_entry_set_position (ClutterEntry *entry, gint position)
|
|||||||
else
|
else
|
||||||
priv->position = position;
|
priv->position = position;
|
||||||
|
|
||||||
|
clutter_entry_clear_cursor_position (entry);
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(entry)))
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(entry)))
|
||||||
clutter_actor_queue_redraw (CLUTTER_ACTOR(entry));
|
clutter_actor_queue_redraw (CLUTTER_ACTOR(entry));
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,13 @@ struct _ClutterEntryClass
|
|||||||
/*< private >*/
|
/*< private >*/
|
||||||
ClutterActorClass parent_class;
|
ClutterActorClass parent_class;
|
||||||
|
|
||||||
|
/* vfuncs, not signals */
|
||||||
|
void (* paint_cursor) (ClutterEntry *entry);
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* text_changed) (ClutterEntry *stage);
|
void (* text_changed) (ClutterEntry *entry);
|
||||||
|
void (* cursor_event) (ClutterEntry *entry,
|
||||||
|
ClutterGeometry *geometry);
|
||||||
|
|
||||||
/* padding for future */
|
/* padding for future */
|
||||||
void (*_clutter_entry_1) (void);
|
void (*_clutter_entry_1) (void);
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2007-06-01 Neil J. Patel <njp@o-hand.com>
|
||||||
|
* clutter.types:
|
||||||
|
* tmpl/clutter-entry.sgml:
|
||||||
|
Updated for new signals/properties.
|
||||||
|
|
||||||
2007-06-01 Neil J. Patel <njp@o-hand.com>
|
2007-06-01 Neil J. Patel <njp@o-hand.com>
|
||||||
|
|
||||||
* clutter-sections.txt:
|
* clutter-sections.txt:
|
||||||
|
@ -19,3 +19,4 @@ clutter_behaviour_rotate_get_type
|
|||||||
clutter_behaviour_scale_get_type
|
clutter_behaviour_scale_get_type
|
||||||
clutter_backend_get_type
|
clutter_backend_get_type
|
||||||
clutter_vertices_get_type
|
clutter_vertices_get_type
|
||||||
|
clutter_entry_get_type
|
||||||
|
@ -22,7 +22,51 @@ ClutterEntry
|
|||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@parent:
|
|
||||||
|
<!-- ##### SIGNAL ClutterEntry::cursor-event ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@clutterentry: the object which received the signal.
|
||||||
|
@arg1:
|
||||||
|
|
||||||
|
<!-- ##### SIGNAL ClutterEntry::text-changed ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@clutterentry: the object which received the signal.
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:alignment ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:color ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:cursor-visible ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:font-name ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:position ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### ARG ClutterEntry:text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
<!-- ##### STRUCT ClutterEntryClass ##### -->
|
<!-- ##### STRUCT ClutterEntryClass ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
Reference in New Issue
Block a user