summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/edje/edje_calc.c34
-rw-r--r--src/lib/edje/edje_load.c22
-rw-r--r--src/lib/edje/edje_private.h5
-rw-r--r--src/lib/edje/edje_textblock.c639
-rw-r--r--src/lib/edje/edje_util.c11
5 files changed, 523 insertions, 188 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 5c5f048b02..2c6e20fe3a 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2401,7 +2401,7 @@ _edje_part_recalc_single_filter(Edje *ed,
2401 Eina_List *li1, *li2; 2401 Eina_List *li1, *li2;
2402 2402
2403 /* handle TEXT, IMAGE, PROXY, SNAPSHOT part types here */ 2403 /* handle TEXT, IMAGE, PROXY, SNAPSHOT part types here */
2404 if (ep->part->type == EDJE_PART_TYPE_TEXT) 2404 if (PART_IS_TEXT(ed, ep))
2405 { 2405 {
2406 Edje_Part_Description_Text *chosen_edt = (Edje_Part_Description_Text *) chosen_desc; 2406 Edje_Part_Description_Text *chosen_edt = (Edje_Part_Description_Text *) chosen_desc;
2407 Edje_Part_Description_Text *edt = (Edje_Part_Description_Text *) desc; 2407 Edje_Part_Description_Text *edt = (Edje_Part_Description_Text *) desc;
@@ -2521,6 +2521,10 @@ _edje_part_recalc_single_filter(Edje *ed,
2521 } 2521 }
2522 } 2522 }
2523 efl_gfx_filter_program_set(obj, code, filter->name); 2523 efl_gfx_filter_program_set(obj, code, filter->name);
2524 if (PART_IS_TEXT(ed, ep))
2525 {
2526 efl_text_gfx_filter_set(obj, filter->name);
2527 }
2524 if (prev_sources != filter_sources) 2528 if (prev_sources != filter_sources)
2525 { 2529 {
2526 /* remove sources that are not there anymore 2530 /* remove sources that are not there anymore
@@ -2828,11 +2832,9 @@ _edje_part_recalc_single(Edje *ed,
2828 } 2832 }
2829 2833
2830 /* if we have text that wants to make the min size the text size... */ 2834 /* if we have text that wants to make the min size the text size... */
2831 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) 2835 if (PART_IS_TEXT(ed, ep))
2832 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
2833 else if (ep->part->type == EDJE_PART_TYPE_TEXT)
2834 { 2836 {
2835 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text*) desc, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh); 2837 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text *)chosen_desc, params, &minw, &minh, &maxw, &maxh);
2836 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos); 2838 _edje_part_recalc_single_filter(ed, ep, desc, chosen_desc, pos);
2837 } 2839 }
2838 2840
@@ -4387,11 +4389,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4387 break; 4389 break;
4388 4390
4389 case EDJE_PART_TYPE_TEXT: 4391 case EDJE_PART_TYPE_TEXT:
4390 _edje_calc_params_need_type_text(p3);
4391 p3->type.text->size = INTP(p1->type.text->size, p2->type.text->size, pos);
4392 EINA_FALLTHROUGH;
4393
4394 /* no break as we share code with the TEXTBLOCK type here. */
4395 case EDJE_PART_TYPE_TEXTBLOCK: 4392 case EDJE_PART_TYPE_TEXTBLOCK:
4396 _edje_calc_params_need_type_text(p3); 4393 _edje_calc_params_need_type_text(p3);
4397 p3->type.text->color2.r = INTP(p1->type.text->color2.r, p2->type.text->color2.r, pos2); 4394 p3->type.text->color2.r = INTP(p1->type.text->color2.r, p2->type.text->color2.r, pos2);
@@ -4603,6 +4600,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4603 EINA_FALLTHROUGH; 4600 EINA_FALLTHROUGH;
4604 case EDJE_PART_TYPE_RECTANGLE: 4601 case EDJE_PART_TYPE_RECTANGLE:
4605 EINA_FALLTHROUGH; 4602 EINA_FALLTHROUGH;
4603 case EDJE_PART_TYPE_TEXT:
4604 EINA_FALLTHROUGH;
4606 case EDJE_PART_TYPE_TEXTBLOCK: 4605 case EDJE_PART_TYPE_TEXTBLOCK:
4607 EINA_FALLTHROUGH; 4606 EINA_FALLTHROUGH;
4608 case EDJE_PART_TYPE_BOX: 4607 case EDJE_PART_TYPE_BOX:
@@ -4612,11 +4611,18 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4612 case EDJE_PART_TYPE_SNAPSHOT: 4611 case EDJE_PART_TYPE_SNAPSHOT:
4613 EINA_FALLTHROUGH; 4612 EINA_FALLTHROUGH;
4614 case EDJE_PART_TYPE_VECTOR: 4613 case EDJE_PART_TYPE_VECTOR:
4614 if (ep->part->type == EDJE_PART_TYPE_TEXT)
4615 {
4616 evas_object_color_set(ep->object, 255, 255, 255, 255);
4617 }
4618 else
4619 {
4615 evas_object_color_set(ep->object, 4620 evas_object_color_set(ep->object,
4616 (pf->color.r * pf->color.a) / 255, 4621 (pf->color.r * pf->color.a) / 255,
4617 (pf->color.g * pf->color.a) / 255, 4622 (pf->color.g * pf->color.a) / 255,
4618 (pf->color.b * pf->color.a) / 255, 4623 (pf->color.b * pf->color.a) / 255,
4619 pf->color.a); 4624 pf->color.a);
4625 }
4620 4626
4621#ifdef HAVE_EPHYSICS 4627#ifdef HAVE_EPHYSICS
4622/* body attributes should be updated for invisible objects */ 4628/* body attributes should be updated for invisible objects */
@@ -4704,10 +4710,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4704 } 4710 }
4705 break; 4711 break;
4706 4712
4707 case EDJE_PART_TYPE_TEXT:
4708 /* This is correctly handle in _edje_text_recalc_apply at the moment. */
4709 break;
4710
4711 case EDJE_PART_TYPE_GRADIENT: 4713 case EDJE_PART_TYPE_GRADIENT:
4712 /* FIXME: definitivly remove this code when we switch to new format. */ 4714 /* FIXME: definitivly remove this code when we switch to new format. */
4713 abort(); 4715 abort();
@@ -4912,9 +4914,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4912 /* Some object need special recalc. */ 4914 /* Some object need special recalc. */
4913 switch (ep->part->type) 4915 switch (ep->part->type)
4914 { 4916 {
4915 case EDJE_PART_TYPE_TEXT:
4916 _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc, EINA_FALSE);
4917 break;
4918 4917
4919 case EDJE_PART_TYPE_PROXY: 4918 case EDJE_PART_TYPE_PROXY:
4920 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy *)chosen_desc, pos); 4919 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy *)chosen_desc, pos);
@@ -4932,6 +4931,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4932 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table *)chosen_desc); 4931 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table *)chosen_desc);
4933 break; 4932 break;
4934 4933
4934 case EDJE_PART_TYPE_TEXT:
4935 case EDJE_PART_TYPE_TEXTBLOCK: 4935 case EDJE_PART_TYPE_TEXTBLOCK:
4936 _edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text *)chosen_desc); 4936 _edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text *)chosen_desc);
4937 break; 4937 break;
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 94f8c0e401..c2da41d884 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1045,11 +1045,21 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
1045 break; 1045 break;
1046 1046
1047 case EDJE_PART_TYPE_TEXT: 1047 case EDJE_PART_TYPE_TEXT:
1048 _edje_text_part_on_add(ed, rp); 1048 case EDJE_PART_TYPE_TEXTBLOCK:
1049 rp->object = evas_object_text_add(ed->base.evas); 1049 _edje_textblock_styles_add(ed, rp);
1050 evas_object_text_font_source_set(rp->object, ed->path); 1050 textblocks = eina_list_append(textblocks, rp);
1051 if (rp->part->type == EDJE_PART_TYPE_TEXT)
1052 {
1053 rp->object = efl_add(EFL_CANVAS_TEXT_CLASS,
1054 ed->base.evas);
1055 }
1056 else
1057 {
1058 rp->object = evas_object_textblock_add(ed->base.evas);
1059 }
1051 break; 1060 break;
1052 1061
1062
1053 case EDJE_PART_TYPE_GROUP: 1063 case EDJE_PART_TYPE_GROUP:
1054 sources = eina_list_append(sources, rp); 1064 sources = eina_list_append(sources, rp);
1055 1065
@@ -1067,12 +1077,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
1067 _edje_callbacks_focus_add(rp->object, ed, rp); 1077 _edje_callbacks_focus_add(rp->object, ed, rp);
1068 break; 1078 break;
1069 1079
1070 case EDJE_PART_TYPE_TEXTBLOCK:
1071 _edje_textblock_styles_add(ed, rp);
1072 textblocks = eina_list_append(textblocks, rp);
1073 rp->object = evas_object_textblock_add(ed->base.evas);
1074 break;
1075
1076 case EDJE_PART_TYPE_BOX: 1080 case EDJE_PART_TYPE_BOX:
1077 sources = eina_list_append(sources, rp); 1081 sources = eina_list_append(sources, rp);
1078 rp->object = evas_object_box_add(ed->base.evas); 1082 rp->object = evas_object_box_add(ed->base.evas);
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 581893ffaa..86099c5ddd 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -2533,6 +2533,11 @@ const char * _edje_text_class_font_get(Edje *ed,
2533 int *size, char **free_later); 2533 int *size, char **free_later);
2534const char * _edje_text_font_get(const char *base, const char *new, 2534const char * _edje_text_font_get(const char *base, const char *new,
2535 char **free_later); 2535 char **free_later);
2536const char * _set_translated_string(Edje *ed, Edje_Real_Part *ep);
2537
2538#define PART_IS_TEXT(ed, ep) \
2539 (((ep)->part->type == EDJE_PART_TYPE_TEXTBLOCK) || \
2540 ((ep)->part->type == EDJE_PART_TYPE_TEXT))
2536 2541
2537void 2542void
2538_edje_part_recalc_single_textblock(FLOAT_T sc, 2543_edje_part_recalc_single_textblock(FLOAT_T sc,
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index 0451099fa4..c46c2a9543 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -1,5 +1,17 @@
1#include "edje_private.h" 1#include "edje_private.h"
2 2
3#ifdef DEBUG_TEXT
4# define TPRN(...) do { printf(__VA_ARGS__); } while(0)
5#else
6# define TPRN(...)
7#endif
8
9#define COLOR_SET(color) \
10 (color).r * (color).a / 255, \
11 (color).g * (color).a / 255, \
12 (color).b * (color).a / 255, \
13 (color).a
14
3static double 15static double
4_edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text *chosen_desc, double base_scale, double scale) 16_edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text *chosen_desc, double base_scale, double scale)
5{ 17{
@@ -20,6 +32,248 @@ _edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text
20 return scale; 32 return scale;
21} 33}
22 34
35static void
36_edje_part_recalc_textblock_font_get(Edje *ed, Edje_Real_Part *ep,
37 Edje_Part_Description_Text *chosen_desc,
38 const char **ret_font_source,
39 const char **ret_font, int *ret_size)
40
41{
42 Edje_Real_Part *source;
43 const char *font;
44 int size;
45 Eina_Bool inlined_font = EINA_FALSE;
46 const char *font_source = NULL;
47 char *sfont, *font2;
48
49 sfont = font2 = NULL;
50
51 source = ep->typedata.text->source;
52
53 if (source)
54 font = _edje_text_class_font_get(ed,
55 _edje_real_part_text_source_description_get(ep,
56 &source), &size, &sfont);
57 else
58 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
59
60 if (size <= 0) size = 1;
61 if (!font) font = "";
62
63 if (source)
64 {
65 if (source->typedata.text->font) font = source->typedata.text->font;
66 if (source->typedata.text->size > 0) size = source->typedata.text->size;
67 }
68 else
69 {
70 if (ep->typedata.text->font) font = ep->typedata.text->font;
71 if (ep->typedata.text->size > 0) size = ep->typedata.text->size;
72 }
73
74 if (ed->file->fonts)
75 {
76 Edje_Font_Directory_Entry *fnt;
77
78 fnt = eina_hash_find(ed->file->fonts, font);
79
80 if (fnt)
81 {
82 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
83 font2 = alloca(len);
84 sprintf(font2, "edje/fonts/%s", font);
85 font = font2;
86 inlined_font = 1;
87 font2 = NULL; // so it is not freed at the end of the function
88 }
89 }
90 if (inlined_font)
91 {
92 font_source = ed->path;
93 }
94
95 if ((_edje_fontset_append) && (font))
96 {
97 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
98 if (font2)
99 {
100 strcpy(font2, font);
101 strcat(font2, ",");
102 strcat(font2, _edje_fontset_append);
103 font = font2; //font2 needs to be freed at the end of the
104 // function.
105 }
106 }
107 if (ret_font) *ret_font = font;
108 if (ret_size) *ret_size = size;
109 if (ret_font_source) *ret_font_source = font_source;
110
111 if (font2) free(font2);
112 if (sfont) free(sfont);
113}
114
115static inline Eina_Bool
116_edje_part_recalc_textblock_text_get(Edje *ed, Edje_Real_Part *ep,
117 Edje_Part_Description_Text *chosen_desc, const char **_ret)
118{
119 Eina_Bool same = EINA_FALSE;
120 const char *text = NULL;
121
122 if (chosen_desc->text.domain)
123 {
124 if (!chosen_desc->text.text.translated)
125 chosen_desc->text.text.translated = _set_translated_string(ed, ep);
126 if (chosen_desc->text.text.translated)
127 text = chosen_desc->text.text.translated;
128 }
129
130 if (!text)
131 {
132 text = edje_string_get(&chosen_desc->text.text);
133 if (ep->typedata.text->text) text = ep->typedata.text->text;
134 }
135
136 if (chosen_desc->text.id_text_source >= 0)
137 {
138 Edje_Part_Description_Text *et;
139 Edje_Real_Part *rp;
140 ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
141
142 et = _edje_real_part_text_text_source_description_get(ep, &rp);
143 text = edje_string_get(&(et->text.text));
144
145 if (rp->typedata.text->text) text = rp->typedata.text->text;
146 }
147
148 if ((text == ep->typedata.text->cache.in_str)
149 || (text && ep->typedata.text->cache.in_str && !strcmp(ep->typedata.text->cache.in_str, text)))
150 {
151 text = ep->typedata.text->cache.in_str;
152 same = EINA_TRUE;
153 }
154
155 if (!same)
156 {
157 eina_stringshare_replace(&ep->typedata.text->cache.in_str, text);
158 }
159
160 *_ret = text;
161 return same;
162}
163
164static inline Edje_Style *
165_edje_part_recalc_textblock_style_get(Edje *ed, Edje_Real_Part *ep,
166 Edje_Part_Description_Text *chosen_desc)
167{
168 Edje_Style *stl = NULL;
169 const char *tmp, *style = "";
170 Eina_List *l;
171
172 if (chosen_desc->text.id_source >= 0)
173 {
174 Edje_Part_Description_Text *et;
175
176 ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
177
178 et = _edje_real_part_text_source_description_get(ep, NULL);
179 tmp = edje_string_get(&et->text.style);
180 if (tmp) style = tmp;
181 }
182 else
183 {
184 ep->typedata.text->source = NULL;
185
186 tmp = edje_string_get(&chosen_desc->text.style);
187 if (tmp) style = tmp;
188 }
189
190 EINA_LIST_FOREACH(ed->file->styles, l, stl)
191 {
192 if ((stl->name) && (!strcmp(stl->name, style))) break;
193 stl = NULL;
194 }
195
196 return stl;
197}
198
199static inline void
200_edje_part_recalc_textblock_fit(Edje_Real_Part *ep,
201 Edje_Part_Description_Text *chosen_desc,
202 Edje_Calc_Params *params,
203 FLOAT_T sc, Evas_Coord *tw, Evas_Coord *th)
204{
205 double base_s = 1.0;
206 double orig_s;
207 double s = base_s;
208
209 if (ep->part->scale) base_s = TO_DOUBLE(sc);
210 efl_canvas_object_scale_set(ep->object, base_s);
211 efl_canvas_text_size_native_get(ep->object, tw, th);
212
213 orig_s = base_s;
214 /* Now make it bigger so calculations will be more accurate
215 * and less influenced by hinting... */
216 {
217 orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
218 orig_s * TO_INT(params->eval.w) / *tw);
219 efl_canvas_object_scale_set(ep->object, orig_s);
220 efl_canvas_text_size_native_get(ep->object, tw, th);
221 }
222 if (chosen_desc->text.fit_x)
223 {
224 if (*tw > 0)
225 {
226 s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
227 orig_s * TO_INT(params->eval.w) / *tw);
228 efl_canvas_object_scale_set(ep->object, s);
229 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
230 }
231 }
232 if (chosen_desc->text.fit_y)
233 {
234 if (*th > 0)
235 {
236 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
237 orig_s * TO_INT(params->eval.h) / *th);
238 /* If we already have X fit, restrict Y to be no bigger
239 * than what we got with X. */
240 if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
241 {
242 s = tmp_s;
243 }
244
245 efl_canvas_object_scale_set(ep->object, s);
246 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
247 }
248 }
249
250 /* Final tuning, try going down 90% at a time, hoping it'll
251 * actually end up being correct. */
252 {
253 int i = 5; /* Tries before we give up. */
254 Evas_Coord fw, fh;
255 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
256
257 /* If we are still too big, try reducing the size to
258 * 95% each try. */
259 while ((i > 0) &&
260 ((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
261 (chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
262 {
263 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
264
265 /* Break if we are not making any progress. */
266 if (EQ(tmp_s, s))
267 break;
268 s = tmp_s;
269
270 efl_canvas_object_scale_set(ep->object, s);
271 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
272 i--;
273 }
274 }
275}
276
23/* 277/*
24 * Legacy function for min/max calculation of textblock part. 278 * Legacy function for min/max calculation of textblock part.
25 * It can't calculate min/max properly in many cases. 279 * It can't calculate min/max properly in many cases.
@@ -35,6 +289,7 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
35 int *maxw, int *maxh) 289 int *maxw, int *maxh)
36{ 290{
37 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 291 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
292 ins_l = ins_r = ins_t = ins_b = 0;
38 293
39 /* Legacy code for Textblock min/max calculation */ 294 /* Legacy code for Textblock min/max calculation */
40 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 295 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
@@ -49,8 +304,10 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
49 } 304 }
50 else 305 else
51 evas_object_textblock_size_native_get(ep->object, &tw, &th); 306 evas_object_textblock_size_native_get(ep->object, &tw, &th);
307
52 evas_object_textblock_style_insets_get(ep->object, &ins_l, 308 evas_object_textblock_style_insets_get(ep->object, &ins_l,
53 &ins_r, &ins_t, &ins_b); 309 &ins_r, &ins_t, &ins_b);
310
54 mw = ins_l + tw + ins_r; 311 mw = ins_l + tw + ins_r;
55 mh = ins_t + th + ins_b; 312 mh = ins_t + th + ins_b;
56 if (minw && chosen_desc->text.min_x) 313 if (minw && chosen_desc->text.min_x)
@@ -75,8 +332,10 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
75 } 332 }
76 else 333 else
77 evas_object_textblock_size_native_get(ep->object, &tw, &th); 334 evas_object_textblock_size_native_get(ep->object, &tw, &th);
78 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, 335
79 &ins_t, &ins_b); 336 evas_object_textblock_style_insets_get(ep->object, &ins_l,
337 &ins_r, &ins_t, &ins_b);
338
80 mw = ins_l + tw + ins_r; 339 mw = ins_l + tw + ins_r;
81 mh = ins_t + th + ins_b; 340 mh = ins_t + th + ins_b;
82 if (maxw && chosen_desc->text.max_x) 341 if (maxw && chosen_desc->text.max_x)
@@ -101,19 +360,25 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
101{ 360{
102 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 361 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
103 Evas_Coord min_calc_w = 0, min_calc_h = 0; 362 Evas_Coord min_calc_w = 0, min_calc_h = 0;
363 unsigned char dmin_x, dmin_y;
364
365 ins_l = ins_r = ins_t = ins_b = 0;
104 366
105 /* min_calc_* values need to save calculated minumum size 367 /* min_calc_* values need to save calculated minumum size
106 * for maximum size calculation */ 368 * for maximum size calculation */
107 if (minw) min_calc_w = *minw; 369 if (minw) min_calc_w = *minw;
108 if (minh) min_calc_h = *minh; 370 if (minh) min_calc_h = *minh;
109 371
110 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 372 dmin_x = chosen_desc->text.min_x;
373 dmin_y = chosen_desc->text.min_y;
374
375 if (dmin_x || dmin_y)
111 { 376 {
112 evas_object_textblock_style_insets_get(ep->object, &ins_l, 377 evas_object_textblock_style_insets_get(ep->object, &ins_l,
113 &ins_r, &ins_t, &ins_b); 378 &ins_r, &ins_t, &ins_b);
114 379
115 tw = th = 0; 380 tw = th = 0;
116 if (!chosen_desc->text.min_x) 381 if (!dmin_x)
117 { 382 {
118 /* text.min: 0 1 383 /* text.min: 0 1
119 * text.max: X X */ 384 * text.max: X X */
@@ -161,7 +426,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
161 { 426 {
162 /* text.min: 1 X 427 /* text.min: 1 X
163 * text.max: X X */ 428 * text.max: X X */
164 if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) && 429 if (dmin_y && (!chosen_desc->text.max_x) &&
165 maxw && (*maxw > -1)) 430 maxw && (*maxw > -1))
166 { 431 {
167 /* text.min: 1 1 432 /* text.min: 1 1
@@ -222,14 +487,14 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
222 487
223 if (tw > min_calc_w) min_calc_w = tw; 488 if (tw > min_calc_w) min_calc_w = tw;
224 if (th > min_calc_h) min_calc_h = th; 489 if (th > min_calc_h) min_calc_h = th;
225 if (chosen_desc->text.min_x && minw) *minw = min_calc_w; 490 if (dmin_x && minw) *minw = min_calc_w;
226 if (chosen_desc->text.min_y && minh) *minh = min_calc_h; 491 if (dmin_y && minh) *minh = min_calc_h;
227 } 492 }
228 493
229 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) 494 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
230 { 495 {
231 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, 496 evas_object_textblock_style_insets_get(ep->object, &ins_l,
232 &ins_t, &ins_b); 497 &ins_r, &ins_t, &ins_b);
233 498
234 tw = th = 0; 499 tw = th = 0;
235 if (!chosen_desc->text.max_x) 500 if (!chosen_desc->text.max_x)
@@ -284,7 +549,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
284 else 549 else
285 { 550 {
286 /* text.max: 1 X */ 551 /* text.max: 1 X */
287 if (chosen_desc->text.min_x) 552 if (dmin_x)
288 { 553 {
289 /* text.min: 1 X 554 /* text.min: 1 X
290 * text.max: 1 X 555 * text.max: 1 X
@@ -312,7 +577,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
312 if (min_calc_h > temp_h) 577 if (min_calc_h > temp_h)
313 temp_h = min_calc_h; 578 temp_h = min_calc_h;
314 579
315 if (chosen_desc->text.min_y) 580 if (dmin_y)
316 { 581 {
317 /* text.min: 0 1 582 /* text.min: 0 1
318 * text.max: 1 1 583 * text.max: 1 1
@@ -383,6 +648,147 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
383 } 648 }
384} 649}
385 650
651static void
652_edje_textblock_colors_set(Edje *ed EINA_UNUSED,
653 Edje_Real_Part *ep,
654 Edje_Calc_Params *params,
655 Eina_Bool styles)
656{
657
658 Edje_Text_Effect effect;
659 Efl_Text_Style_Effect_Type st;
660 Efl_Text_Style_Shadow_Direction dir;
661
662 if (ep->part->type == EDJE_PART_TYPE_TEXT)
663 {
664 efl_text_normal_color_set(ep->object, COLOR_SET(params->color));
665 evas_object_color_set(ep->object, 255, 255, 255, 255);
666 }
667
668 effect = ep->part->effect;
669 switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC)
670 {
671 case EDJE_TEXT_EFFECT_NONE:
672 case EDJE_TEXT_EFFECT_PLAIN:
673 st = EFL_TEXT_STYLE_EFFECT_TYPE_NONE;
674 break;
675
676 case EDJE_TEXT_EFFECT_OUTLINE:
677 st = EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE;
678 if (styles) efl_text_outline_color_set(ep->object,
679 COLOR_SET(params->type.text->color2));
680 break;
681
682 case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
683 st = EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_OUTLINE;
684 if (styles) efl_text_outline_color_set(ep->object,
685 COLOR_SET(params->type.text->color2));
686 break;
687
688 case EDJE_TEXT_EFFECT_SHADOW:
689 st = EFL_TEXT_STYLE_EFFECT_TYPE_SHADOW;
690 if (styles) efl_text_shadow_color_set(ep->object,
691 COLOR_SET(params->type.text->color3));
692 break;
693
694 case EDJE_TEXT_EFFECT_SOFT_SHADOW:
695 st = EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_SHADOW;
696 if (styles) efl_text_shadow_color_set(ep->object,
697 COLOR_SET(params->type.text->color3));
698 break;
699
700 case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
701 st = EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE_SHADOW;
702 if (styles)
703 {
704 efl_text_outline_color_set(ep->object,
705 COLOR_SET(params->type.text->color2));
706 efl_text_shadow_color_set(ep->object,
707 COLOR_SET(params->type.text->color3));
708 }
709 break;
710
711 case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
712 st = EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE_SOFT_SHADOW;
713 if (styles)
714 {
715 efl_text_outline_color_set(ep->object,
716 COLOR_SET(params->type.text->color2));
717 efl_text_shadow_color_set(ep->object,
718 COLOR_SET(params->type.text->color3));
719 }
720 break;
721
722 case EDJE_TEXT_EFFECT_FAR_SHADOW:
723 st = EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SHADOW;
724 if (styles) efl_text_shadow_color_set(ep->object,
725 COLOR_SET(params->type.text->color3));
726 break;
727
728 case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
729 st = EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SOFT_SHADOW;
730 if (styles) efl_text_shadow_color_set(ep->object,
731 COLOR_SET(params->type.text->color3));
732 break;
733
734 case EDJE_TEXT_EFFECT_GLOW:
735 st = EFL_TEXT_STYLE_EFFECT_TYPE_GLOW;
736 if (styles)
737 {
738 efl_text_glow_color_set(ep->object,
739 COLOR_SET(params->type.text->color2));
740 efl_text_glow2_color_set(ep->object,
741 COLOR_SET(params->type.text->color3));
742 }
743 break;
744
745 default:
746 st = EFL_TEXT_STYLE_EFFECT_TYPE_NONE;
747 break;
748 }
749
750 switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION)
751 {
752 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT:
753 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_RIGHT;
754 break;
755
756 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM:
757 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM;
758 break;
759
760 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT:
761 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT;
762 break;
763
764 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT:
765 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_LEFT;
766 break;
767
768 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT:
769 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT;
770 break;
771
772 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP:
773 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP;
774 break;
775
776 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT:
777 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT;
778 break;
779
780 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT:
781 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_RIGHT;
782 break;
783
784 default:
785 dir = EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP;
786 break;
787 }
788 efl_text_effect_type_set(ep->object, st);
789 efl_text_shadow_direction_set(ep->object, dir);
790}
791
386void 792void
387_edje_part_recalc_single_textblock(FLOAT_T sc, 793_edje_part_recalc_single_textblock(FLOAT_T sc,
388 Edje *ed, 794 Edje *ed,
@@ -392,172 +798,97 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
392 int *minw, int *minh, 798 int *minw, int *minh,
393 int *maxw, int *maxh) 799 int *maxw, int *maxh)
394{ 800{
801 double align_y;
802
395 if ((ep->type != EDJE_RP_TYPE_TEXT) || 803 if ((ep->type != EDJE_RP_TYPE_TEXT) ||
396 (!ep->typedata.text)) 804 (!ep->typedata.text))
397 return; 805 return;
398 806
399 if (chosen_desc) 807 align_y = TO_DOUBLE(params->type.text->align.y);
400 { 808 efl_text_valign_set(ep->object, align_y);
401 Evas_Coord tw, th;
402 const char *text = "";
403 const char *style = "";
404 Edje_Style *stl = NULL;
405 const char *tmp;
406 Eina_List *l;
407 809
408 if (chosen_desc->text.id_source >= 0) 810 if (ep->part->type == EDJE_PART_TYPE_TEXT)
409 { 811 {
410 Edje_Part_Description_Text *et; 812 double align_x;
411 813
412 ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; 814 align_x = TO_DOUBLE(params->type.text->align.x);
413 815
414 et = _edje_real_part_text_source_description_get(ep, NULL); 816 if (align_x < 0)
415 tmp = edje_string_get(&et->text.style); 817 {
416 if (tmp) style = tmp; 818 efl_text_halign_auto_type_set(ep->object,
819 EFL_TEXT_HORIZONTAL_ALIGNMENT_AUTO_NORMAL);
417 } 820 }
418 else 821 else
419 { 822 {
420 ep->typedata.text->source = NULL; 823 efl_text_halign_set(ep->object, align_x);
421
422 tmp = edje_string_get(&chosen_desc->text.style);
423 if (tmp) style = tmp;
424 } 824 }
825 }
425 826
426 if (chosen_desc->text.id_text_source >= 0) 827 if (chosen_desc)
427 { 828 {
428 Edje_Part_Description_Text *et; 829 const char *font, *font_source;
429 Edje_Real_Part *rp; 830 int size;
430
431 ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
432 831
433 et = _edje_real_part_text_text_source_description_get(ep, &rp); 832 Evas_Coord tw, th;
434 text = edje_string_get(&et->text.text); 833 Edje_Style *stl = NULL;
834 const char *text;
435 835
436 if (rp->typedata.text->text) text = rp->typedata.text->text; 836 _edje_part_recalc_textblock_text_get(ed, ep, chosen_desc,
437 } 837 &text);
438 else
439 {
440 ep->typedata.text->text_source = NULL;
441 text = edje_string_get(&chosen_desc->text.text);
442 if (ep->typedata.text->text) text = ep->typedata.text->text;
443 }
444 838
445 EINA_LIST_FOREACH(ed->file->styles, l, stl) 839 stl = _edje_part_recalc_textblock_style_get(ed, ep, chosen_desc);
446 {
447 if ((stl->name) && (!strcmp(stl->name, style))) break;
448 stl = NULL;
449 }
450 840
451 if (ep->part->scale) 841 if (ep->part->scale)
452 evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 842 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
453 843
454 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y)) 844 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
455 { 845 {
456 double base_s = 1.0; 846 _edje_part_recalc_textblock_fit(ep, chosen_desc, params, sc, &tw, &th);
457 double orig_s;
458 double s = base_s;
459
460 if (ep->part->scale) base_s = TO_DOUBLE(sc);
461 efl_canvas_object_scale_set(ep->object, base_s);
462 efl_canvas_text_size_native_get(ep->object, &tw, &th);
463
464 orig_s = base_s;
465 /* Now make it bigger so calculations will be more accurate
466 * and less influenced by hinting... */
467 {
468 orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
469 orig_s * TO_INT(params->eval.w) / tw);
470 efl_canvas_object_scale_set(ep->object, orig_s);
471 efl_canvas_text_size_native_get(ep->object, &tw, &th);
472 }
473 if (chosen_desc->text.fit_x)
474 {
475 if (tw > 0)
476 {
477 s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
478 orig_s * TO_INT(params->eval.w) / tw);
479 efl_canvas_object_scale_set(ep->object, s);
480 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
481 }
482 }
483 if (chosen_desc->text.fit_y)
484 {
485 if (th > 0)
486 {
487 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
488 orig_s * TO_INT(params->eval.h) / th);
489 /* If we already have X fit, restrict Y to be no bigger
490 * than what we got with X. */
491 if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
492 {
493 s = tmp_s;
494 }
495
496 efl_canvas_object_scale_set(ep->object, s);
497 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
498 }
499 }
500
501 /* Final tuning, try going down 90% at a time, hoping it'll
502 * actually end up being correct. */
503 {
504 int i = 5; /* Tries before we give up. */
505 Evas_Coord fw, fh;
506 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
507
508 /* If we are still too big, try reducing the size to
509 * 95% each try. */
510 while ((i > 0) &&
511 ((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
512 (chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
513 {
514 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
515
516 /* Break if we are not making any progress. */
517 if (EQ(tmp_s, s))
518 break;
519 s = tmp_s;
520
521 efl_canvas_object_scale_set(ep->object, s);
522 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
523 i--;
524 }
525 }
526 } 847 }
527 848
849 _edje_part_recalc_textblock_font_get(ed, ep, chosen_desc,
850 &font_source, &font, &size);
851
528 if (stl) 852 if (stl)
529 { 853 {
530 if (evas_object_textblock_style_get(ep->object) != stl->style) 854 if (evas_object_textblock_style_get(ep->object) != stl->style)
531 evas_object_textblock_style_set(ep->object, stl->style); 855 evas_object_textblock_style_set(ep->object, stl->style);
532 // FIXME: need to account for editing 856 }
533 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
534 {
535 // do nothing - should be done elsewhere
536 }
537 else
538 {
539 evas_object_textblock_text_markup_set(ep->object, text);
540 }
541 857
542 if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19)) 858 if (ep->part->type == EDJE_PART_TYPE_TEXT)
543 { 859 {
544 _edje_part_recalc_single_textblock_min_max_calc(ep, 860 FLOAT_T ellip = params->type.text->ellipsis;
545 chosen_desc, 861 efl_text_font_set(ep->object, font, size);
546 params, 862 efl_text_ellipsis_set(ep->object, (ellip == -1.0) ? -1.0 : 1.0 - ellip);
547 minw, minh, 863 _edje_textblock_colors_set(ed, ep, params, EINA_TRUE);
548 maxw, maxh);
549 }
550 else
551 {
552 _edje_part_recalc_single_textblock_min_max_calc_legacy(ep,
553 chosen_desc,
554 params,
555 minw, minh,
556 maxw, maxh);
557 }
558 } 864 }
559 865
560 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y)); 866 // FIXME: need to account for editing
867 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
868 {
869 // do nothing - should be done elsewhere
870 }
871 else
872 {
873 evas_object_textblock_text_markup_set(ep->object, text);
874 }
875
876 if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19))
877 {
878 _edje_part_recalc_single_textblock_min_max_calc(ep,
879 chosen_desc,
880 params,
881 minw, minh,
882 maxw, maxh);
883 }
884 else
885 {
886 _edje_part_recalc_single_textblock_min_max_calc_legacy(ep,
887 chosen_desc,
888 params,
889 minw, minh,
890 maxw, maxh);
891 }
561 } 892 }
562} 893}
563 894
@@ -566,15 +897,11 @@ _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
566 Edje_Calc_Params *params, 897 Edje_Calc_Params *params,
567 Edje_Part_Description_Text *chosen_desc) 898 Edje_Part_Description_Text *chosen_desc)
568{ 899{
569 /* FIXME: this is just an hack. */
570 FLOAT_T sc; 900 FLOAT_T sc;
571 901
572#if 0
573 _get_text(ep);
574#endif
575
576 sc = DIV(ed->scale, ed->file->base_scale); 902 sc = DIV(ed->scale, ed->file->base_scale);
577 if (EQ(sc, ZERO)) sc = DIV(_edje_scale, ed->file->base_scale); 903 if (EQ(sc, ZERO)) sc = DIV(_edje_scale, ed->file->base_scale);
904 _edje_textblock_colors_set(ed, ep, params, EINA_FALSE);
578 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y) 905 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
579 { 906 {
580 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params, 907 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 1b772d4be7..c6a2f8cacf 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1981,7 +1981,7 @@ _edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part,
1981 return desc->text.text.str; 1981 return desc->text.text.str;
1982 } 1982 }
1983 } 1983 }
1984 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) 1984 else
1985 { 1985 {
1986 const char *entry; 1986 const char *entry;
1987 if (legacy) 1987 if (legacy)
@@ -3399,7 +3399,7 @@ again:
3399 //width 3399 //width
3400 if (!ep->chosen_description->fixed.w) 3400 if (!ep->chosen_description->fixed.w)
3401 { 3401 {
3402 if ((legacy_calc) && (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)) 3402 if ((legacy_calc) && PART_IS_TEXT(ed, ep))
3403 { 3403 {
3404 //We care textblock width size specially. 3404 //We care textblock width size specially.
3405 Evas_Coord tb_mw; 3405 Evas_Coord tb_mw;
@@ -3427,9 +3427,8 @@ again:
3427 { 3427 {
3428 if (legacy_calc) 3428 if (legacy_calc)
3429 { 3429 {
3430 if ((ep->part->type != EDJE_PART_TYPE_TEXTBLOCK) || 3430 if (!PART_IS_TEXT(ed, ep) ||
3431 ((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x || 3431 ((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x || !skip_h)
3432 !skip_h)
3433 { 3432 {
3434 if (over_h > max_over_h) 3433 if (over_h > max_over_h)
3435 { 3434 {
@@ -3439,7 +3438,7 @@ again:
3439 } 3438 }
3440 } 3439 }
3441 3440
3442 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) 3441 if (PART_IS_TEXT(ed, ep))
3443 has_fixed_tb = EINA_FALSE; 3442 has_fixed_tb = EINA_FALSE;
3444 } 3443 }
3445 else if (over_h > max_over_h) 3444 else if (over_h > max_over_h)