summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2017-10-20 18:02:08 +0300
committerCedric BAIL <cedric@osg.samsung.com>2017-11-10 10:30:00 -0800
commit58ce1d654b0d4ead58bba384b1e1edd5b605bc4e (patch)
tree0561edc127d4689834f156da648142a8ab5f3929 /src
parent941fe1ffbd29b42be4b4d62ec5a35727f19a0394 (diff)
Canvas text: change halign/valign to use doubles
There are use cases where you would want to align by a value. The wordy alignment values are thus removed. This commit also separates auto-modes (none, normal, locale) for horizontal alignment to its own API. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_efl_ui_text.c6
-rw-r--r--src/lib/efl/interfaces/efl_text_format.eo35
-rw-r--r--src/lib/evas/canvas/efl_canvas_text.eo1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c82
4 files changed, 57 insertions, 67 deletions
diff --git a/src/bin/elementary/test_efl_ui_text.c b/src/bin/elementary/test_efl_ui_text.c
index a8629a8e09..b53c427b9a 100644
--- a/src/bin/elementary/test_efl_ui_text.c
+++ b/src/bin/elementary/test_efl_ui_text.c
@@ -53,11 +53,11 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
53 efl_text_set(en, "This is a\t small label"); 53 efl_text_set(en, "This is a\t small label");
54 // 012345678901234567890 54 // 012345678901234567890
55 _apply_style(en, 0, 21, "font_size=12 font_weight=bold"); 55 _apply_style(en, 0, 21, "font_size=12 font_weight=bold");
56 efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER); 56 efl_text_halign_set(en, 0.5);
57 efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD); 57 efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD);
58 58
59 en = _create_label(win, bx); 59 en = _create_label(win, bx);
60 efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER); 60 efl_text_halign_set(en, 0.5);
61 efl_text_set(en, "This is a text. Is also has\n" 61 efl_text_set(en, "This is a text. Is also has\n"
62 "newlines. There are several styles applied."); 62 "newlines. There are several styles applied.");
63 _apply_style(en, 40, 45, "font_weight=bold color=#ff0"); 63 _apply_style(en, 40, 45, "font_weight=bold color=#ff0");
@@ -65,7 +65,7 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
65 efl_text_multiline_set(en, EINA_TRUE); 65 efl_text_multiline_set(en, EINA_TRUE);
66 66
67 en = _create_label(win, bx); 67 en = _create_label(win, bx);
68 efl_text_halign_set(en, EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER); 68 efl_text_halign_set(en, 0.5);
69 efl_text_set(en, "By default 'multiline' is disabled.\n" 69 efl_text_set(en, "By default 'multiline' is disabled.\n"
70 "So, \\n would only work if you enable it."); 70 "So, \\n would only work if you enable it.");
71 71
diff --git a/src/lib/efl/interfaces/efl_text_format.eo b/src/lib/efl/interfaces/efl_text_format.eo
index 5e14893f06..0e1829972b 100644
--- a/src/lib/efl/interfaces/efl_text_format.eo
+++ b/src/lib/efl/interfaces/efl_text_format.eo
@@ -7,23 +7,13 @@ enum Efl.Text.Format.Wrap {
7 hyphenation [[Wrap mode hyphenation]] 7 hyphenation [[Wrap mode hyphenation]]
8} 8}
9 9
10enum Efl.Text.Format.Horizontal_Alignment_Type { 10enum Efl.Text.Format.Horizontal_Alignment_Auto_Type {
11 [[Horizontal alignment of the text]] 11 [[Auto-horizontal alignment of the text]]
12 legacy: efl_text_horizontal_alignment; 12 legacy: efl_text_horizontal_alignment_auto;
13 auto, [[Respects LTR/RTL (bidirectional) settings]] 13 none, [[No auto-alignment rule]]
14 locale, [[Respects locale's langauge settings]] 14 normal, [[Respects LTR/RTL (bidirectional) settings]]
15 left, [[Text is placed at the left end of the line]] 15 locale, [[Respects locale's langauge settings]]
16 right, [[Text is placed at the right end of the line]] 16 end [[Text is places at opposite side of LTR/RTL (bidirectional) settings]]
17 center, [[Text is places at the center of the line]]
18 end [[Text is places at opposite side of LTR/RTL (bidirectional) settings]]
19}
20
21enum Efl.Text.Format.Vertical_Alignment_Type {
22 [[Horizontal alignment of the text]]
23 legacy: efl_text_vertical_alignment;
24 top, [[Text is placed at the top]]
25 center, [[Text is placed at the center]]
26 bottom [[Text is placed at the bottom]]
27} 17}
28 18
29interface Efl.Text.Format { 19interface Efl.Text.Format {
@@ -58,17 +48,24 @@ interface Efl.Text.Format {
58 } 48 }
59 } 49 }
60 50
51 @property halign_auto_type {
52 [[Horizontal alignment of text]]
53 values {
54 value: Efl.Text.Format.Horizontal_Alignment_Auto_Type; [[Alignment type]]
55 }
56 }
57
61 @property halign { 58 @property halign {
62 [[Horizontal alignment of text]] 59 [[Horizontal alignment of text]]
63 values { 60 values {
64 value: Efl.Text.Format.Horizontal_Alignment_Type; [[Alignment type]] 61 value: double; [[Horizontal alignment value]]
65 } 62 }
66 } 63 }
67 64
68 @property valign { 65 @property valign {
69 [[Vertical alignment of text]] 66 [[Vertical alignment of text]]
70 values { 67 values {
71 value: Efl.Text.Format.Vertical_Alignment_Type; [[Allignment type]] 68 value: double; [[Vertical alignment value]]
72 } 69 }
73 } 70 }
74 71
diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo
index d2fce3b1c2..e401577d18 100644
--- a/src/lib/evas/canvas/efl_canvas_text.eo
+++ b/src/lib/evas/canvas/efl_canvas_text.eo
@@ -308,6 +308,7 @@ Efl.Text.Cursor, Efl.Text.Annotate, Efl.Text.Markup)
308 Efl.Text.Format.wrap { get; set; } 308 Efl.Text.Format.wrap { get; set; }
309 Efl.Text.Format.multiline { get; set; } 309 Efl.Text.Format.multiline { get; set; }
310 Efl.Text.Format.halign { get; set; } 310 Efl.Text.Format.halign { get; set; }
311 Efl.Text.Format.halign_auto_type { get; set; }
311 Efl.Text.Format.valign { get; set; } 312 Efl.Text.Format.valign { get; set; }
312 Efl.Text.Format.linegap { get; set; } 313 Efl.Text.Format.linegap { get; set; }
313 Efl.Text.Format.linerelgap { get; set; } 314 Efl.Text.Format.linerelgap { get; set; }
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index b44f0246fd..4bc6ad66b7 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -15397,6 +15397,11 @@ _efl_canvas_text_efl_text_font_font_bitmap_scalable_get(Eo *obj EINA_UNUSED, Efl
15397 _FMT(x) = v; \ 15397 _FMT(x) = v; \
15398 _canvas_text_format_changed(obj, o); 15398 _canvas_text_format_changed(obj, o);
15399 15399
15400#define _FMT_DBL_SET(x, v) \
15401 if (EINA_DBL_EQ(_FMT(x), v)) return; \
15402 _FMT(x) = v; \
15403 _canvas_text_format_changed(obj, o);
15404
15400/* Helper: updates format field of extended format information, and informs if changed. */ 15405/* Helper: updates format field of extended format information, and informs if changed. */
15401#define _FMT_INFO_SET_START(x, v) \ 15406#define _FMT_INFO_SET_START(x, v) \
15402 Eina_Bool changed = EINA_FALSE; \ 15407 Eina_Bool changed = EINA_FALSE; \
@@ -15801,81 +15806,68 @@ _efl_canvas_text_efl_text_format_multiline_get(Eo *obj EINA_UNUSED, Efl_Canvas_T
15801} 15806}
15802 15807
15803static void 15808static void
15804_efl_canvas_text_efl_text_format_halign_set(Eo *obj, Efl_Canvas_Text_Data *o, Efl_Text_Format_Horizontal_Alignment_Type type) 15809_efl_canvas_text_efl_text_format_halign_auto_type_set(Eo *obj, Efl_Canvas_Text_Data *o, Efl_Text_Format_Horizontal_Alignment_Auto_Type type)
15805{ 15810{
15806 ASYNC_BLOCK; 15811 ASYNC_BLOCK;
15807 if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO) 15812 if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NONE)
15808 { 15813 {
15809 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL); 15814 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_NONE);
15810 } 15815 }
15811 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_END) 15816 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NORMAL)
15812 { 15817 {
15813 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_END); 15818 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL);
15814 } 15819 }
15815 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_LOCALE) 15820 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_LOCALE)
15816 { 15821 {
15817 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE); 15822 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE);
15818 } 15823 }
15819 else 15824 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_END)
15820 { 15825 {
15821 double value = 0.0; // EFL_TEXT_HORIZONTAL_ALIGNMENT_LEFT 15826 _FMT_SET(halign_auto, EVAS_TEXTBLOCK_ALIGN_AUTO_END);
15822 _FMT(halign_auto) = EINA_FALSE;
15823
15824 if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER)
15825 {
15826 value = 0.5;
15827 }
15828 else if (type == EFL_TEXT_HORIZONTAL_ALIGNMENT_RIGHT)
15829 {
15830 value = 1.0;
15831 }
15832 _FMT_SET(halign, value);
15833 } 15827 }
15834} 15828}
15835 15829
15836static Efl_Text_Format_Horizontal_Alignment_Type 15830static Efl_Text_Format_Horizontal_Alignment_Auto_Type
15837_efl_canvas_text_efl_text_format_halign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o) 15831_efl_canvas_text_efl_text_format_halign_auto_type_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o)
15838{ 15832{
15839 Efl_Text_Format_Horizontal_Alignment_Type ret = 15833 Efl_Text_Format_Horizontal_Alignment_Auto_Type ret =
15840 EFL_TEXT_HORIZONTAL_ALIGNMENT_LEFT; 15834 EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NONE;
15841 15835
15842 if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL) 15836 if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL)
15843 { 15837 {
15844 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO; 15838 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NORMAL;
15845 } 15839 }
15846 else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_END) 15840 else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_END)
15847 { 15841 {
15848 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_END; 15842 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_END;
15849 } 15843 }
15850 else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE) 15844 else if (_FMT(halign_auto) == EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE)
15851 { 15845 {
15852 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_LOCALE; 15846 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_LOCALE;
15853 }
15854 else if (EINA_DBL_EQ(_FMT(halign), 0.5))
15855 {
15856 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_CENTER;
15857 }
15858 else if (EINA_DBL_EQ(_FMT(halign), 1.0))
15859 {
15860 ret = EFL_TEXT_HORIZONTAL_ALIGNMENT_RIGHT;
15861 } 15847 }
15862 return ret; 15848 return ret;
15863} 15849}
15864 15850
15865static void 15851static void
15852_efl_canvas_text_efl_text_format_halign_set(Eo *obj, Efl_Canvas_Text_Data *o,
15853 double value)
15854{
15855 ASYNC_BLOCK;
15856 _FMT_DBL_SET(halign, value);
15857 _FMT(halign_auto) = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE;
15858}
15859
15860static double
15861_efl_canvas_text_efl_text_format_halign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED)
15862{
15863 return _FMT(halign);
15864}
15865
15866static void
15866_efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o, 15867_efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o,
15867 Efl_Text_Format_Vertical_Alignment_Type type) 15868 double value)
15868{ 15869{
15869 ASYNC_BLOCK; 15870 ASYNC_BLOCK;
15870 double value = 0.0; // EFL_TEXT_VERTICAL_ALIGNMENT_TOP
15871 if (type == EFL_TEXT_VERTICAL_ALIGNMENT_CENTER)
15872 {
15873 value = 0.5;
15874 }
15875 else if (type == EFL_TEXT_VERTICAL_ALIGNMENT_BOTTOM)
15876 {
15877 value = 1.0;
15878 }
15879 if (!EINA_DBL_EQ(o->valign, value)) 15871 if (!EINA_DBL_EQ(o->valign, value))
15880 { 15872 {
15881 o->valign = value; 15873 o->valign = value;
@@ -15883,7 +15875,7 @@ _efl_canvas_text_efl_text_format_valign_set(Eo *obj, Efl_Canvas_Text_Data *o,
15883 } 15875 }
15884} 15876}
15885 15877
15886static Efl_Text_Format_Vertical_Alignment_Type 15878static double
15887_efl_canvas_text_efl_text_format_valign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED) 15879_efl_canvas_text_efl_text_format_valign_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED)
15888{ 15880{
15889 return o->valign; 15881 return o->valign;