summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora.srour <a.srour@samsung.com>2020-01-02 09:11:06 +0000
committerCedric BAIL <cedric.bail@free.fr>2020-01-02 11:00:04 -0800
commit0aaad623a01a623db7e89cb8ed2e8b7636d05867 (patch)
treec89f024a733561f3d80da7f199204e63994322c3
parentcb2645058e8252f5910d9869524ada70c26bef47 (diff)
edje: implement text_class override at object level
implement text_class override at object level, where you can change the text_class for single textblock object instead of override all objects that share same text class. This imported from TIZEN Note: This also fix edje_textblock font/font_size parsing by adding condition Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10598
-rw-r--r--src/lib/edje/Edje_Legacy.h38
-rw-r--r--src/lib/edje/edje_cache.c11
-rw-r--r--src/lib/edje/edje_load.c1
-rw-r--r--src/lib/edje/edje_private.h6
-rw-r--r--src/lib/edje/edje_smart.c7
-rw-r--r--src/lib/edje/edje_textblock_styles.c156
-rw-r--r--src/lib/edje/edje_util.c160
-rw-r--r--src/tests/elementary/elm_test_entry.c73
8 files changed, 404 insertions, 48 deletions
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index af89a4939c..f36cb53953 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -3147,6 +3147,44 @@ EAPI void edje_object_perspective_set(Evas_Object *obj, Edje_Perspective *ps);
3147EAPI const Edje_Perspective *edje_object_perspective_get(const Evas_Object *obj); 3147EAPI const Edje_Perspective *edje_object_perspective_get(const Evas_Object *obj);
3148 3148
3149/** 3149/**
3150 * @brief Sets Edje text class for edje file (if loaded)
3151 *
3152 * This function sets the text class for All Edje Objects created from Edje file.
3153 * (if edje file loaded before)
3154 *
3155 * @param[in] file edje file path
3156 * @param[in] text_class The text class name
3157 * @param[in] font Font name
3158 * @param[in] size Font Size
3159 *
3160 * @return @c true, on success or @c false, on error
3161 */
3162EAPI Eina_Bool edje_file_text_class_set(const char *file, const char *text_class, const char *font, Evas_Font_Size size);
3163
3164/**
3165 * @brief Delete the file text class.
3166 *
3167 * This function deletes any values at the file level for the specified
3168 * file and text class.
3169 *
3170 * @param[in] text_class The text class to be deleted.
3171 */
3172EAPI Eina_Bool edje_file_text_class_del(const char *file, const char *text_class);
3173
3174/**
3175 * @brief Gets font and font size from edje file if loaded.
3176 *
3177 * This function gets the font and the font size from the file text class.
3178 *
3179 * @param[in] text_class The text class name
3180 * @param[out] font Font name
3181 * @param[out] size Font Size
3182 *
3183 * @return @c true, on success or @c false, on error
3184 */
3185EAPI Eina_Bool edje_file_text_class_get(const char *file, const char * text_class, const char **font, Evas_Font_Size *size);
3186
3187/**
3150 * @} 3188 * @}
3151 */ 3189 */
3152 3190
diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index 64eb6ad5ec..e58584cba4 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -600,8 +600,13 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll
600 600
601 edf->text_hash = eina_hash_string_small_new(NULL); 601 edf->text_hash = eina_hash_string_small_new(NULL);
602 EINA_LIST_FOREACH(edf->text_classes, l, tc) 602 EINA_LIST_FOREACH(edf->text_classes, l, tc)
603 if (tc->name) 603 {
604 eina_hash_direct_add(edf->text_hash, tc->name, tc); 604 if (tc->name)
605 eina_hash_direct_add(edf->text_hash, tc->name, tc);
606
607 if (tc->font)
608 tc->font = eina_stringshare_add(tc->font);
609 }
605 610
606 edf->size_hash = eina_hash_string_small_new(NULL); 611 edf->size_hash = eina_hash_string_small_new(NULL);
607 EINA_LIST_FOREACH(edf->size_classes, l, sc) 612 EINA_LIST_FOREACH(edf->size_classes, l, sc)
@@ -713,7 +718,7 @@ _edje_file_cache_trash_pop(const Eina_File *file)
713 return NULL; 718 return NULL;
714} 719}
715 720
716static inline Edje_File* 721Edje_File*
717_edje_file_cache_find(const Eina_File *file) 722_edje_file_cache_find(const Eina_File *file)
718{ 723{
719 Edje_File *edf; 724 Edje_File *edf;
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 92713a2325..0e74db9fca 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -2081,6 +2081,7 @@ _edje_file_del(Edje *ed)
2081 _edje_text_part_on_del(ed, ep); 2081 _edje_text_part_on_del(ed, ep);
2082 _edje_color_class_on_del(ed, ep); 2082 _edje_color_class_on_del(ed, ep);
2083 } 2083 }
2084 _edje_object_textblock_styles_cache_cleanup(ed);
2084 2085
2085 _edje_cache_coll_unref(ed->file, ed->collection); 2086 _edje_cache_coll_unref(ed->file, ed->collection);
2086 ed->collection = NULL; 2087 ed->collection = NULL;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 9a293e2e33..9abbb50962 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1723,6 +1723,7 @@ struct _Edje
1723 1723
1724 Eina_List *groups; 1724 Eina_List *groups;
1725 1725
1726 Eina_Hash *styles;
1726 Edje_Perspective *persp; 1727 Edje_Perspective *persp;
1727 1728
1728 Ecore_Animator *animator; 1729 Ecore_Animator *animator;
@@ -2802,14 +2803,17 @@ void _edje_message_del (Edje *ed);
2802Evas_Textblock_Style * _edje_textblock_style_get(Edje *ed, const char *style); 2803Evas_Textblock_Style * _edje_textblock_style_get(Edje *ed, const char *style);
2803void _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep); 2804void _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep);
2804void _edje_textblock_styles_del(Edje *ed, Edje_Part *pt); 2805void _edje_textblock_styles_del(Edje *ed, Edje_Part *pt);
2806void _edje_object_textblock_style_all_update_text_class(Edje *ed, const char *text_class);
2807void _edje_object_textblock_styles_cache_cleanup(Edje *ed);
2805 2808
2806// Edje File level textblock style api 2809// Edje File level textblock style api
2807void _edje_file_textblock_style_all_update(Edje_File *ed); 2810void _edje_file_textblock_style_all_update(Edje_File *ed);
2808void _edje_file_textblock_style_all_update_text_class(Edje_File *edf, const char *text_class); 2811void _edje_file_textblock_styles_all_update_text_class(Edje *ed, const char *text_class);
2809void _edje_file_textblock_style_parse_and_fix(Edje_File *edf); 2812void _edje_file_textblock_style_parse_and_fix(Edje_File *edf);
2810void _edje_file_textblock_style_cleanup(Edje_File *edf); 2813void _edje_file_textblock_style_cleanup(Edje_File *edf);
2811 2814
2812Edje_File *_edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed); 2815Edje_File *_edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed);
2816Edje_File *_edje_file_cache_find(const Eina_File *file);
2813void _edje_cache_coll_clean(Edje_File *edf); 2817void _edje_cache_coll_clean(Edje_File *edf);
2814void _edje_cache_coll_flush(Edje_File *edf); 2818void _edje_cache_coll_flush(Edje_File *edf);
2815void _edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc); 2819void _edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc);
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index f8d42d9069..d0d794790b 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -504,7 +504,12 @@ _efl_canvas_layout_efl_observer_update(Eo *obj EINA_UNUSED, Edje *ed, Efl_Object
504 } 504 }
505 else if (obs == _edje_text_class_member) 505 else if (obs == _edje_text_class_member)
506 { 506 {
507 _edje_file_textblock_style_all_update_text_class(ed->file, key); 507 if (data == ed)
508 // Object level update
509 _edje_object_textblock_style_all_update_text_class(ed, key);
510 else if ((data == ed->file) || // File level update will pass ed->file
511 (!data)) // Global update will pass NULL
512 _edje_file_textblock_styles_all_update_text_class(ed, key);
508#ifdef EDJE_CALC_CACHE 513#ifdef EDJE_CALC_CACHE
509 ed->text_part_change = EINA_TRUE; 514 ed->text_part_change = EINA_TRUE;
510#endif 515#endif
diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c
index 3618d201c4..0eec7bca80 100644
--- a/src/lib/edje/edje_textblock_styles.c
+++ b/src/lib/edje/edje_textblock_styles.c
@@ -1,5 +1,72 @@
1#include "edje_private.h" 1#include "edje_private.h"
2 2
3void _edje_textblock_style_update(Edje *ed, Edje_Style *stl);
4
5static Edje_Style *
6_edje_textblock_style_copy(Edje_Style *stl)
7{
8 Edje_Style *new_stl;
9
10 new_stl = calloc(1, sizeof(Edje_Style));
11 if (!new_stl) return NULL;
12
13 new_stl->style = evas_textblock_style_new();
14 evas_textblock_style_set(new_stl->style, NULL);
15
16 // just keep a reference.
17 new_stl->tags = stl->tags;
18 new_stl->name = stl->name;
19 new_stl->cache = EINA_FALSE;
20
21 return new_stl;
22}
23
24static void
25_edje_object_textblock_styles_cache_style_free(void *data)
26{
27 Edje_Style *obj_stl = data;
28
29 if (!obj_stl) return;
30
31 if (obj_stl->style) evas_textblock_style_free(obj_stl->style);
32 free(obj_stl);
33}
34
35static Edje_Style *
36_edje_object_textblock_styles_cache_add(Edje *ed, Edje_Style *stl)
37{
38 Edje_Style *obj_stl = eina_hash_find(ed->styles, stl->name);
39 // Find the style in the object cache
40
41 if (!obj_stl)
42 {
43 obj_stl = _edje_textblock_style_copy(stl);
44
45 if (obj_stl)
46 {
47 if (!ed->styles) ed->styles = eina_hash_stringshared_new(_edje_object_textblock_styles_cache_style_free);
48 eina_hash_direct_add(ed->styles, obj_stl->name, obj_stl);
49 _edje_textblock_style_update(ed, obj_stl);
50 }
51 }
52 return obj_stl;
53}
54
55void
56_edje_object_textblock_styles_cache_cleanup(Edje *ed)
57{
58 if (!ed || !ed->styles) return;
59 eina_hash_free(ed->styles);
60 ed->styles = NULL;
61}
62
63static Edje_Style *
64_edje_object_textblock_styles_cache_get(Edje *ed, const char *stl)
65{
66 // Find the style in the object cache
67 return eina_hash_find(ed->styles, stl);
68}
69
3static int 70static int
4_edje_font_is_embedded(Edje_File *edf, const char *font) 71_edje_font_is_embedded(Edje_File *edf, const char *font)
5{ 72{
@@ -230,26 +297,6 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl)
230 eina_strbuf_free(txt); 297 eina_strbuf_free(txt);
231} 298}
232 299
233/*
234 * mark all the styles in the Edje_File dirty (except readonly styles)so that
235 * subsequent request to style will update before giving the style.
236 * Note: this will enable lazy style computation (only when some
237 * widget request for new style it will get computed).
238 *
239 * @param ed The edje containing styles which need to be updated
240 */
241void
242_edje_file_textblock_style_all_update(Edje_File *edf)
243{
244 Eina_List *l;
245 Edje_Style *stl;
246
247 if (!edf) return;
248
249 EINA_LIST_FOREACH(edf->styles, l, stl)
250 if (stl && !stl->readonly) stl->cache = EINA_FALSE;
251}
252
253static inline Edje_Style * 300static inline Edje_Style *
254_edje_textblock_style_search(Edje *ed, const char *style) 301_edje_textblock_style_search(Edje *ed, const char *style)
255{ 302{
@@ -371,9 +418,18 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt)
371Evas_Textblock_Style * 418Evas_Textblock_Style *
372_edje_textblock_style_get(Edje *ed, const char *style) 419_edje_textblock_style_get(Edje *ed, const char *style)
373{ 420{
421 Edje_Style *stl;
422
374 if (!style) return NULL; 423 if (!style) return NULL;
375 424
376 Edje_Style *stl = _edje_textblock_style_search(ed, style); 425 // First search in Edje_Object styles list
426 stl = _edje_object_textblock_styles_cache_get(ed, style);
427
428 if (!stl)
429 {
430 // If not found in Edje_Object search in Edje_File styles list
431 stl = _edje_textblock_style_search(ed, style);
432 }
377 433
378 if (!stl) return NULL; 434 if (!stl) return NULL;
379 435
@@ -387,19 +443,21 @@ _edje_textblock_style_get(Edje *ed, const char *style)
387 return stl->style; 443 return stl->style;
388} 444}
389 445
390/* 446static void
391 * Finds all the styles having text class tag as text_class and 447_edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class, Eina_Bool is_object_level)
392 * updates them.
393 */
394void
395_edje_file_textblock_style_all_update_text_class(Edje_File *edf, const char *text_class)
396{ 448{
397 Eina_List *l, *ll; 449 Eina_List *ll, *l;
398 Edje_Style *stl; 450 Edje_Style *stl;
451 Edje_Style *obj_stl;
452 Edje_File *edf;
399 453
400 if (!edf) return; 454 if (!ed) return;
455 if (!ed->file) return;
401 if (!text_class) return; 456 if (!text_class) return;
402 457
458 edf = ed->file;
459
460 // check if there is styles in file that uses this text_class
403 EINA_LIST_FOREACH(edf->styles, l, stl) 461 EINA_LIST_FOREACH(edf->styles, l, stl)
404 { 462 {
405 Edje_Style_Tag *tag; 463 Edje_Style_Tag *tag;
@@ -412,15 +470,49 @@ _edje_file_textblock_style_all_update_text_class(Edje_File *edf, const char *tex
412 470
413 if (!strcmp(tag->text_class, text_class)) 471 if (!strcmp(tag->text_class, text_class))
414 { 472 {
415 // just mark it dirty so the next request 473 if (is_object_level)
416 // for this style will trigger recomputation. 474 {
417 stl->cache = EINA_FALSE; 475 obj_stl = _edje_object_textblock_styles_cache_get(ed, stl->name);
476 if (obj_stl)
477 // If already in Edje styles just make it dirty
478 obj_stl->cache = EINA_FALSE;
479 else
480 // create a copy from it if it's not exists
481 _edje_object_textblock_styles_cache_add(ed, stl);
482 }
483 else
484 {
485 // just mark it dirty so the next request
486 // for this style will trigger recomputation.
487 stl->cache = EINA_FALSE;
488 }
489 // don't need to continue searching
418 break; 490 break;
419 } 491 }
420 } 492 }
421 } 493 }
422} 494}
423 495
496/*
497 * Finds all the styles having text class tag as text_class and
498 * updates them in object level.
499 */
500void
501_edje_object_textblock_style_all_update_text_class(Edje *ed, const char *text_class)
502{
503 _edje_textblock_style_all_update_text_class(ed, text_class, EINA_TRUE);
504}
505
506/*
507 * Finds all the styles having text class tag as text_class and
508 * updates them in file level.
509 */
510void
511_edje_file_textblock_styles_all_update_text_class(Edje *ed, const char *text_class)
512{
513 _edje_textblock_style_all_update_text_class(ed, text_class, EINA_FALSE);
514}
515
424/* When we get to here the edje file had been read into memory 516/* When we get to here the edje file had been read into memory
425 * the name of the style is established as well as the name and 517 * the name of the style is established as well as the name and
426 * data for the tags. This function will create the Evas_Style 518 * data for the tags. This function will create the Evas_Style
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index f699f835ff..0e6bc3e9ba 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1336,6 +1336,140 @@ _edje_text_class_list_foreach(const Eina_Hash *hash EINA_UNUSED, const void *key
1336 return EINA_TRUE; 1336 return EINA_TRUE;
1337} 1337}
1338 1338
1339static Edje_File *
1340_edje_file_find(const char *file)
1341{
1342 char *tmp = NULL;
1343 Eina_File *f = NULL;
1344 Edje_File *edf = NULL;
1345
1346 if (!file) return NULL;
1347
1348 tmp = eina_vpath_resolve(file);
1349 if (!tmp) return NULL;
1350
1351 f = eina_file_open(tmp, EINA_FALSE);
1352
1353 if (tmp) free(tmp);
1354 if (!f) return NULL;
1355
1356 edf = _edje_file_cache_find(f);
1357
1358 eina_file_close(f);
1359 return edf;
1360}
1361
1362EAPI Eina_Bool
1363edje_file_text_class_get(const char *file, const char * text_class, const char **font, Evas_Font_Size *size)
1364{
1365 Edje_Text_Class *tc = NULL;
1366 Edje_File *edf = NULL;
1367 Eina_Bool ret = EINA_FALSE;
1368
1369 if (font) *font = NULL;
1370 if (size) *size = 0;
1371
1372 if ((!file) || (!text_class)) return ret;
1373 if ((!font) && (!size)) return ret; // No need to go deep
1374
1375 edf = _edje_file_find(file);
1376 if (!edf) return ret;
1377
1378 tc = eina_hash_find(edf->text_hash, text_class);
1379 if (!tc) goto end;
1380
1381 if (font) *font = tc->font;
1382 if (size) *size = tc->size;
1383 ret = EINA_TRUE;
1384
1385end:
1386 _edje_cache_file_unref(edf);
1387 return ret;
1388}
1389
1390EAPI Eina_Bool
1391edje_file_text_class_del(const char *file, const char *text_class)
1392{
1393 Edje_Text_Class *tc = NULL;
1394 Edje_File *edf = NULL;
1395 Eina_Bool ret = EINA_FALSE;
1396 if ((!file) || (!text_class)) return ret;
1397
1398 edf = _edje_file_find(file);
1399 if (!edf) return ret;
1400
1401 tc = eina_hash_find(edf->text_hash, text_class);
1402 if (!tc) goto end;
1403
1404 eina_hash_del(edf->text_hash, text_class, tc);
1405 eina_stringshare_del(tc->name);
1406 eina_stringshare_del(tc->font);
1407 free(tc);
1408
1409 /* Tell all members of the text class to recalc */
1410 efl_observable_observers_update(_edje_text_class_member, text_class, edf);
1411
1412 ret = EINA_TRUE;
1413end:
1414 _edje_cache_file_unref(edf);
1415 return ret;
1416}
1417
1418EAPI Eina_Bool
1419edje_file_text_class_set(const char *file, const char *text_class, const char *font, Evas_Font_Size size)
1420{
1421 Edje_File *edf = NULL;
1422 Edje_Text_Class *tc = NULL;
1423 Eina_Bool ret = EINA_FALSE;
1424
1425 if ((!file) || (!text_class)) return ret;
1426
1427 edf = _edje_file_find(file);
1428 if (!edf) return ret;
1429
1430 // update text_class properties, or create new text_class if not found
1431 if (edf->text_hash) tc = eina_hash_find(edf->text_hash, text_class);
1432 if (!tc)
1433 {
1434 /* Create new text class */
1435 tc = calloc(1, sizeof(Edje_Text_Class));
1436 if (!tc) goto error_end;
1437 tc->name = eina_stringshare_add(text_class);
1438 if (!tc->name)
1439 {
1440 free(tc);
1441 goto error_end;
1442 }
1443 if (!edf->text_hash) edf->text_hash = eina_hash_string_small_new(NULL);
1444 eina_hash_direct_add(edf->text_hash, text_class, tc);
1445
1446 tc->font = eina_stringshare_add(font);
1447 tc->size = size;
1448 }
1449 else
1450 {
1451 /* Match and the same, return */
1452 if (((tc->font && font) && !strcmp(tc->font, font)) &&
1453 (tc->size == size))
1454 goto success_end;
1455
1456 /* Update the class found */
1457 eina_stringshare_replace(&tc->font, font);
1458 tc->size = size;
1459 }
1460
1461
1462 /* Tell all members of the text class to recalc */
1463 efl_observable_observers_update(_edje_text_class_member, text_class, edf);
1464
1465success_end:
1466 ret = EINA_TRUE;
1467
1468error_end:
1469 _edje_cache_file_unref(edf);
1470 return ret;
1471}
1472
1339EAPI Eina_Bool 1473EAPI Eina_Bool
1340edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size) 1474edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size)
1341{ 1475{
@@ -1401,7 +1535,7 @@ _efl_canvas_layout_efl_gfx_text_class_text_class_set(Eo *obj EINA_UNUSED, Edje *
1401 text_class, font, size); 1535 text_class, font, size);
1402 } 1536 }
1403 1537
1404 efl_observer_update(obj, _edje_text_class_member, text_class, NULL); 1538 efl_observer_update(obj, _edje_text_class_member, text_class, ed);
1405 1539
1406 return EINA_TRUE; 1540 return EINA_TRUE;
1407} 1541}
@@ -1460,7 +1594,7 @@ _efl_canvas_layout_efl_gfx_text_class_text_class_del(Eo *obj EINA_UNUSED, Edje *
1460 efl_gfx_text_class_del(rp->typedata.swallow->swallowed_object, text_class); 1594 efl_gfx_text_class_del(rp->typedata.swallow->swallowed_object, text_class);
1461 } 1595 }
1462 1596
1463 efl_observer_update(obj, _edje_text_class_member, text_class, NULL); 1597 efl_observer_update(obj, _edje_text_class_member, text_class, ed);
1464} 1598}
1465 1599
1466typedef struct _Edje_File_Text_Class_Iterator Edje_File_Text_Class_Iterator; 1600typedef struct _Edje_File_Text_Class_Iterator Edje_File_Text_Class_Iterator;
@@ -5828,24 +5962,28 @@ _edje_color_class_on_del(Edje *ed, Edje_Part *ep)
5828Edje_Text_Class * 5962Edje_Text_Class *
5829_edje_text_class_find(Edje *ed, const char *text_class) 5963_edje_text_class_find(Edje *ed, const char *text_class)
5830{ 5964{
5831 Edje_Text_Class *tc; 5965 Edje_Text_Class *tc = NULL;
5966
5967 if (!text_class) return NULL;
5832 5968
5833 if ((!ed) || (!text_class)) return NULL; 5969 if (!ed)
5970 {
5971 /* If ed object is NULL, then look through the global scope only */
5972 return eina_hash_find(_edje_text_class_hash, text_class);
5973 }
5834 5974
5835 /* first look through the object scope */ 5975 /* first look through the object scope */
5836 tc = eina_hash_find(ed->text_classes, text_class); 5976 tc = eina_hash_find(ed->text_classes, text_class);
5837 if (tc) return tc; 5977
5838
5839 /* next look through the global scope */ 5978 /* next look through the global scope */
5840 tc = eina_hash_find(_edje_text_class_hash, text_class); 5979 if (!tc)
5841 if (tc) return tc; 5980 tc = eina_hash_find(_edje_text_class_hash, text_class);
5842 5981
5843 /* finally, look through the file scope */ 5982 /* finally, look through the file scope */
5844 if (ed->file) 5983 if (!tc && ed->file)
5845 tc = eina_hash_find(ed->file->text_hash, text_class); 5984 tc = eina_hash_find(ed->file->text_hash, text_class);
5846 if (tc) return tc;
5847 5985
5848 return NULL; 5986 return tc;
5849} 5987}
5850 5988
5851static Eina_Bool 5989static Eina_Bool
diff --git a/src/tests/elementary/elm_test_entry.c b/src/tests/elementary/elm_test_entry.c
index 1b383b2936..4655a688ba 100644
--- a/src/tests/elementary/elm_test_entry.c
+++ b/src/tests/elementary/elm_test_entry.c
@@ -518,6 +518,78 @@ EFL_START_TEST(elm_entry_file_get_set)
518} 518}
519EFL_END_TEST 519EFL_END_TEST
520 520
521EFL_START_TEST(elm_entry_test_text_class)
522{
523 Evas_Object *win, *entry1, *entry2, *entry3, *entry4;
524 const char *filename = NULL;
525 int w1 = 0, h1 = 0, w2 = 0, h2 = 0, w3 = 0, h3 = 0;
526 const char *font;
527 int font_size;
528
529 win = win_add(NULL, "entry", ELM_WIN_BASIC);
530 entry1 = elm_entry_add(win);
531 entry2 = elm_entry_add(win);
532 entry3 = elm_entry_add(win);
533
534 elm_object_text_set(entry1, "hello");
535 elm_object_text_set(entry2, "hello");
536 elm_object_text_set(entry3, "hello");
537
538 edje_object_file_get(elm_layout_edje_get(entry1), &filename, NULL);
539 ck_assert(filename != NULL);
540
541 ck_assert(edje_file_text_class_set(filename, "entry_text", "Serif:Style=Bold", 24));
542
543 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry1), "entry_text", &font, &font_size));
544 ck_assert_int_eq(font_size, 24);
545 ck_assert_str_eq(font, "Serif:Style=Bold");
546 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry2), "entry_text", &font, &font_size));
547 ck_assert_int_eq(font_size, 24);
548 ck_assert_str_eq(font, "Serif:Style=Bold");
549 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry3), "entry_text", &font, &font_size));
550 ck_assert_int_eq(font_size, 24);
551 ck_assert_str_eq(font, "Serif:Style=Bold");
552
553 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry1), &w1, &h1);
554 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry2), &w2, &h2);
555 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry3), &w3, &h3);
556
557 ck_assert_int_eq(w1, w2);
558 ck_assert_int_eq(h1, h2);
559 ck_assert_int_eq(w2, w3);
560 ck_assert_int_eq(h2, h3);
561
562 ck_assert(edje_object_text_class_set(elm_layout_edje_get(entry1), "entry_text", "Sans", 50));
563 ck_assert(edje_object_text_class_set(elm_layout_edje_get(entry2), "entry_text", "Serif", 20));
564
565 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry1), "entry_text", &font, &font_size));
566 ck_assert_int_eq(font_size, 50);
567 ck_assert_str_eq(font, "Sans");
568 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry2), "entry_text", &font, &font_size));
569 ck_assert_int_eq(font_size, 20);
570 ck_assert_str_eq(font, "Serif");
571 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry3), "entry_text", &font, &font_size));
572 ck_assert_int_eq(font_size, 24);
573 ck_assert_str_eq(font, "Serif:Style=Bold");
574
575 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry1), &w1, &h1);
576 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry2), &w2, &h2);
577 evas_object_textblock_size_formatted_get(elm_entry_textblock_get(entry3), &w3, &h3);
578
579 ck_assert_int_ne(w1, w2);
580 ck_assert_int_ne(h1, h2);
581 ck_assert_int_ne(w2, w3);
582 ck_assert_int_ne(h2, h3);
583
584 entry4 = elm_entry_add(win);
585
586 elm_object_text_set(entry4, "hello");
587 ck_assert(edje_object_text_class_get(elm_layout_edje_get(entry4), "entry_text", &font, &font_size));
588 ck_assert_int_eq(font_size, 24);
589 ck_assert_str_eq(font, "Serif:Style=Bold");
590}
591EFL_END_TEST
592
521void elm_test_entry(TCase *tc) 593void elm_test_entry(TCase *tc)
522{ 594{
523 tcase_add_test(tc, elm_entry_legacy_type_check); 595 tcase_add_test(tc, elm_entry_legacy_type_check);
@@ -535,4 +607,5 @@ void elm_test_entry(TCase *tc)
535 tcase_add_test(tc, elm_entry_text_set); 607 tcase_add_test(tc, elm_entry_text_set);
536 tcase_add_test(tc, elm_entry_magnifier); 608 tcase_add_test(tc, elm_entry_magnifier);
537 tcase_add_test(tc, elm_entry_file_get_set); 609 tcase_add_test(tc, elm_entry_file_get_set);
610 tcase_add_test(tc, elm_entry_test_text_class);
538} 611}