diff options
author | Daniel Hirt <daniel.hirt@samsung.com> | 2016-11-16 16:28:31 +0200 |
---|---|---|
committer | Daniel Hirt <daniel.hirt@samsung.com> | 2016-11-16 16:42:23 +0200 |
commit | d604a9b83265ca1e491db63504e9da7a4e7265cb (patch) | |
tree | 465c7a8afa0782ce0fe94e82bd4c2b8d47ba5a46 | |
parent | ee5a1d28f13f3f43737d31490f4b5428ce469dbe (diff) | |
download | efl-d604a9b83265ca1e491db63504e9da7a4e7265cb.tar.gz |
Edje object: port part_text to efl_part
You now use the following:
efl_text_set(efl_part(edje_obj, "part"), "text");
const char *text = efl_text_get(efl_part(edje_obj, "part"));
The former method of edje_object_part_text_set/get is now legacy.
Also, adjusted 'tests/emotion/emotion_test_main-eo.c' with
this change.
-rw-r--r-- | src/Makefile_Edje.am | 6 | ||||
-rw-r--r-- | src/lib/edje/Edje_Legacy.h | 22 | ||||
-rw-r--r-- | src/lib/edje/edje_object.eo | 19 | ||||
-rw-r--r-- | src/lib/edje/edje_part_text.c | 29 | ||||
-rw-r--r-- | src/lib/edje/edje_private.h | 5 | ||||
-rw-r--r-- | src/lib/edje/edje_util.c | 25 | ||||
-rw-r--r-- | src/lib/edje/efl_canvas_layout_internal_text.eo | 15 | ||||
-rw-r--r-- | src/tests/emotion/emotion_test_main-eo.c | 10 |
8 files changed, 102 insertions, 29 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am index f6921bcadf..b0861ec48a 100644 --- a/src/Makefile_Edje.am +++ b/src/Makefile_Edje.am @@ -12,7 +12,8 @@ edje_eolian_priv_files = \ lib/edje/efl_canvas_layout_internal.eo \ lib/edje/efl_canvas_layout_internal_box.eo \ lib/edje/efl_canvas_layout_internal_table.eo \ - lib/edje/efl_canvas_layout_internal_swallow.eo + lib/edje/efl_canvas_layout_internal_swallow.eo \ + lib/edje/efl_canvas_layout_internal_text.eo edje_eolian_c = $(edje_eolian_files:%.eo=%.eo.c) edje_eolian_h = $(edje_eolian_files:%.eo=%.eo.h) \ @@ -95,7 +96,8 @@ lib/edje/edje_signal.c \ lib/edje/edje_part.c \ lib/edje/edje_part_swallow.c \ lib/edje/edje_part_table.c \ -lib/edje/edje_part_box.c +lib/edje/edje_part_box.c \ +lib/edje/edje_part_text.c lib_edje_libedje_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EDJE_COMMON_CPPFLAGS) lib_edje_libedje_la_LIBADD = @EDJE_LIBS@ @EDJE_LUA_LIBS@ diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index f7e234b949..0ca7323983 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -593,5 +593,27 @@ EAPI Eina_Bool edje_object_color_class_get(const Evas_Object *obj, const char * */ EAPI void edje_object_part_text_select_allow_set(const Edje_Object *obj, const char *part, Eina_Bool allow); +/** + * @brief Sets a given text to an Edje object @c TEXT or TEXTBLOCK + * parts. + * + * @param[in] part The part name + * @param[in] text The text to set on that part + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text); + +/** + * @brief Gets the text currntly set to the given part + * + * @param[in] part The part name + * + * @return The text set on the part, @c null otherwise. + * + * @ingroup Edje_Object + */ +EAPI const char * edje_object_part_text_get(const Edje_Object *obj, const char *part); + #include "edje_object.eo.legacy.h" #include "edje_edit.eo.legacy.h" diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index 66269d354a..ee3d808a8c 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -1210,25 +1210,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, data: void_ptr; [[The data associated to the callback function.]] } } - @property part_text { - set { - [[Sets the text for an object part]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Return the text of the object part. - - This function returns the text associated to the object part. - - See also @.part_text.set().]] - } - keys { - part: string; [[The part name]] - } - values { - text: string; [[The text string]] - } - } @property part_text_escaped { set { [[Sets the text for an object part, but converts HTML escapes to UTF8 diff --git a/src/lib/edje/edje_part_text.c b/src/lib/edje/edje_part_text.c new file mode 100644 index 0000000000..2aed9070e7 --- /dev/null +++ b/src/lib/edje/edje_part_text.c @@ -0,0 +1,29 @@ +/* Implementation of "TEXT" part as an Efl Object. */ + +#include "edje_private.h" +#include "edje_part_helper.h" + +#define EFL_CANVAS_LAYOUT_INTERNAL_TEXT_PROTECTED +#include "efl_canvas_layout_internal_text.eo.h" +#define MY_CLASS EFL_CANVAS_LAYOUT_INTERNAL_TEXT_CLASS + +#include "../evas/canvas/evas_text.eo.h" + +PROXY_IMPLEMENTATION(text, TEXT, Edje_Text_Data) +#undef PROXY_IMPLEMENTATION + +EOLIAN static void +_efl_canvas_layout_internal_text_efl_text_text_set(Eo *obj, + Edje_Text_Data *pd, const char *text) +{ + _edje_efl_text_set(obj, pd->ed, pd->part, text); +} + +EOLIAN static const char * +_efl_canvas_layout_internal_text_efl_text_text_get(Eo *obj, + Edje_Text_Data *pd) +{ + RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part)); +} + +#include "efl_canvas_layout_internal_text.eo.c" diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 3e610d2639..f714561070 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -3074,6 +3074,11 @@ Eo *_edje_swallow_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part Efl_Gfx *_edje_efl_container_content_get(Edje *ed, const char *part); Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow); +/* part text: TEXT */ +Eo *_edje_text_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp); +Eina_Bool _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text); +const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part); + void _edje_internal_proxy_shutdown(void); // Svg loader diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 83c37d5859..bb15d4dc80 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -2037,8 +2037,8 @@ _edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_ eud->u.string.type = type; } -EOLIAN Eina_Bool -_edje_object_part_text_set(Eo *obj, Edje *ed, const char *part, const char *text) +Eina_Bool +_edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text) { Edje_Real_Part *rp; Eina_Bool int_ret; @@ -2059,7 +2059,7 @@ _edje_object_part_text_set(Eo *obj, Edje *ed, const char *part, const char *text } EOLIAN const char * -_edje_object_part_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) +_edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) { Edje_Real_Part *rp; @@ -3732,6 +3732,10 @@ _edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part) return _edje_table_internal_proxy_get(obj, ed, rp); else if (rp->part->type == EDJE_PART_TYPE_SWALLOW) return _edje_swallow_internal_proxy_get(obj, ed, rp); + else if (rp->part->type == EDJE_PART_TYPE_TEXT) + return _edje_text_internal_proxy_get(obj, ed, rp); + else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + return _edje_text_internal_proxy_get(obj, ed, rp); else return NULL; /* FIXME/TODO: text & others (color, ...) */ } @@ -6612,4 +6616,19 @@ edje_object_part_swallow_get(const Edje_Object *obj, const char *part) return efl_content_get(efl_part(obj, part)); } +EAPI Eina_Bool +edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text) +{ + efl_text_set(efl_part(obj, part), text); + // XXX: either add proper check the call is successful, directly call + // the internal function + return EINA_TRUE; +} + +EAPI const char * +edje_object_part_text_get(const Edje_Object *obj, const char *part) +{ + return efl_text_get(efl_part(obj, part)); +} + /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ diff --git a/src/lib/edje/efl_canvas_layout_internal_text.eo b/src/lib/edje/efl_canvas_layout_internal_text.eo new file mode 100644 index 0000000000..ef342cdd7d --- /dev/null +++ b/src/lib/edje/efl_canvas_layout_internal_text.eo @@ -0,0 +1,15 @@ +class Efl.Canvas.Layout_Internal.Text (Efl.Object, Efl.Canvas.Layout_Internal, Efl.Text) +{ + [[Represents a TEXT part of an Edje object. + + Its lifetime is limited to one function call only, unless an extra + reference is explicitely held. + ]] + data: Edje_Text_Data; + implements { + Efl.Object.finalize; + Efl.Canvas.Layout_Internal.real_part.set; + Efl.Text.text.set; + Efl.Text.text.get; + } +} diff --git a/src/tests/emotion/emotion_test_main-eo.c b/src/tests/emotion/emotion_test_main-eo.c index b096137ba6..a2490fd69b 100644 --- a/src/tests/emotion/emotion_test_main-eo.c +++ b/src/tests/emotion/emotion_test_main-eo.c @@ -320,7 +320,7 @@ video_obj_time_changed(Evas_Object *obj, Evas_Object *edje) snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i", ph, pm, ps, pf, lh, lm, ls); - edje_obj_part_text_set(edje, "video_progress_txt", buf); + edje_object_part_text_set(edje, "video_progress_txt", buf); } static void @@ -478,7 +478,7 @@ video_obj_signal_alpha_cb(void *data, Evas_Object *o, const char *emission EINA_ alpha = 255 * y; efl_gfx_color_set(ov, alpha, alpha, alpha, alpha); snprintf(buf, sizeof(buf), "alpha %.0f", alpha); - edje_obj_part_text_set(o, "video_alpha_txt", buf); + edje_object_part_text_set(o, "video_alpha_txt", buf); } static void @@ -491,7 +491,7 @@ video_obj_signal_vol_cb(void *data, Evas_Object *o, const char *emission EINA_UN edje_obj_part_drag_value_get(o, source, NULL, &vol); emotion_object_audio_volume_set(ov, vol); snprintf(buf, sizeof(buf), "vol %.2f", vol); - edje_obj_part_text_set(o, "video_volume_txt", buf); + edje_object_part_text_set(o, "video_volume_txt", buf); } static void @@ -642,9 +642,9 @@ init_video_object(const char *module_filename, const char *filename) edje_obj_signal_callback_add(oe, "frame_resize", "stop", video_obj_signal_frame_resize_stop_cb, oe); edje_obj_signal_callback_add(oe, "mouse, move", "*", video_obj_signal_frame_move_cb, oe); edje_obj_part_drag_value_set(oe, "video_alpha", 0.0, 1.0); - edje_obj_part_text_set(oe, "video_alpha_txt", "alpha 255"); + edje_object_part_text_set(oe, "video_alpha_txt", "alpha 255"); edje_obj_part_drag_value_set(oe, "video_volume", 0.0, 0.5); - edje_obj_part_text_set(oe, "video_volume_txt", "vol 0.50"); + edje_object_part_text_set(oe, "video_volume_txt", "vol 0.50"); edje_obj_signal_emit(oe, "video_state", "play"); efl_gfx_visible_set(oe, EINA_TRUE); } |