summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2020-06-10 15:39:03 +0900
committerHermet Park <chuneon.park@samsung.com>2020-06-10 15:39:03 +0900
commit4331c1e08eb43162635aa99125319d569dae9f45 (patch)
tree5fc38c400a1b3a9ba4e26a9f3ce9ff941a56c72b /src/lib
parent4f6a086f6ad9e0151e32930bafb6e85d5cb8f826 (diff)
efl_ui_textpath: add the efl_ui_textpath_text_user_style_set API for applying the user text style
Summary: For the text style customizing, added the new API to apply user text style. The following example is the user style sample. DEFAULT='font_size=16 color=#F00 underline=on underline_color=#00ffff'"; {F3899541} Test Plan: 1. run elementary_text (textpath) 2. toggle user style check box 3. see the result Reviewers: Hermet, kimcinoo, jsuya, bu5hm4n Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11953
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_textpath.c73
-rw-r--r--src/lib/elementary/elm_textpath_legacy.h12
2 files changed, 80 insertions, 5 deletions
diff --git a/src/lib/elementary/efl_ui_textpath.c b/src/lib/elementary/efl_ui_textpath.c
index 3cb1d96809..539f996108 100644
--- a/src/lib/elementary/efl_ui_textpath.c
+++ b/src/lib/elementary/efl_ui_textpath.c
@@ -15,6 +15,8 @@
15 15
16#define MY_CLASS EFL_UI_TEXTPATH_CLASS 16#define MY_CLASS EFL_UI_TEXTPATH_CLASS
17#define MY_CLASS_NAME "Efl.Ui.Textpath" 17#define MY_CLASS_NAME "Efl.Ui.Textpath"
18#define LEGACY_TEXT_PART_NAME "elm.text"
19#define EFL_UI_TEXT_PART_NAME "efl.text"
18 20
19#define SLICE_DEFAULT_NO 99 21#define SLICE_DEFAULT_NO 99
20typedef struct _Efl_Ui_Textpath_Point Efl_Ui_Textpath_Point; 22typedef struct _Efl_Ui_Textpath_Point Efl_Ui_Textpath_Point;
@@ -54,6 +56,7 @@ struct _Efl_Ui_Textpath_Data
54{ 56{
55 Evas_Object *text_obj; 57 Evas_Object *text_obj;
56 char *text; 58 char *text;
59 Eina_Strbuf *user_style;
57 Efl_Gfx_Path *path; 60 Efl_Gfx_Path *path;
58 struct { 61 struct {
59 double x, y; 62 double x, y;
@@ -529,13 +532,40 @@ _sizing_eval(Efl_Ui_Textpath_Data *pd)
529} 532}
530 533
531static void 534static void
532_textpath_ellipsis_set(Efl_Ui_Textpath_Data *pd, Eina_Bool enabled) 535_textpath_ellipsis_set(Eo *obj, Efl_Ui_Textpath_Data *pd, Eina_Bool enabled)
533{ 536{
534 edje_object_part_text_style_user_pop(pd->text_obj, "efl.text"); 537 char *text_part;
538 if (elm_widget_is_legacy(obj))
539 text_part = LEGACY_TEXT_PART_NAME;
540 else
541 text_part = EFL_UI_TEXT_PART_NAME;
542
543 edje_object_part_text_style_user_pop(pd->text_obj, text_part);
535 544
536 if (enabled) 545 if (enabled)
537 edje_object_part_text_style_user_push(pd->text_obj, "efl.text", 546 {
538 "DEFAULT='ellipsis=1.0'"); 547 if (pd->user_style)
548 {
549 eina_strbuf_replace_first(pd->user_style, "DEFAULT='", "DEFAULT='ellipsis=1.0 ");
550 edje_object_part_text_style_user_push(pd->text_obj, text_part,
551 eina_strbuf_string_get(pd->user_style));
552 }
553 else
554 {
555 edje_object_part_text_style_user_push(pd->text_obj, text_part,
556 "DEFAULT='ellipsis=1.0 '");
557 return;
558 }
559 }
560 else
561 {
562 if (pd->user_style)
563 {
564 eina_strbuf_replace_first(pd->user_style, "DEFAULT='ellipsis=1.0 ", "DEFAULT='");
565 edje_object_part_text_style_user_push(pd->text_obj, text_part,
566 eina_strbuf_string_get(pd->user_style));
567 }
568 }
539} 569}
540 570
541static void 571static void
@@ -563,7 +593,7 @@ _ellipsis_set(Efl_Ui_Textpath_Data *pd, Eo *obj)
563 } 593 }
564 } 594 }
565 efl_gfx_entity_size_set(pd->text_obj, EINA_SIZE2D(w, h)); 595 efl_gfx_entity_size_set(pd->text_obj, EINA_SIZE2D(w, h));
566 _textpath_ellipsis_set(pd, is_ellipsis); 596 _textpath_ellipsis_set(obj, pd, is_ellipsis);
567} 597}
568 598
569static void 599static void
@@ -713,6 +743,7 @@ _efl_ui_textpath_efl_object_destructor(Eo *obj, Efl_Ui_Textpath_Data *pd)
713 743
714 if (pd->text) free(pd->text); 744 if (pd->text) free(pd->text);
715 if (pd->text_obj) evas_object_del(pd->text_obj); 745 if (pd->text_obj) evas_object_del(pd->text_obj);
746 if (pd->user_style) eina_strbuf_free(pd->user_style);
716 EINA_INLIST_FREE(pd->segments, seg) 747 EINA_INLIST_FREE(pd->segments, seg)
717 { 748 {
718 pd->segments = eina_inlist_remove(pd->segments, EINA_INLIST_GET(seg)); 749 pd->segments = eina_inlist_remove(pd->segments, EINA_INLIST_GET(seg));
@@ -1013,5 +1044,37 @@ elm_textpath_circle_set(Eo *obj, double x, double y, double radius, double start
1013 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(x * 2, y * 2)); 1044 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(x * 2, y * 2));
1014} 1045}
1015 1046
1047EAPI void
1048elm_textpath_text_user_style_set(Eo *obj, const char *style)
1049{
1050 EFL_UI_TEXTPATH_DATA_GET(obj, pd);
1051 if (!pd) return;
1052
1053 char *text_part;
1054 if (elm_widget_is_legacy(obj))
1055 text_part = LEGACY_TEXT_PART_NAME;
1056 else
1057 text_part = EFL_UI_TEXT_PART_NAME;
1058
1059 if (pd->user_style)
1060 {
1061 edje_object_part_text_style_user_pop(pd->text_obj, text_part);
1062 eina_strbuf_free(pd->user_style);
1063 pd->user_style = NULL;
1064 }
1065
1066 if (style)
1067 {
1068 pd->user_style = eina_strbuf_new();
1069 eina_strbuf_append(pd->user_style, style);
1070
1071 edje_object_part_text_style_user_pop(pd->text_obj, text_part);
1072 edje_object_part_text_style_user_push(pd->text_obj, text_part, eina_strbuf_string_get(pd->user_style));
1073 }
1074
1075 _ellipsis_set(pd, obj);
1076 _sizing_eval(pd);
1077}
1078
1016#include "efl_ui_textpath_legacy_eo.c" 1079#include "efl_ui_textpath_legacy_eo.c"
1017 1080
diff --git a/src/lib/elementary/elm_textpath_legacy.h b/src/lib/elementary/elm_textpath_legacy.h
index 1795bdfa60..259c63b9bd 100644
--- a/src/lib/elementary/elm_textpath_legacy.h
+++ b/src/lib/elementary/elm_textpath_legacy.h
@@ -12,4 +12,16 @@ typedef Eo Elm_Textpath;
12 */ 12 */
13EAPI Evas_Object *elm_textpath_add(Evas_Object *parent); 13EAPI Evas_Object *elm_textpath_add(Evas_Object *parent);
14 14
15/**
16 * @brief Set the user text style
17 *
18 * @param[in] obj The textpath object
19 * @param[in] style The user text style. If the sytle is $null, the default style will be applied
20 *
21 * @ingroup Elm_Textpath
22 *
23 * @since 1.25
24 */
25EAPI void elm_textpath_text_user_style_set(Evas_Object *obj, const char *style);
26
15#include "efl_ui_textpath_eo.legacy.h" 27#include "efl_ui_textpath_eo.legacy.h"