Edje entry: Added cursor_mode to edje to toggle between UNDER (efl/terminal) and BEFORE (gtk/rest of the world) cursor modes.

SVN revision: 56547
This commit is contained in:
Tom Hacohen 2011-01-30 10:46:33 +00:00
parent 20e89e9d01
commit b34172c91e
4 changed files with 75 additions and 3 deletions

View File

@ -128,6 +128,7 @@ static void st_collections_group_parts_part_source5(void);
static void st_collections_group_parts_part_source6(void);
static void st_collections_group_parts_part_entry_mode(void);
static void st_collections_group_parts_part_select_mode(void);
static void st_collections_group_parts_part_cursor_mode(void);
static void st_collections_group_parts_part_multiline(void);
static void st_collections_group_parts_part_dragable_x(void);
static void st_collections_group_parts_part_dragable_y(void);
@ -350,6 +351,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.dragable.events", st_collections_group_parts_part_dragable_events},
{"collections.group.parts.part.entry_mode", st_collections_group_parts_part_entry_mode},
{"collections.group.parts.part.select_mode", st_collections_group_parts_part_select_mode},
{"collections.group.parts.part.cursor_mode", st_collections_group_parts_part_cursor_mode},
{"collections.group.parts.part.multiline", st_collections_group_parts_part_multiline},
{"collections.group.parts.part.image", st_images_image}, /* dup */
{"collections.group.parts.part.set.name", st_images_set_name},
@ -2688,6 +2690,38 @@ st_collections_group_parts_part_select_mode(void)
NULL);
}
/**
@page edcref
@property
cursor_mode
@parameters
[MODE]
@effect
Sets the cursor mode for a textblock part to one of:
@li UNDER
@li BEFORE
UNDER cursor mode means the cursor will draw below the character pointed
at. That's the default.
BEFORE cursor mode means the cursor is drawn as a vertical line before
the current character, just like many other GUI toolkits handle it.
@endproperty
*/
static void
st_collections_group_parts_part_cursor_mode(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
check_arg_count(1);
pc = eina_list_data_get(eina_list_last(edje_collections));
ep = pc->parts[pc->parts_count - 1];
ep->cursor_mode = parse_enum(0,
"UNDER", EDJE_ENTRY_CURSOR_MODE_UNDER,
"BEFORE", EDJE_ENTRY_CURSOR_MODE_BEFORE,
NULL);
}
/**
@page edcref
@property

View File

@ -755,6 +755,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "entry_mode", entry_mode, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "select_mode", select_mode, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "cursor_mode", cursor_mode, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "multiline", multiline, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.name", api.name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.description", api.description, EET_T_STRING);

View File

@ -251,8 +251,19 @@ static void
_curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en)
{
Evas_Coord cx, cy, cw, ch;
Evas_Textblock_Cursor_Type cur_type;
if (c != en->cursor) return;
evas_textblock_cursor_geometry_get(c, &cx, &cy, &cw, &ch, NULL, EVAS_TEXTBLOCK_CURSOR_UNDER);
switch (en->rp->part->cursor_mode)
{
case EDJE_ENTRY_CURSOR_MODE_BEFORE:
cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
break;
case EDJE_ENTRY_CURSOR_MODE_UNDER:
/* no break for a resaon */
default:
cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
}
evas_textblock_cursor_geometry_get(c, &cx, &cy, &cw, &ch, NULL, cur_type);
en->cx = cx + (cw / 2);
en->cy = cy + (ch / 2);
}
@ -1930,14 +1941,25 @@ _edje_entry_real_part_configure(Edje_Real_Part *rp)
{
Evas_Coord x, y, w, h, xx, yy, ww, hh;
Entry *en = rp->entry_data;
Evas_Textblock_Cursor_Type cur_type;
if (!en) return;
switch (rp->part->cursor_mode)
{
case EDJE_ENTRY_CURSOR_MODE_BEFORE:
cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
break;
case EDJE_ENTRY_CURSOR_MODE_UNDER:
/* no break for a resaon */
default:
cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
}
_sel_update(en->cursor, rp->object, en);
_anchors_update(en->cursor, rp->object, en);
x = y = w = h = -1;
xx = yy = ww = hh = -1;
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, EVAS_TEXTBLOCK_CURSOR_UNDER);
evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
if (ww < 1) ww = 1;
if (hh < 1) ww = 1;
if (en->cursor_bg)
@ -2190,12 +2212,23 @@ _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *
{
Evas_Coord x, y, w, h, xx, yy, ww, hh;
Entry *en = rp->entry_data;
Evas_Textblock_Cursor_Type cur_type;
if (!en) return;
switch (rp->part->cursor_mode)
{
case EDJE_ENTRY_CURSOR_MODE_BEFORE:
cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
break;
case EDJE_ENTRY_CURSOR_MODE_UNDER:
/* no break for a resaon */
default:
cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
}
x = y = w = h = -1;
xx = yy = ww = hh = -1;
evas_object_geometry_get(rp->object, &x, &y, &w, &h);
evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, EVAS_TEXTBLOCK_CURSOR_UNDER);
evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
if (ww < 1) ww = 1;
if (hh < 1) ww = 1;
if (cx) *cx = x + xx;

View File

@ -362,6 +362,9 @@ typedef struct _Edje_Part_Box_Animation Edje_Part_Box_Animation;
#define EDJE_ENTRY_SELECTION_MODE_DEFAULT 0
#define EDJE_ENTRY_SELECTION_MODE_EXPLICIT 1
#define EDJE_ENTRY_CURSOR_MODE_UNDER 0
#define EDJE_ENTRY_CURSOR_MODE_BEFORE 1
#define EDJE_PART_PATH_SEPARATOR ':'
#define EDJE_PART_PATH_SEPARATOR_STRING ":"
#define EDJE_PART_PATH_SEPARATOR_INDEXL '['
@ -707,6 +710,7 @@ struct _Edje_Part
unsigned char pointer_mode;
unsigned char entry_mode;
unsigned char select_mode;
unsigned char cursor_mode;
unsigned char multiline;
Edje_Part_Api api;
};