Evas textblock: Added dashed underline support.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Oct 2011 10:43:08 +0000 (10:43 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Oct 2011 10:43:08 +0000 (10:43 +0000)
Patch by Shilpa Singh

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@64131 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/canvas/evas_object_textblock.c
src/tests/evas_test_textblock.c

index 30d7a93..96b0394 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * Add colorspaces NV12 and MT12 (64 * 32 macro block tiled
        format, see Linux videodev documentation for more information).
+
+2011-10-17  Shilpa Singh
+
+       * Textblock: Added underline=dashed support.
+       Tag changes:
+        - dashed is a legal value for underline
+       New tags:
+        - underline_dash_color
+        - underline_dash_width
+        - underline_dash_gap
index b87eed5..0d135fe 100644 (file)
@@ -354,7 +354,7 @@ struct _Evas_Object_Textblock_Format
    struct {
       struct {
         unsigned char  r, g, b, a;
-      } normal, underline, underline2, outline, shadow, glow, glow2, backing,
+      } normal, underline, underline2, underline_dash, outline, shadow, glow, glow2, backing,
        strikethrough;
    } color;
    struct {
@@ -364,6 +364,8 @@ struct _Evas_Object_Textblock_Format
    int                  tabstops;
    int                  linesize;
    int                  linegap;
+   int                  underline_dash_width;
+   int                  underline_dash_gap;
    double               linerelsize;
    double               linerelgap;
    double               linefill;
@@ -374,6 +376,7 @@ struct _Evas_Object_Textblock_Format
    Eina_Bool            wrap_mixed : 1;
    Eina_Bool            underline : 1;
    Eina_Bool            underline2 : 1;
+   Eina_Bool            underline_dash : 1;
    Eina_Bool            strikethrough : 1;
    Eina_Bool            backing : 1;
    Eina_Bool            password : 1;
@@ -997,6 +1000,7 @@ static const char *langstr = NULL;
 static const char *colorstr = NULL;
 static const char *underline_colorstr = NULL;
 static const char *underline2_colorstr = NULL;
+static const char *underline_dash_colorstr = NULL;
 static const char *outline_colorstr = NULL;
 static const char *shadow_colorstr = NULL;
 static const char *glow_colorstr = NULL;
@@ -1021,6 +1025,8 @@ static const char *itemstr = NULL;
 static const char *linefillstr = NULL;
 static const char *ellipsisstr = NULL;
 static const char *passwordstr = NULL;
+static const char *underline_dash_widthstr = NULL;
+static const char *underline_dash_gapstr = NULL;
 
 /**
  * @internal
@@ -1042,6 +1048,7 @@ _format_command_init(void)
         colorstr = eina_stringshare_add("color");
         underline_colorstr = eina_stringshare_add("underline_color");
         underline2_colorstr = eina_stringshare_add("underline2_color");
+        underline_dash_colorstr = eina_stringshare_add("underline_dash_color");
         outline_colorstr = eina_stringshare_add("outline_color");
         shadow_colorstr = eina_stringshare_add("shadow_color");
         glow_colorstr = eina_stringshare_add("glow_color");
@@ -1066,6 +1073,8 @@ _format_command_init(void)
         linefillstr = eina_stringshare_add("linefill");
         ellipsisstr = eina_stringshare_add("ellipsis");
         passwordstr = eina_stringshare_add("password");
+        underline_dash_widthstr = eina_stringshare_add("underline_dash_width");
+        underline_dash_gapstr = eina_stringshare_add("underline_dash_gap");
      }
    format_refcount++;
 }
@@ -1090,6 +1099,7 @@ _format_command_shutdown(void)
    eina_stringshare_del(colorstr);
    eina_stringshare_del(underline_colorstr);
    eina_stringshare_del(underline2_colorstr);
+   eina_stringshare_del(underline_dash_colorstr);
    eina_stringshare_del(outline_colorstr);
    eina_stringshare_del(shadow_colorstr);
    eina_stringshare_del(glow_colorstr);
@@ -1114,6 +1124,8 @@ _format_command_shutdown(void)
    eina_stringshare_del(linefillstr);
    eina_stringshare_del(ellipsisstr);
    eina_stringshare_del(passwordstr);
+   eina_stringshare_del(underline_dash_widthstr);
+   eina_stringshare_del(underline_dash_gapstr);
 }
 
 /**
@@ -1234,6 +1246,10 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char
      _format_color_parse(tmp_param,
            &(fmt->color.underline2.r), &(fmt->color.underline2.g),
            &(fmt->color.underline2.b), &(fmt->color.underline2.a));
+   else if (cmd == underline_dash_colorstr)
+     _format_color_parse(tmp_param,
+           &(fmt->color.underline_dash.r), &(fmt->color.underline_dash.g),
+           &(fmt->color.underline_dash.b), &(fmt->color.underline_dash.a));
    else if (cmd == outline_colorstr)
      _format_color_parse(tmp_param,
            &(fmt->color.outline.r), &(fmt->color.outline.g),
@@ -1382,6 +1398,8 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char
              fmt->underline = 1;
              fmt->underline2 = 1;
           }
+        else if (!strcmp(tmp_param, "dashed"))
+          fmt->underline_dash = 1;
      }
    else if (cmd == strikethroughstr)
      {
@@ -1542,6 +1560,16 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char
         else if (!strcmp(tmp_param, "on"))
           fmt->password = 1;
      }
+   else if (cmd == underline_dash_widthstr)
+     {
+        fmt->underline_dash_width = atoi(tmp_param);
+        if (fmt->underline_dash_width <= 0) fmt->underline_dash_width = 1;
+     }
+   else if (cmd == underline_dash_gapstr)
+     {
+        fmt->underline_dash_gap = atoi(tmp_param);
+        if (fmt->underline_dash_gap <= 0) fmt->underline_dash_gap = 1;
+     }
 }
 
 /**
@@ -2077,6 +2105,8 @@ _layout_format_push(Ctxt *c, Evas_Object_Textblock_Format *fmt,
         fmt->linesize = 0;
         fmt->linerelsize = 0.0;
         fmt->linegap = 0;
+        fmt->underline_dash_width = 6;
+        fmt->underline_dash_gap = 2;
         fmt->linerelgap = 0.0;
         fmt->password = 1;
      }
@@ -3161,7 +3191,7 @@ _layout_do_format(const Evas_Object *obj __UNUSED__, Ctxt *c,
 
    if (fmt->underline2)
      c->have_underline2 = 1;
-   else if (fmt->underline)
+   else if (fmt->underline || fmt->underline_dash)
      c->have_underline = 1;
    *_fmt = fmt;
 }
@@ -8960,6 +8990,37 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
      } \
    while (0)
 
+#define DRAW_FORMAT_DASHED(oname, oy, oh, or, og, ob, oa, dw, dp) \
+   do \
+     { \
+        if (itr->format->oname) \
+          { \
+             int i, dx = 0, dn, dr; \
+             or = itr->format->color.oname.r; \
+             og = itr->format->color.oname.g; \
+             ob = itr->format->color.oname.b; \
+             oa = itr->format->color.oname.a; \
+             if (!EINA_INLIST_GET(itr)->next) \
+               { \
+                  dn = itr->w / (dw + dp); \
+                  dr = itr->w % (dw + dp); \
+               } \
+             else \
+               { \
+                  dn = itr->adv / (dw + dp); \
+                  dr = itr->adv % (dw + dp); \
+               } \
+             if (dr > dw) dr = dw; \
+             for (i = dn; i > 0 ; i--) \
+               { \
+                  DRAW_RECT(itr->x + dx, oy, dw, oh, or, og, ob, oa); \
+                  dx += dw + dp; \
+               } \
+             DRAW_RECT(itr->x + dx, oy, dr, oh, or, og, ob, oa); \
+          } \
+     } \
+   while (0)
+
 #define DRAW_FORMAT(oname, oy, oh, or, og, ob, oa) \
    do \
      { \
@@ -9192,6 +9253,10 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
         /* UNDERLINE */
         DRAW_FORMAT(underline, ln->baseline + 1, 1, r2, g2, b2, a2);
 
+        /* UNDERLINE DASHED */
+        DRAW_FORMAT_DASHED(underline_dash, ln->baseline + 1, 1, r2, g2, b2, a2,
+                         ti->parent.format->underline_dash_width, ti->parent.format->underline_dash_gap);
+
         /* UNDERLINE2 */
         DRAW_FORMAT(underline2, ln->baseline + 3, 1, r3, g3, b3, a3);
      }
index 8252109..6a28353 100644 (file)
@@ -1656,6 +1656,7 @@ START_TEST(evas_textblock_formats)
          "<color=#F210B3FF>color=#F210B3FF</><ps>"
          "<underline=single underline_color=#A2B3C4>underline=single underline_color=#A2B3C4</><ps>"
          "<underline=double underline_color=#F00 underline2_color=#00F>underline=double underline_color=#F00 underline2_color=#00F</><ps>"
+         "<underline=dashed underline_dash_color=#0F0 underline_dash_width=2 underline_dash_gap=1>underline=dashed underline_dash_color=#0F0 underline_dash_width=2 underline_dash_gap=1</><ps>"
          "<style=outline outline_color=#F0FA>style=outline outline_color=#F0FA</><ps>"
          "<style=shadow shadow_color=#F0F>style=shadow shadow_color=#F0F</><ps>"
          "<style=glow glow_color=#BBB>style=glow glow_color=#BBB</><ps>"