From: Carsten Haitzler Date: Fri, 8 Feb 2013 09:46:47 +0000 (+0000) Subject: add test case to slider X-Git-Tag: submit/efl/20131021.015827~1013 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d72abefe28787ecc2de3aa3af894640abb09f7e;p=platform%2Fupstream%2Felementary.git add test case to slider SVN revision: 83775 --- diff --git a/src/bin/test_slider.c b/src/bin/test_slider.c index 5e62efb..66a151c 100644 --- a/src/bin/test_slider.c +++ b/src/bin/test_slider.c @@ -12,9 +12,40 @@ _change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) } void +_change_print_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + double val = elm_slider_value_get(obj); + printf("change to %3.3f\n", val); +} + +void +_bt_0(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_slider_value_set(data, 0.0); +} + +void +_bt_1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_slider_value_set(data, 1.0); +} + +void +_bt_p1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_slider_value_set(data, elm_slider_value_get(data) + 0.1); +} + +void +_bt_m1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_slider_value_set(data, elm_slider_value_get(data) - 0.1); +} + +void test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bx, *sl, *ic, *sl1, *bx2; + Evas_Object *win, *bx, *sl, *ic, *sl1, *bx2, *bt; char buf[PATH_MAX]; win = elm_win_util_standard_add("slider", "Slider"); @@ -37,7 +68,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info elm_slider_unit_format_set(sl, "%1.1f units"); elm_slider_span_size_set(sl, 120); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0); elm_box_pack_end(bx, sl); evas_object_show(ic); evas_object_show(sl); @@ -57,7 +88,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info elm_slider_value_set(sl, 80); elm_object_disabled_set(sl, EINA_TRUE); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0); elm_box_pack_end(bx, sl); evas_object_show(ic); evas_object_show(sl); @@ -72,7 +103,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info elm_object_part_content_set(sl, "end", ic); elm_slider_span_size_set(sl, 80); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0); elm_slider_indicator_format_set(sl, "%3.0f"); elm_slider_min_max_set(sl, 50, 150); elm_slider_value_set(sl, 80); @@ -94,7 +125,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info elm_object_part_content_set(sl, "end", ic); elm_slider_span_size_set(sl, 80); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0); elm_slider_indicator_format_set(sl, "%3.0f"); elm_slider_min_max_set(sl, 50, 150); elm_slider_value_set(sl, 80); @@ -112,7 +143,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info elm_slider_unit_format_set(sl, "%3.0f units"); elm_slider_span_size_set(sl, 40); evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 00); elm_slider_indicator_format_set(sl, "%3.0f"); elm_slider_min_max_set(sl, 50, 150); elm_slider_value_set(sl, 80); @@ -124,6 +155,7 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info bx2 = elm_box_add(win); evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx2, 0.5, EVAS_HINT_FILL); elm_box_horizontal_set(bx2, EINA_TRUE); elm_box_pack_end(bx, bx2); evas_object_show(bx2); @@ -152,15 +184,18 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_smart_callback_add(sl1, "changed", _change_cb, sl); sl = elm_slider_add(win); - elm_object_text_set(sl, "Vertical"); + elm_object_part_content_set(sl, "icon", ic); + elm_object_text_set(sl, "Disabled vertical"); + elm_slider_inverted_set(sl, EINA_TRUE); elm_slider_unit_format_set(sl, "%1.1f units"); - elm_slider_span_size_set(sl, 60); + elm_slider_span_size_set(sl, 100); evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL); evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND); elm_slider_indicator_format_set(sl, "%1.1f"); elm_slider_value_set(sl, 0.2); elm_object_scale_set(sl, 1.0); - elm_slider_horizontal_set(sl, EINA_FALSE); + elm_slider_horizontal_set(sl, 0); + elm_object_disabled_set(sl, EINA_TRUE); elm_box_pack_end(bx2, sl); evas_object_show(ic); evas_object_show(sl); @@ -172,22 +207,50 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1); sl = elm_slider_add(win); - elm_object_part_content_set(sl, "icon", ic); - elm_object_text_set(sl, "Disabled vertical"); - elm_slider_inverted_set(sl, EINA_TRUE); + elm_object_text_set(sl, "Vertical"); elm_slider_unit_format_set(sl, "%1.1f units"); - elm_slider_span_size_set(sl, 100); + elm_slider_span_size_set(sl, 60); evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL); evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND); elm_slider_indicator_format_set(sl, "%1.1f"); elm_slider_value_set(sl, 0.2); elm_object_scale_set(sl, 1.0); - elm_slider_horizontal_set(sl, 0); - elm_object_disabled_set(sl, EINA_TRUE); + elm_slider_horizontal_set(sl, EINA_FALSE); + evas_object_smart_callback_add(sl, "changed", _change_print_cb, sl); elm_box_pack_end(bx2, sl); evas_object_show(ic); evas_object_show(sl); + bx2 = elm_box_add(win); + evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0); + elm_box_horizontal_set(bx2, EINA_TRUE); + elm_box_pack_end(bx, bx2); + evas_object_show(bx2); + + bt = elm_button_add(win); + elm_object_text_set(bt, "0"); + evas_object_smart_callback_add(bt, "clicked", _bt_0, sl); + evas_object_show(bt); + elm_box_pack_end(bx2, bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "1"); + evas_object_smart_callback_add(bt, "clicked", _bt_1, sl); + evas_object_show(bt); + elm_box_pack_end(bx2, bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "+.1"); + evas_object_smart_callback_add(bt, "clicked", _bt_p1, sl); + evas_object_show(bt); + elm_box_pack_end(bx2, bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "-.1"); + evas_object_smart_callback_add(bt, "clicked", _bt_m1, sl); + evas_object_show(bt); + elm_box_pack_end(bx2, bt); + evas_object_show(win); } #endif