add text effect shadow direction support.

SVN revision: 58548
devs/devilhorns/wayland_egl
Carsten Haitzler 12 years ago
parent bb03df9625
commit 0b0d51c5cf
  1. 5
      legacy/edje/ChangeLog
  2. 1
      legacy/edje/src/bin/edje_cc.h
  3. 29
      legacy/edje/src/bin/edje_cc_handlers.c
  4. 6
      legacy/edje/src/bin/edje_cc_parse.c
  5. 18
      legacy/edje/src/lib/Edje.h
  6. 26
      legacy/edje/src/lib/edje_calc.c
  7. 126
      legacy/edje/src/lib/edje_text.c

@ -75,3 +75,8 @@
* text.align (only the vertical part) now works for textblock.
2011-04-1 Carsten Haitzler (The Rasterman)
* Add Feature: Support explicit shadow direction with extra effect
param (optional). Default as before.

@ -135,6 +135,7 @@ int parse_int_range(int n, int f, int t);
int parse_bool(int n);
double parse_float(int n);
double parse_float_range(int n, double f, double t);
int get_arg_count(void);
void check_arg_count(int n);
void check_min_arg_count(int n);

@ -2639,6 +2639,7 @@ st_collections_group_parts_part_source6(void)
effect
@parameters
[EFFECT]
(optional) [SHADOW DIRECTION]
@effect
Causes Edje to draw the selected effect among:
@li PLAIN
@ -2651,6 +2652,16 @@ st_collections_group_parts_part_source6(void)
@li FAR_SHADOW
@li FAR_SOFT_SHADOW
@li GLOW
Shadow directions (default if not given is BOTTOM_RIGHT):
@li BOTTOM_RIGHT
@li BOTTOM
@li BOTTOM_LEFT
@li LEFT
@li TOP_LEFT
@li TOP
@li TOP_RIGHT
@li RIGHT
@endproperty
*/
static void
@ -2659,7 +2670,7 @@ st_collections_group_parts_part_effect(void)
Edje_Part_Collection *pc;
Edje_Part *ep;
check_arg_count(1);
check_min_arg_count(1);
pc = eina_list_data_get(eina_list_last(edje_collections));
ep = pc->parts[pc->parts_count - 1];
@ -2676,6 +2687,22 @@ st_collections_group_parts_part_effect(void)
"FAR_SOFT_SHADOW", EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW,
"GLOW", EDJE_TEXT_EFFECT_GLOW,
NULL);
if (get_arg_count() >= 2)
{
unsigned char shadow;
shadow = parse_enum(1,
"BOTTOM_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT,
"BOTTOM", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM,
"BOTTOM_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT,
"LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT,
"TOP_LEFT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT,
"TOP", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP,
"TOP_RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT,
"RIGHT", EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT,
NULL);
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(ep->effect, shadow);
}
}
/**

@ -1063,6 +1063,12 @@ parse_float_range(int n, double f, double t)
return i;
}
int
get_arg_count(void)
{
return eina_list_count (params);
}
void
check_arg_count(int required_args)
{

@ -633,6 +633,9 @@ typedef enum _Edje_Part_Type
typedef enum _Edje_Text_Effect
{
#define EDJE_TEXT_EFFECT_MASK_BASIC 0xf
#define EDJE_TEXT_EFFECT_BASIC_SET(x, s) \
do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_BASIC) | (s); } while (0)
EDJE_TEXT_EFFECT_NONE = 0,
EDJE_TEXT_EFFECT_PLAIN = 1,
EDJE_TEXT_EFFECT_OUTLINE = 2,
@ -644,7 +647,20 @@ typedef enum _Edje_Text_Effect
EDJE_TEXT_EFFECT_FAR_SHADOW = 8,
EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW = 9,
EDJE_TEXT_EFFECT_GLOW = 10,
EDJE_TEXT_EFFECT_LAST = 11
EDJE_TEXT_EFFECT_LAST = 11,
#define EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION (0x7 << 4)
#define EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(x, s) \
do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) | (s); } while (0)
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT = (0x0 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM = (0x1 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT = (0x2 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT = (0x3 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT = (0x4 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP = (0x5 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT = (0x6 << 4),
EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT = (0x7 << 4)
} Edje_Text_Effect;
typedef enum _Edje_Action_Type

@ -1030,7 +1030,9 @@ _edje_part_recalc_single_text(FLOAT_T sc,
(chosen_desc->text.max_x) || (chosen_desc->text.max_y))
{
int mw, mh;
Evas_Text_Style_Type style;
Evas_Text_Style_Type
style = EVAS_TEXT_STYLE_PLAIN,
shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT;
const Evas_Text_Style_Type styles[] = {
EVAS_TEXT_STYLE_PLAIN,
EVAS_TEXT_STYLE_PLAIN,
@ -1044,12 +1046,24 @@ _edje_part_recalc_single_text(FLOAT_T sc,
EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
EVAS_TEXT_STYLE_GLOW
};
if (ep->part->effect < EDJE_TEXT_EFFECT_LAST)
const Evas_Text_Style_Type shadows[] = {
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT,
EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT
};
if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC)
< EDJE_TEXT_EFFECT_LAST)
style = styles[ep->part->effect];
else
style = EVAS_TEXT_STYLE_PLAIN;
shadow = shadows
[(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4];
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow);
evas_object_text_style_set(ep->object, style);
evas_object_text_text_set(ep->object, text);
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);

@ -609,6 +609,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
else evas_object_hide(ep->object);
{
Evas_Text_Style_Type style;
Edje_Text_Effect effect;
style = EVAS_TEXT_STYLE_PLAIN;
@ -617,50 +618,46 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
(params->color.g * params->color.a) / 255,
(params->color.b * params->color.a) / 255,
params->color.a);
if ((ep->part->effect == EDJE_TEXT_EFFECT_NONE) ||
(ep->part->effect == EDJE_TEXT_EFFECT_PLAIN))
{
effect = ep->part->effect;
switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC)
{
case EDJE_TEXT_EFFECT_NONE:
case EDJE_TEXT_EFFECT_PLAIN:
style = EVAS_TEXT_STYLE_PLAIN;
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE)
{
break;
case EDJE_TEXT_EFFECT_OUTLINE:
style = EVAS_TEXT_STYLE_OUTLINE;
evas_object_text_outline_color_set(ep->object,
(params->type.text.color2.r * params->type.text.color2.a) / 255,
(params->type.text.color2.g * params->type.text.color2.a) / 255,
(params->type.text.color2.b * params->type.text.color2.a) / 255,
params->type.text.color2.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_SOFT_OUTLINE)
{
break;
case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
evas_object_text_outline_color_set(ep->object,
(params->type.text.color2.r * params->type.text.color2.a) / 255,
(params->type.text.color2.g * params->type.text.color2.a) / 255,
(params->type.text.color2.b * params->type.text.color2.a) / 255,
params->type.text.color2.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_SHADOW:
style = EVAS_TEXT_STYLE_SHADOW;
evas_object_text_shadow_color_set(ep->object,
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_SOFT_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_SOFT_SHADOW:
style = EVAS_TEXT_STYLE_SOFT_SHADOW;
evas_object_text_shadow_color_set(ep->object,
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
evas_object_text_outline_color_set(ep->object,
(params->type.text.color2.r * params->type.text.color2.a) / 255,
@ -672,9 +669,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
evas_object_text_outline_color_set(ep->object,
(params->type.text.color2.r * params->type.text.color2.a) / 255,
@ -686,48 +682,84 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_FAR_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_FAR_SHADOW:
style = EVAS_TEXT_STYLE_FAR_SHADOW;
evas_object_text_shadow_color_set(ep->object,
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW)
{
break;
case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW;
evas_object_text_shadow_color_set(ep->object,
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
else if (ep->part->effect == EDJE_TEXT_EFFECT_GLOW)
{
break;
case EDJE_TEXT_EFFECT_GLOW:
style = EVAS_TEXT_STYLE_GLOW;
evas_object_text_glow_color_set(ep->object,
(params->type.text.color2.r * params->type.text.color2.a) / 255,
(params->type.text.color2.g * params->type.text.color2.a) / 255,
(params->type.text.color2.b * params->type.text.color2.a) / 255,
params->type.text.color2.a);
(params->type.text.color2.r * params->type.text.color2.a) / 255,
(params->type.text.color2.g * params->type.text.color2.a) / 255,
(params->type.text.color2.b * params->type.text.color2.a) / 255,
params->type.text.color2.a);
evas_object_text_glow2_color_set(ep->object,
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
}
(params->type.text.color3.r * params->type.text.color3.a) / 255,
(params->type.text.color3.g * params->type.text.color3.a) / 255,
(params->type.text.color3.b * params->type.text.color3.a) / 255,
params->type.text.color3.a);
break;
default:
style = EVAS_TEXT_STYLE_PLAIN;
break;
}
switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION)
{
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT);
break;
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT:
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT);
break;
default:
break;
}
evas_object_text_style_set(ep->object, style);
}
if (free_text)
free((char *)text);
if (font2)
free(font2);
if (sfont)
free(sfont);
if (free_text) free((char *)text);
if (font2) free(font2);
if (sfont) free(sfont);
}
Evas_Font_Size

Loading…
Cancel
Save