1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
8 _change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
10 double val = elm_slider_value_get(obj);
11 elm_slider_value_set(data, val);
15 test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
17 Evas_Object *win, *bg, *bx, *sl, *ic, *sl1, *bx2;
20 win = elm_win_add(NULL, "slider", ELM_WIN_BASIC);
21 elm_win_title_set(win, "Slider");
22 elm_win_autodel_set(win, EINA_TRUE);
25 elm_win_resize_object_add(win, bg);
26 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29 bx = elm_box_add(win);
30 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31 elm_win_resize_object_add(win, bx);
34 ic = elm_icon_add(win);
35 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
36 elm_icon_file_set(ic, buf, NULL);
37 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
39 sl = elm_slider_add(win);
41 elm_object_text_set(sl, "Horizontal");
42 elm_object_part_content_set(sl, "icon", ic);
43 elm_slider_unit_format_set(sl, "%1.1f units");
44 elm_slider_span_size_set(sl, 120);
45 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
46 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
47 elm_box_pack_end(bx, sl);
51 /* horizontal disable state */
52 ic = elm_icon_add(win);
53 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
54 elm_icon_file_set(ic, buf, NULL);
55 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
57 sl = elm_slider_add(win);
58 elm_object_text_set(sl, "Disabled");
59 elm_object_part_content_set(sl, "icon", ic);
60 elm_slider_unit_format_set(sl, "%1.1f units");
61 elm_slider_span_size_set(sl, 120);
62 elm_slider_min_max_set(sl, 50, 150);
63 elm_slider_value_set(sl, 80);
64 elm_object_disabled_set(sl, EINA_TRUE);
65 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
66 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 elm_box_pack_end(bx, sl);
71 ic = elm_icon_add(win);
72 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
73 elm_icon_file_set(ic, buf, NULL);
74 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
76 sl = elm_slider_add(win);
77 elm_object_text_set(sl, "Horizontal inverted");
78 elm_object_part_content_set(sl, "end", ic);
79 elm_slider_span_size_set(sl, 80);
80 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
81 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82 elm_slider_indicator_format_set(sl, "%3.0f");
83 elm_slider_min_max_set(sl, 50, 150);
84 elm_slider_value_set(sl, 80);
85 elm_slider_inverted_set(sl, EINA_TRUE);
86 evas_object_size_hint_align_set(sl, 0.5, 0.5);
87 evas_object_size_hint_weight_set(sl, 0.0, 0.0);
88 elm_box_pack_end(bx, sl);
93 ic = elm_icon_add(win);
94 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
95 elm_icon_file_set(ic, buf, NULL);
96 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
98 sl = elm_slider_add(win);
99 elm_object_text_set(sl, "Disabled inverted");
100 elm_object_part_content_set(sl, "end", ic);
101 elm_slider_span_size_set(sl, 80);
102 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
103 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
104 elm_slider_indicator_format_set(sl, "%3.0f");
105 elm_slider_min_max_set(sl, 50, 150);
106 elm_slider_value_set(sl, 80);
107 elm_slider_inverted_set(sl, EINA_TRUE);
108 elm_object_disabled_set(sl, EINA_TRUE);
109 evas_object_size_hint_align_set(sl, 0.5, 0.5);
110 evas_object_size_hint_weight_set(sl, 0.0, 0.0);
111 elm_box_pack_end(bx, sl);
112 evas_object_show(ic);
113 evas_object_show(sl);
115 sl = elm_slider_add(win);
116 elm_slider_indicator_show_set(sl, EINA_FALSE);
117 elm_object_text_set(sl, "Scale doubled");
118 elm_slider_unit_format_set(sl, "%3.0f units");
119 elm_slider_span_size_set(sl, 40);
120 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
121 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
122 elm_slider_indicator_format_set(sl, "%3.0f");
123 elm_slider_min_max_set(sl, 50, 150);
124 elm_slider_value_set(sl, 80);
125 elm_slider_inverted_set(sl, EINA_TRUE);
126 elm_object_scale_set(sl, 2.0);
127 elm_box_pack_end(bx, sl);
128 evas_object_show(ic);
129 evas_object_show(sl);
131 bx2 = elm_box_add(win);
132 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
133 elm_box_horizontal_set(bx2, EINA_TRUE);
134 elm_box_pack_end(bx, bx2);
135 evas_object_show(bx2);
137 ic = elm_icon_add(win);
138 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
139 elm_icon_file_set(ic, buf, NULL);
140 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
142 sl = elm_slider_add(win);
143 elm_object_part_content_set(sl, "icon", ic);
144 elm_object_text_set(sl, "Vertical inverted");
145 elm_slider_inverted_set(sl, EINA_TRUE);
146 elm_slider_unit_format_set(sl, "units");
147 elm_slider_span_size_set(sl, 60);
148 evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
149 evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
150 elm_slider_indicator_format_set(sl, "%1.1f");
151 elm_slider_value_set(sl, 0.2);
152 elm_object_scale_set(sl, 1.0);
153 elm_slider_horizontal_set(sl, 0);
154 elm_box_pack_end(bx2, sl);
155 evas_object_show(ic);
156 evas_object_show(sl);
158 evas_object_smart_callback_add(sl1, "changed", _change_cb, sl);
160 sl = elm_slider_add(win);
161 elm_object_text_set(sl, "Vertical");
162 elm_slider_unit_format_set(sl, "units");
163 elm_slider_span_size_set(sl, 60);
164 evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
165 evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
166 elm_slider_indicator_format_set(sl, "%1.1f");
167 elm_slider_value_set(sl, 0.2);
168 elm_object_scale_set(sl, 1.0);
169 elm_slider_horizontal_set(sl, EINA_FALSE);
170 elm_box_pack_end(bx2, sl);
171 evas_object_show(ic);
172 evas_object_show(sl);
174 /* vertical disable state */
175 ic = elm_icon_add(win);
176 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
177 elm_icon_file_set(ic, buf, NULL);
178 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
180 sl = elm_slider_add(win);
181 elm_object_part_content_set(sl, "icon", ic);
182 elm_object_text_set(sl, "Disabled vertical");
183 elm_slider_inverted_set(sl, EINA_TRUE);
184 elm_slider_unit_format_set(sl, "units");
185 elm_slider_span_size_set(sl, 100);
186 evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
187 evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
188 elm_slider_indicator_format_set(sl, "%1.1f");
189 elm_slider_value_set(sl, 0.2);
190 elm_object_scale_set(sl, 1.0);
191 elm_slider_horizontal_set(sl, 0);
192 elm_object_disabled_set(sl, EINA_TRUE);
193 elm_box_pack_end(bx2, sl);
194 evas_object_show(ic);
195 evas_object_show(sl);
197 evas_object_show(win);