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;
22 external_slider_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
24 const Elm_Params_Slider *p;
26 if (to_params) p = to_params;
27 else if (from_params) p = from_params;
31 elm_object_text_set(obj, p->label);
33 elm_object_part_content_set(obj, "icon", p->icon);
35 elm_slider_span_size_set(obj, p->span);
36 if ((p->min_exists) && (p->max_exists))
37 elm_slider_min_max_set(obj, p->min, p->max);
38 else if ((p->min_exists) || (p->max_exists))
41 elm_slider_min_max_get(obj, &min, &max);
43 elm_slider_min_max_set(obj, p->min, max);
45 elm_slider_min_max_set(obj, min, p->max);
48 elm_slider_value_set(obj, p->value);
49 if (p->inverted_exists)
50 elm_slider_inverted_set(obj, p->inverted);
51 if (p->horizontal_exists)
52 elm_slider_horizontal_set(obj, p->horizontal);
54 elm_slider_indicator_format_set(obj, p->indicator);
56 elm_slider_unit_format_set(obj, p->unit);
60 external_slider_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
62 if (!strcmp(param->name, "label"))
64 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
66 elm_object_text_set(obj, param->s);
70 else if (!strcmp(param->name, "icon"))
72 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
74 Evas_Object *icon = external_common_param_icon_get(obj, param);
75 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
76 elm_object_part_content_set(obj, "icon", icon);
80 else if (!strcmp(param->name, "min"))
82 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
85 elm_slider_min_max_get(obj, &min, &max);
86 elm_slider_min_max_set(obj, param->d, max);
90 else if (!strcmp(param->name, "max"))
92 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
95 elm_slider_min_max_get(obj, &min, &max);
96 elm_slider_min_max_set(obj, min, param->d);
100 else if (!strcmp(param->name, "value"))
102 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
104 elm_slider_value_set(obj, param->d);
108 else if (!strcmp(param->name, "horizontal"))
110 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
112 elm_slider_horizontal_set(obj, param->i);
116 else if (!strcmp(param->name, "inverted"))
118 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
120 elm_slider_inverted_set(obj, param->i);
124 else if (!strcmp(param->name, "span"))
126 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
128 elm_slider_span_size_set(obj, param->i);
132 else if (!strcmp(param->name, "unit format"))
134 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
136 elm_slider_unit_format_set(obj, param->s);
140 else if (!strcmp(param->name, "indicator format"))
142 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
144 elm_slider_indicator_format_set(obj, param->s);
149 ERR("unknown parameter '%s' of type '%s'",
150 param->name, edje_external_param_type_str(param->type));
156 external_slider_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
158 if (!strcmp(param->name, "label"))
160 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
162 param->s = elm_object_text_get(obj);
166 else if (!strcmp(param->name, "icon"))
168 /* not easy to get icon name back from live object */
171 else if (!strcmp(param->name, "min"))
173 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
176 elm_slider_min_max_get(obj, &min, &max);
181 else if (!strcmp(param->name, "max"))
183 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
186 elm_slider_min_max_get(obj, &min, &max);
191 else if (!strcmp(param->name, "value"))
193 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
195 param->d = elm_slider_value_get(obj);
199 else if (!strcmp(param->name, "horizontal"))
201 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
203 param->i = elm_slider_horizontal_get(obj);
207 else if (!strcmp(param->name, "inverted"))
209 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
211 param->i = elm_slider_inverted_get(obj);
215 else if (!strcmp(param->name, "span"))
217 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
219 param->i = elm_slider_span_size_get(obj);
223 else if (!strcmp(param->name, "unit format"))
225 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
227 param->s = elm_slider_unit_format_get(obj);
231 else if (!strcmp(param->name, "indicator format"))
233 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
235 param->s = elm_slider_indicator_format_get(obj);
240 ERR("unknown parameter '%s' of type '%s'",
241 param->name, edje_external_param_type_str(param->type));
247 external_slider_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
249 Elm_Params_Slider *mem;
250 Edje_External_Param *param;
253 mem = calloc(1, sizeof(Elm_Params_Slider));
257 external_common_icon_param_parse(&mem->icon, obj, params);
259 EINA_LIST_FOREACH(params, l, param)
261 if (!strcmp(param->name, "span"))
263 mem->span = param->i;
264 mem->span_exists = EINA_TRUE;
266 else if (!strcmp(param->name, "min"))
269 mem->min_exists = EINA_TRUE;
271 else if (!strcmp(param->name, "max"))
274 mem->max_exists = EINA_TRUE;
276 else if (!strcmp(param->name, "value"))
278 mem->value = param->d;
279 mem->value_exists = EINA_TRUE;
281 else if (!strcmp(param->name, "inverted"))
283 mem->inverted = param->i;
284 mem->inverted_exists = EINA_TRUE;
286 else if (!strcmp(param->name, "horizontal"))
288 mem->horizontal = param->i;
289 mem->horizontal_exists = EINA_TRUE;
291 else if (!strcmp(param->name, "unit format"))
292 mem->unit = eina_stringshare_add(param->s);
293 else if (!strcmp(param->name, "indicator format"))
294 mem->indicator = eina_stringshare_add(param->s);
295 else if (!strcmp(param->name, "label"))
296 mem->label = eina_stringshare_add(param->s);
302 static Evas_Object *external_slider_content_get(void *data __UNUSED__,
303 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
310 external_slider_params_free(void *params)
312 Elm_Params_Slider *mem = params;
315 eina_stringshare_del(mem->unit);
317 eina_stringshare_del(mem->indicator);
319 eina_stringshare_del(mem->label);
323 static Edje_External_Param_Info external_slider_params[] = {
324 DEFINE_EXTERNAL_COMMON_PARAMS,
325 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
326 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
327 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("min"),
328 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT("max", 10.0),
329 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("value"),
330 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"),
331 EDJE_EXTERNAL_PARAM_INFO_BOOL("inverted"),
332 EDJE_EXTERNAL_PARAM_INFO_INT("span"),
333 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("unit format", "%1.2f"),
334 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("indicator format", "%1.2f"),
335 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
338 DEFINE_EXTERNAL_ICON_ADD(slider, "slider")
339 DEFINE_EXTERNAL_TYPE_SIMPLE(slider, "Slider")