3 typedef struct _Elm_Params_Slider
8 const char *indicator, *unit;
9 double min, max, value;
10 Eina_Bool min_exists:1;
11 Eina_Bool max_exists:1;
12 Eina_Bool value_exists:1;
14 Eina_Bool inverted_exists:1;
16 Eina_Bool span_exists:1;
17 Eina_Bool horizontal:1;
18 Eina_Bool horizontal_exists:1;
19 Evas_Object *end_icon;
20 Eina_Bool indicator_show:1;
21 Eina_Bool indicator_show_exists:1;
25 external_slider_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
27 const Elm_Params_Slider *p;
29 if (to_params) p = to_params;
30 else if (from_params) p = from_params;
34 elm_object_text_set(obj, p->label);
36 elm_object_part_content_set(obj, "icon", p->icon);
38 elm_slider_span_size_set(obj, p->span);
39 if ((p->min_exists) && (p->max_exists))
40 elm_slider_min_max_set(obj, p->min, p->max);
41 else if ((p->min_exists) || (p->max_exists))
44 elm_slider_min_max_get(obj, &min, &max);
46 elm_slider_min_max_set(obj, p->min, max);
48 elm_slider_min_max_set(obj, min, p->max);
51 elm_slider_value_set(obj, p->value);
52 if (p->inverted_exists)
53 elm_slider_inverted_set(obj, p->inverted);
54 if (p->horizontal_exists)
55 elm_slider_horizontal_set(obj, p->horizontal);
57 elm_slider_indicator_format_set(obj, p->indicator);
59 elm_slider_unit_format_set(obj, p->unit);
61 elm_slider_icon_set(obj, p->end_icon);
62 if (p->indicator_show_exists)
63 elm_slider_horizontal_set(obj, p->indicator_show);
67 external_slider_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
69 if (!strcmp(param->name, "label"))
71 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
73 elm_object_text_set(obj, param->s);
77 else if (!strcmp(param->name, "icon"))
79 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
81 Evas_Object *icon = external_common_param_icon_get(obj, param);
82 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
83 elm_object_part_content_set(obj, "icon", icon);
87 else if (!strcmp(param->name, "min"))
89 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
92 elm_slider_min_max_get(obj, &min, &max);
93 elm_slider_min_max_set(obj, param->d, max);
97 else if (!strcmp(param->name, "max"))
99 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
102 elm_slider_min_max_get(obj, &min, &max);
103 elm_slider_min_max_set(obj, min, param->d);
107 else if (!strcmp(param->name, "value"))
109 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
111 elm_slider_value_set(obj, param->d);
115 else if (!strcmp(param->name, "horizontal"))
117 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
119 elm_slider_horizontal_set(obj, param->i);
123 else if (!strcmp(param->name, "inverted"))
125 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
127 elm_slider_inverted_set(obj, param->i);
131 else if (!strcmp(param->name, "span"))
133 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
135 elm_slider_span_size_set(obj, param->i);
139 else if (!strcmp(param->name, "unit format"))
141 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
143 elm_slider_unit_format_set(obj, param->s);
147 else if (!strcmp(param->name, "indicator format"))
149 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
151 elm_slider_indicator_format_set(obj, param->s);
155 else if (!strcmp(param->name, "end icon"))
157 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
159 Evas_Object *end_icon = external_common_param_icon_get(obj, param);
160 if ((strcmp(param->s, "")) && (!end_icon)) return EINA_FALSE;
161 elm_slider_icon_set(obj, end_icon);
165 else if (!strcmp(param->name, "indicator show"))
167 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
169 elm_slider_indicator_show_set(obj, param->i);
174 ERR("unknown parameter '%s' of type '%s'",
175 param->name, edje_external_param_type_str(param->type));
181 external_slider_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
183 if (!strcmp(param->name, "label"))
185 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
187 param->s = elm_object_text_get(obj);
191 else if (!strcmp(param->name, "icon"))
193 /* not easy to get icon name back from live object */
196 else if (!strcmp(param->name, "min"))
198 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
201 elm_slider_min_max_get(obj, &min, &max);
206 else if (!strcmp(param->name, "max"))
208 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
211 elm_slider_min_max_get(obj, &min, &max);
216 else if (!strcmp(param->name, "value"))
218 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
220 param->d = elm_slider_value_get(obj);
224 else if (!strcmp(param->name, "horizontal"))
226 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
228 param->i = elm_slider_horizontal_get(obj);
232 else if (!strcmp(param->name, "inverted"))
234 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
236 param->i = elm_slider_inverted_get(obj);
240 else if (!strcmp(param->name, "span"))
242 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
244 param->i = elm_slider_span_size_get(obj);
248 else if (!strcmp(param->name, "unit format"))
250 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
252 param->s = elm_slider_unit_format_get(obj);
256 else if (!strcmp(param->name, "indicator format"))
258 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
260 param->s = elm_slider_indicator_format_get(obj);
264 else if (!strcmp(param->name, "end icon"))
266 /* not easy to get icon name back from live object */
269 else if (!strcmp(param->name, "indicator show"))
271 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
277 ERR("unknown parameter '%s' of type '%s'",
278 param->name, edje_external_param_type_str(param->type));
284 external_slider_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
286 Elm_Params_Slider *mem;
287 Edje_External_Param *param;
290 mem = calloc(1, sizeof(Elm_Params_Slider));
294 external_common_icon_param_parse(&mem->icon, obj, params);
295 external_common_icon_param_parse(&mem->end_icon, obj, params);
297 EINA_LIST_FOREACH(params, l, param)
299 if (!strcmp(param->name, "span"))
301 mem->span = param->i;
302 mem->span_exists = EINA_TRUE;
304 else if (!strcmp(param->name, "min"))
307 mem->min_exists = EINA_TRUE;
309 else if (!strcmp(param->name, "max"))
312 mem->max_exists = EINA_TRUE;
314 else if (!strcmp(param->name, "value"))
316 mem->value = param->d;
317 mem->value_exists = EINA_TRUE;
319 else if (!strcmp(param->name, "inverted"))
321 mem->inverted = param->i;
322 mem->inverted_exists = EINA_TRUE;
324 else if (!strcmp(param->name, "horizontal"))
326 mem->horizontal = param->i;
327 mem->horizontal_exists = EINA_TRUE;
329 else if (!strcmp(param->name, "unit format"))
330 mem->unit = eina_stringshare_add(param->s);
331 else if (!strcmp(param->name, "indicator format"))
332 mem->indicator = eina_stringshare_add(param->s);
333 else if (!strcmp(param->name, "indicator show"))
335 mem->indicator_show = param->i;
336 mem->indicator_show_exists = EINA_TRUE;
338 else if (!strcmp(param->name, "label"))
339 mem->label = eina_stringshare_add(param->s);
345 static Evas_Object *external_slider_content_get(void *data __UNUSED__,
346 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
353 external_slider_params_free(void *params)
355 Elm_Params_Slider *mem = params;
358 eina_stringshare_del(mem->unit);
360 eina_stringshare_del(mem->indicator);
362 eina_stringshare_del(mem->label);
366 static Edje_External_Param_Info external_slider_params[] = {
367 DEFINE_EXTERNAL_COMMON_PARAMS,
368 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
369 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
370 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("min"),
371 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT("max", 10.0),
372 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("value"),
373 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"),
374 EDJE_EXTERNAL_PARAM_INFO_BOOL("inverted"),
375 EDJE_EXTERNAL_PARAM_INFO_INT("span"),
376 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("unit format", "%1.2f"),
377 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("indicator format", "%1.2f"),
378 EDJE_EXTERNAL_PARAM_INFO_STRING("end icon"),
379 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
382 DEFINE_EXTERNAL_ICON_ADD(slider, "slider")
383 DEFINE_EXTERNAL_TYPE_SIMPLE(slider, "Slider")