forked from enlightenment/efl
evas_textblock: update color text parsingUpdate text color parsing for rgba(r, g, b, a) for alpha to be value between 0.0 - 1.0 same as CSS.
Summary: ... spam removed ... Reviewers: woohyun, bowonryu, id213sin, AbdullehGhujeh, devilhorns Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12248
This commit is contained in:
parent
69cd4b4188
commit
b2f61deb37
|
@ -1785,8 +1785,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* backing_color=<color>
|
* backing_color=<color>
|
||||||
|
@ -1827,8 +1827,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* underline2_color=<color>
|
* underline2_color=<color>
|
||||||
|
@ -1849,8 +1849,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* glow2_color=<color>
|
* glow2_color=<color>
|
||||||
|
@ -2001,8 +2001,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* underline_dash_color=<color>
|
* underline_dash_color=<color>
|
||||||
|
@ -2516,8 +2516,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* color=<color>
|
* color=<color>
|
||||||
|
@ -2537,8 +2537,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* underline_color=<color>
|
* underline_color=<color>
|
||||||
|
@ -2559,8 +2559,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* outline_color=<color>
|
* outline_color=<color>
|
||||||
|
@ -2581,8 +2581,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* shadow_color=<color>
|
* shadow_color=<color>
|
||||||
|
@ -2603,8 +2603,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* glow_color=<color>
|
* glow_color=<color>
|
||||||
|
@ -2625,8 +2625,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
|
||||||
* @li "#RRGGBBAA"
|
* @li "#RRGGBBAA"
|
||||||
* @li "#RGB"
|
* @li "#RGB"
|
||||||
* @li "#RGBA"
|
* @li "#RGBA"
|
||||||
* @li "rgb(r,g,b)"
|
* @li "rgb(0-255,0-255,0-255)"
|
||||||
* @li "rgba(r,g,b,a)"
|
* @li "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* @li "color_name" like "red"
|
* @li "color_name" like "red"
|
||||||
* @code
|
* @code
|
||||||
* strikethrough_color=<color>
|
* strikethrough_color=<color>
|
||||||
|
|
|
@ -1362,8 +1362,8 @@ Eina_Bool read_byte_color_component(const char* source,char ** next,unsigned cha
|
||||||
* 3. "#RGB"
|
* 3. "#RGB"
|
||||||
* 4. "#RGBA"
|
* 4. "#RGBA"
|
||||||
* 5. "color names"
|
* 5. "color names"
|
||||||
* 6. "rgb(r,g,b)"
|
* 6. "rgb(0-255,0-255,0-255)"
|
||||||
* 7. "rgba(r,g,b,a)"
|
* 7. "rgba(0-255,0-255,0-255,0.0-1.0)"
|
||||||
* TODO (we may use specific color parser)
|
* TODO (we may use specific color parser)
|
||||||
* 8. "hsl(H,S,L)"
|
* 8. "hsl(H,S,L)"
|
||||||
* 9. "hsla(H,S,L,A)"
|
* 9. "hsla(H,S,L,A)"
|
||||||
|
@ -1422,7 +1422,7 @@ evas_common_format_color_parse(const char *str, int slen,
|
||||||
}
|
}
|
||||||
else v = EINA_FALSE;
|
else v = EINA_FALSE;
|
||||||
}
|
}
|
||||||
else if (slen <= 21)/* search for rgb(),hsv(),colorname, 20 is length of rgba(255,255,255,255) */
|
else if (slen <= 25)/* search for rgb(),hsv(),colorname, 25 is length of rgba(255,255,255,1.0) */
|
||||||
{
|
{
|
||||||
/*remove spaces and convert name to lowercase*/
|
/*remove spaces and convert name to lowercase*/
|
||||||
char color_name[0xFF] = {0};
|
char color_name[0xFF] = {0};
|
||||||
|
@ -1446,20 +1446,23 @@ evas_common_format_color_parse(const char *str, int slen,
|
||||||
*a = 0xff;
|
*a = 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((strncmp(color_name,"rgba(",4) == 0) && color_name[slen-1] == ')'&& slen >= 13 && slen <=21) /* rgba() */
|
else if ((strncmp(color_name,"rgba(",4) == 0) && color_name[slen-1] == ')'&& slen >= 13 && slen <=25) /* rgba() */
|
||||||
{
|
{
|
||||||
char * p_color = &color_name[4];
|
char * p_color = &color_name[4];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!read_byte_color_component(++p_color,&p_color,r) || !p_color || *p_color != ',') ||
|
(!read_byte_color_component(++p_color,&p_color,r) || !p_color || *p_color != ',') ||
|
||||||
(!read_byte_color_component(++p_color,&p_color,g) || !p_color || *p_color != ',') ||
|
(!read_byte_color_component(++p_color,&p_color,g) || !p_color || *p_color != ',') ||
|
||||||
(!read_byte_color_component(++p_color,&p_color,b) || !p_color || *p_color != ',') ||
|
(!read_byte_color_component(++p_color,&p_color,b) || !p_color || *p_color != ',')
|
||||||
(!read_byte_color_component(++p_color,&p_color,a) || !p_color || *p_color != ')')
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
*r = *g = *b = *a = 0;
|
*r = *g = *b = *a = 0;
|
||||||
v = EINA_FALSE;
|
v = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*a = (unsigned char)(strtof(++p_color, NULL) * 255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue