From 0823b6be7197370a68056fb598e33a588242f68f Mon Sep 17 00:00:00 2001 From: SubodhKumar Date: Fri, 28 Oct 2016 18:22:43 +0530 Subject: [PATCH] Edje entry: Add link press effect Summary: Add link press effect Custom tag (linked_pressed) has to be supplied in entry tb style with color value for press effect to be applied on link text. Reviewers: tasn Subscribers: shilpasingh, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3629 Change-Id: I2084a2bde237ea7a0a09fdc93b4f93a5a7b31143 Signed-off-by: SubodhKumar --- src/lib/edje/edje_entry.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index b590009..41ba192 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -50,6 +50,7 @@ struct _Entry Eina_Bool input_panel_enable : 1; Eina_Bool prediction_allow : 1; Eina_Bool anchors_updated : 1; + Eina_Bool have_link_pressed : 1; // TIZEN_ONLY(20150716): Add edje_object_part_text_freeze, thaw APIs for freezing cursor movements. Eina_Bool freeze : 1; // @@ -752,6 +753,28 @@ _sel_update(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o, Entr } } +static Eina_Bool +_edje_entry_style_tag_check(Edje_Real_Part *rp, const char *tag) +{ + const Evas_Textblock_Style *ts = NULL; + + ts = evas_object_textblock_style_user_peek(rp->object); + if (ts) + { + if (strstr(evas_textblock_style_get(ts), tag)) return EINA_TRUE; + } + else + { + ts = evas_object_textblock_style_get(rp->object); + if (ts) + { + if (strstr(evas_textblock_style_get(ts), tag)) return EINA_TRUE; + } + } + + return EINA_FALSE; +} + static void _edje_anchor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) { @@ -785,6 +808,13 @@ _edje_anchor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EIN else snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n); _edje_emit(ed, buf, rp->part->name); + /* Link Pressed effect */ + if (_edje_entry_style_tag_check(rp, "link_pressed=")) + { + an->en->have_link_pressed = EINA_TRUE; + evas_textblock_cursor_format_append(an->start, ""); + evas_textblock_cursor_format_prepend(an->end, ""); + } } ev->event_flags |= rp->mask_flags; } @@ -817,8 +847,29 @@ _edje_anchor_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_ { snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n); _edje_emit(ed, buf, rp->part->name); + /* Link Pressed effect */ + if (an->en->have_link_pressed) + { + const Evas_Object_Textblock_Node_Format *node; + node = evas_textblock_node_format_first_get(rp->object); + for (; node; node = evas_textblock_node_format_next_get(node)) + { + const char *text = evas_textblock_node_format_text_get(node); + + if (text) + { + if (!strcmp(text, "+ link_pressed")) + { + evas_textblock_node_format_remove_pair(rp->object, + (Evas_Object_Textblock_Node_Format *)node); + break; + } + } + } + } } } + if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored)) { snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n); -- 2.7.4