add test4 for table
[framework/uifw/elementary.git] / src / bin / test_actionslider.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 static void _pos_selected_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info)
8 {
9    printf("Selection: %s\n", (char *)event_info);
10    printf("Label selected: %s\n", elm_actionslider_selected_label_get(obj));
11 }
12
13 static void
14 _position_change_magnetic_cb(void *data __UNUSED__, Evas_Object * obj, void *event_info)
15 {
16    if (!strcmp((char *)event_info, "left"))
17      elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_LEFT);
18    else if (!strcmp((char *)event_info, "right"))
19      elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_RIGHT);
20 }
21
22 static void
23 _magnet_enable_disable_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info)
24 {
25    if (!strcmp((char *)event_info, "left"))
26       elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_CENTER);
27    else if (!strcmp((char *)event_info, "right"))
28       elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_NONE);
29 }
30
31 void
32 test_actionslider(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info __UNUSED__)
33 {
34    Evas_Object *win, *bg, *bx, *as;
35
36    win = elm_win_add(NULL, "actionslider", ELM_WIN_BASIC);
37    elm_win_title_set(win, "Actionslider");
38    elm_win_autodel_set(win, 1);
39
40    bg = elm_bg_add(win);
41    elm_win_resize_object_add(win, bg);
42    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, 0);
43    evas_object_show(bg);
44
45    bx = elm_box_add(win);
46    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
47    elm_win_resize_object_add(win, bx);
48    evas_object_show(bx);
49
50    as = elm_actionslider_add(win);
51    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
52    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
53    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
54    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
55    elm_actionslider_labels_set(as, "Snooze", NULL, "Stop");
56    elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
57                                     ELM_ACTIONSLIDER_RIGHT);
58    evas_object_smart_callback_add(as, "pos_changed",
59                                   _position_change_magnetic_cb, NULL);
60    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
61    evas_object_show(as);
62    elm_box_pack_end(bx, as);
63
64    as = elm_actionslider_add(win);
65    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
66    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
67    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
68    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
69    elm_actionslider_labels_set(as, "Snooze", NULL, "Stop");
70    elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
71                                     ELM_ACTIONSLIDER_RIGHT);
72    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
73    evas_object_show(as);
74    elm_box_pack_end(bx, as);
75
76    as = elm_actionslider_add(win);
77    elm_object_style_set(as, "bar");
78    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
79    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
80    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
81    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER|
82                                    ELM_ACTIONSLIDER_RIGHT);
83    elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_CENTER |
84                                     ELM_ACTIONSLIDER_RIGHT);
85    elm_actionslider_labels_set(as, NULL, "Accept", "Reject");
86    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
87    evas_object_show(as);
88    elm_box_pack_end(bx, as);
89
90    as = elm_actionslider_add(win);
91    elm_object_style_set(as, "bar");
92    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
93    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
94    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
95    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_LEFT);
96    elm_actionslider_labels_set(as, NULL, "Accept", "Reject");
97    elm_actionslider_indicator_label_set(as, "Go");
98    evas_object_smart_callback_add(as, "pos_changed",
99                                   _position_change_magnetic_cb, NULL);
100    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
101    evas_object_show(as);
102    elm_box_pack_end(bx, as);
103
104
105    as = elm_actionslider_add(win);
106    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
107    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
108    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
109    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_ALL);
110    elm_actionslider_labels_set(as, "Left", "Center", "Right");
111    elm_actionslider_indicator_label_set(as, "Go");
112    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
113    evas_object_show(as);
114    elm_box_pack_end(bx, as);
115
116    as = elm_actionslider_add(win);
117    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
118    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
119    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
120    elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
121    elm_actionslider_labels_set(as, "Enable", "Magnet", "Disable");
122    evas_object_smart_callback_add(as, "pos_changed",
123                                   _magnet_enable_disable_cb, NULL);
124    evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
125    evas_object_show(as);
126    elm_box_pack_end(bx, as);
127
128    evas_object_resize(win, 320, 400);
129    evas_object_show(win);
130 }
131 #endif