From: Daniel Hirt Date: Thu, 28 Sep 2017 07:27:32 +0000 (+0300) Subject: Ui layout: support markup for efl_part() X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~2436 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=deca3c947ff1a2bed3f4baadce576105055af266;p=platform%2Fupstream%2Fefl.git Ui layout: support markup for efl_part() Also implement markup_set/get for: - Efl.Ui.Frame - Efl.Ui.Slider Users may choose between text_set/get and markup_set/get, depending on whether they want to escape their text or not. --- diff --git a/src/lib/elementary/efl_ui_button.eo b/src/lib/elementary/efl_ui_button.eo index 021c822..d349b7a 100644 --- a/src/lib/elementary/efl_ui_button.eo +++ b/src/lib/elementary/efl_ui_button.eo @@ -1,4 +1,5 @@ -class Efl.Ui.Button (Efl.Ui.Layout, Efl.Ui.Clickable, Efl.Ui.Autorepeat, Efl.Text, +class Efl.Ui.Button (Efl.Ui.Layout, Efl.Ui.Clickable, Efl.Ui.Autorepeat, + Efl.Text, Efl.Text.Markup, Elm.Interface.Atspi_Widget_Action, Efl.Ui.Translatable) { [[Push-button widget diff --git a/src/lib/elementary/efl_ui_frame.c b/src/lib/elementary/efl_ui_frame.c index 5f07ba8..e023999 100644 --- a/src/lib/elementary/efl_ui_frame.c +++ b/src/lib/elementary/efl_ui_frame.c @@ -257,6 +257,7 @@ _efl_ui_frame_class_constructor(Efl_Class *klass) } ELM_PART_TEXT_DEFAULT_IMPLEMENT(efl_ui_frame, Efl_Ui_Frame_Data) +ELM_PART_MARKUP_DEFAULT_IMPLEMENT(efl_ui_frame, Efl_Ui_Frame_Data) /* Internal EO APIs and hidden overrides */ diff --git a/src/lib/elementary/efl_ui_frame.eo b/src/lib/elementary/efl_ui_frame.eo index 21e305c..9282901 100644 --- a/src/lib/elementary/efl_ui_frame.eo +++ b/src/lib/elementary/efl_ui_frame.eo @@ -1,4 +1,4 @@ -class Efl.Ui.Frame (Efl.Ui.Layout, Efl.Ui.Clickable, Efl.Text, +class Efl.Ui.Frame (Efl.Ui.Layout, Efl.Ui.Clickable, Efl.Text, Efl.Text.Markup, Efl.Ui.Translatable) { [[Frame widget @@ -62,6 +62,7 @@ class Efl.Ui.Frame (Efl.Ui.Layout, Efl.Ui.Clickable, Efl.Text, Elm.Widget.focus_next; Elm.Widget.focus_direction_manager_is; Efl.Text.text { get; set; } + Efl.Text.Markup.markup { get; set; } Efl.Ui.Translatable.translatable_text { get; set; } } } diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c index 6ba041d..37fe34d 100644 --- a/src/lib/elementary/efl_ui_layout.c +++ b/src/lib/elementary/efl_ui_layout.c @@ -1225,7 +1225,7 @@ _efl_ui_layout_efl_container_content_count(Eo *eo_obj EINA_UNUSED, Efl_Ui_Layout } static Eina_Bool -_efl_ui_layout_text_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const char *text) +_efl_ui_layout_text_generic_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const char *text, Eina_Bool is_markup) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); @@ -1255,9 +1255,18 @@ _efl_ui_layout_text_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const if (!text) return EINA_TRUE; - if (!edje_object_part_text_escaped_set + if (is_markup) + { + if (!edje_object_part_text_escaped_set (wd->resize_obj, part, text)) - return EINA_FALSE; + return EINA_FALSE; + } + else + { + if (!edje_object_part_text_unescaped_set + (wd->resize_obj, part, text)) + return EINA_FALSE; + } if (!sub_d) { @@ -1296,12 +1305,32 @@ _efl_ui_layout_text_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const return EINA_TRUE; } +static Eina_Bool +_efl_ui_layout_text_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const char *text) +{ + return _efl_ui_layout_text_generic_set(obj, sd, part, text, EINA_FALSE); +} + static const char* _efl_ui_layout_text_get(Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED, const char *part) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); - return edje_object_part_text_get(wd->resize_obj, part); + return efl_text_get(efl_part(wd->resize_obj, part)); +} + +static const char* +_efl_ui_layout_text_markup_get(Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED, const char *part) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + + return efl_text_markup_get(efl_part(wd->resize_obj, part)); +} + +static Eina_Bool +_efl_ui_layout_text_markup_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const char *text) +{ + return _efl_ui_layout_text_generic_set(obj, sd, part, text, EINA_TRUE); } static void @@ -2564,6 +2593,8 @@ ELM_PART_OVERRIDE_CONTENT_UNSET_FULL(efl_ui_layout_part_content, efl_ui_layout, /* Efl.Ui.Layout.Part_Text */ ELM_PART_OVERRIDE_TEXT_GET_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) ELM_PART_OVERRIDE_TEXT_SET_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) +ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) +ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) EOLIAN static const char * _efl_ui_layout_part_text_efl_ui_translatable_translatable_text_get(Eo *obj, void *_pd EINA_UNUSED, const char **domain) @@ -2585,6 +2616,8 @@ ELM_PART_OVERRIDE_CONTENT_SET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL ELM_PART_OVERRIDE_CONTENT_UNSET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) ELM_PART_OVERRIDE_TEXT_GET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) ELM_PART_OVERRIDE_TEXT_SET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) +ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) +ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(efl_ui_layout_part_legacy, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) EOLIAN static const char * _efl_ui_layout_part_legacy_efl_ui_translatable_translatable_text_get(Eo *obj, void *_pd EINA_UNUSED, const char **domain) diff --git a/src/lib/elementary/efl_ui_layout_part_legacy.eo b/src/lib/elementary/efl_ui_layout_part_legacy.eo index 3d4d335..df10b04 100644 --- a/src/lib/elementary/efl_ui_layout_part_legacy.eo +++ b/src/lib/elementary/efl_ui_layout_part_legacy.eo @@ -1,4 +1,5 @@ class Efl.Ui.Layout.Part_Legacy (Efl.Ui.Layout.Part, Efl.Container, Efl.Text, + Efl.Text.Markup, Efl.Ui.Translatable) { [[Elementary layout internal part class]] @@ -7,6 +8,7 @@ class Efl.Ui.Layout.Part_Legacy (Efl.Ui.Layout.Part, Efl.Container, Efl.Text, Efl.Container.content { get; set; } Efl.Container.content_unset; Efl.Text.text { set; get; } + Efl.Text.Markup.markup { get; set; } Efl.Ui.Translatable.translatable_text { get; set; } } } diff --git a/src/lib/elementary/efl_ui_layout_part_text.eo b/src/lib/elementary/efl_ui_layout_part_text.eo index b117a5f..9dda607 100644 --- a/src/lib/elementary/efl_ui_layout_part_text.eo +++ b/src/lib/elementary/efl_ui_layout_part_text.eo @@ -1,10 +1,11 @@ -class Efl.Ui.Layout.Part_Text (Efl.Ui.Layout.Part, Efl.Text, +class Efl.Ui.Layout.Part_Text (Efl.Ui.Layout.Part, Efl.Text, Efl.Text.Markup, Efl.Ui.Translatable) { [[Elementary layout internal part class]] data: null; implements { Efl.Text.text { set; get; } + Efl.Text.Markup.markup { get; set; } Efl.Ui.Translatable.translatable_text { get; set; } } } diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c index f53f576..53fe364 100644 --- a/src/lib/elementary/efl_ui_slider.c +++ b/src/lib/elementary/efl_ui_slider.c @@ -1491,6 +1491,7 @@ _efl_ui_slider_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UN /* Standard widget overrides */ ELM_PART_TEXT_DEFAULT_IMPLEMENT(efl_ui_slider, Efl_Ui_Slider_Data) +ELM_PART_MARKUP_DEFAULT_IMPLEMENT(efl_ui_slider, Efl_Ui_Slider_Data) static void _slider_span_size_set(Eo *obj, Efl_Ui_Slider_Data *sd, int size) diff --git a/src/lib/elementary/efl_ui_slider.eo b/src/lib/elementary/efl_ui_slider.eo index 0e7d21a..4c1cd71 100644 --- a/src/lib/elementary/efl_ui_slider.eo +++ b/src/lib/elementary/efl_ui_slider.eo @@ -2,8 +2,8 @@ type slider_func_type: __undefined_type; [[Elementary slider function type]] type slider_freefunc_type: __undefined_type; [[Elementary slider free function type]] class Efl.Ui.Slider (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Direction, - Efl.Access.Value, Efl.Text, Efl.Ui.Translatable, - Elm.Interface.Atspi_Widget_Action) + Efl.Access.Value, Efl.Text, Efl.Text.Markup, + Efl.Ui.Translatable, Elm.Interface.Atspi_Widget_Action) { [[Elementary slider class]] legacy_prefix: elm_slider; @@ -130,6 +130,7 @@ class Efl.Ui.Slider (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Direction, Efl.Access.Value.increment { get; } Elm.Interface.Atspi_Widget_Action.elm_actions { get; } Efl.Text.text { get; set; } + Efl.Text.Markup.markup { get; set; } Efl.Ui.Translatable.translatable_text { get; set; } } events { diff --git a/src/lib/elementary/elm_entry_part.eo b/src/lib/elementary/elm_entry_part.eo index 8ad6754..a296844 100644 --- a/src/lib/elementary/elm_entry_part.eo +++ b/src/lib/elementary/elm_entry_part.eo @@ -5,6 +5,6 @@ class Elm.Entry.Part (Efl.Ui.Layout.Part_Legacy) implements { Efl.Container.content { set; } Efl.Container.content_unset; - Efl.Text.text { set; get; } + Efl.Text.text { get; set; } } } diff --git a/src/lib/elementary/elm_label.c b/src/lib/elementary/elm_label.c index 891e1d2..8f5b74b 100644 --- a/src/lib/elementary/elm_label.c +++ b/src/lib/elementary/elm_label.c @@ -342,7 +342,7 @@ _elm_label_text_set(Eo *obj, Elm_Label_Data *sd, const char *part, const char *l if (!label) label = ""; _label_format_set(wd->resize_obj, sd->format); - efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label); + efl_text_markup_set(efl_part(efl_super(obj, MY_CLASS), part), label); if (int_ret) { diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h index bf84b57..f776b27 100644 --- a/src/lib/elementary/elm_part_helper.h +++ b/src/lib/elementary/elm_part_helper.h @@ -125,6 +125,25 @@ _ ## full ## _efl_text_text_get(Eo *obj, void *_pd EINA_UNUSED) \ ELM_PART_RETURN_VAL(_ ## type ## _text_get(pd->obj, sd, pd->part)); \ } +#define ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(full, type, TYPE, typedata) \ +EOLIAN static const char *\ +_ ## full ## _efl_text_markup_markup_get(Eo *obj, void *_pd EINA_UNUSED) \ +{ \ + Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); \ + typedata *sd = efl_data_scope_get(pd->obj, TYPE ## _CLASS); \ + ELM_PART_RETURN_VAL(_ ## type ## _text_markup_get(pd->obj, sd, pd->part)); \ +} + +#define ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(full, type, TYPE, typedata) \ +EOLIAN static void \ +_ ## full ## _efl_text_markup_markup_set(Eo *obj, void *_pd EINA_UNUSED, const char *markup) \ +{ \ + Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); \ + typedata *sd = efl_data_scope_get(pd->obj, TYPE ## _CLASS); \ + _ ## type ## _text_markup_set(pd->obj, sd, pd->part, markup); \ + ELM_PART_RETURN_VOID; \ +} + #define ELM_PART_OVERRIDE_CONTENT_SET(type, TYPE, typedata) \ ELM_PART_OVERRIDE_CONTENT_SET_FULL(type ## _part, type, TYPE, typedata) @@ -140,6 +159,12 @@ _ ## full ## _efl_text_text_get(Eo *obj, void *_pd EINA_UNUSED) \ #define ELM_PART_OVERRIDE_TEXT_GET(type, TYPE, typedata) \ ELM_PART_OVERRIDE_TEXT_GET_FULL(type ## _part, type, TYPE, typedata) +#define ELM_PART_OVERRIDE_MARKUP_SET(type, TYPE, typedata) \ + ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(type ## _part, type, TYPE, typedata) + +#define ELM_PART_OVERRIDE_MARKUP_GET(type, TYPE, typedata) \ + ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(type ## _part, type, TYPE, typedata) + #define ELM_PART_TEXT_DEFAULT_IMPLEMENT(type, Type) \ EOLIAN static void \ _ ## type ## _efl_text_text_set(Eo *obj, Type *pd EINA_UNUSED, const char *text) \ @@ -162,4 +187,16 @@ _ ## type ## _efl_ui_translatable_translatable_text_get(Eo *obj, Type *pd EINA_U return efl_ui_translatable_text_get(efl_part(efl_super(obj, MY_CLASS), "elm.text"), domain); \ } +#define ELM_PART_MARKUP_DEFAULT_IMPLEMENT(type, Type) \ +EOLIAN static const char * \ +_ ## type ## _efl_text_markup_markup_get(Eo *obj, Type *pd EINA_UNUSED) \ +{ \ + return efl_text_markup_get(efl_part(efl_super(obj, MY_CLASS), "elm.text")); \ +} \ +EOLIAN static void \ +_ ## type ## _efl_text_markup_markup_set(Eo *obj, Type *pd EINA_UNUSED, const char *markup) \ +{ \ + return efl_text_markup_set(efl_part(efl_super(obj, MY_CLASS), "elm.text"), markup); \ +} \ + #endif