diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/elementary/src/examples/actionslider_example_01.c | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/actionslider_example_01.c b/libraries/elementary/src/examples/actionslider_example_01.c new file mode 100644 index 0000000..3e31347 --- /dev/null +++ b/libraries/elementary/src/examples/actionslider_example_01.c | |||
@@ -0,0 +1,148 @@ | |||
1 | //Compile with: | ||
2 | //gcc -g actionslider_example_01.c -o actionslider_example_01 `pkg-config --cflags --libs elementary` | ||
3 | |||
4 | #include <Elementary.h> | ||
5 | |||
6 | static void _pos_selected_cb(void *data, Evas_Object *obj, void *event_info) | ||
7 | { | ||
8 | printf("Selection: %s\n", (char *)event_info); | ||
9 | printf("Label selected: %s\n", elm_actionslider_selected_label_get(obj)); | ||
10 | } | ||
11 | |||
12 | static void | ||
13 | _position_change_magnetic_cb(void *data, Evas_Object * obj, void *event_info) | ||
14 | { | ||
15 | if (!strcmp((char *)event_info, "left")) | ||
16 | elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_LEFT); | ||
17 | else if (!strcmp((char *)event_info, "right")) | ||
18 | elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_RIGHT); | ||
19 | } | ||
20 | |||
21 | static void | ||
22 | _magnet_enable_disable_cb(void *data, Evas_Object *obj, void *event_info) | ||
23 | { | ||
24 | if (!strcmp((char *)event_info, "left")) | ||
25 | elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_CENTER); | ||
26 | else if (!strcmp((char *)event_info, "right")) | ||
27 | elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_NONE); | ||
28 | } | ||
29 | |||
30 | static void | ||
31 | on_done(void *data, Evas_Object *obj, void *event_info) | ||
32 | { | ||
33 | elm_exit(); | ||
34 | } | ||
35 | |||
36 | EAPI_MAIN int | ||
37 | elm_main(int argc, char **argv) | ||
38 | { | ||
39 | Evas_Object *win, *bg, *bx, *as; | ||
40 | |||
41 | win = elm_win_add(NULL, "actionslider", ELM_WIN_BASIC); | ||
42 | elm_win_title_set(win, "Actionslider"); | ||
43 | evas_object_smart_callback_add(win, "delete,request", on_done, NULL); | ||
44 | |||
45 | bg = elm_bg_add(win); | ||
46 | elm_win_resize_object_add(win, bg); | ||
47 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, 0); | ||
48 | evas_object_show(bg); | ||
49 | |||
50 | bx = elm_box_add(win); | ||
51 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0); | ||
52 | elm_win_resize_object_add(win, bx); | ||
53 | evas_object_show(bx); | ||
54 | |||
55 | as = elm_actionslider_add(win); | ||
56 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
57 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
58 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT); | ||
59 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT); | ||
60 | elm_object_part_text_set(as, "left", "Snooze"); | ||
61 | elm_object_part_text_set(as, "right", "Stop"); | ||
62 | elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT | | ||
63 | ELM_ACTIONSLIDER_RIGHT); | ||
64 | evas_object_smart_callback_add(as, "pos_changed", | ||
65 | _position_change_magnetic_cb, NULL); | ||
66 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
67 | evas_object_show(as); | ||
68 | elm_box_pack_end(bx, as); | ||
69 | |||
70 | as = elm_actionslider_add(win); | ||
71 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
72 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
73 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER); | ||
74 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER); | ||
75 | elm_object_part_text_set(as, "left", "Snooze"); | ||
76 | elm_object_part_text_set(as, "right", "Stop"); | ||
77 | elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT | | ||
78 | ELM_ACTIONSLIDER_RIGHT); | ||
79 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
80 | evas_object_show(as); | ||
81 | elm_box_pack_end(bx, as); | ||
82 | |||
83 | as = elm_actionslider_add(win); | ||
84 | elm_object_style_set(as, "bar"); | ||
85 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
86 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
87 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT); | ||
88 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER| | ||
89 | ELM_ACTIONSLIDER_RIGHT); | ||
90 | elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_CENTER | | ||
91 | ELM_ACTIONSLIDER_RIGHT); | ||
92 | elm_object_part_text_set(as, "center", "Accept"); | ||
93 | elm_object_part_text_set(as, "right", "Reject"); | ||
94 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
95 | evas_object_show(as); | ||
96 | elm_box_pack_end(bx, as); | ||
97 | |||
98 | as = elm_actionslider_add(win); | ||
99 | elm_object_style_set(as, "bar"); | ||
100 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
101 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
102 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT); | ||
103 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_LEFT); | ||
104 | elm_object_part_text_set(as, "center", "Accept"); | ||
105 | elm_object_part_text_set(as, "right", "Reject"); | ||
106 | elm_object_text_set(as, "Go"); | ||
107 | evas_object_smart_callback_add(as, "pos_changed", | ||
108 | _position_change_magnetic_cb, NULL); | ||
109 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
110 | evas_object_show(as); | ||
111 | elm_box_pack_end(bx, as); | ||
112 | |||
113 | |||
114 | as = elm_actionslider_add(win); | ||
115 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
116 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
117 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT); | ||
118 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_ALL); | ||
119 | elm_object_part_text_set(as, "left", "Left"); | ||
120 | elm_object_part_text_set(as, "center", "Center"); | ||
121 | elm_object_part_text_set(as, "right", "Right"); | ||
122 | elm_object_text_set(as, "Go"); | ||
123 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
124 | evas_object_show(as); | ||
125 | elm_box_pack_end(bx, as); | ||
126 | |||
127 | as = elm_actionslider_add(win); | ||
128 | evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0); | ||
129 | evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0); | ||
130 | elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER); | ||
131 | elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER); | ||
132 | elm_object_part_text_set(as, "left", "Enable"); | ||
133 | elm_object_part_text_set(as, "center", "Magnet"); | ||
134 | elm_object_part_text_set(as, "right", "Disable"); | ||
135 | evas_object_smart_callback_add(as, "pos_changed", | ||
136 | _magnet_enable_disable_cb, NULL); | ||
137 | evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL); | ||
138 | evas_object_show(as); | ||
139 | elm_box_pack_end(bx, as); | ||
140 | |||
141 | evas_object_resize(win, 320, 400); | ||
142 | evas_object_show(win); | ||
143 | |||
144 | elm_run(); | ||
145 | elm_shutdown(); | ||
146 | return 0; | ||
147 | } | ||
148 | ELM_MAIN() | ||