Evas textblock: Added dashed underline support.

Patch by Shilpa Singh

SVN revision: 64131
This commit is contained in:
Tom Hacohen 2011-10-17 10:43:08 +00:00
parent be90232bc0
commit ea9f23ad28
3 changed files with 78 additions and 2 deletions

View File

@ -475,3 +475,13 @@
* Add colorspaces NV12 and MT12 (64 * 32 macro block tiled * Add colorspaces NV12 and MT12 (64 * 32 macro block tiled
format, see Linux videodev documentation for more information). 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

View File

@ -354,7 +354,7 @@ struct _Evas_Object_Textblock_Format
struct { struct {
struct { struct {
unsigned char r, g, b, a; 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; strikethrough;
} color; } color;
struct { struct {
@ -364,6 +364,8 @@ struct _Evas_Object_Textblock_Format
int tabstops; int tabstops;
int linesize; int linesize;
int linegap; int linegap;
int underline_dash_width;
int underline_dash_gap;
double linerelsize; double linerelsize;
double linerelgap; double linerelgap;
double linefill; double linefill;
@ -374,6 +376,7 @@ struct _Evas_Object_Textblock_Format
Eina_Bool wrap_mixed : 1; Eina_Bool wrap_mixed : 1;
Eina_Bool underline : 1; Eina_Bool underline : 1;
Eina_Bool underline2 : 1; Eina_Bool underline2 : 1;
Eina_Bool underline_dash : 1;
Eina_Bool strikethrough : 1; Eina_Bool strikethrough : 1;
Eina_Bool backing : 1; Eina_Bool backing : 1;
Eina_Bool password : 1; Eina_Bool password : 1;
@ -997,6 +1000,7 @@ static const char *langstr = NULL;
static const char *colorstr = NULL; static const char *colorstr = NULL;
static const char *underline_colorstr = NULL; static const char *underline_colorstr = NULL;
static const char *underline2_colorstr = NULL; static const char *underline2_colorstr = NULL;
static const char *underline_dash_colorstr = NULL;
static const char *outline_colorstr = NULL; static const char *outline_colorstr = NULL;
static const char *shadow_colorstr = NULL; static const char *shadow_colorstr = NULL;
static const char *glow_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 *linefillstr = NULL;
static const char *ellipsisstr = NULL; static const char *ellipsisstr = NULL;
static const char *passwordstr = NULL; static const char *passwordstr = NULL;
static const char *underline_dash_widthstr = NULL;
static const char *underline_dash_gapstr = NULL;
/** /**
* @internal * @internal
@ -1042,6 +1048,7 @@ _format_command_init(void)
colorstr = eina_stringshare_add("color"); colorstr = eina_stringshare_add("color");
underline_colorstr = eina_stringshare_add("underline_color"); underline_colorstr = eina_stringshare_add("underline_color");
underline2_colorstr = eina_stringshare_add("underline2_color"); underline2_colorstr = eina_stringshare_add("underline2_color");
underline_dash_colorstr = eina_stringshare_add("underline_dash_color");
outline_colorstr = eina_stringshare_add("outline_color"); outline_colorstr = eina_stringshare_add("outline_color");
shadow_colorstr = eina_stringshare_add("shadow_color"); shadow_colorstr = eina_stringshare_add("shadow_color");
glow_colorstr = eina_stringshare_add("glow_color"); glow_colorstr = eina_stringshare_add("glow_color");
@ -1066,6 +1073,8 @@ _format_command_init(void)
linefillstr = eina_stringshare_add("linefill"); linefillstr = eina_stringshare_add("linefill");
ellipsisstr = eina_stringshare_add("ellipsis"); ellipsisstr = eina_stringshare_add("ellipsis");
passwordstr = eina_stringshare_add("password"); 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++; format_refcount++;
} }
@ -1090,6 +1099,7 @@ _format_command_shutdown(void)
eina_stringshare_del(colorstr); eina_stringshare_del(colorstr);
eina_stringshare_del(underline_colorstr); eina_stringshare_del(underline_colorstr);
eina_stringshare_del(underline2_colorstr); eina_stringshare_del(underline2_colorstr);
eina_stringshare_del(underline_dash_colorstr);
eina_stringshare_del(outline_colorstr); eina_stringshare_del(outline_colorstr);
eina_stringshare_del(shadow_colorstr); eina_stringshare_del(shadow_colorstr);
eina_stringshare_del(glow_colorstr); eina_stringshare_del(glow_colorstr);
@ -1114,6 +1124,8 @@ _format_command_shutdown(void)
eina_stringshare_del(linefillstr); eina_stringshare_del(linefillstr);
eina_stringshare_del(ellipsisstr); eina_stringshare_del(ellipsisstr);
eina_stringshare_del(passwordstr); 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, _format_color_parse(tmp_param,
&(fmt->color.underline2.r), &(fmt->color.underline2.g), &(fmt->color.underline2.r), &(fmt->color.underline2.g),
&(fmt->color.underline2.b), &(fmt->color.underline2.a)); &(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) else if (cmd == outline_colorstr)
_format_color_parse(tmp_param, _format_color_parse(tmp_param,
&(fmt->color.outline.r), &(fmt->color.outline.g), &(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->underline = 1;
fmt->underline2 = 1; fmt->underline2 = 1;
} }
else if (!strcmp(tmp_param, "dashed"))
fmt->underline_dash = 1;
} }
else if (cmd == strikethroughstr) 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")) else if (!strcmp(tmp_param, "on"))
fmt->password = 1; 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->linesize = 0;
fmt->linerelsize = 0.0; fmt->linerelsize = 0.0;
fmt->linegap = 0; fmt->linegap = 0;
fmt->underline_dash_width = 6;
fmt->underline_dash_gap = 2;
fmt->linerelgap = 0.0; fmt->linerelgap = 0.0;
fmt->password = 1; fmt->password = 1;
} }
@ -3161,7 +3191,7 @@ _layout_do_format(const Evas_Object *obj __UNUSED__, Ctxt *c,
if (fmt->underline2) if (fmt->underline2)
c->have_underline2 = 1; c->have_underline2 = 1;
else if (fmt->underline) else if (fmt->underline || fmt->underline_dash)
c->have_underline = 1; c->have_underline = 1;
*_fmt = fmt; *_fmt = fmt;
} }
@ -8960,6 +8990,37 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
} \ } \
while (0) 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) \ #define DRAW_FORMAT(oname, oy, oh, or, og, ob, oa) \
do \ do \
{ \ { \
@ -9192,6 +9253,10 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
/* UNDERLINE */ /* UNDERLINE */
DRAW_FORMAT(underline, ln->baseline + 1, 1, r2, g2, b2, a2); 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 */ /* UNDERLINE2 */
DRAW_FORMAT(underline2, ln->baseline + 3, 1, r3, g3, b3, a3); DRAW_FORMAT(underline2, ln->baseline + 3, 1, r3, g3, b3, a3);
} }

View File

@ -1656,6 +1656,7 @@ START_TEST(evas_textblock_formats)
"<color=#F210B3FF>color=#F210B3FF</><ps>" "<color=#F210B3FF>color=#F210B3FF</><ps>"
"<underline=single underline_color=#A2B3C4>underline=single underline_color=#A2B3C4</><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=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=outline outline_color=#F0FA>style=outline outline_color=#F0FA</><ps>"
"<style=shadow shadow_color=#F0F>style=shadow shadow_color=#F0F</><ps>" "<style=shadow shadow_color=#F0F>style=shadow shadow_color=#F0F</><ps>"
"<style=glow glow_color=#BBB>style=glow glow_color=#BBB</><ps>" "<style=glow glow_color=#BBB>style=glow glow_color=#BBB</><ps>"