Evas textblock: Add underline height support

Summary:
For showing text error like spell error thick underline is used hence added the underline height support.

@feature

Test Plan: test case added in evas textblock test.

Reviewers: raster, shilpasingh, tasn

Subscribers: govi, rajeshps, cedric

Differential Revision: https://phab.enlightenment.org/D2531

TAsn comment: I wonder if the format should be renamed to
underline_relheight instead of height. If you have any thoughts, please
let me know.
This commit is contained in:
Subodh Kumar 2015-05-27 11:14:59 +01:00 committed by Tom Hacohen
parent 0e2dee5b2e
commit 77e3ac7f82
3 changed files with 25 additions and 1 deletions

View File

@ -146,6 +146,7 @@ MinKyoung Kim <mer.kim@samsung.com>
Pierre Lamot <pierre.lamot@yahoo.fr>
Michelle Legrand <legrand.michelle@outlook.com>
Romain Perier <romain.perier@openwide.fr>
Subodh Kumar <s7158.kumar@samsung.com>
Ecore
-----

View File

@ -444,6 +444,7 @@ struct _Evas_Object_Textblock_Format
int linegap; /**< Value to set the line gap in text. */
int underline_dash_width; /**< Valule to set the width of the underline dash. */
int underline_dash_gap; /**< Value to set the gap of the underline dash. */
double underline_height; /**< Value to set the height of the single underline. */
double linerelsize; /**< Value to set the size of line of text. */
double linerelgap; /**< Value for setting line gap. */
double linefill; /**< The value must be a percentage. */
@ -1130,6 +1131,7 @@ static const char *ellipsisstr = NULL;
static const char *passwordstr = NULL;
static const char *underline_dash_widthstr = NULL;
static const char *underline_dash_gapstr = NULL;
static const char *underline_heightstr = NULL;
/**
* @page evas_textblock_style_page Evas Textblock Style Options
@ -1190,6 +1192,7 @@ _format_command_init(void)
* @li @ref evas_textblock_style_password
* @li @ref evas_textblock_style_underline_dash_width
* @li @ref evas_textblock_style_underline_dash_gap
* @li @ref evas_textblock_style_underline_height
*
* @section evas_textblock_style_contents Contents
*/
@ -1231,6 +1234,7 @@ _format_command_init(void)
passwordstr = eina_stringshare_add("password");
underline_dash_widthstr = eina_stringshare_add("underline_dash_width");
underline_dash_gapstr = eina_stringshare_add("underline_dash_gap");
underline_heightstr = eina_stringshare_add("underline_height");
}
format_refcount++;
}
@ -1282,6 +1286,7 @@ _format_command_shutdown(void)
eina_stringshare_del(passwordstr);
eina_stringshare_del(underline_dash_widthstr);
eina_stringshare_del(underline_dash_gapstr);
eina_stringshare_del(underline_heightstr);
}
/**
@ -2317,6 +2322,21 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
fmt->underline_dash_gap = atoi(param);
if (fmt->underline_dash_gap <= 0) fmt->underline_dash_gap = 1;
}
else if (cmd == underline_heightstr)
{
/**
* @page evas_textblock_style_page Evas Textblock Style Options
*
* @subsection evas_textblock_style_underline_height Underline height
*
* Sets the height of the single underline. The value should be a floating number.
* @code
* underline_height=<floatingnumber>
* @endcode
*/
fmt->underline_height = atof(param);
if (fmt->underline_height <= 0.0) fmt->underline_height = 1.0;
}
}
/**
@ -3000,6 +3020,7 @@ _layout_format_push(Ctxt *c, Evas_Object_Textblock_Format *fmt,
fmt->linegap = 0;
fmt->underline_dash_width = 6;
fmt->underline_dash_gap = 2;
fmt->underline_height = 1.0;
fmt->linerelgap = 0.0;
fmt->password = 1;
fmt->ellipsis = -1;
@ -11699,7 +11720,8 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
DRAW_FORMAT(strikethrough, (ln->h / 2), line_thickness);
/* UNDERLINE */
DRAW_FORMAT(underline, ln->baseline + line_position, line_thickness);
DRAW_FORMAT(underline, ln->baseline + line_position,
line_thickness * itr->format->underline_height);
/* UNDERLINE DASHED */
DRAW_FORMAT_DASHED(underline_dash, ln->baseline + line_position,

View File

@ -2842,6 +2842,7 @@ START_TEST(evas_textblock_formats)
"<font_size=40>font_size=40</><ps/>"
"<color=#F210B3FF>color=#F210B3FF</><ps/>"
"<underline=single underline_color=#A2B3C4>underline=single underline_color=#A2B3C4</><ps/>"
"<underline=single underline_color=#F2D006 underline_height=5.5>underline=single underline_color=#F2D006 underline_height=5.5</><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/>"