many more shadow options (8 shadow directions now)

SVN revision: 58546
This commit is contained in:
Carsten Haitzler 2011-04-11 12:05:59 +00:00
parent 0f42616889
commit 5bc7805b28
3 changed files with 397 additions and 178 deletions

View File

@ -5234,6 +5234,10 @@ EAPI Eina_Bool evas_object_image_source_unset (Evas_Obj
*/ */
typedef enum _Evas_Text_Style_Type typedef enum _Evas_Text_Style_Type
{ {
/* basic styles (4 bits allocatedm use 0->10 now, 5 left) */
#define EVAS_TEXT_STYLE_MASK_BASIC 0xf
#define EVAS_TEXT_STYLE_BASIC_SET(x, s) \
do { x = ((x) & ~EVAS_TEXT_STYLE_MASK_BASIC) | (s); } while (0)
EVAS_TEXT_STYLE_PLAIN, EVAS_TEXT_STYLE_PLAIN,
EVAS_TEXT_STYLE_SHADOW, EVAS_TEXT_STYLE_SHADOW,
EVAS_TEXT_STYLE_OUTLINE, EVAS_TEXT_STYLE_OUTLINE,
@ -5243,9 +5247,21 @@ EAPI Eina_Bool evas_object_image_source_unset (Evas_Obj
EVAS_TEXT_STYLE_FAR_SHADOW, EVAS_TEXT_STYLE_FAR_SHADOW,
EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW, EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW,
EVAS_TEXT_STYLE_SOFT_SHADOW, EVAS_TEXT_STYLE_SOFT_SHADOW,
EVAS_TEXT_STYLE_FAR_SOFT_SHADOW EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
#define EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION (0x7 << 4)
#define EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(x, s) \
do { x = ((x) & ~EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION) | (s); } while (0)
/* OR these to modify shadow direction (3 bits needed) */
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT = (0x0 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM = (0x1 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT = (0x2 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT = (0x3 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT = (0x4 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP = (0x5 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT = (0x6 << 4),
EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT = (0x7 << 4)
} Evas_Text_Style_Type; } Evas_Text_Style_Type;
/** /**
* Creates a new text @c Evas_Object on the provided @c Evas canvas. * Creates a new text @c Evas_Object on the provided @c Evas canvas.
@ -5259,6 +5275,7 @@ EAPI Eina_Bool evas_object_image_source_unset (Evas_Obj
* @returns NULL on error, A pointer to a new @c Evas_Object on success. * @returns NULL on error, A pointer to a new @c Evas_Object on success.
*/ */
EAPI Evas_Object *evas_object_text_add (Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Evas_Object *evas_object_text_add (Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
EAPI void evas_object_text_font_source_set (Evas_Object *obj, const char *font) EINA_ARG_NONNULL(1); EAPI void evas_object_text_font_source_set (Evas_Object *obj, const char *font) EINA_ARG_NONNULL(1);
EAPI const char *evas_object_text_font_source_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE; EAPI const char *evas_object_text_font_source_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI void evas_object_text_font_set (Evas_Object *obj, const char *font, Evas_Font_Size size) EINA_ARG_NONNULL(1); EAPI void evas_object_text_font_set (Evas_Object *obj, const char *font, Evas_Font_Size size) EINA_ARG_NONNULL(1);

View File

@ -25,7 +25,7 @@ struct _Evas_Object_Text
unsigned char r, g, b, a; unsigned char r, g, b, a;
} outline, shadow, glow, glow2; } outline, shadow, glow, glow2;
unsigned char style; unsigned char style;
} cur, prev; } cur, prev;
float ascent, descent; float ascent, descent;
@ -1367,77 +1367,107 @@ evas_string_char_len_get(const char *str)
void void
evas_text_style_pad_get(Evas_Text_Style_Type style, int *l, int *r, int *t, int *b) evas_text_style_pad_get(Evas_Text_Style_Type style, int *l, int *r, int *t, int *b)
{ {
int sl, sr, st, sb; int shad_sz = 0, shad_dst = 0, out_sz = 0;
int dx = 0, minx = 0, maxx = 0, shx1, shx2;
int dy = 0, miny = 0, maxy = 0, shy1, shy2;
int sl = 0, sr = 0, st = 0, sb = 0;
switch (style & EVAS_TEXT_STYLE_MASK_BASIC)
{
case EVAS_TEXT_STYLE_SHADOW:
shad_dst = 1;
break;
case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
case EVAS_TEXT_STYLE_FAR_SHADOW:
shad_dst = 2;
out_sz = 1;
break;
case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
shad_dst = 1;
shad_sz = 2;
out_sz = 1;
break;
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
shad_dst = 2;
shad_sz = 2;
break;
case EVAS_TEXT_STYLE_SOFT_SHADOW:
shad_dst = 1;
shad_sz = 2;
break;
case EVAS_TEXT_STYLE_GLOW:
case EVAS_TEXT_STYLE_SOFT_OUTLINE:
out_sz = 2;
break;
case EVAS_TEXT_STYLE_OUTLINE:
out_sz = 1;
break;
default:
break;
}
switch (style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
{
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
dx = 1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
dx = 0;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
dx = -1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
dx = -1;
dy = 0;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
dx = -1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
dx = 0;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
dx = 1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
dx = 1;
dy = 0;
default:
break;
}
minx = -out_sz;
maxx = out_sz;
shx1 = dx * shad_dst;
shx1 -= shad_sz;
shx2 = dx * shad_dst;
shx2 += shad_sz;
if (shx1 < minx) minx = shx1;
if (shx2 > maxx) maxx = shx2;
miny = -out_sz;
maxy = out_sz;
shy1 = dy * shad_dst;
shy1 -= shad_sz;
shy2 = dy * shad_dst;
shy2 += shad_sz;
if (shy1 < miny) miny = shy1;
if (shy2 > maxy) maxy = shy2;
if (l) sl = *l; if (l) sl = *l;
else sl = 0;
if (r) sr = *r; if (r) sr = *r;
else sr = 0;
if (t) st = *t; if (t) st = *t;
else st = 0;
if (b) sb = *b; if (b) sb = *b;
else sb = 0;
if (style == EVAS_TEXT_STYLE_SHADOW) if (sr < maxx) sr = maxx;
{ if (sl < -minx) sl = -minx;
if (sr < 1) sr = 1; if (sb < maxy) sb = maxy;
if (sb < 1) sb = 1; if (st < -miny) st = -miny;
}
else if (style == EVAS_TEXT_STYLE_OUTLINE)
{
if (sl < 1) sl = 1;
if (sr < 1) sr = 1;
if (st < 1) st = 1;
if (sb < 1) sb = 1;
}
else if (style == EVAS_TEXT_STYLE_SOFT_OUTLINE)
{
if (sl < 2) sl = 2;
if (sr < 2) sr = 2;
if (st < 2) st = 2;
if (sb < 2) sb = 2;
}
else if (style == EVAS_TEXT_STYLE_GLOW)
{
if (sl < 2) sl = 2;
if (sr < 2) sr = 2;
if (st < 2) st = 2;
if (sb < 2) sb = 2;
}
else if (style == EVAS_TEXT_STYLE_OUTLINE_SHADOW)
{
if (sl < 1) sl = 1;
if (sr < 2) sr = 2;
if (st < 1) st = 1;
if (sb < 2) sb = 2;
}
else if (style == EVAS_TEXT_STYLE_FAR_SHADOW)
{
if (sr < 2) sr = 2;
if (sb < 2) sb = 2;
}
else if (style == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW)
{
if (sl < 1) sl = 1;
if (sr < 3) sr = 3;
if (st < 1) st = 1;
if (sb < 3) sb = 3;
}
else if (style == EVAS_TEXT_STYLE_SOFT_SHADOW)
{
if (sl < 1) sl = 1;
if (sr < 3) sr = 3;
if (st < 1) st = 1;
if (sb < 3) sb = 3;
}
else if (style == EVAS_TEXT_STYLE_FAR_SOFT_SHADOW)
{
if (sr < 4) sr = 4;
if (sb < 4) sb = 4;
}
if (l) *l = sl; if (l) *l = sl;
if (r) *r = sr; if (r) *r = sr;
@ -1600,48 +1630,95 @@ evas_object_text_render(Evas_Object *obj, void *output, void *context, void *sur
it->text, &it->text_props); it->text, &it->text_props);
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it) EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
{ {
/* shadows */ int shad_dst, shad_sz, dx, dy;
if (o->cur.style == EVAS_TEXT_STYLE_SHADOW)
{
COLOR_SET(o, cur, shadow);
DRAW_TEXT(1, 1);
}
else if ((o->cur.style == EVAS_TEXT_STYLE_OUTLINE_SHADOW) ||
(o->cur.style == EVAS_TEXT_STYLE_FAR_SHADOW))
{
COLOR_SET(o, cur, shadow);
DRAW_TEXT(2, 2);
}
else if ((o->cur.style == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW) ||
(o->cur.style == EVAS_TEXT_STYLE_FAR_SOFT_SHADOW))
{
for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
{
if (vals[i][j] != 0)
{
COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
DRAW_TEXT(i, j);
}
}
}
}
else if (o->cur.style == EVAS_TEXT_STYLE_SOFT_SHADOW)
{
for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
{
if (vals[i][j] != 0)
{
COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
DRAW_TEXT(i - 1, j - 1);
}
}
}
}
/* shadows */
shad_dst = shad_sz = dx = dy = 0;
switch (o->cur.style & EVAS_TEXT_STYLE_MASK_BASIC)
{
case EVAS_TEXT_STYLE_SHADOW:
case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
shad_dst = 1;
break;
case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
case EVAS_TEXT_STYLE_FAR_SHADOW:
shad_dst = 2;
break;
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
shad_dst = 2;
shad_sz = 2;
break;
case EVAS_TEXT_STYLE_SOFT_SHADOW:
shad_dst = 1;
shad_sz = 2;
break;
default:
break;
}
if (shad_dst > 0)
{
switch (o->cur.style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
{
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
dx = 1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
dx = 0;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
dx = -1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
dx = -1;
dy = 0;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
dx = -1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
dx = 0;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
dx = 1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
dx = 1;
dy = 0;
default:
break;
}
dx *= shad_dst;
dy *= shad_dst;
}
switch (shad_sz)
{
case 0:
COLOR_SET(o, cur, shadow);
DRAW_TEXT(dx, dy);
break;
case 2:
for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
{
if (vals[i][j] != 0)
{
COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
DRAW_TEXT(i - 2 + dx, j - 2 + dy);
}
}
}
break;
default:
break;
}
/* glows */ /* glows */
if (o->cur.style == EVAS_TEXT_STYLE_GLOW) if (o->cur.style == EVAS_TEXT_STYLE_GLOW)
{ {

View File

@ -287,16 +287,14 @@ struct _Evas_Object_Textblock_Format_Item
struct _Evas_Object_Textblock_Format struct _Evas_Object_Textblock_Format
{ {
int ref;
double halign; double halign;
Eina_Bool halign_auto;
double valign; double valign;
struct { struct {
const char *name; const char *name;
const char *source; const char *source;
const char *fallbacks; const char *fallbacks;
int size;
void *font; void *font;
int size;
} font; } font;
struct { struct {
struct { struct {
@ -307,13 +305,15 @@ struct _Evas_Object_Textblock_Format
struct { struct {
int l, r; int l, r;
} margin; } margin;
int ref;
int tabstops; int tabstops;
int linesize; int linesize;
double linerelsize;
int linegap; int linegap;
double linerelsize;
double linerelgap; double linerelgap;
double linefill; double linefill;
double ellipsis; double ellipsis;
Eina_Bool halign_auto;
unsigned char style; unsigned char style;
unsigned char wrap_word : 1; unsigned char wrap_word : 1;
unsigned char wrap_char : 1; unsigned char wrap_char : 1;
@ -1125,9 +1125,11 @@ static void
_format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char *cmd, const char *param) _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char *cmd, const char *param)
{ {
int new_font = 0; int new_font = 0;
int len;
char *tmp_param; char *tmp_param;
tmp_param = alloca(strlen(param) + 1); len = strlen(param);
tmp_param = alloca(len + 1);
_format_clean_param(tmp_param, param); _format_clean_param(tmp_param, param);
if (cmd == fontstr) if (cmd == fontstr)
@ -1351,19 +1353,60 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char
} }
else if (cmd == stylestr) else if (cmd == stylestr)
{ {
if (!strcmp(tmp_param, "off")) fmt->style = EVAS_TEXT_STYLE_PLAIN; char *p1, *p2, *p, *pp;
else if (!strcmp(tmp_param, "none")) fmt->style = EVAS_TEXT_STYLE_PLAIN;
else if (!strcmp(tmp_param, "plain")) fmt->style = EVAS_TEXT_STYLE_PLAIN; p1 = alloca(len + 1);
else if (!strcmp(tmp_param, "shadow")) fmt->style = EVAS_TEXT_STYLE_SHADOW; *p1 = 0;
else if (!strcmp(tmp_param, "outline")) fmt->style = EVAS_TEXT_STYLE_OUTLINE; p2 = alloca(len + 1);
else if (!strcmp(tmp_param, "soft_outline")) fmt->style = EVAS_TEXT_STYLE_SOFT_OUTLINE; *p2 = 0;
else if (!strcmp(tmp_param, "outline_shadow")) fmt->style = EVAS_TEXT_STYLE_OUTLINE_SHADOW; /* no comma */
else if (!strcmp(tmp_param, "outline_soft_shadow")) fmt->style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW; if (!strstr(tmp_param, ",")) p1 = tmp_param;
else if (!strcmp(tmp_param, "glow")) fmt->style = EVAS_TEXT_STYLE_GLOW; else
else if (!strcmp(tmp_param, "far_shadow")) fmt->style = EVAS_TEXT_STYLE_FAR_SHADOW; {
else if (!strcmp(tmp_param, "soft_shadow")) fmt->style = EVAS_TEXT_STYLE_SOFT_SHADOW; /* split string "str1,str2" into p1 and p2 (if we have more than
else if (!strcmp(tmp_param, "far_soft_shadow")) fmt->style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW; * 1 str2 eg "str1,str2,str3,str4" then we don't care. p2 just
else fmt->style = EVAS_TEXT_STYLE_PLAIN; * ends up being the last one as right now it's only valid to have
* 1 comma and 2 strings */
pp = p1;
for (p = tmp_param; *p; p++)
{
if (*p == ',')
{
*pp = 0;
pp = p2;
continue;
}
*pp = *p;
pp++;
}
*pp = 0;
}
if (!strcmp(p1, "off")) fmt->style = EVAS_TEXT_STYLE_PLAIN;
else if (!strcmp(p1, "none")) fmt->style = EVAS_TEXT_STYLE_PLAIN;
else if (!strcmp(p1, "plain")) fmt->style = EVAS_TEXT_STYLE_PLAIN;
else if (!strcmp(p1, "shadow")) fmt->style = EVAS_TEXT_STYLE_SHADOW;
else if (!strcmp(p1, "outline")) fmt->style = EVAS_TEXT_STYLE_OUTLINE;
else if (!strcmp(p1, "soft_outline")) fmt->style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
else if (!strcmp(p1, "outline_shadow")) fmt->style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
else if (!strcmp(p1, "outline_soft_shadow")) fmt->style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
else if (!strcmp(p1, "glow")) fmt->style = EVAS_TEXT_STYLE_GLOW;
else if (!strcmp(p1, "far_shadow")) fmt->style = EVAS_TEXT_STYLE_FAR_SHADOW;
else if (!strcmp(p1, "soft_shadow")) fmt->style = EVAS_TEXT_STYLE_SOFT_SHADOW;
else if (!strcmp(p1, "far_soft_shadow")) fmt->style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW;
else fmt->style = EVAS_TEXT_STYLE_PLAIN;
if (*p2)
{
if (!strcmp(p2, "bottom_right")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
else if (!strcmp(p2, "bottom")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM);
else if (!strcmp(p2, "bottom_left")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT);
else if (!strcmp(p2, "left")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT);
else if (!strcmp(p2, "top_left")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT);
else if (!strcmp(p2, "top")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP);
else if (!strcmp(p2, "top_right")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT);
else if (!strcmp(p2, "right")) EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT);
else EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(fmt->style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
}
} }
else if (cmd == tabstopsstr) else if (cmd == tabstopsstr)
{ {
@ -2517,6 +2560,8 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti)
{ {
int tw, th, inset, right_inset; int tw, th, inset, right_inset;
const Evas_Object_Textblock_Format *fmt = ti->parent.format; const Evas_Object_Textblock_Format *fmt = ti->parent.format;
int shad_sz = 0, shad_dst = 0, out_sz = 0;
int dx = 0, minx = 0, maxx = 0, shx1, shx2;
tw = th = 0; tw = th = 0;
if (fmt->font.font) if (fmt->font.font)
@ -2533,35 +2578,69 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti)
/* These adjustments are calculated and thus heavily linked to those in /* These adjustments are calculated and thus heavily linked to those in
* textblock_render!!! Don't change one without the other. */ * textblock_render!!! Don't change one without the other. */
switch (ti->parent.format->style)
// XXX: YYY: handle EVAS_TEXT_STYLE_SHADOW_DIRECTION*
switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
{ {
case EVAS_TEXT_STYLE_SHADOW: case EVAS_TEXT_STYLE_SHADOW:
ti->x_adjustment = 1; shad_dst = 1;
break; break;
case EVAS_TEXT_STYLE_OUTLINE_SHADOW: case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
case EVAS_TEXT_STYLE_FAR_SHADOW: case EVAS_TEXT_STYLE_FAR_SHADOW:
ti->x_adjustment = 2; shad_dst = 2;
break; out_sz = 1;
case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW: break;
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW: case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
ti->x_adjustment = 4; shad_dst = 1;
break; shad_sz = 2;
case EVAS_TEXT_STYLE_SOFT_SHADOW: out_sz = 1;
inset += 1; break;
ti->x_adjustment = 4; case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
break; shad_dst = 2;
case EVAS_TEXT_STYLE_GLOW: shad_sz = 2;
case EVAS_TEXT_STYLE_SOFT_OUTLINE: break;
inset += 2; case EVAS_TEXT_STYLE_SOFT_SHADOW:
ti->x_adjustment = 4; shad_dst = 1;
break; shad_sz = 2;
case EVAS_TEXT_STYLE_OUTLINE: break;
inset += 1; case EVAS_TEXT_STYLE_GLOW:
ti->x_adjustment = 1; case EVAS_TEXT_STYLE_SOFT_OUTLINE:
break; out_sz = 2;
default: break;
break; case EVAS_TEXT_STYLE_OUTLINE:
out_sz = 1;
break;
default:
break;
} }
switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
{
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
dx = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
dx = 1;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
default:
dx = 0;
break;
}
minx = -out_sz;
maxx = out_sz;
shx1 = dx * shad_dst;
shx1 -= shad_sz;
shx2 = dx * shad_dst;
shx2 += shad_sz;
if (shx1 < minx) minx = shx1;
if (shx2 > maxx) maxx = shx2;
inset += -minx;
ti->x_adjustment = maxx - minx;
ti->inset = inset; ti->inset = inset;
ti->parent.w = tw + ti->x_adjustment; ti->parent.w = tw + ti->x_adjustment;
ti->parent.h = th; ti->parent.h = th;
@ -7913,25 +7992,82 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
/* shadows */ /* shadows */
ITEM_WALK() ITEM_WALK()
{ {
int shad_dst, shad_sz, dx, dy;
Evas_Object_Textblock_Text_Item *ti; Evas_Object_Textblock_Text_Item *ti;
ITEM_WALK_LINE_SKIP_DROP(); ITEM_WALK_LINE_SKIP_DROP();
ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL; ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
if (!ti) continue; if (!ti) continue;
if (ti->parent.format->style == EVAS_TEXT_STYLE_SHADOW) shad_dst = shad_sz = dx = dy = 0;
switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
{ {
COLOR_SET(shadow); case EVAS_TEXT_STYLE_SHADOW:
DRAW_TEXT(1, 1); case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
shad_dst = 1;
break;
case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
case EVAS_TEXT_STYLE_FAR_SHADOW:
shad_dst = 2;
break;
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
shad_dst = 2;
shad_sz = 2;
break;
case EVAS_TEXT_STYLE_SOFT_SHADOW:
shad_dst = 1;
shad_sz = 2;
break;
default:
break;
} }
else if ((ti->parent.format->style == EVAS_TEXT_STYLE_OUTLINE_SHADOW) || if (shad_dst > 0)
(ti->parent.format->style == EVAS_TEXT_STYLE_FAR_SHADOW))
{ {
COLOR_SET(shadow); switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
DRAW_TEXT(2, 2); {
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
dx = 1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
dx = 0;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
dx = -1;
dy = 1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
dx = -1;
dy = 0;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
dx = -1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
dx = 0;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
dx = 1;
dy = -1;
break;
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
dx = 1;
dy = 0;
default:
break;
}
dx *= shad_dst;
dy *= shad_dst;
} }
else if ((ti->parent.format->style == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW) || switch (shad_sz)
(ti->parent.format->style == EVAS_TEXT_STYLE_FAR_SOFT_SHADOW))
{ {
case 0:
COLOR_SET(shadow);
DRAW_TEXT(dx, dy);
break;
case 2:
for (j = 0; j < 5; j++) for (j = 0; j < 5; j++)
{ {
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
@ -7939,24 +8075,13 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
if (vals[i][j] != 0) if (vals[i][j] != 0)
{ {
COLOR_SET_AMUL(shadow, vals[i][j] * 50); COLOR_SET_AMUL(shadow, vals[i][j] * 50);
DRAW_TEXT(i, j); DRAW_TEXT(i - 2 + dx, j - 2 + dy);
}
}
}
}
else if (ti->parent.format->style == EVAS_TEXT_STYLE_SOFT_SHADOW)
{
for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
{
if (vals[i][j] != 0)
{
COLOR_SET_AMUL(shadow, vals[i][j] * 50);
DRAW_TEXT(i - 1, j - 1);
} }
} }
} }
break;
default:
break;
} }
} }
ITEM_WALK_END(); ITEM_WALK_END();