X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbin%2Ftest_tooltip.c;h=d82516c223ec4df46a73633576626c45ba96d519;hb=1d0aa805ddc0b3efa007581eaa0b37690fd22f4f;hp=d5acd7ddb19e080e8fac8facd22f788ff53babda;hpb=d05ea5cefc91c01d29bbe90c7e18188853c3a477;p=framework%2Fuifw%2Felementary.git diff --git a/src/bin/test_tooltip.c b/src/bin/test_tooltip.c index d5acd7d..d82516c 100644 --- a/src/bin/test_tooltip.c +++ b/src/bin/test_tooltip.c @@ -1,12 +1,12 @@ -#include #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif +#include #ifndef ELM_LIB_QUICKLAUNCH typedef struct _Testitem { - Elm_Gengrid_Item *item; + Elm_Object_Item *item; const char *path; int mode; int onoff; @@ -51,22 +51,22 @@ gltt_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { - Elm_Genlist_Item *it = event_info; - Evas_Object *gl = elm_genlist_item_genlist_get(it); - int val = (int)(long)elm_genlist_item_data_get(it); - Elm_Genlist_Item *it1, *it2, *it3; + Elm_Object_Item *glit = event_info; + Evas_Object *gl = elm_object_item_widget_get(glit); + int val = (int)(long) elm_object_item_data_get(glit); + Elm_Object_Item *glit1, *glit2, *glit3; val *= 10; - it1 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 1), it, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - it2 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 2), it, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - it3 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 3), it, - ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL); - - elm_genlist_item_tooltip_text_set(it1, "Testing A"); - elm_genlist_item_tooltip_text_set(it2, "Testing B"); - elm_genlist_item_tooltip_text_set(it3, "Testing C"); + glit1 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 1), glit, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + glit2 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 2), glit, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + glit3 = elm_genlist_item_append(gl, &itct, (void *)(long) (val + 3), glit, + ELM_GENLIST_ITEM_TREE, NULL, NULL); + + elm_genlist_item_tooltip_text_set(glit1, "Testing A"); + elm_genlist_item_tooltip_text_set(glit2, "Testing B"); + elm_genlist_item_tooltip_text_set(glit3, "Testing C"); } static void @@ -74,8 +74,8 @@ gltt_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { - Elm_Genlist_Item *it = event_info; - elm_genlist_item_subitems_clear(it); + Elm_Object_Item *glit = event_info; + elm_genlist_item_subitems_clear(glit); } static void @@ -83,8 +83,8 @@ gltt_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { - Elm_Genlist_Item *it = event_info; - elm_genlist_item_expanded_set(it, 1); + Elm_Object_Item *glit = event_info; + elm_genlist_item_expanded_set(glit, EINA_TRUE); } static void @@ -92,12 +92,12 @@ gltt_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { - Elm_Genlist_Item *it = event_info; - elm_genlist_item_expanded_set(it, 0); + Elm_Object_Item *glit = event_info; + elm_genlist_item_expanded_set(glit, EINA_FALSE); } char * -gltt_label_get(void *data, +gltt_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) { @@ -117,7 +117,7 @@ _tt_item_icon(void *data __UNUSED__, snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); - elm_icon_scale_set(ic, 0, 0); + elm_icon_resizable_set(ic, 0, 0); evas_object_resize(ic, 64, 64); return ic; } @@ -132,7 +132,7 @@ _tt_item_icon2(void *data __UNUSED__, char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); - elm_icon_scale_set(ic, 0, 0); + elm_icon_resizable_set(ic, 0, 0); return ic; } @@ -142,11 +142,24 @@ _tt_item_icon3(void *data __UNUSED__, Evas_Object *tt, void *item __UNUSED__) { + int w, h, sw, sh; Evas_Object *ic = elm_icon_add(tt); + char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); - elm_icon_scale_set(ic, 0, 0); + elm_icon_size_get(ic, &w, &h); + elm_icon_resizable_set(ic, 0, 0); + elm_win_screen_size_get(tt, NULL, NULL, &sw, &sh); + if ((w > sw) || (h > sh)) + { + float sc = 0; + if ((float)w / (float)sw >= 0.8) + sc = ((float)sw * 0.8) / (float)w; + else if ((float)h / (float)sh >= 0.8) + sc = ((float)sh * 0.8) / (float)h; + if (sc) elm_object_scale_set(ic, sc); + } return ic; } @@ -157,9 +170,9 @@ _tt_item_label(void *data __UNUSED__, void *item __UNUSED__) { Evas_Object *l = elm_label_add(tt); - elm_object_text_set(l, "Something useful here?" - "No probably not, but this is a super long label" - "which probably breaks on your system, now doesn't it?" + elm_object_text_set(l, "Something useful here?" + "No probably not, but this is a super long label" + "which probably breaks on your system, now doesn't it?" "Yeah, I thought so."); elm_label_line_wrap_set(l, ELM_WRAP_MIXED); return l; @@ -236,7 +249,7 @@ _tt_icon(void *data __UNUSED__, snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); - elm_icon_scale_set(ic, 0, 0); + elm_icon_resizable_set(ic, 0, 0); evas_object_resize(ic, 64, 64); return ic; } @@ -250,7 +263,7 @@ _tt_icon2(void *data __UNUSED__, char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/images/icon_00.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); - elm_icon_scale_set(ic, 0, 0); + elm_icon_resizable_set(ic, 0, 0); evas_object_resize(ic, 64, 64); return ic; } @@ -339,7 +352,7 @@ _tt_visible_lock_toggle(void *data __UNUSED__, { elm_object_text_set(obj, "Locked tooltip visibility"); elm_object_tooltip_text_set(obj, "This tooltip is locked" - " visible,
click the button" + " visible,
click the button" " to unlock!"); elm_object_tooltip_show(obj); } @@ -347,7 +360,7 @@ _tt_visible_lock_toggle(void *data __UNUSED__, { elm_object_text_set(obj, "Unlocked tooltip visibility"); elm_object_tooltip_text_set(obj, "This tooltip is unlocked" - " visible,
click the button" + " visible,
click the button" " to lock!"); elm_object_tooltip_hide(obj); } @@ -358,20 +371,13 @@ test_tooltip(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst; - Elm_Toolbar_Item *ti; - Elm_List_Item *li; + Evas_Object *win, *bx, *tb, *bt, *se, *lst; + Elm_Object_Item *tb_it; + Elm_Object_Item *lit; - win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC); - elm_win_title_set(win, "Tooltip"); + win = elm_win_util_standard_add("tooltip", "Tooltip"); elm_win_autodel_set(win, EINA_TRUE); - bg = elm_bg_add(win); - elm_win_resize_object_add(win, bg); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_show(bg); - bx = elm_box_add(win); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -385,13 +391,13 @@ test_tooltip(void *data __UNUSED__, elm_box_pack_end(bx, tb); evas_object_show(tb); - ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL); - elm_toolbar_item_tooltip_text_set(ti, "Opens a file"); + tb_it = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL); + elm_object_item_tooltip_text_set(tb_it, "Opens a file"); - ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL); - elm_toolbar_item_tooltip_content_cb_set - (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del); - elm_toolbar_item_tooltip_style_set(ti, "transparent"); + tb_it = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL); + elm_object_item_tooltip_content_cb_set + (tb_it, _tt_item_icon, (void *)456L, _tt_item_icon_del); + elm_object_item_tooltip_style_set(tb_it, "transparent"); bt = elm_button_add(win); elm_object_text_set(bt, "Simple text tooltip"); @@ -454,7 +460,7 @@ test_tooltip(void *data __UNUSED__, bt = elm_button_add(win); elm_object_text_set(bt, "Unlocked tooltip visibility"); - elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,
" + elm_object_tooltip_text_set(bt, "This tooltip is unlocked visible,
" " click the button to lock!"); evas_object_smart_callback_add(bt, "clicked", _tt_visible_lock_toggle, NULL); @@ -467,20 +473,26 @@ test_tooltip(void *data __UNUSED__, evas_object_size_hint_align_set(se, EVAS_HINT_FILL, 0.5); elm_entry_scrollbar_policy_set(se, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_entry_entry_set(se, "Hello, some scrolled entry here!"); + elm_object_text_set(se, "Hello, some entry here!"); elm_object_tooltip_text_set(se, "Type something here!"); - elm_entry_single_line_set(se, 1); + elm_entry_single_line_set(se, EINA_TRUE); elm_box_pack_end(bx, se); evas_object_show(se); lst = elm_list_add(win); - li = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL); - elm_list_item_tooltip_text_set(li, "Something useful here?"); - li = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL); - elm_list_item_tooltip_content_cb_set(li, _tt_item_icon, NULL, NULL); - li = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL); - elm_list_item_tooltip_content_cb_set(li, _tt_item_icon2, NULL, NULL); - elm_list_item_tooltip_size_restrict_disable(li, EINA_TRUE); + lit = elm_list_item_append(lst, "Hello", NULL, NULL, NULL, NULL); + elm_object_item_tooltip_content_cb_set(lit, _tt_item_label, NULL, NULL); + elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE); + lit = elm_list_item_append(lst, "Icon Tooltip", NULL, NULL, NULL, NULL); + elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon, NULL, NULL); + lit = elm_list_item_append(lst, "Big Icon Tooltip", NULL, NULL, NULL, NULL); + elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon2, NULL, NULL); + elm_object_item_tooltip_style_set(lit, "transparent"); + elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE); + lit = elm_list_item_append(lst, "Insanely Big Icon Tooltip", NULL, NULL, NULL, NULL); + elm_object_item_tooltip_content_cb_set(lit, _tt_item_icon3, NULL, NULL); + elm_object_item_tooltip_style_set(lit, "transparent"); + elm_object_item_tooltip_window_mode_set(lit, EINA_TRUE); evas_object_size_hint_weight_set(lst, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(lst, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -498,8 +510,8 @@ test_tooltip2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *bx, *grid, *gl; - Elm_Genlist_Item *it1, *it2, *it3; + Evas_Object *win, *bx, *grid, *gl; + Elm_Object_Item *glit1, *glit2, *glit3; static Testitem ti[144]; int i, n; char buf[PATH_MAX]; @@ -516,16 +528,9 @@ test_tooltip2(void *data __UNUSED__, "wood_01.jpg", }; - win = elm_win_add(NULL, "tooltip2", ELM_WIN_BASIC); - elm_win_title_set(win, "Tooltip 2"); + win = elm_win_util_standard_add("tooltip2", "Tooltip 2"); elm_win_autodel_set(win, EINA_TRUE); - bg = elm_bg_add(win); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, bg); - evas_object_show(bg); - bx = elm_box_add(win); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -541,7 +546,7 @@ test_tooltip2(void *data __UNUSED__, EVAS_HINT_EXPAND); gic.item_style = "default"; - gic.func.label_get = grdt_lbl_get; + gic.func.text_get = grdt_lbl_get; gic.func.content_get = grdt_content_get; n = 0; @@ -571,18 +576,18 @@ test_tooltip2(void *data __UNUSED__, EVAS_HINT_EXPAND); itct.item_style = "default"; - itct.func.label_get = gltt_label_get; - - it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL, - ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL); - it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL, - ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL); - it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - - elm_genlist_item_tooltip_text_set(it1, "Testing 1"); - elm_genlist_item_tooltip_text_set(it2, "Testing 2"); - elm_genlist_item_tooltip_text_set(it3, "Testing 3"); + itct.func.text_get = gltt_text_get; + + glit1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL, + ELM_GENLIST_ITEM_TREE, NULL, NULL); + glit2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL, + ELM_GENLIST_ITEM_TREE, NULL, NULL); + glit3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_tooltip_text_set(glit1, "Testing 1"); + elm_genlist_item_tooltip_text_set(glit2, "Testing 2"); + elm_genlist_item_tooltip_text_set(glit3, "Testing 3"); evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl); evas_object_smart_callback_add(gl, "contract,request", gltt_con_req,