2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
6 * Copyright (c) 2009 Samsung Electronics, Inc.
9 * This software is a confidential and proprietary information
10 * of Samsung Electronics, Inc. ("Confidential Information"). You
11 * shall not disclose such Confidential Information and shall use
12 * it only in accordance with the terms of the license agreement
13 * you entered into with Samsung Electronics.
18 * @defgroup Actionslider Actionslider
21 * A magnet slider is a switcher for 3 labels with customizable
22 * magnet properties. When the position is set with magnet, the knob
23 * will be moved to it if it's nearest the magnetized position.
25 * Signals that you can add callbacks for are:
27 * "selected" - when user selects a position (the label is passed as
29 * "pos_changed" - when a button reaches to the special position like
30 * "left", "right" and "center".
33 #include <Elementary.h>
38 * internal data structure of actionslider object
40 typedef struct _Widget_Data Widget_Data;
44 Evas_Object *as; // actionslider
45 Evas_Object *icon; // an icon for a button or a bar
46 Evas_Object *icon_fake; // an icon for a button or a bar
49 Elm_Actionslider_Magnet_Pos magnet_position, enabled_position;
50 const char *text_left, *text_right, *text_center, *text_button;
57 Ecore_Animator *icon_animator;
58 double final_position;
61 static void _del_hook(Evas_Object *obj);
62 static void _theme_hook(Evas_Object *obj);
63 static void _disable_hook(Evas_Object *obj);
64 static void _sizing_eval(Evas_Object *obj);
65 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
70 static void _icon_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
71 static void _icon_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
72 static void _icon_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
77 static Eina_Bool _icon_animation(void *data);
79 static const char *widtype = NULL;
81 static const char SIG_CHANGED[] = "pos_changed";
82 static const char SIG_SELECTED[] = "selected";
84 static const Evas_Smart_Cb_Description _signals[] =
93 _del_hook(Evas_Object *obj)
95 Widget_Data *wd = elm_widget_data_get(obj);
99 evas_object_del(wd->icon);
104 evas_object_del(wd->icon_fake);
105 wd->icon_fake = NULL;
107 if (wd->text_left) eina_stringshare_del(wd->text_left);
108 if (wd->text_right) eina_stringshare_del(wd->text_right);
109 if (wd->text_center) eina_stringshare_del(wd->text_center);
110 if (wd->text_button) eina_stringshare_del(wd->text_button);
113 evas_object_smart_member_del(wd->as);
114 evas_object_del(wd->as);
120 static Elm_Actionslider_Indicator_Pos
121 _get_pos_by_orientation(const Evas_Object *obj, Elm_Actionslider_Indicator_Pos pos)
123 if (elm_widget_mirrored_get(obj))
127 case ELM_ACTIONSLIDER_INDICATOR_LEFT:
128 pos = ELM_ACTIONSLIDER_INDICATOR_RIGHT;
130 case ELM_ACTIONSLIDER_INDICATOR_RIGHT:
131 pos = ELM_ACTIONSLIDER_INDICATOR_LEFT;
141 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
143 Widget_Data *wd = elm_widget_data_get(obj);
147 if (edje_object_mirrored_get(wd->as) == rtl)
150 edje_object_mirrored_set(wd->as, rtl);
151 if (!elm_widget_mirrored_get(obj))
153 edje_object_part_text_set(wd->as, "elm.text.left", wd->text_left);
154 edje_object_part_text_set(wd->as, "elm.text.right", wd->text_right);
158 edje_object_part_text_set(wd->as, "elm.text.left", wd->text_right);
159 edje_object_part_text_set(wd->as, "elm.text.right", wd->text_left);
161 edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &pos, NULL);
162 edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", 1.0 - pos, 0.5);
166 _sizing_eval(Evas_Object *obj)
168 Widget_Data *wd = elm_widget_data_get(obj);
169 Evas_Coord minw = -1, minh = -1;
172 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
173 evas_object_size_hint_min_set(wd->icon, minw, minh);
174 evas_object_size_hint_max_set(wd->icon, -1, -1);
178 elm_coords_finger_size_adjust(3, &minw, 1, &minh);
179 edje_object_size_min_restricted_calc(wd->as, &minw, &minh, minw, minh);
180 evas_object_size_hint_min_set(obj, minw, minh);
181 evas_object_size_hint_max_set(obj, -1, -1);
185 _theme_hook(Evas_Object *obj)
187 Widget_Data *wd = elm_widget_data_get(obj);
189 _elm_widget_mirrored_reload(obj);
190 if (edje_object_part_swallow_get(wd->as, "elm.swallow.icon") == NULL)
191 edje_object_part_unswallow(wd->as, wd->icon);
192 if (edje_object_part_swallow_get(wd->as, "elm.swallow.space") == NULL)
193 edje_object_part_unswallow(wd->as, wd->icon_fake);
195 _elm_theme_object_set(obj, wd->as, "actionslider", "base", elm_widget_style_get(obj));
196 _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", elm_widget_style_get(obj));
197 _elm_theme_object_set(obj, wd->icon_fake, "actionslider", "icon", elm_widget_style_get(obj));
198 edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
199 edje_object_part_swallow(wd->as, "elm.swallow.space", wd->icon_fake);
201 _mirrored_set(obj, elm_widget_mirrored_get(obj));
202 edje_object_part_text_set(wd->as, "elm.text.center", wd->text_center);
203 edje_object_part_text_set(wd->icon, "elm.text.button", wd->text_button);
204 edje_object_message_signal_process(wd->as);
205 //edje_object_scale_set(wd->as, elm_widget_scale_get(obj) * _elm_config->scale);
210 _disable_hook(Evas_Object *obj)
212 Widget_Data *wd = elm_widget_data_get(obj);
214 if (elm_widget_disabled_get(obj))
215 edje_object_signal_emit(wd->icon, "elm,state,disabled", "elm");
217 edje_object_signal_emit(wd->icon, "elm,state,enabled", "elm");
222 _icon_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
224 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
226 wd->mouse_down = EINA_TRUE;
230 _icon_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
232 Evas_Object *as = (Evas_Object *)data;
233 Widget_Data *wd = elm_widget_data_get(as);
236 elm_actionslider_hold(as, EINA_FALSE);
237 if (wd->mouse_down == EINA_FALSE) return;
239 edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &pos, NULL);
242 evas_object_smart_callback_call(as, SIG_CHANGED, (void *) ((!elm_widget_mirrored_get(as)) ? "left" : "right"));
244 evas_object_smart_callback_call(as, SIG_CHANGED, (void *) ((!elm_widget_mirrored_get(as)) ? "right" : "left"));
245 else if (pos >= 0.495 && pos <= 0.505)
246 evas_object_smart_callback_call(as, SIG_CHANGED, (void *)"center");
250 if (wd->type == ELM_ACTIONSLIDER_TYPE_BAR_GREEN ||
251 wd->type == ELM_ACTIONSLIDER_TYPE_BAR_RED ) {
253 //edje_object_signal_emit(wd->as, "elm,show,bar,text,center", "elm");
254 edje_object_signal_emit(wd->as, "elm,show,text,center", "elm");
256 //edje_object_signal_emit(wd->as, "elm,hide,bar,text,center", "elm");
257 edje_object_signal_emit(wd->as, "elm,hide,text,center", "elm");
264 _icon_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
266 Evas_Object *as = (Evas_Object *)data;
267 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
268 double position = 0.0;
270 wd->mouse_down = EINA_FALSE;
272 if (wd->mouse_hold == EINA_FALSE)
274 edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &position, NULL);
276 if ((wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_LEFT) && ((!elm_widget_mirrored_get(as) && position == 0.0) ||(elm_widget_mirrored_get(obj) && position == 1.0)))
278 wd->final_position = 0.0;
279 evas_object_smart_callback_call(data, SIG_SELECTED,(void *) wd->text_left);
281 else if (position >= 0.495 && position <= 0.505 && (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_CENTER))
283 wd->final_position = 0.5;
284 evas_object_smart_callback_call(data, SIG_SELECTED,(void *)wd->text_center);
286 else if ((wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_RIGHT) && ((!elm_widget_mirrored_get(as) && position == 1.0) ||(elm_widget_mirrored_get(obj) && position == 0.0)))
288 wd->final_position = 1.0;
289 evas_object_smart_callback_call(data, SIG_SELECTED, (void *) wd->text_right);
291 if (wd->magnet_position == ELM_ACTIONSLIDER_MAGNET_NONE) return;
293 #define _FINAL_POS_BY_ORIENTATION(x) (x)
294 #define _POS_BY_ORIENTATION(x) ((!elm_widget_mirrored_get(as)) ? x : 1.0 - x)
296 position = _POS_BY_ORIENTATION(position);
300 if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_LEFT)
301 wd->final_position = _FINAL_POS_BY_ORIENTATION(0);
302 else if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_CENTER)
303 wd->final_position = 0.5;
304 else if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_RIGHT)
305 wd->final_position = _FINAL_POS_BY_ORIENTATION(1);
307 else if ((position >= 0.3) && (position <= 0.7))
309 if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_CENTER)
310 wd->final_position = 0.5;
311 else if (position < 0.5)
313 if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_LEFT)
314 wd->final_position = _FINAL_POS_BY_ORIENTATION(0);
316 wd->final_position = _FINAL_POS_BY_ORIENTATION(1);
320 if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_RIGHT)
321 wd->final_position = _FINAL_POS_BY_ORIENTATION(1);
323 wd->final_position = _FINAL_POS_BY_ORIENTATION(0);
328 if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_RIGHT)
329 wd->final_position = _FINAL_POS_BY_ORIENTATION(1);
330 else if (wd->magnet_position & ELM_ACTIONSLIDER_MAGNET_CENTER)
331 wd->final_position = 0.5;
333 wd->final_position = _FINAL_POS_BY_ORIENTATION(0);
335 wd->icon_animator = ecore_animator_add(_icon_animation, as);
337 #undef _FINAL_POS_BY_ORIENTATION
342 _icon_animation(void *data)
344 Widget_Data *wd = elm_widget_data_get(data);
345 double cur_position = 0.0, new_position = 0.0;
346 double move_amount = 0.05;
347 double adjusted_final;
348 Eina_Bool flag_finish_animation = EINA_FALSE;
350 if (!wd) return ECORE_CALLBACK_CANCEL;
352 edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &cur_position, NULL);
353 adjusted_final = (!elm_widget_mirrored_get(data)) ? wd->final_position : 1.0 - wd->final_position;
355 if ( (adjusted_final == 0.0) ||(adjusted_final == 0.5 && cur_position >= adjusted_final) )
357 new_position = cur_position - move_amount;
358 if (new_position <= adjusted_final)
360 new_position = adjusted_final;
361 flag_finish_animation = EINA_TRUE;
364 else if ((adjusted_final == 1.0) || (adjusted_final == 0.5 && cur_position < adjusted_final) )
366 new_position = cur_position + move_amount;
367 if (new_position >= adjusted_final)
369 new_position = adjusted_final;
370 flag_finish_animation = EINA_TRUE;
373 if (wd->type == ELM_ACTIONSLIDER_TYPE_BAR_GREEN ||
374 wd->type == ELM_ACTIONSLIDER_TYPE_BAR_RED ) {
375 edje_object_signal_emit(wd->as, "elm,show,bar,text,center", "elm");
380 edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", new_position, 0.5);
382 if (flag_finish_animation)
384 if ((!wd->final_position) &&
385 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_LEFT))
386 evas_object_smart_callback_call(data, SIG_SELECTED,
387 (void *)wd->text_left);
388 else if ((wd->final_position == 0.5) &&
389 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_CENTER))
390 evas_object_smart_callback_call(data, SIG_SELECTED,
391 (void *)wd->text_center);
392 else if ((wd->final_position == 1) &&
393 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_RIGHT))
394 evas_object_smart_callback_call(data, SIG_SELECTED,
395 (void *)wd->text_right);
396 wd->icon_animator = NULL;
397 return ECORE_CALLBACK_CANCEL;
399 return ECORE_CALLBACK_RENEW;
404 _elm_actionslider_label_set(Evas_Object *obj, const char *item, const char *label)
406 ELM_CHECK_WIDTYPE(obj, widtype);
407 Widget_Data *wd = elm_widget_data_get(obj);
410 if (!item || !strcmp(item, "default"))
412 eina_stringshare_replace(&wd->text_button, label);
413 edje_object_part_text_set(wd->icon, "elm.text.button",
416 else if (!strcmp(item, "left"))
418 eina_stringshare_replace(&wd->text_left, label);
419 if (!elm_widget_mirrored_get(obj))
421 edje_object_part_text_set(wd->as, "elm.text.left", wd->text_left);
425 edje_object_part_text_set(wd->as, "elm.text.right", wd->text_left);
428 else if (!strcmp(item, "center"))
430 eina_stringshare_replace(&wd->text_center, label);
431 edje_object_part_text_set(wd->as, "elm.text.center", wd->text_center);
433 else if (!strcmp(item, "right"))
435 eina_stringshare_replace(&wd->text_right, label);
436 if (!elm_widget_mirrored_get(obj))
438 edje_object_part_text_set(wd->as, "elm.text.right", wd->text_right);
442 edje_object_part_text_set(wd->as, "elm.text.left", wd->text_right);
448 _elm_actionslider_label_get(const Evas_Object *obj, const char *item)
450 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
451 Widget_Data *wd = elm_widget_data_get(obj);
452 if (!wd) return NULL;
454 if (!item || !strcmp(item, "default"))
456 return wd->text_button;
458 else if (!strcmp(item, "left"))
460 return wd->text_left;
462 else if (!strcmp(item, "center"))
464 return wd->text_center;
466 else if (!strcmp(item, "right"))
468 return wd->text_right;
475 * Add a new actionslider to the parent.
477 * @param[in] parent The parent object
478 * @return The new actionslider object or NULL if it cannot be created
480 * @ingroup Actionslider
483 elm_actionslider_add(Evas_Object *parent)
487 Widget_Data *wd = NULL;
489 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
491 ELM_SET_WIDTYPE(widtype, "actionslider");
492 elm_widget_type_set(obj, "actionslider");
493 elm_widget_sub_object_add(parent, obj);
494 elm_widget_data_set(obj, wd);
496 elm_widget_del_hook_set(obj, _del_hook);
497 elm_widget_theme_hook_set(obj, _theme_hook);
498 elm_widget_disable_hook_set(obj, _disable_hook);
499 elm_widget_text_set_hook_set(obj, _elm_actionslider_label_set);
500 elm_widget_text_get_hook_set(obj, _elm_actionslider_label_get);
502 wd->mouse_down = EINA_FALSE;
503 wd->mouse_hold = EINA_FALSE;
504 wd->enabled_position = ELM_ACTIONSLIDER_MAGNET_ALL;
506 // load background edj
507 wd->as = edje_object_add(e);
510 printf("Cannot load actionslider edj!\n");
513 _elm_theme_object_set(obj, wd->as, "actionslider", "base", elm_widget_style_get(obj));
514 elm_widget_resize_object_set(obj, wd->as);
517 wd->icon = edje_object_add(e);
518 if (wd->icon == NULL)
520 printf("Cannot load acitionslider icon!\n");
523 evas_object_smart_member_add(wd->icon, obj);
524 _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", elm_widget_style_get(obj));
525 edje_object_part_swallow(wd->as, "elm.swallow.icon", wd->icon);
527 wd->icon_fake = edje_object_add(e);
528 evas_object_smart_member_add(wd->icon_fake, obj);
529 _elm_theme_object_set(obj, wd->icon_fake, "actionslider", "icon", elm_widget_style_get(obj));
530 edje_object_part_swallow(wd->as, "elm.swallow.space", wd->icon_fake);
533 evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_DOWN, _icon_down_cb, obj);
534 evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_MOVE, _icon_move_cb, obj);
535 evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_UP, _icon_up_cb, obj);
537 _mirrored_set(obj, elm_widget_mirrored_get(obj));
544 elm_actionslider_add_with_set(Evas_Object *parent, Elm_Actionslider_Icon_Pos pos, Elm_Actionslider_Magnet_Pos magnet, const char* label_left, const char* label_center, const char* label_right)
548 obj = elm_actionslider_add(parent);
550 elm_actionslider_icon_set(obj, pos);
551 elm_actionslider_magnet_set(obj, magnet);
552 if (label_left != NULL)
553 elm_actionslider_label_set(obj, ELM_ACTIONSLIDER_LABEL_LEFT, label_left);
554 if (label_center != NULL)
555 elm_actionslider_label_set(obj, ELM_ACTIONSLIDER_LABEL_CENTER, label_center);
556 if (label_right != NULL)
557 elm_actionslider_label_set(obj, ELM_ACTIONSLIDER_LABEL_RIGHT, label_right);
564 * Set actionslider indicator position.
566 * @param[in] obj The actionslider object.
567 * @param[in] pos The position of the indicator.
568 * (ELM_ACTIONSLIDER_INDICATOR_LEFT, ELM_ACTIONSLIDER_INDICATOR_RIGHT,
569 * ELM_ACTIONSLIDER_INDICATOR_CENTER)
571 * @ingroup Actionslider
574 elm_actionslider_indicator_pos_set(Evas_Object *obj, Elm_Actionslider_Indicator_Pos pos)
576 ELM_CHECK_WIDTYPE(obj, widtype);
578 Widget_Data *wd = elm_widget_data_get(obj);
579 double position = 0.0;
582 pos = _get_pos_by_orientation(obj, pos);
583 if (pos == ELM_ACTIONSLIDER_INDICATOR_LEFT) position = 0.0;
584 else if (pos == ELM_ACTIONSLIDER_INDICATOR_RIGHT) position = 1.0;
585 else if (pos == ELM_ACTIONSLIDER_INDICATOR_CENTER) position = 0.5;
588 edje_object_part_drag_value_set(wd->as, "elm.swallow.icon", position, 0.5);
592 * Get actionslider indicator position.
594 * @param obj The actionslider object.
595 * @return The position of the indicator.
597 * @ingroup Actionslider
599 EAPI Elm_Actionslider_Indicator_Pos
600 elm_actionslider_indicator_pos_get(const Evas_Object *obj)
602 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ACTIONSLIDER_INDICATOR_NONE;
603 Widget_Data *wd = elm_widget_data_get(obj);
605 if (!wd) return ELM_ACTIONSLIDER_INDICATOR_NONE;
607 edje_object_part_drag_value_get(wd->as, "elm.swallow.icon", &position, NULL);
609 return _get_pos_by_orientation(obj, ELM_ACTIONSLIDER_INDICATOR_LEFT);
610 else if (position < 0.7)
611 return ELM_ACTIONSLIDER_INDICATOR_CENTER;
613 return _get_pos_by_orientation(obj, ELM_ACTIONSLIDER_INDICATOR_RIGHT);
616 * Set actionslider magnet position.
618 * @param[in] obj The actionslider object.
619 * @param[in] pos The position of the magnet.
620 * (ELM_ACTIONSLIDER_MAGNET_LEFT, ELM_ACTIONSLIDER_MAGNET_RIGHT,
621 * ELM_ACTIONSLIDER_MAGNET_BOTH, ELM_ACTIONSLIDER_MAGNET_CENTER)
623 * @ingroup Actionslider
626 elm_actionslider_magnet_pos_set(Evas_Object *obj, Elm_Actionslider_Magnet_Pos pos)
628 ELM_CHECK_WIDTYPE(obj, widtype);
629 Widget_Data *wd = elm_widget_data_get(obj);
631 wd->magnet_position = pos;
635 * Get actionslider magnet position.
637 * @param obj The actionslider object.
638 * @return The positions with magnet property.
640 * @ingroup Actionslider
642 EAPI Elm_Actionslider_Magnet_Pos
643 elm_actionslider_magnet_pos_get(const Evas_Object *obj)
645 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ACTIONSLIDER_MAGNET_NONE;
646 Widget_Data *wd = elm_widget_data_get(obj);
647 if (!wd) return ELM_ACTIONSLIDER_MAGNET_NONE;
648 return wd->magnet_position;
652 * Set actionslider enabled position.
654 * All the positions are enabled by default.
656 * @param obj The actionslider object.
657 * @param pos Bit mask indicating the enabled positions.
658 * Example: use (ELM_ACTIONSLIDER_MAGNET_LEFT | ELM_ACTIONSLIDER_MAGNET_RIGHT)
659 * to enable both positions, so the user can select it.
661 * @ingroup Actionslider
664 elm_actionslider_enabled_pos_set(Evas_Object *obj, Elm_Actionslider_Magnet_Pos pos)
666 ELM_CHECK_WIDTYPE(obj, widtype);
667 Widget_Data *wd = elm_widget_data_get(obj);
669 wd->enabled_position = pos;
673 * Get actionslider enabled position.
675 * All the positions are enabled by default.
677 * @param obj The actionslider object.
678 * @return The enabled positions.
680 * @ingroup Actionslider
682 EAPI Elm_Actionslider_Magnet_Pos
683 elm_actionslider_enabled_pos_get(const Evas_Object *obj)
685 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ACTIONSLIDER_MAGNET_NONE;
686 Widget_Data *wd = elm_widget_data_get(obj);
687 if (!wd) return ELM_ACTIONSLIDER_MAGNET_NONE;
688 return wd->enabled_position;
692 * Set actionslider label.
694 * @param[in] obj The actionslider object
695 * @param[in] pos The position of the label.
696 * (ELM_ACTIONSLIDER_LABEL_LEFT, ELM_ACTIONSLIDER_LABEL_RIGHT)
697 * @param label The label which is going to be set.
699 * @ingroup Actionslider
702 elm_actionslider_label_set(Evas_Object *obj, Elm_Actionslider_Label_Pos pos, const char *label)
704 ELM_CHECK_WIDTYPE(obj, widtype);
705 Widget_Data *wd = elm_widget_data_get(obj);
708 if(label == NULL) label = "";
710 if (pos == ELM_ACTIONSLIDER_LABEL_RIGHT)
711 _elm_actionslider_label_set(obj, "right", label);
712 else if (pos == ELM_ACTIONSLIDER_LABEL_LEFT)
713 _elm_actionslider_label_set(obj, "left", label);
714 else if (pos == ELM_ACTIONSLIDER_LABEL_CENTER)
715 _elm_actionslider_label_set(obj, "center", label);
716 else if (pos == ELM_ACTIONSLIDER_LABEL_BUTTON)
718 _elm_actionslider_label_set(obj, NULL, label);
720 /* Resize button width */
722 txt = (Evas_Object *)edje_object_part_object_get (wd->icon, "elm.text.button");
725 evas_object_text_text_set (txt, wd->text_button);
728 evas_object_geometry_get (txt, &x,&y,&w,&h);
730 char *data_left = NULL, *data_right = NULL;
731 int pad_left = 0, pad_right = 0;
733 data_left = (char *)edje_object_data_get (wd->icon, "left");
734 data_right = (char *)edje_object_data_get (wd->icon, "right");
736 if (data_left) pad_left = atoi(data_left);
737 if (data_right) pad_right = atoi(data_right);
739 evas_object_size_hint_min_set (wd->icon, w + pad_left + pad_right, 0);
740 evas_object_size_hint_min_set (wd->icon_fake, w + pad_left + pad_right, 0);
746 * Get actionslider labels.
748 * @param obj The actionslider object
749 * @param left_label A char** to place the left_label of @p obj into
750 * @param center_label A char** to place the center_label of @p obj into
751 * @param right_label A char** to place the right_label of @p obj into
753 * @ingroup Actionslider
756 elm_actionslider_labels_get(const Evas_Object *obj, const char **left_label, const char **center_label, const char **right_label)
758 if (left_label) *left_label = _elm_actionslider_label_get(obj, "left");
759 if (center_label) *center_label = _elm_actionslider_label_get(obj, "center");
760 if (right_label) *right_label = _elm_actionslider_label_get(obj, "right");
764 * Get actionslider selected label.
766 * @param obj The actionslider object
767 * @return The selected label
769 * @ingroup Actionslider
772 elm_actionslider_selected_label_get(const Evas_Object *obj)
774 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
775 Widget_Data *wd = elm_widget_data_get(obj);
776 if (!wd) return NULL;
778 if ((wd->final_position == 0.0) &&
779 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_LEFT))
780 return wd->text_left;
782 if ((wd->final_position == 0.5) &&
783 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_CENTER))
784 return wd->text_center;
786 if ((wd->final_position == 1.0) &&
787 (wd->enabled_position & ELM_ACTIONSLIDER_MAGNET_RIGHT))
788 return wd->text_right;
794 * Set the label used on the indicator object.
796 * @param obj The actionslider object
797 * @param label The label which is going to be set.
799 * @ingroup Actionslider
802 elm_actionslider_indicator_label_set(Evas_Object *obj, const char *label)
804 _elm_actionslider_label_set(obj, NULL, label);
808 * Get the label used on the indicator object.
810 * @param obj The actionslider object
811 * @return The indicator label
813 * @ingroup Actionslider
816 elm_actionslider_indicator_label_get(Evas_Object *obj)
818 return _elm_actionslider_label_get(obj, NULL);
822 * Hold actionslider object movement.
824 * @param[in] obj The actionslider object
825 * @param[in] flag Actionslider hold/release
826 * (EINA_TURE = hold/EIN_FALSE = release)
828 * @ingroup Actionslider
831 elm_actionslider_hold(Evas_Object *obj, Eina_Bool flag)
833 ELM_CHECK_WIDTYPE(obj, widtype);
834 Widget_Data *wd = elm_widget_data_get(obj);
836 wd->mouse_hold = flag;