X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbin%2Ftest_bubble.c;h=57433dc96310a6ed76a8d9dacac813f8da526b57;hb=13a1745d21b244c168568848e5144cbf610be4b1;hp=a4e81112751b80df6d652a73c6a837da5a6fb36e;hpb=dd81a4628031c82966ec4987c8b369e47c3ce396;p=framework%2Fuifw%2Felementary.git diff --git a/src/bin/test_bubble.c b/src/bin/test_bubble.c index a4e8111..57433dc 100644 --- a/src/bin/test_bubble.c +++ b/src/bin/test_bubble.c @@ -1,4 +1,5 @@ #include +#include "test.h" #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif @@ -10,37 +11,145 @@ _print_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i printf("bubble clicked\n"); } +struct _api_data +{ + unsigned int state; /* What state we are testing */ + Evas_Object *win; /* Parent Window of widgets */ + void *box; /* Use this to get box content */ +}; +typedef struct _api_data api_data; + +enum _api_state +{ + BUBBLE_SET_CORNER_1, + BUBBLE_SET_CORNER_2, + BUBBLE_SET_ICON_CONTENT, + API_STATE_LAST +}; +typedef enum _api_state api_state; + +static void +set_api_state(api_data *api) +{ + const Eina_List *items = elm_box_children_get(api->box); + if(!eina_list_count(items)) + return; + + switch(api->state) + { /* Put all api-changes under switch */ + case BUBBLE_SET_CORNER_1: + elm_bubble_pos_set(eina_list_nth(items, 0), ELM_BUBBLE_POS_BOTTOM_LEFT); + elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)), + "Corner: base (bottom-left) - with icon"); + elm_bubble_pos_set(eina_list_nth(items, 1), ELM_BUBBLE_POS_TOP_RIGHT); + elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)), + "Corner: base (top-right) - no icon"); + break; + + case BUBBLE_SET_CORNER_2: + elm_bubble_pos_set(eina_list_nth(items, 0), ELM_BUBBLE_POS_TOP_RIGHT); + elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)), + "Corner: base (top-right) - with icon"); + elm_bubble_pos_set(eina_list_nth(items, 1), ELM_BUBBLE_POS_BOTTOM_LEFT); + elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)), + "Corner: base (bottom-left) - no icon"); + break; + + case BUBBLE_SET_ICON_CONTENT: + { + char buf[PATH_MAX]; + Evas_Object *ct, *ic = elm_icon_add(api->win); + + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); + elm_icon_file_set(ic, buf, NULL); + elm_icon_resizable_set(ic, 0, 0); + elm_object_content_set(eina_list_nth(items, 0), ic); + ct = elm_label_add(api->win); + elm_object_text_set(ct, "Using icon as top-bubble content"); + elm_object_content_set(eina_list_nth(items, 1), ct); + evas_object_size_hint_align_set(ic, 0.5, 0.5); + evas_object_show(ic); + } + break; + + case API_STATE_LAST: + + break; + default: + return; + } +} + +static void +_api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) +{ /* Will add here a SWITCH command containing code to modify test-object */ + /* in accordance a->state value. */ + api_data *a = data; + char str[128]; + + printf("clicked event on API Button: api_state=<%d>\n", a->state); + set_api_state(a); + a->state++; + sprintf(str, "Next API function (%u)", a->state); + elm_object_text_set(obj, str); + elm_object_disabled_set(obj, a->state == API_STATE_LAST); +} + +static void +_cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + free(data); +} + + void test_bubble(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *bx, *ic, *bb, *ct; + Evas_Object *win, *bg, *bx, *ic, *bb, *ct, *bxx, *bt; char buf[PATH_MAX]; + api_data *api = calloc(1, sizeof(api_data)); win = elm_win_add(NULL, "box-vert", ELM_WIN_BASIC); + api->win = win; elm_win_title_set(win, "Bubble"); elm_win_autodel_set(win, EINA_TRUE); + evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); 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); + bxx = elm_box_add(win); + elm_win_resize_object_add(win, bxx); + evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bxx); + bx = elm_box_add(win); - elm_win_resize_object_add(win, bx); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + api->box = bx; evas_object_show(bx); + bt = elm_button_add(win); + elm_object_text_set(bt, "Next API function"); + evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api); + elm_box_pack_end(bxx, bt); + elm_object_disabled_set(bt, api->state == API_STATE_LAST); + evas_object_show(bt); + + elm_box_pack_end(bxx, bx); + ic = elm_icon_add(win); 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_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1); bb = elm_bubble_add(win); elm_object_text_set(bb, "Message 1"); - elm_object_text_part_set(bb, "info", "Corner: bottom_right"); - elm_bubble_icon_set(bb, ic); - elm_bubble_corner_set(bb, "bottom_right"); + elm_object_part_text_set(bb, "info", "Corner: bottom_right"); + elm_object_part_content_set(bb, "icon", ic); + elm_bubble_pos_set(bb, ELM_BUBBLE_POS_BOTTOM_RIGHT); evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL); evas_object_show(ic); evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); @@ -49,21 +158,21 @@ test_bubble(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info ct = elm_label_add(win); elm_object_text_set(ct, "\"The future of the art: R or G or B?\", by Rusty"); - elm_bubble_content_set(bb, ct); + elm_object_content_set(bb, ct); elm_box_pack_end(bx, bb); evas_object_show(bb); bb = elm_bubble_add(win); elm_object_text_set(bb, "Message 2"); - elm_object_text_part_set(bb, "info", "10:32 4/11/2008"); + elm_object_part_text_set(bb, "info", "10:32 4/11/2008"); evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL); 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); ct = elm_label_add(win); elm_object_text_set(ct, "Corner: base (top-left) - no icon"); - elm_bubble_content_set(bb, ct); + elm_object_content_set(bb, ct); elm_box_pack_end(bx, bb); evas_object_show(bb);