From: tasn Date: Tue, 6 Mar 2012 10:09:13 +0000 (+0000) Subject: Elm entry: Merge anchorview/anchorblock into entry. X-Git-Tag: REL_F_I9500_20120323_1~17^2~331 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a466cfe552a03d4dee1f99c4e12ee30d28c57269;p=framework%2Fuifw%2Felementary.git Elm entry: Merge anchorview/anchorblock into entry. And kill those damn widgets. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68802 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/doc/widgets/Makefile.am b/doc/widgets/Makefile.am index 9f6efd1..f665b0b 100644 --- a/doc/widgets/Makefile.am +++ b/doc/widgets/Makefile.am @@ -68,8 +68,6 @@ widget_preview_fileselector_entry \ widget_preview_flipselector \ widget_preview_hoversel \ widget_preview_hover \ -widget_preview_anchorview \ -widget_preview_anchorblock \ widget_preview_flip \ widget_preview_separator \ widget_preview_radio \ diff --git a/doc/widgets/widget_preview_anchorblock.c b/doc/widgets/widget_preview_anchorblock.c deleted file mode 100644 index b60f0b1..0000000 --- a/doc/widgets/widget_preview_anchorblock.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "widget_preview_tmpl_head.c" - -Evas_Object *o = elm_anchorblock_add(win); -evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); -elm_win_resize_object_add(win, o); -evas_object_show(o); - -elm_object_text_set(o, "Anchorblock bold and lots and lots and lots and " - "lots and lots and lots and lots and lots of text"); - -#include "widget_preview_tmpl_foot.c" diff --git a/doc/widgets/widget_preview_anchorview.c b/doc/widgets/widget_preview_anchorview.c deleted file mode 100644 index 6522a65..0000000 --- a/doc/widgets/widget_preview_anchorview.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "widget_preview_tmpl_head.c" - -Evas_Object *o = elm_anchorview_add(win); -evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); -elm_win_resize_object_add(win, o); -evas_object_show(o); - -elm_object_text_set(o, "Anchorview bold and lots and lots and lots and " - "lots and lots and lots and lots and lots of text"); - -#include "widget_preview_tmpl_foot.c" diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 8e0d75f..92789cf 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -33,8 +33,6 @@ elementary_test_SOURCES = \ test.c \ test_3d.c \ test_actionslider.c \ -test_anchorblock.c \ -test_anchorview.c \ test_anim.c \ test_bg.c \ test_box.c \ @@ -51,6 +49,8 @@ test_cursor.c \ test_datetime.c \ test_diskselector.c \ test_entry.c \ +test_entry_anchor.c \ +test_entry_anchor2.c \ test_fileselector_button.c \ test_fileselector.c \ test_fileselector_entry.c \ diff --git a/src/bin/test.c b/src/bin/test.c index e24bdd1..1e9c633 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -48,8 +48,8 @@ void test_entry7(void *data, Evas_Object *obj, void *event_info); void test_entry8(void *data, Evas_Object *obj, void *event_info); void test_entry_notepad(void *data, Evas_Object *obj, void *event_info); void test_multibuttonentry(void *data, Evas_Object *obj, void *event_info); -void test_anchorview(void *data, Evas_Object *obj, void *event_info); -void test_anchorblock(void *data, Evas_Object *obj, void *event_info); +void test_entry_anchor2(void *data, Evas_Object *obj, void *event_info); +void test_entry_anchor(void *data, Evas_Object *obj, void *event_info); void test_toolbar(void *data, Evas_Object *obj, void *event_info); void test_toolbar2(void *data, Evas_Object *obj, void *event_info); void test_toolbar3(void *data, Evas_Object *obj, void *event_info); @@ -377,6 +377,8 @@ add_tests: ADD_TEST(NULL, "Entries", "Entry 8", test_entry8); ADD_TEST(NULL, "Entries", "Entry Notepad", test_entry_notepad); ADD_TEST(NULL, "Entries", "Multibuttonentry", test_multibuttonentry); + ADD_TEST(NULL, "Entries", "Entry Anchor", test_entry_anchor); + ADD_TEST(NULL, "Entries", "Entry Anchor2", test_entry_anchor2); //------------------------------// ADD_TEST(NULL, "Buttons", "Buttons", test_button); @@ -516,8 +518,6 @@ add_tests: ADD_TEST(NULL, "Times & Dates", "Datetime", test_datetime); //------------------------------// - ADD_TEST(NULL, "Text", "Anchorview", test_anchorview); - ADD_TEST(NULL, "Text", "Anchorblock", test_anchorblock); ADD_TEST(NULL, "Text", "Label", test_label); //------------------------------// diff --git a/src/bin/test_anchorblock.c b/src/bin/test_entry_anchor.c similarity index 72% rename from src/bin/test_anchorblock.c rename to src/bin/test_entry_anchor.c index 0533afe..6764ed8 100644 --- a/src/bin/test_anchorblock.c +++ b/src/bin/test_entry_anchor.c @@ -11,21 +11,21 @@ _print_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i } static void -my_anchorblock_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *av = data; - elm_anchorblock_hover_end(av); + elm_entry_anchor_hover_end(av); } static void -my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info) +my_entry_anchor(void *data, Evas_Object *obj, void *event_info) { Evas_Object *av = data; - Elm_Entry_Anchorblock_Info *ei = event_info; + Elm_Entry_Anchor_Hover_Info *ei = event_info; Evas_Object *bt, *bx; bt = elm_button_add(obj); - elm_object_text_set(bt, ei->name); + elm_object_text_set(bt, ei->anchor_info->name); elm_object_part_content_set(ei->hover, "middle", bt); evas_object_show(bt); @@ -36,17 +36,17 @@ my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Top 1"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); bt = elm_button_add(obj); elm_object_text_set(bt, "Top 2"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); bt = elm_button_add(obj); elm_object_text_set(bt, "Top 3"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); elm_object_part_content_set(ei->hover, "top", bx); evas_object_show(bx); @@ -56,7 +56,7 @@ my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Bot"); elm_object_part_content_set(ei->hover, "bottom", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } if (ei->hover_left) @@ -64,7 +64,7 @@ my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Left"); elm_object_part_content_set(ei->hover, "left", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } if (ei->hover_right) @@ -72,37 +72,37 @@ my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Right"); elm_object_part_content_set(ei->hover, "right", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } } static void -my_anchorblock_edge_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_edge_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("left\n"); } static void -my_anchorblock_edge_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_edge_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("right\n"); } static void -my_anchorblock_edge_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_edge_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("top\n"); } static void -my_anchorblock_edge_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_edge_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("bottom\n"); } static void -my_anchorblock_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +my_entry_anchor_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { Evas_Coord x, y, w, h, vw, vh; @@ -112,12 +112,12 @@ my_anchorblock_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info } void -test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +test_entry_anchor(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *win, *bg, *av, *sc, *bx, *bb, *ic; char buf[PATH_MAX]; - win = elm_win_add(NULL, "anchorblock", ELM_WIN_BASIC); + win = elm_win_add(NULL, "entry_anchor", ELM_WIN_BASIC); elm_win_title_set(win, "Anchorblock"); elm_win_autodel_set(win, EINA_TRUE); @@ -130,11 +130,11 @@ test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, sc); - evas_object_smart_callback_add(sc, "edge_left", my_anchorblock_edge_left, NULL); - evas_object_smart_callback_add(sc, "edge_right", my_anchorblock_edge_right, NULL); - evas_object_smart_callback_add(sc, "edge_top", my_anchorblock_edge_top, NULL); - evas_object_smart_callback_add(sc, "edge_bottom", my_anchorblock_edge_bottom, NULL); - evas_object_smart_callback_add(sc, "scroll", my_anchorblock_scroll, NULL); + evas_object_smart_callback_add(sc, "edge_left", my_entry_anchor_edge_left, NULL); + evas_object_smart_callback_add(sc, "edge_right", my_entry_anchor_edge_right, NULL); + evas_object_smart_callback_add(sc, "edge_top", my_entry_anchor_edge_top, NULL); + evas_object_smart_callback_add(sc, "edge_bottom", my_entry_anchor_edge_bottom, NULL); + evas_object_smart_callback_add(sc, "scroll", my_entry_anchor_scroll, NULL); bx = elm_box_add(win); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); @@ -154,15 +154,15 @@ test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hi there. This is the most recent message in the " "list of messages. It has one +61 432 1234 " "(phone number) to click on."); - evas_object_smart_callback_add(av, "anchor,clicked", - my_anchorblock_anchor, av); + evas_object_smart_callback_add(av, "anchor,hover,opened", + my_entry_anchor, av); elm_object_content_set(bb, av); evas_object_show(av); elm_box_pack_end(bx, bb); @@ -181,9 +181,9 @@ test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hey what are you doing? This is the second last message " "Hi there. This is the most recent message in the " @@ -198,7 +198,7 @@ test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event "done by links maybe running local apps or even being " "web URL's too that launch the web browser and point it " "to that URL. "); - evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av); + evas_object_smart_callback_add(av, "anchor,hover,opened", my_entry_anchor, av); elm_object_content_set(bb, av); evas_object_show(av); elm_box_pack_end(bx, bb); @@ -219,12 +219,12 @@ test_anchorblock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "This is a short message. "); - evas_object_smart_callback_add(av, "anchor,clicked", - my_anchorblock_anchor, av); + evas_object_smart_callback_add(av, "anchor,hover,opened", + my_entry_anchor, av); elm_object_content_set(bb, av); evas_object_show(av); elm_box_pack_end(bx, bb); diff --git a/src/bin/test_anchorview.c b/src/bin/test_entry_anchor2.c similarity index 71% rename from src/bin/test_anchorview.c rename to src/bin/test_entry_anchor2.c index e7d709d..c75b640 100644 --- a/src/bin/test_anchorview.c +++ b/src/bin/test_entry_anchor2.c @@ -4,21 +4,21 @@ #endif #ifndef ELM_LIB_QUICKLAUNCH static void -my_anchorview_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +my_entry_anchor_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *av = data; - elm_anchorview_hover_end(av); + elm_entry_anchor_hover_end(av); } static void my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info) { Evas_Object *av = data; - Elm_Entry_Anchorview_Info *ei = event_info; + Elm_Entry_Anchor_Hover_Info *ei = event_info; Evas_Object *bt, *bx; bt = elm_button_add(obj); - elm_object_text_set(bt, ei->name); + elm_object_text_set(bt, ei->anchor_info->name); elm_object_part_content_set(ei->hover, "middle", bt); evas_object_show(bt); @@ -29,17 +29,17 @@ my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Top 1"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); bt = elm_button_add(obj); elm_object_text_set(bt, "Top 2"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); bt = elm_button_add(obj); elm_object_text_set(bt, "Top 3"); elm_box_pack_end(bx, bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); elm_object_part_content_set(ei->hover, "top", bx); evas_object_show(bx); @@ -49,7 +49,7 @@ my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Bot"); elm_object_part_content_set(ei->hover, "bottom", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } if (ei->hover_left) @@ -57,7 +57,7 @@ my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Left"); elm_object_part_content_set(ei->hover, "left", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } if (ei->hover_right) @@ -65,17 +65,17 @@ my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info) bt = elm_button_add(obj); elm_object_text_set(bt, "Right"); elm_object_part_content_set(ei->hover, "right", bt); - evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av); + evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av); evas_object_show(bt); } } void -test_anchorview(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +test_entry_anchor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *win, *bg, *av; - win = elm_win_add(NULL, "anchorview", ELM_WIN_BASIC); + win = elm_win_add(NULL, "entry_anchor", ELM_WIN_BASIC); elm_win_title_set(win, "Anchorview"); elm_win_autodel_set(win, EINA_TRUE); @@ -84,9 +84,9 @@ test_anchorview(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bg); - av = elm_anchorview_add(win); - elm_anchorview_hover_style_set(av, "popout"); - elm_anchorview_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "This is an entry widget in this window that
" "uses markup like this for styling and
" @@ -96,7 +96,7 @@ test_anchorview(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_ "called Anchors so you will need
" "to refer to them this way. "); evas_object_size_hint_weight_set(av, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_smart_callback_add(av, "anchor,clicked", my_anchorview_anchor, av); + evas_object_smart_callback_add(av, "anchor,hover,opened", my_anchorview_anchor, av); elm_win_resize_object_add(win, av); evas_object_show(av); diff --git a/src/bin/test_win_inline.c b/src/bin/test_win_inline.c index 874634c..17fff1c 100644 --- a/src/bin/test_win_inline.c +++ b/src/bin/test_win_inline.c @@ -59,9 +59,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hi there. This is the most recent message in the " "list of messages. It has one +61 432 1234 " @@ -83,9 +83,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hey what are you doing? This is the second last message " "Hi there. This is the most recent message in the " @@ -119,9 +119,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "This is a short message. "); elm_object_content_set(bb, av); evas_object_show(av); diff --git a/src/bin/test_win_socket.c b/src/bin/test_win_socket.c index 5beaeae..1a93ecb 100644 --- a/src/bin/test_win_socket.c +++ b/src/bin/test_win_socket.c @@ -66,9 +66,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hi there. This is the most recent message in the " "list of messages. It has one +61 432 1234 " @@ -90,9 +90,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "Hey what are you doing? This is the second last message " "Hi there. This is the most recent message in the " @@ -126,9 +126,9 @@ fill(Evas_Object *win, Eina_Bool do_bg) evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); - av = elm_anchorblock_add(win); - elm_anchorblock_hover_style_set(av, "popout"); - elm_anchorblock_hover_parent_set(av, win); + av = elm_entry_add(win); + elm_entry_anchor_hover_style_set(av, "popout"); + elm_entry_anchor_hover_parent_set(av, win); elm_object_text_set(av, "This is a short message. "); elm_object_content_set(bb, av); evas_object_show(av); diff --git a/src/edje_externals/Makefile.am b/src/edje_externals/Makefile.am index 875ad7f..b321e18 100644 --- a/src/edje_externals/Makefile.am +++ b/src/edje_externals/Makefile.am @@ -30,8 +30,6 @@ module_la_SOURCES = private.h \ modules.inc \ elm.c \ elm_actionslider.c \ -elm_anchorblock.c \ -elm_anchorview.c \ elm_bubble.c \ elm_button.c \ elm_calendar.c \ diff --git a/src/edje_externals/elm_anchorblock.c b/src/edje_externals/elm_anchorblock.c deleted file mode 100644 index 8b71ebb..0000000 --- a/src/edje_externals/elm_anchorblock.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "private.h" - -typedef struct _Elm_Params_Anchorblock -{ - Elm_Params base; - const char *text; -} Elm_Params_Anchorblock; - -static void -external_anchorblock_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) -{ - const Elm_Params_Anchorblock *p; - - if (to_params) p = to_params; - else if (from_params) p = from_params; - else return; - - if (p->text) - { - elm_object_text_set(obj, p->text); - } -} - -static Eina_Bool -external_anchorblock_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) -{ - if (!strcmp(param->name, "text")) - { - if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) - { - elm_object_text_set(obj, param->s); - return EINA_TRUE; - } - } - - ERR("unknown parameter '%s' of type '%s'", - param->name, edje_external_param_type_str(param->type)); - - return EINA_FALSE; -} - -static Eina_Bool -external_anchorblock_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) -{ - if (!strcmp(param->name, "text")) - { - if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) - { - param->s = elm_object_text_get(obj); - return EINA_TRUE; - } - } - - ERR("unknown parameter '%s' of type '%s'", - param->name, edje_external_param_type_str(param->type)); - - return EINA_FALSE; -} - -static void * -external_anchorblock_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) -{ - Elm_Params_Anchorblock *mem; - Edje_External_Param *param; - const Eina_List *l; - - mem = ELM_NEW(Elm_Params_Anchorblock); - if (!mem) - return NULL; - - EINA_LIST_FOREACH(params, l, param) - { - if (!strcmp(param->name, "text")) - mem->text = eina_stringshare_add(param->s); - } - - return mem; -} - -static Evas_Object *external_anchorblock_content_get(void *data __UNUSED__, - const Evas_Object *obj __UNUSED__, const char *content __UNUSED__) -{ - ERR("No content."); - return NULL; -} - -static void -external_anchorblock_params_free(void *params) -{ - Elm_Params_Anchorblock *mem = params; - - if (mem->text) - eina_stringshare_del(mem->text); - free(mem); -} - -static Edje_External_Param_Info external_anchorblock_params[] = { - DEFINE_EXTERNAL_COMMON_PARAMS, - EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("text", "some text"), - EDJE_EXTERNAL_PARAM_INFO_SENTINEL -}; - -DEFINE_EXTERNAL_ICON_ADD(anchorblock, "anchorblock") -DEFINE_EXTERNAL_TYPE_SIMPLE(anchorblock, "Anchorblock"); diff --git a/src/edje_externals/elm_anchorview.c b/src/edje_externals/elm_anchorview.c deleted file mode 100644 index 33c7c6a..0000000 --- a/src/edje_externals/elm_anchorview.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "private.h" - -typedef struct _Elm_Params_Anchorview -{ - Elm_Params base; - const char *text; -} Elm_Params_Anchorview; - -static void -external_anchorview_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) -{ - const Elm_Params_Anchorview *p; - - if (to_params) p = to_params; - else if (from_params) p = from_params; - else return; - - if (p->text) - { - elm_object_text_set(obj, p->text); - } -} - -static Eina_Bool -external_anchorview_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) -{ - if (!strcmp(param->name, "text")) - { - if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) - { - elm_object_text_set(obj, param->s); - return EINA_TRUE; - } - } - - ERR("unknown parameter '%s' of type '%s'", - param->name, edje_external_param_type_str(param->type)); - - return EINA_FALSE; -} - -static Eina_Bool -external_anchorview_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) -{ - if (!strcmp(param->name, "text")) - { - if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) - { - param->s = elm_object_text_get(obj); - return EINA_TRUE; - } - } - - ERR("unknown parameter '%s' of type '%s'", - param->name, edje_external_param_type_str(param->type)); - - return EINA_FALSE; -} - -static void * -external_anchorview_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) -{ - Elm_Params_Anchorview *mem; - Edje_External_Param *param; - const Eina_List *l; - - mem = ELM_NEW(Elm_Params_Anchorview); - if (!mem) - return NULL; - - EINA_LIST_FOREACH(params, l, param) - { - if (!strcmp(param->name, "text")) - mem->text = eina_stringshare_add(param->s); - } - - return mem; -} - -static Evas_Object *external_anchorview_content_get(void *data __UNUSED__, - const Evas_Object *obj __UNUSED__, const char *content __UNUSED__) -{ - ERR("No content."); - return NULL; -} - -static void -external_anchorview_params_free(void *params) -{ - Elm_Params_Anchorview *mem = params; - - if (mem->text) - eina_stringshare_del(mem->text); - free(mem); -} - -static Edje_External_Param_Info external_anchorview_params[] = { - DEFINE_EXTERNAL_COMMON_PARAMS, - EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("text", "some text"), - EDJE_EXTERNAL_PARAM_INFO_SENTINEL -}; - -DEFINE_EXTERNAL_ICON_ADD(anchorview, "anchorview") -DEFINE_EXTERNAL_TYPE_SIMPLE(anchorview, "Anchorview"); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 7a82472..537d52b 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -160,8 +160,6 @@ EAPI extern Elm_Version *elm_version; /* other includes */ // Tom Hacohen -#include -#include #include #include #include diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 7c4d309..6381eea 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -45,8 +45,6 @@ elm_widget.h includesunstabledir = $(includedir)/elementary-@VMAJ@ includesub_HEADERS = \ -elc_anchorblock.h \ -elc_anchorview.h \ elc_ctxpopup.h \ elc_fileselector_button.h \ elc_fileselector_entry.h \ @@ -137,8 +135,6 @@ includesubdir = $(includedir)/elementary-@VMAJ@/ libelementary_la_SOURCES = \ elm_priv.h \ -elc_anchorblock.c \ -elc_anchorview.c \ elc_ctxpopup.c \ elc_popup.c \ elc_fileselector_button.c \ diff --git a/src/lib/elc_anchorblock.c b/src/lib/elc_anchorblock.c deleted file mode 100644 index fe1866a..0000000 --- a/src/lib/elc_anchorblock.c +++ /dev/null @@ -1,351 +0,0 @@ -#include -#include "elm_priv.h" - -typedef struct _Widget_Data Widget_Data; -typedef struct _Elm_Anchorblock_Item_Provider Elm_Anchorblock_Item_Provider; - -struct _Widget_Data -{ - Evas_Object *entry; - Evas_Object *hover_parent; - Evas_Object *pop, *hover; - Eina_List *item_providers; - const char *hover_style; -}; - -struct _Elm_Anchorblock_Item_Provider -{ - Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item); - void *data; -}; - -static const char *widtype = NULL; - -static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked"; -static const Evas_Smart_Cb_Description _signals[] = { - {SIG_ANCHOR_CLICKED, ""}, /* TODO: declare the type properly, as data is - * being passed - */ - {NULL, NULL} -}; - -static void _del_pre_hook(Evas_Object *obj); -static void _del_hook(Evas_Object *obj); -static void _sizing_eval(Evas_Object *obj); -static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl); - -static void -_del_pre_hook(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - evas_object_event_callback_del_full(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _changed_size_hints, obj); - elm_anchorblock_hover_end(obj); - elm_anchorblock_hover_parent_set(obj, NULL); -} - -static void -_del_hook(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - Elm_Anchorblock_Item_Provider *ip; - if (!wd) return; - if (wd->hover_style) eina_stringshare_del(wd->hover_style); - EINA_LIST_FREE(wd->item_providers, ip) - { - free(ip); - } - free(wd); -} - -static void -_mirrored_set(Evas_Object *obj, Eina_Bool rtl) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - elm_widget_mirrored_set(wd->hover, rtl); -} - -static void -_theme_hook(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - _elm_widget_mirrored_reload(obj); - _mirrored_set(obj, elm_widget_mirrored_get(obj)); -} - -static void -_sizing_eval(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; - if (!wd) return; - evas_object_size_hint_min_get(wd->entry, &minw, &minh); - evas_object_size_hint_min_set(obj, minw, minh); - evas_object_size_hint_max_set(obj, maxw, maxh); -} - -static void -_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - _sizing_eval(data); -} - -static void -_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - elm_anchorblock_hover_end(data); -} - -static void -_anchor_clicked(void *data, Evas_Object *obj, void *event_info) -{ - Widget_Data *wd = elm_widget_data_get(data); - Elm_Entry_Anchor_Info *info = event_info; - Evas_Object *hover_parent; - Elm_Entry_Anchorblock_Info ei; - Evas_Coord x, w, y, h, px, py; - if (!wd) return; - wd->pop = elm_icon_add(obj); - evas_object_move(wd->pop, info->x, info->y); - evas_object_resize(wd->pop, info->w, info->h); - wd->hover = elm_hover_add(obj); - elm_widget_mirrored_set(wd->hover, elm_widget_mirrored_get((Evas_Object *) data)); - if (wd->hover_style) - elm_object_style_set(wd->hover, wd->hover_style); - hover_parent = wd->hover_parent; - if (!hover_parent) hover_parent = obj; - elm_hover_parent_set(wd->hover, hover_parent); - elm_hover_target_set(wd->hover, wd->pop); - ei.name = info->name; - ei.button = info->button; - ei.hover = wd->hover; - ei.anchor.x = info->x; - ei.anchor.y = info->y; - ei.anchor.w = info->w; - ei.anchor.h = info->h; - evas_object_geometry_get(hover_parent, &x, &y, &w, &h); - ei.hover_parent.x = x; - ei.hover_parent.y = y; - ei.hover_parent.w = w; - ei.hover_parent.h = h; - px = info->x + (info->w / 2); - py = info->y + (info->h / 2); - ei.hover_left = 1; - if (px < (x + (w / 3))) ei.hover_left = 0; - ei.hover_right = 1; - if (px > (x + ((w * 2) / 3))) ei.hover_right = 0; - ei.hover_top = 1; - if (py < (y + (h / 3))) ei.hover_top = 0; - ei.hover_bottom = 1; - if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0; - - if (elm_widget_mirrored_get(wd->hover)) - { /* Swap right and left because they switch sides in RTL */ - Eina_Bool tmp = ei.hover_left; - ei.hover_left = ei.hover_right; - ei.hover_right = tmp; - } - - evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei); - evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data); - evas_object_show(wd->hover); -} - -static void -_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Widget_Data *wd = elm_widget_data_get(data); - if (!wd) return; - wd->hover_parent = NULL; -} - -static Evas_Object * -_item_provider(void *data, Evas_Object *entry __UNUSED__, const char *item) -{ - Widget_Data *wd = elm_widget_data_get(data); - Eina_List *l; - Elm_Anchorblock_Item_Provider *ip; - - EINA_LIST_FOREACH(wd->item_providers, l, ip) - { - Evas_Object *o; - - o = ip->func(ip->data, data, item); - if (o) return o; - } - return NULL; -} - -static void -_elm_anchorblock_text_set(Evas_Object *obj, const char *item, const char *text) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (item && strcmp(item, "default")) return; - if (!wd) return; - elm_object_text_set(wd->entry, text); - if (wd->hover) evas_object_del(wd->hover); - if (wd->pop) evas_object_del(wd->pop); - wd->hover = NULL; - wd->pop = NULL; - _sizing_eval(obj); -} - -static const char* -_elm_anchorblock_text_get(const Evas_Object *obj, const char *item) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (item && strcmp(item, "default")) return NULL; - if (!wd) return NULL; - return elm_object_text_get(wd->entry); -} - -EAPI Evas_Object * -elm_anchorblock_add(Evas_Object *parent) -{ - Evas_Object *obj; - Evas *e; - Widget_Data *wd; - - ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); - - ELM_SET_WIDTYPE(widtype, "anchorblock"); - elm_widget_type_set(obj, "anchorblock"); - elm_widget_sub_object_add(parent, obj); - elm_widget_data_set(obj, wd); - elm_widget_del_pre_hook_set(obj, _del_pre_hook); - elm_widget_del_hook_set(obj, _del_hook); - elm_widget_theme_hook_set(obj, _theme_hook); - elm_widget_can_focus_set(obj, EINA_TRUE); - elm_widget_text_set_hook_set(obj, _elm_anchorblock_text_set); - elm_widget_text_get_hook_set(obj, _elm_anchorblock_text_get); - - wd->entry = elm_entry_add(parent); - elm_entry_item_provider_prepend(wd->entry, _item_provider, obj); - elm_widget_resize_object_set(obj, wd->entry); - elm_entry_editable_set(wd->entry, 0); - evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL); - - evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _changed_size_hints, obj); - - elm_object_text_set(wd->entry, ""); - - evas_object_smart_callback_add(wd->entry, "anchor,clicked", - _anchor_clicked, obj); - - _mirrored_set(obj, elm_widget_mirrored_get(obj)); - _sizing_eval(obj); - - // TODO: convert Elementary to subclassing of Evas_Smart_Class - // TODO: and save some bytes, making descriptions per-class and not instance! - evas_object_smart_callbacks_descriptions_set(obj, _signals); - return obj; -} - -EAPI void -elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - if (wd->hover_parent) - evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); - wd->hover_parent = parent; - if (wd->hover_parent) - evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); -} - -EAPI Evas_Object * -elm_anchorblock_hover_parent_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->hover_parent; -} - -EAPI void -elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - eina_stringshare_replace(&wd->hover_style, style); -} - -EAPI const char * -elm_anchorblock_hover_style_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->hover_style; -} - -EAPI void -elm_anchorblock_hover_end(Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - if (wd->hover) evas_object_del(wd->hover); - if (wd->pop) evas_object_del(wd->pop); - wd->hover = NULL; - wd->pop = NULL; -} - -EAPI void -elm_anchorblock_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - Elm_Anchorblock_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorblock_Item_Provider)); - if (!ip) return; - ip->func = func; - ip->data = data; - wd->item_providers = eina_list_append(wd->item_providers, ip); -} - -EAPI void -elm_anchorblock_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - Elm_Anchorblock_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorblock_Item_Provider)); - if (!ip) return; - ip->func = func; - ip->data = data; - wd->item_providers = eina_list_prepend(wd->item_providers, ip); -} - -EAPI void -elm_anchorblock_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - Eina_List *l; - Elm_Anchorblock_Item_Provider *ip; - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - EINA_LIST_FOREACH(wd->item_providers, l, ip) - { - if ((ip->func == func) && (ip->data == data)) - { - wd->item_providers = eina_list_remove_list(wd->item_providers, l); - free(ip); - return; - } - } -} diff --git a/src/lib/elc_anchorblock.h b/src/lib/elc_anchorblock.h deleted file mode 100644 index 0d49db8..0000000 --- a/src/lib/elc_anchorblock.h +++ /dev/null @@ -1,206 +0,0 @@ -/** - * @defgroup Anchorblock Anchorblock - * - * @image html img/widget/anchorblock/preview-00.png - * @image latex img/widget/anchorblock/preview-00.eps - * - * Anchorblock is for displaying text that contains markup with anchors - * like \something\ in it. - * - * Besides being styled differently, the anchorblock widget provides the - * necessary functionality so that clicking on these anchors brings up a - * popup with user defined content such as "call", "add to contacts" or - * "open web page". This popup is provided using the @ref Hover widget. - * - * This widget emits the following signals: - * @li "anchor,clicked": will be called when an anchor is clicked. The - * @p event_info parameter on the callback will be a pointer of type - * ::Elm_Entry_Anchorblock_Info. - * - * @see Anchorview - * @see Entry - * @see Hover - * - * Default text parts of the anchorblock widget that you can use for are: - * @li "default" - A label of the anchorblock - * - * Supported elm_object common APIs. - * @li elm_object_part_text_set - * @li elm_object_part_text_get - * - * Since examples are usually better than plain words, we might as well - * try @ref tutorial_anchorblock_example "one". - */ - -/** - * @addtogroup Anchorblock - * @{ - */ - -/* XXX: Remove this awful widget. */ - -/** - * @typedef Elm_Entry_Anchorblock_Info - * - * The info sent in the callback for "anchor,clicked" signals emitted by - * the Anchorblock widget. - */ -typedef struct _Elm_Entry_Anchorblock_Info Elm_Entry_Anchorblock_Info; - -/** - * @struct _Elm_Entry_Anchorblock_Info - * - * The info sent in the callback for "anchor,clicked" signals emitted by - * the Anchorblock widget. - */ -struct _Elm_Entry_Anchorblock_Info -{ - const char *name; /**< Name of the anchor, as indicated in its href - attribute */ - int button; /**< The mouse button used to click on it */ - Evas_Object *hover; /**< The hover object to use for the popup */ - struct - { - Evas_Coord x, y, w, h; - } anchor, /**< Geometry selection of text used as anchor */ - hover_parent; /**< Geometry of the object used as parent by the - hover */ - Eina_Bool hover_left : 1; /**< Hint indicating if there's space - for content on the left side of - the hover. Before calling the - callback, the widget will make the - necessary calculations to check - which sides are fit to be set with - content, based on the position the - hover is activated and its distance - to the edges of its parent object - */ - Eina_Bool hover_right : 1; /**< Hint indicating content fits on - the right side of the hover. - See @ref hover_left */ - Eina_Bool hover_top : 1; /**< Hint indicating content fits on top - of the hover. See @ref hover_left */ - Eina_Bool hover_bottom : 1; /**< Hint indicating content fits - below the hover. See @ref - hover_left */ -}; - -/** - * Add a new Anchorblock object - * - * @param parent The parent object - * @return The new object or NULL if it cannot be created - */ -EAPI Evas_Object *elm_anchorblock_add(Evas_Object *parent); - -/** - * Set the parent of the hover popup - * - * Sets the parent object to use by the hover created by the anchorblock - * when an anchor is clicked. See @ref Hover for more details on this. - * - * @param obj The anchorblock object - * @param parent The object to use as parent for the hover - */ -EAPI void elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent); - -/** - * Get the parent of the hover popup - * - * Get the object used as parent for the hover created by the anchorblock - * widget. See @ref Hover for more details on this. - * If no parent is set, the same anchorblock object will be used. - * - * @param obj The anchorblock object - * @return The object used as parent for the hover, NULL if none is set. - */ -EAPI Evas_Object *elm_anchorblock_hover_parent_get(const Evas_Object *obj); - -/** - * Set the style that the hover should use - * - * When creating the popup hover, anchorblock will request that it's - * themed according to @p style. - * - * @param obj The anchorblock object - * @param style The style to use for the underlying hover - * - * @see elm_object_style_set() - */ -EAPI void elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style); - -/** - * Get the style that the hover should use - * - * Get the style, the hover created by anchorblock will use. - * - * @param obj The anchorblock object - * @return The style to use by the hover. NULL means the default is used. - * - * @see elm_object_style_set() - */ -EAPI const char *elm_anchorblock_hover_style_get(const Evas_Object *obj); - -/** - * Ends the hover popup in the anchorblock - * - * When an anchor is clicked, the anchorblock widget will create a hover - * object to use as a popup with user provided content. This function - * terminates this popup, returning the anchorblock to its normal state. - * - * @param obj The anchorblock object - */ -EAPI void elm_anchorblock_hover_end(Evas_Object *obj); - -/** - * Appends a custom item provider to the given anchorblock - * - * Appends the given function to the list of items providers. This list is - * called, one function at a time, with the given @p data pointer, the - * anchorblock object and, in the @p item parameter, the item name as - * referenced in its href string. Following functions in the list will be - * called in order until one of them returns something different to NULL, - * which should be an Evas_Object which will be used in place of the item - * element. - * - * Items in the markup text take the form \\ - * - * @param obj The anchorblock object - * @param func The function to add to the list of providers - * @param data User data that will be passed to the callback function - * - * @see elm_entry_item_provider_append() - */ -EAPI void elm_anchorblock_item_provider_append(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorblock, const char *item), void *data); - -/** - * Prepend a custom item provider to the given anchorblock - * - * Like elm_anchorblock_item_provider_append(), but it adds the function - * @p func to the beginning of the list, instead of the end. - * - * @param obj The anchorblock object - * @param func The function to add to the list of providers - * @param data User data that will be passed to the callback function - */ -EAPI void elm_anchorblock_item_provider_prepend(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorblock, const char *item), void *data); - -/** - * Remove a custom item provider from the list of the given anchorblock - * - * Removes the function and data pairing that matches @p func and @p data. - * That is, unless the same function and same user data are given, the - * function will not be removed from the list. This allows us to add the - * same callback several times, with different @p data pointers and be - * able to remove them later without conflicts. - * - * @param obj The anchorblock object - * @param func The function to remove from the list - * @param data The data matching the function to remove from the list - */ -EAPI void elm_anchorblock_item_provider_remove(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorblock, const char *item), void *data); - -/** - * @} - */ diff --git a/src/lib/elc_anchorview.c b/src/lib/elc_anchorview.c deleted file mode 100644 index ebe9528..0000000 --- a/src/lib/elc_anchorview.c +++ /dev/null @@ -1,366 +0,0 @@ -#include -#include "elm_priv.h" - -typedef struct _Widget_Data Widget_Data; -typedef struct _Elm_Anchorview_Item_Provider Elm_Anchorview_Item_Provider; - -struct _Widget_Data -{ - Evas_Object *scroller, *entry; - Evas_Object *hover_parent; - Evas_Object *pop, *hover; - Eina_List *item_providers; - const char *hover_style; -}; - -struct _Elm_Anchorview_Item_Provider -{ - Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item); - void *data; -}; - -static const char *widtype = NULL; - -static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked"; -static const Evas_Smart_Cb_Description _signals[] = { - {SIG_ANCHOR_CLICKED, ""}, /* TODO: declare the type properly, as data is - * being passed - */ - {NULL, NULL} -}; - -static void _del_pre_hook(Evas_Object *obj); -static void _del_hook(Evas_Object *obj); -static void _sizing_eval(Evas_Object *obj); -static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl); - -static void -_del_pre_hook(Evas_Object *obj) -{ - elm_anchorview_hover_end(obj); - elm_anchorview_hover_parent_set(obj, NULL); -} - -static void -_del_hook(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - Elm_Anchorview_Item_Provider *ip; - if (!wd) return; - if (wd->hover_style) eina_stringshare_del(wd->hover_style); - EINA_LIST_FREE(wd->item_providers, ip) - { - free(ip); - } - free(wd); -} - -static void -_mirrored_set(Evas_Object *obj, Eina_Bool rtl) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - elm_widget_mirrored_set(wd->hover, rtl); -} - -static void -_theme_hook(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - _elm_widget_mirrored_reload(obj); - _mirrored_set(obj, elm_widget_mirrored_get(obj)); -} - -static void -_sizing_eval(Evas_Object *obj) -{ - Widget_Data *wd = elm_widget_data_get(obj); - Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; - if (!wd) return; - evas_object_size_hint_min_set(obj, minw, minh); - evas_object_size_hint_max_set(obj, maxw, maxh); -} - -static void -_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - _sizing_eval(data); -} - -static void -_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - elm_anchorview_hover_end(data); -} - -static void -_anchor_clicked(void *data, Evas_Object *obj, void *event_info) -{ - Widget_Data *wd = elm_widget_data_get(data); - Elm_Entry_Anchor_Info *info = event_info; - Evas_Object *hover_parent; - Elm_Entry_Anchorview_Info ei; - Evas_Coord x, w, y, h, px, py; - if (!wd) return; - wd->pop = elm_icon_add(obj); - evas_object_move(wd->pop, info->x, info->y); - evas_object_resize(wd->pop, info->w, info->h); - wd->hover = elm_hover_add(obj); - elm_widget_mirrored_set(wd->hover, elm_widget_mirrored_get((Evas_Object *) data)); - if (wd->hover_style) elm_object_style_set(wd->hover, wd->hover_style); - hover_parent = wd->hover_parent; - if (!hover_parent) hover_parent = obj; - elm_hover_parent_set(wd->hover, hover_parent); - elm_hover_target_set(wd->hover, wd->pop); - ei.name = info->name; - ei.button = info->button; - ei.hover = wd->hover; - ei.anchor.x = info->x; - ei.anchor.y = info->y; - ei.anchor.w = info->w; - ei.anchor.h = info->h; - evas_object_geometry_get(hover_parent, &x, &y, &w, &h); - ei.hover_parent.x = x; - ei.hover_parent.y = y; - ei.hover_parent.w = w; - ei.hover_parent.h = h; - px = info->x + (info->w / 2); - py = info->y + (info->h / 2); - ei.hover_left = 1; - if (px < (x + (w / 3))) ei.hover_left = 0; - ei.hover_right = 1; - if (px > (x + ((w * 2) / 3))) ei.hover_right = 0; - ei.hover_top = 1; - if (py < (y + (h / 3))) ei.hover_top = 0; - ei.hover_bottom = 1; - if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0; - - if (elm_widget_mirrored_get(wd->hover)) - { /* Swap right and left because they switch sides in RTL */ - Eina_Bool tmp = ei.hover_left; - ei.hover_left = ei.hover_right; - ei.hover_right = tmp; - } - - evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei); - evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data); - evas_object_show(wd->hover); -} - -static void -_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Widget_Data *wd = elm_widget_data_get(data); - if (!wd) return; - wd->hover_parent = NULL; -} - -static Evas_Object * -_item_provider(void *data, Evas_Object *entry __UNUSED__, const char *item) -{ - Widget_Data *wd = elm_widget_data_get(data); - Eina_List *l; - Elm_Anchorview_Item_Provider *ip; - - EINA_LIST_FOREACH(wd->item_providers, l, ip) - { - Evas_Object *o; - - o = ip->func(ip->data, data, item); - if (o) return o; - } - return NULL; -} - -static void -_elm_anchorview_text_set(Evas_Object *obj, const char *item, const char *text) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (item && strcmp(item, "default")) return; - if (!wd) return; - elm_object_text_set(wd->entry, text); - if (wd->hover) evas_object_del(wd->hover); - if (wd->pop) evas_object_del(wd->pop); - wd->hover = NULL; - wd->pop = NULL; - _sizing_eval(obj); -} - -static const char* -_elm_anchorview_text_get(const Evas_Object *obj, const char *item) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (item && strcmp(item, "default")) return NULL; - if (!wd) return NULL; - return elm_object_text_get(wd->entry); -} - -EAPI Evas_Object * -elm_anchorview_add(Evas_Object *parent) -{ - Evas_Object *obj; - Evas *e; - Widget_Data *wd; - - ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); - - ELM_SET_WIDTYPE(widtype, "anchorview"); - elm_widget_type_set(obj, "anchorview"); - elm_widget_sub_object_add(parent, obj); - elm_widget_data_set(obj, wd); - elm_widget_del_pre_hook_set(obj, _del_pre_hook); - elm_widget_del_hook_set(obj, _del_hook); - elm_widget_theme_hook_set(obj, _theme_hook); - elm_widget_can_focus_set(obj, EINA_TRUE); - elm_widget_text_set_hook_set(obj, _elm_anchorview_text_set); - elm_widget_text_get_hook_set(obj, _elm_anchorview_text_get); - - wd->scroller = elm_scroller_add(parent); - elm_widget_resize_object_set(obj, wd->scroller); - wd->entry = elm_entry_add(parent); - elm_entry_item_provider_prepend(wd->entry, _item_provider, obj); - elm_entry_editable_set(wd->entry, 0); - evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_content_set(wd->scroller, wd->entry); - evas_object_show(wd->entry); - - evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _changed_size_hints, obj); - - elm_object_text_set(wd->entry, ""); - - evas_object_smart_callback_add(wd->entry, "anchor,clicked", - _anchor_clicked, obj); - - _mirrored_set(obj, elm_widget_mirrored_get(obj)); - _sizing_eval(obj); - - // TODO: convert Elementary to subclassing of Evas_Smart_Class - // TODO: and save some bytes, making descriptions per-class and not instance! - evas_object_smart_callbacks_descriptions_set(obj, _signals); - return obj; -} - -EAPI void -elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - if (wd->hover_parent) - evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); - wd->hover_parent = parent; - if (wd->hover_parent) - evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); -} - -EAPI Evas_Object * -elm_anchorview_hover_parent_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->hover_parent; -} - -EAPI void -elm_anchorview_hover_style_set(Evas_Object *obj, const char *style) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - eina_stringshare_replace(&wd->hover_style, style); -} - -EAPI const char * -elm_anchorview_hover_style_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->hover_style; -} - -EAPI void -elm_anchorview_hover_end(Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - if (wd->hover) evas_object_del(wd->hover); - if (wd->pop) evas_object_del(wd->pop); - wd->hover = NULL; - wd->pop = NULL; -} - -EAPI void -elm_anchorview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce); -} - -EAPI void -elm_anchorview_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - elm_scroller_bounce_get(wd->scroller, h_bounce, v_bounce); -} - -EAPI void -elm_anchorview_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - Elm_Anchorview_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorview_Item_Provider)); - if (!ip) return; - ip->func = func; - ip->data = data; - wd->item_providers = eina_list_append(wd->item_providers, ip); -} - -EAPI void -elm_anchorview_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - Elm_Anchorview_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorview_Item_Provider)); - if (!ip) return; - ip->func = func; - ip->data = data; - wd->item_providers = eina_list_prepend(wd->item_providers, ip); -} - -EAPI void -elm_anchorview_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - Eina_List *l; - Elm_Anchorview_Item_Provider *ip; - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(func); - EINA_LIST_FOREACH(wd->item_providers, l, ip) - { - if ((ip->func == func) && (ip->data == data)) - { - wd->item_providers = eina_list_remove_list(wd->item_providers, l); - free(ip); - return; - } - } -} diff --git a/src/lib/elc_anchorview.h b/src/lib/elc_anchorview.h deleted file mode 100644 index d70c1e4..0000000 --- a/src/lib/elc_anchorview.h +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @defgroup Anchorview Anchorview - * - * @image html img/widget/anchorview/preview-00.png - * @image latex img/widget/anchorview/preview-00.eps - * - * Anchorview is for displaying text that contains markup with anchors - * like \something\ in it. - * - * Besides being styled differently, the anchorview widget provides the - * necessary functionality so that clicking on these anchors brings up a - * popup with user defined content such as "call", "add to contacts" or - * "open web page". This popup is provided using the @ref Hover widget. - * - * This widget is very similar to @ref Anchorblock, so refer to that - * widget for an example. The only difference Anchorview has is that the - * widget is already provided with scrolling functionality, so if the - * text set to it is too large to fit in the given space, it will scroll, - * whereas the @ref Anchorblock widget will keep growing to ensure all the - * text can be displayed. - * - * This widget emits the following signals: - * @li "anchor,clicked": will be called when an anchor is clicked. The - * @p event_info parameter on the callback will be a pointer of type - * ::Elm_Entry_Anchorview_Info. - * - * See @ref Anchorblock for an example on how to use both of them. - * - * @see Anchorblock - * @see Entry - * @see Hover - * - * @{ - */ - -/** - * @typedef Elm_Entry_Anchorview_Info - * - * The info sent in the callback for "anchor,clicked" signals emitted by - * the Anchorview widget. - */ -typedef struct _Elm_Entry_Anchorview_Info Elm_Entry_Anchorview_Info; - -/* XXX: Merge into entry. */ - -/** - * @struct _Elm_Entry_Anchorview_Info - * - * The info sent in the callback for "anchor,clicked" signals emitted by - * the Anchorview widget. - */ -struct _Elm_Entry_Anchorview_Info -{ - const char *name; /**< Name of the anchor, as indicated in its href - attribute */ - int button; /**< The mouse button used to click on it */ - Evas_Object *hover; /**< The hover object to use for the popup */ - struct - { - Evas_Coord x, y, w, h; - } anchor, /**< Geometry selection of text used as anchor */ - hover_parent; /**< Geometry of the object used as parent by the - hover */ - Eina_Bool hover_left : 1; /**< Hint indicating if there's space - for content on the left side of - the hover. Before calling the - callback, the widget will make the - necessary calculations to check - which sides are fit to be set with - content, based on the position the - hover is activated and its distance - to the edges of its parent object - */ - Eina_Bool hover_right : 1; /**< Hint indicating content fits on - the right side of the hover. - See @ref hover_left */ - Eina_Bool hover_top : 1; /**< Hint indicating content fits on top - of the hover. See @ref hover_left */ - Eina_Bool hover_bottom : 1; /**< Hint indicating content fits - below the hover. See @ref - hover_left */ -}; - -/** - * Add a new Anchorview object to the parent. - * - * @param parent The parent object - * @return The new object or NULL if it cannot be created - */ -EAPI Evas_Object *elm_anchorview_add(Evas_Object *parent); - -/** - * Set the parent of the hover popup - * - * Sets the parent object to use by the hover created by the anchorview - * when an anchor is clicked. See @ref Hover for more details on this. - * If no parent is set, the same anchorview object will be used. - * - * @param obj The anchorview object - * @param parent The object to use as parent for the hover - */ -EAPI void elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent); - -/** - * Get the parent of the hover popup - * - * Get the object used as parent for the hover created by the anchorview - * widget. See @ref Hover for more details on this. - * - * @param obj The anchorview object - * @return The object used as parent for the hover, NULL if none is set. - */ -EAPI Evas_Object *elm_anchorview_hover_parent_get(const Evas_Object *obj); - -/** - * Set the style that the hover should use - * - * When creating the popup hover, anchorview will request that it is - * themed according to @p style. - * - * @param obj The anchorview object - * @param style The style to use for the underlying hover - * - * @see elm_object_style_set() - */ -EAPI void elm_anchorview_hover_style_set(Evas_Object *obj, const char *style); - -/** - * Get the style that the hover uses. - * - * Get the style the hover created by anchorview will use. - * - * @param obj The anchorview object - * @return The style to use by the hover. NULL means the default is used. - * - * @see elm_object_style_set() - */ -EAPI const char *elm_anchorview_hover_style_get(const Evas_Object *obj); - -/** - * Ends the hover popup in the anchorview - * - * When an anchor is clicked, the anchorview widget will create a hover - * object to use as a popup with user provided content. This function - * terminates this popup, returning the anchorview to its normal state. - * - * @param obj The anchorview object - */ -EAPI void elm_anchorview_hover_end(Evas_Object *obj); - -/** - * Set bouncing behaviour when the scrolled content reaches an edge - * - * Tell the internal scroller object whether it should bounce or not - * when it reaches the respective edges for each axis. - * - * @param obj The anchorview object - * @param h_bounce Whether to bounce or not in the horizontal axis - * @param v_bounce Whether to bounce or not in the vertical axis - * - * @see elm_scroller_bounce_set() - */ -EAPI void elm_anchorview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce); - -/** - * Get the bouncing behaviour of the internal scroller - * - * Get whether the internal scroller will bounce when the edge of each - * axis is reached scrolling. - * - * @param obj The anchorview object - * @param h_bounce Pointer to store the bounce state of the horizontal - * axis - * @param v_bounce Pointer to store the bounce state of the vertical - * axis - * - * @see elm_scroller_bounce_get() - */ -EAPI void elm_anchorview_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce); - -/** - * Appends a custom item provider to the given anchorview - * - * Appends the given function to the list of items providers. This list is - * called, one function at a time, with the given @p data pointer, the - * anchorview object and, in the @p item parameter, the item name as - * referenced in its href string. Following functions in the list will be - * called in order until one of them returns something different to NULL, - * which should be an Evas_Object which will be used in place of the item - * element. - * - * Items in the markup text take the form \\ - * - * @param obj The anchorview object - * @param func The function to add to the list of providers - * @param data User data that will be passed to the callback function - * - * @see elm_entry_item_provider_append() - */ -EAPI void elm_anchorview_item_provider_append(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorview, const char *item), void *data); - -/** - * Prepend a custom item provider to the given anchorview - * - * Like elm_anchorview_item_provider_append(), but it adds the function - * @p func to the beginning of the list, instead of the end. - * - * @param obj The anchorview object - * @param func The function to add to the list of providers - * @param data User data that will be passed to the callback function - */ -EAPI void elm_anchorview_item_provider_prepend(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorview, const char *item), void *data); - -/** - * Remove a custom item provider from the list of the given anchorview - * - * Removes the function and data pairing that matches @p func and @p data. - * That is, unless the same function and same user data are given, the - * function will not be removed from the list. This allows us to add the - * same callback several times, with different @p data pointers and be - * able to remove them later without conflicts. - * - * @param obj The anchorview object - * @param func The function to remove from the list - * @param data The data matching the function to remove from the list - */ -EAPI void elm_anchorview_item_provider_remove(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * anchorview, const char *item), void *data); - -/** - * @} - */ diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 3605e9a..d9890c2 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -53,6 +53,11 @@ struct _Widget_Data Elm_Input_Panel_Return_Key_Type input_panel_return_key_type; void *input_panel_imdata; int input_panel_imdata_len; + struct { + Evas_Object *hover_parent; + Evas_Object *pop, *hover; + const char *hover_style; + } anchor_hover; Eina_Bool changed : 1; Eina_Bool single_line : 1; Eina_Bool password : 1; @@ -133,6 +138,7 @@ static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char * static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source); static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source); static void _add_chars_till_limit(Evas_Object *obj, char **text, int can_add, Length_Unit unit); +static void _entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info); static const char SIG_CHANGED[] = "changed"; static const char SIG_CHANGED_USER[] = "changed,user"; @@ -153,6 +159,7 @@ static const char SIG_SELECTION_CLEARED[] = "selection,cleared"; static const char SIG_CURSOR_CHANGED[] = "cursor,changed"; static const char SIG_CURSOR_CHANGED_MANUAL[] = "cursor,changed,manual"; static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked"; +static const char SIG_ANCHOR_HOVER_OPENED[] = "anchor,hover,opened"; static const char SIG_ANCHOR_DOWN[] = "anchor,down"; static const char SIG_ANCHOR_UP[] = "anchor,up"; static const char SIG_ANCHOR_IN[] = "anchor,in"; @@ -179,6 +186,7 @@ static const Evas_Smart_Cb_Description _signals[] = { {SIG_CURSOR_CHANGED, ""}, {SIG_CURSOR_CHANGED_MANUAL, ""}, {SIG_ANCHOR_CLICKED, ""}, + {SIG_ANCHOR_HOVER_OPENED, ""}, {SIG_ANCHOR_DOWN, ""}, {SIG_ANCHOR_UP, ""}, {SIG_ANCHOR_IN, ""}, @@ -453,6 +461,8 @@ _del_pre_hook(Evas_Object *obj) wd->delay_write = NULL; if (wd->autosave) _save(obj); } + elm_entry_anchor_hover_end(obj); + elm_entry_anchor_hover_parent_set(obj, NULL); } static void @@ -511,6 +521,7 @@ _del_hook(Evas_Object *obj) if (wd->input_panel_imdata) free(wd->input_panel_imdata); free(wd); + if (wd->anchor_hover.hover_style) eina_stringshare_del(wd->anchor_hover.hover_style); evas_event_thaw(evas_object_evas_get(obj)); evas_event_thaw_eval(evas_object_evas_get(obj)); } @@ -520,6 +531,8 @@ _mirrored_set(Evas_Object *obj, Eina_Bool rtl) { Widget_Data *wd = elm_widget_data_get(obj); edje_object_mirrored_set(wd->ent, rtl); + if (wd->anchor_hover.hover) + elm_widget_mirrored_set(wd->anchor_hover.hover, rtl); } static void @@ -1836,7 +1849,11 @@ _signal_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emis _signal_anchor_geoms_do_things_with(wd, &ei); if (!wd->disabled) - evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei); + { + evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei); + + _entry_hover_anchor_clicked(data, data, &ei); + } } static void @@ -3831,3 +3848,123 @@ elm_entry_imf_context_get(Evas_Object *obj) return edje_object_part_text_imf_context_get(wd->ent, "elm.text"); } + +/* START - ANCHOR HOVER */ +static void +_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Widget_Data *wd = elm_widget_data_get(data); + if (!wd) return; + wd->anchor_hover.hover_parent = NULL; +} + +EAPI void +elm_entry_anchor_hover_parent_set(Evas_Object *obj, Evas_Object *parent) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->anchor_hover.hover_parent) + evas_object_event_callback_del_full(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); + wd->anchor_hover.hover_parent = parent; + if (wd->anchor_hover.hover_parent) + evas_object_event_callback_add(wd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj); +} + +EAPI Evas_Object * +elm_entry_anchor_hover_parent_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return wd->anchor_hover.hover_parent; +} + +EAPI void +elm_entry_anchor_hover_style_set(Evas_Object *obj, const char *style) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + eina_stringshare_replace(&wd->anchor_hover.hover_style, style); +} + +EAPI const char * +elm_entry_anchor_hover_style_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return wd->anchor_hover.hover_style; +} + +EAPI void +elm_entry_anchor_hover_end(Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->anchor_hover.hover) evas_object_del(wd->anchor_hover.hover); + if (wd->anchor_hover.pop) evas_object_del(wd->anchor_hover.pop); + wd->anchor_hover.hover = NULL; + wd->anchor_hover.pop = NULL; +} + + +static void +_anchor_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_entry_anchor_hover_end(data); +} + +static void +_entry_hover_anchor_clicked(void *data, Evas_Object *obj, void *event_info) +{ + Widget_Data *wd = elm_widget_data_get(obj); + Elm_Entry_Anchor_Info *info = event_info; + Evas_Object *hover_parent; + Elm_Entry_Anchor_Hover_Info ei; + Evas_Coord x, w, y, h, px, py; + if (!wd) return; + ei.anchor_info = event_info; + wd->anchor_hover.pop = elm_icon_add(obj); + evas_object_move(wd->anchor_hover.pop, info->x, info->y); + evas_object_resize(wd->anchor_hover.pop, info->w, info->h); + wd->anchor_hover.hover = elm_hover_add(obj); + elm_widget_mirrored_set(wd->anchor_hover.hover, elm_widget_mirrored_get(obj)); + if (wd->anchor_hover.hover_style) + elm_object_style_set(wd->anchor_hover.hover, wd->anchor_hover.hover_style); + hover_parent = wd->anchor_hover.hover_parent; + if (!hover_parent) hover_parent = obj; + elm_hover_parent_set(wd->anchor_hover.hover, hover_parent); + elm_hover_target_set(wd->anchor_hover.hover, wd->anchor_hover.pop); + ei.hover = wd->anchor_hover.hover; + evas_object_geometry_get(hover_parent, &x, &y, &w, &h); + ei.hover_parent.x = x; + ei.hover_parent.y = y; + ei.hover_parent.w = w; + ei.hover_parent.h = h; + px = info->x + (info->w / 2); + py = info->y + (info->h / 2); + ei.hover_left = 1; + if (px < (x + (w / 3))) ei.hover_left = 0; + ei.hover_right = 1; + if (px > (x + ((w * 2) / 3))) ei.hover_right = 0; + ei.hover_top = 1; + if (py < (y + (h / 3))) ei.hover_top = 0; + ei.hover_bottom = 1; + if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0; + + if (elm_widget_mirrored_get(wd->anchor_hover.hover)) + { /* Swap right and left because they switch sides in RTL */ + Eina_Bool tmp = ei.hover_left; + ei.hover_left = ei.hover_right; + ei.hover_right = tmp; + } + + evas_object_smart_callback_call(data, SIG_ANCHOR_HOVER_OPENED, &ei); + evas_object_smart_callback_add(wd->anchor_hover.hover, "clicked", _anchor_hover_clicked, data); + evas_object_show(wd->anchor_hover.hover); +} +/* END - ANCHOR HOVER */ + diff --git a/src/lib/elm_entry.h b/src/lib/elm_entry.h index b9ca59e..81b296b 100644 --- a/src/lib/elm_entry.h +++ b/src/lib/elm_entry.h @@ -371,6 +371,49 @@ struct _Elm_Entry_Anchor_Info }; /** + * @typedef Elm_Entry_Anchor_Hover_Info + * + * The info sent in the callback for "anchor,clicked" signals emitted by + * the Anchor_Hover widget. + */ +typedef struct _Elm_Entry_Anchor_Hover_Info Elm_Entry_Anchor_Hover_Info; + +/** + * @struct _Elm_Entry_Anchor_Hover_Info + * + * The info sent in the callback for "anchor,clicked" signals emitted by + * the Anchor_Hover widget. + */ +struct _Elm_Entry_Anchor_Hover_Info +{ + const Elm_Entry_Anchor_Info *anchor_info; /**< The actual anchor info. */ + Evas_Object *hover; /**< The hover object to use for the popup */ + struct + { + Evas_Coord x, y, w, h; + } hover_parent; /**< Geometry of the object used as parent by the + hover */ + Eina_Bool hover_left : 1; /**< Hint indicating if there's space + for content on the left side of + the hover. Before calling the + callback, the widget will make the + necessary calculations to check + which sides are fit to be set with + content, based on the position the + hover is activated and its distance + to the edges of its parent object + */ + Eina_Bool hover_right : 1; /**< Hint indicating content fits on + the right side of the hover. + See @ref hover_left */ + Eina_Bool hover_top : 1; /**< Hint indicating content fits on top + of the hover. See @ref hover_left */ + Eina_Bool hover_bottom : 1; /**< Hint indicating content fits + below the hover. See @ref + hover_left */ +}; + +/** * @typedef Elm_Entry_Filter_Cb * This callback type is used by entry filters to modify text. * @param data The data specified as the last param when adding the filter @@ -1426,6 +1469,66 @@ EAPI void elm_entry_cnp_mode_set(Evas_Object *obj, Elm_Cnp_Mode cnp_mode */ EAPI Elm_Cnp_Mode elm_entry_cnp_mode_get(const Evas_Object *obj); +/** + * Set the parent of the hover popup + * + * Sets the parent object to use by the hover created by the entry + * when an anchor is clicked. See @ref Hover for more details on this. + * + * @param obj The entry object + * @param parent The object to use as parent for the hover + */ +EAPI void elm_entry_anchor_hover_parent_set(Evas_Object *obj, Evas_Object *parent); + +/** + * Get the parent of the hover popup + * + * Get the object used as parent for the hover created by the entry + * widget. See @ref Hover for more details on this. + * If no parent is set, the same entry object will be used. + * + * @param obj The entry object + * @return The object used as parent for the hover, NULL if none is set. + */ +EAPI Evas_Object *elm_entry_anchor_hover_parent_get(const Evas_Object *obj); + +/** + * Set the style that the hover should use + * + * When creating the popup hover, entry will request that it's + * themed according to @p style. + * + * Setting style no NULL means disabling automatic hover. + * + * @param obj The entry object + * @param style The style to use for the underlying hover + * + * @see elm_object_style_set() + */ +EAPI void elm_entry_anchor_hover_style_set(Evas_Object *obj, const char *style); + +/** + * Get the style that the hover should use + * + * Get the style, the hover created by entry will use. + * + * @param obj The entry object + * @return The style to use by the hover. NULL means the default is used. + * + * @see elm_object_style_set() + */ +EAPI const char *elm_entry_anchor_hover_style_get(const Evas_Object *obj); + +/** + * Ends the hover popup in the entry + * + * When an anchor is clicked, the entry widget will create a hover + * object to use as a popup with user provided content. This function + * terminates this popup, returning the entry to its normal state. + * + * @param obj The entry object + */ +EAPI void elm_entry_anchor_hover_end(Evas_Object *obj); /** * @}