Edje entry: Added cursor_mode to edje to toggle between UNDER (efl/terminal) and...
authortasn <tasn>
Sun, 30 Jan 2011 10:46:33 +0000 (10:46 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:46:33 +0000 (10:46 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@56547 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_cc_handlers.c
src/lib/edje_data.c
src/lib/edje_entry.c
src/lib/edje_private.h

index 3613473..ec2ab2e 100644 (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},
@@ -2691,6 +2693,38 @@ st_collections_group_parts_part_select_mode(void)
 /**
     @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
         multiline
     @parameters
         [1 or 0]
index 28fe86d..2c80933 100644 (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);
index 996b38c..1846c98 100644 (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;
index 4611e04..5581706 100644 (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;
 };