2 # include "elementary_config.h"
5 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
8 #define ELM_WIDGET_ITEM_PROTECTED
9 #include <Elementary.h>
11 #include "elm_widget_hoversel.h"
13 #define MY_CLASS ELM_HOVERSEL_CLASS
15 #define MY_CLASS_NAME "Elm_Hoversel"
16 #define MY_CLASS_NAME_LEGACY "elm_hoversel"
18 static const char SIG_SELECTED[] = "selected";
19 static const char SIG_DISMISSED[] = "dismissed";
20 static const char SIG_EXPANDED[] = "expanded";
21 static const char SIG_ITEM_FOCUSED[] = "item,focused";
22 static const char SIG_ITEM_UNFOCUSED[] = "item,unfocused";
24 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
28 {SIG_ITEM_FOCUSED, ""},
29 {SIG_ITEM_UNFOCUSED, ""},
30 {"clicked", ""}, /**< handled by parent button class */
31 {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
32 {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
36 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
37 static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
39 static const Elm_Action key_actions[] = {
40 {"move", _key_action_move},
41 {"activate", _key_action_activate},
45 EOLIAN static Eina_Bool
46 _elm_hoversel_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
51 EINA_LIST_FOREACH(sd->items, l, it)
52 eo_do(it, elm_wdg_item_translate());
54 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
59 EOLIAN static Eina_Bool
60 _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd)
62 Eina_Bool int_ret = EINA_FALSE;
64 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
69 style = eina_stringshare_add(elm_widget_style_get(obj));
72 snprintf(buf, sizeof(buf), "hoversel_horizontal/%s", style);
74 snprintf(buf, sizeof(buf), "hoversel_vertical/%s", style);
76 /* hoversel's style has an extra bit: orientation */
77 eina_stringshare_replace(&(wd->style), buf);
79 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
80 if (!int_ret) return EINA_FALSE;
82 eina_stringshare_replace(&(wd->style), style);
84 eina_stringshare_del(style);
87 elm_widget_mirrored_set(sd->hover, elm_widget_mirrored_get(obj));
89 elm_hoversel_hover_end(obj);
95 _on_hover_clicked(void *data EINA_UNUSED,
96 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED,
97 void *event_info EINA_UNUSED)
99 const char *dismissstr;
101 dismissstr = edje_object_data_get(elm_layout_edje_get(obj), "dismiss");
103 if (!dismissstr || strcmp(dismissstr, "on"))
104 elm_hoversel_hover_end(data); // for backward compatibility
110 _on_item_clicked(void *data EINA_UNUSED,
111 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
112 void *event_info EINA_UNUSED)
114 Elm_Hoversel_Item_Data *item = data;
115 Evas_Object *obj2 = WIDGET(item);
116 Elm_Object_Item *eo_it = EO_OBJ(item);
118 ELM_HOVERSEL_DATA_GET(obj2, sd);
120 if (item->func) item->func((void *)WIDGET_ITEM_DATA_GET(eo_it), obj2, eo_it);
121 eo_do(obj2, eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it));
127 ic = elm_object_part_content_unset(obj2, "icon");
128 ELM_SAFE_FREE(ic, evas_object_del);
132 ic = elm_icon_add(obj2);
133 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
134 if (item->icon_type == ELM_ICON_FILE)
135 elm_image_file_set(ic, item->icon_file, item->icon_group);
136 else if (item->icon_type == ELM_ICON_STANDARD)
137 elm_icon_standard_set(ic, item->icon_file);
138 elm_object_part_content_set(obj2, "icon", ic);
142 elm_object_text_set(obj2, item->label);
145 elm_hoversel_hover_end(obj2);
151 _item_focused_cb(void *data EINA_UNUSED,
152 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
153 void *event_info EINA_UNUSED)
155 Elm_Hoversel_Item_Data *it = data;
157 eo_do(WIDGET(it), eo_event_callback_call(ELM_HOVERSEL_EVENT_ITEM_FOCUSED, EO_OBJ(it)));
163 _item_unfocused_cb(void *data EINA_UNUSED,
164 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
165 void *event_info EINA_UNUSED)
167 Elm_Hoversel_Item_Data *it = data;
169 eo_do(WIDGET(it), eo_event_callback_call(ELM_HOVERSEL_EVENT_ITEM_UNFOCUSED, EO_OBJ(it)));
175 _create_scroller(Evas_Object *obj, Elm_Hoversel_Data *sd)
178 sd->tbl = elm_table_add(obj);
181 sd->spacer = evas_object_rectangle_add(evas_object_evas_get(obj));
182 evas_object_color_set(sd->spacer, 0, 0, 0, 0);
183 elm_table_pack(sd->tbl, sd->spacer, 0, 0, 1, 1);
186 sd->scr = elm_scroller_add(sd->tbl);
187 elm_object_style_set(sd->scr, "popup/no_inset_shadow");
188 evas_object_size_hint_weight_set(sd->scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
189 evas_object_size_hint_align_set(sd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
192 elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
193 elm_scroller_content_min_limit(sd->scr, EINA_FALSE, EINA_TRUE);
194 elm_scroller_bounce_set(sd->scr, EINA_TRUE, EINA_FALSE);
198 elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
199 elm_scroller_content_min_limit(sd->scr, EINA_TRUE, EINA_FALSE);
200 elm_scroller_bounce_set(sd->scr, EINA_FALSE, EINA_TRUE);
202 elm_table_pack(sd->tbl, sd->scr, 0, 0, 1, 1);
203 evas_object_show(sd->scr);
207 _resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
209 Evas_Object *bx = NULL;
210 const char *max_size_str;
213 Evas_Coord box_w = -1, box_h = -1;
214 Evas_Coord x, y, w, h, xx, yy, ww, hh, vw = 0, vh = 0;
218 Evas_Coord obj_x, obj_y, obj_w, obj_h, it_w, it_h;
221 bx = elm_object_content_get(sd->scr);
223 if ((!sd->expanded) || (!bx)) return;
225 edje_object_size_min_calc(elm_layout_edje_get(sd->scr), &vw, &vh);
226 evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
228 evas_object_size_hint_align_get(obj, &align_x, NULL);
229 if (!sd->horizontal && align_x == EVAS_HINT_FILL)
231 l = elm_box_children_get(bx);
232 EINA_LIST_FREE(l, it)
234 edje_object_size_min_calc(elm_layout_edje_get(it), &it_w, &it_h);
235 if ((obj_w - vw) > it_w)
236 evas_object_size_hint_min_set(it, (obj_w - vw), it_h);
238 evas_object_size_hint_min_set(it, it_w, it_h);
242 elm_box_recalculate(bx);
243 evas_object_size_hint_min_get(bx, &box_w, &box_h);
248 max_size_str = edje_object_data_get(elm_layout_edje_get(sd->hover), "max_size");
250 max_size = (int)(atoi(max_size_str)
251 * elm_config_scale_get()
252 * elm_object_scale_get(obj))
253 / edje_object_base_scale_get(elm_layout_edje_get(sd->hover));
257 ww = (max_size > 0) ? MIN(box_w, max_size) : box_w ;
260 evas_object_size_hint_min_set(sd->spacer, ww, hh);
262 if (!sd->last_location)
263 sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_HORIZONTAL);
268 hh = (max_size > 0) ? MIN(box_h, max_size) : box_h ;
270 evas_object_size_hint_min_set(sd->spacer, ww, hh);
272 if (!sd->last_location)
273 sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_VERTICAL);
276 evas_object_geometry_get(sd->hover_parent, &x, &y, &w, &h);
277 if (eo_isa(sd->hover_parent, ELM_WIN_CLASS))
283 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", sd->last_location);
284 edje_object_part_geometry_get(elm_layout_edje_get(sd->hover), buf, &xx, &yy, NULL, NULL);
293 if ((xx + ww) > obj_x)
298 if ((xx + ww) > (x + w))
303 if ((yy + hh) > (y + h))
311 if ((yy + hh) > obj_y)
316 if ((yy + hh) > (y + h))
321 if ((xx + ww) > (x + w))
325 evas_object_size_hint_min_set(sd->spacer, ww, hh);
329 _hover_end_finished(void *data,
330 Evas_Object *obj EINA_UNUSED,
331 const char *emission EINA_UNUSED,
332 const char *source EINA_UNUSED)
334 Elm_Object_Item *eo_item;
336 const char *dismissstr;
338 ELM_HOVERSEL_DATA_GET(data, sd);
340 dismissstr = edje_object_data_get(elm_layout_edje_get(sd->hover), "dismiss");
342 if (dismissstr && !strcmp(dismissstr, "on"))
344 sd->expanded = EINA_FALSE;
346 EINA_LIST_FOREACH(sd->items, l, eo_item)
348 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
351 ELM_SAFE_FREE(sd->hover, evas_object_del);
353 sd->last_location = NULL;
355 eo_do(data, eo_event_callback_call(ELM_HOVERSEL_EVENT_DISMISSED, NULL));
360 _activate(Evas_Object *obj)
362 Elm_Object_Item *eo_item;
363 Evas_Object *bt, *bx, *ic;
367 ELM_HOVERSEL_DATA_GET(obj, sd);
371 elm_hoversel_hover_end(obj);
374 sd->expanded = EINA_TRUE;
376 if (elm_widget_disabled_get(obj)) return;
378 sd->hover = elm_hover_add(sd->hover_parent);
379 elm_widget_sub_object_add(obj, sd->hover);
382 snprintf(buf, sizeof(buf), "hoversel_horizontal/%s",
383 elm_widget_style_get(obj));
385 snprintf(buf, sizeof(buf), "hoversel_vertical/%s",
386 elm_widget_style_get(obj));
388 elm_object_style_set(sd->hover, buf);
390 eo_do(sd->hover, eo_event_callback_add
391 (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_hover_clicked, obj));
392 elm_layout_signal_callback_add
393 (sd->hover, "elm,action,hide,finished", "elm", _hover_end_finished, obj);
394 elm_hover_target_set(sd->hover, obj);
396 /* hover's content */
397 bx = elm_box_add(sd->hover);
398 elm_box_homogeneous_set(bx, EINA_TRUE);
399 elm_box_horizontal_set(bx, sd->horizontal);
402 snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s",
403 elm_widget_style_get(obj));
405 snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
406 elm_widget_style_get(obj));
408 EINA_LIST_FOREACH(sd->items, l, eo_item)
410 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
411 VIEW(item) = bt = elm_button_add(bx);
412 elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
413 elm_object_style_set(bt, buf);
414 elm_object_text_set(bt, item->label);
418 ic = elm_icon_add(bt);
419 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
420 if (item->icon_type == ELM_ICON_FILE)
421 elm_image_file_set(ic, item->icon_file, item->icon_group);
422 else if (item->icon_type == ELM_ICON_STANDARD)
423 elm_icon_standard_set(ic, item->icon_file);
424 elm_object_part_content_set(bt, "icon", ic);
427 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
428 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
429 elm_box_pack_end(bx, bt);
430 eo_do(bt, eo_event_callback_add
431 (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item));
432 evas_object_show(bt);
434 eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item),
435 eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item));
438 _create_scroller(obj, sd);
439 elm_object_content_set(sd->scr, bx);
441 _resizing_eval(obj, sd);
442 elm_object_part_content_set(sd->hover, sd->last_location, sd->tbl);
444 eo_do(obj, eo_event_callback_call(ELM_HOVERSEL_EVENT_EXPANDED, NULL));
445 evas_object_show(sd->hover);
449 _on_clicked(void *data EINA_UNUSED,
450 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
451 void *event_info EINA_UNUSED)
459 _on_parent_del(void *data,
461 Evas_Object *obj EINA_UNUSED,
462 void *event_info EINA_UNUSED)
464 elm_hoversel_hover_parent_set(data, NULL);
468 _elm_hoversel_item_elm_widget_item_part_text_set(Eo *eo_it EINA_UNUSED,
469 Elm_Hoversel_Item_Data *it,
473 if (part && strcmp(part, "default")) return;
474 eina_stringshare_replace(&it->label, label);
477 elm_object_text_set(VIEW(it), label);
481 _elm_hoversel_item_elm_widget_item_part_text_get(Eo *eo_it EINA_UNUSED,
482 Elm_Hoversel_Item_Data *it,
485 if (part && strcmp(part, "default")) return NULL;
490 _elm_hoversel_item_elm_widget_item_signal_emit(Eo *eo_it EINA_UNUSED,
491 Elm_Hoversel_Item_Data *it,
492 const char *emission,
495 elm_object_signal_emit(VIEW(it), emission, source);
499 _elm_hoversel_item_elm_widget_item_style_set(Eo *eo_it EINA_UNUSED,
500 Elm_Hoversel_Item_Data *it,
503 elm_object_style_set(VIEW(it), style);
506 EOLIAN static const char *
507 _elm_hoversel_item_elm_widget_item_style_get(Eo *eo_it EINA_UNUSED,
508 Elm_Hoversel_Item_Data *it)
510 return elm_object_style_get(VIEW(it));
514 _elm_hoversel_item_elm_widget_item_focus_set(Eo *eo_it EINA_UNUSED,
515 Elm_Hoversel_Item_Data *it,
518 elm_object_focus_set(VIEW(it), focused);
521 EOLIAN static Eina_Bool
522 _elm_hoversel_item_elm_widget_item_focus_get(Eo *eo_it EINA_UNUSED,
523 Elm_Hoversel_Item_Data *it)
525 return elm_widget_focus_get(VIEW(it));
529 _elm_hoversel_item_eo_base_destructor(Eo *eo_item, Elm_Hoversel_Item_Data *item)
531 ELM_HOVERSEL_DATA_GET_OR_RETURN(WIDGET(item), sd);
533 elm_hoversel_hover_end(WIDGET(item));
534 sd->items = eina_list_remove(sd->items, eo_item);
535 eina_stringshare_del(item->label);
536 eina_stringshare_del(item->icon_file);
537 eina_stringshare_del(item->icon_group);
539 eo_do_super(eo_item, ELM_HOVERSEL_ITEM_CLASS, eo_destructor());
543 _on_move_resize(void * data,
546 void *event_info EINA_UNUSED)
548 Elm_Hoversel_Data *sd = data;
550 _resizing_eval(obj, sd);
554 _elm_hoversel_evas_object_smart_add(Eo *obj, Elm_Hoversel_Data *priv)
556 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
557 elm_widget_sub_object_parent_add(obj);
559 eo_do(obj, eo_event_callback_add(
560 EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_clicked, obj));
562 //What are you doing here?
563 eo_do(obj, elm_obj_widget_theme_apply());
565 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _on_move_resize, priv);
566 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_move_resize, priv);
570 _elm_hoversel_evas_object_smart_del(Eo *obj, Elm_Hoversel_Data *sd)
572 Elm_Object_Item *eo_item;
574 EINA_LIST_FREE(sd->items, eo_item)
578 elm_hoversel_hover_parent_set(obj, NULL);
580 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
584 _elm_hoversel_evas_object_smart_show(Eo *obj, Elm_Hoversel_Data *sd)
586 eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
587 evas_object_show(sd->hover);
591 _elm_hoversel_evas_object_smart_hide(Eo *obj, Elm_Hoversel_Data *sd)
593 eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
594 evas_object_hide(sd->hover);
598 _elm_hoversel_elm_widget_parent_set(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED, Evas_Object *parent)
600 elm_hoversel_hover_parent_set(obj, parent);
603 EOLIAN static Eina_Bool
604 _elm_hoversel_elm_button_admits_autorepeat_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd EINA_UNUSED)
610 elm_hoversel_add(Evas_Object *parent)
612 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
613 Evas_Object *obj = eo_add(MY_CLASS, parent);
618 _elm_hoversel_eo_base_constructor(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED)
620 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
622 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
623 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
624 elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_GLASS_PANE));
630 _elm_hoversel_eo_base_destructor(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED)
632 eo_do(obj, elm_obj_hoversel_clear());
633 eo_do_super(obj, MY_CLASS, eo_destructor());
637 _elm_hoversel_hover_parent_set(Eo *obj, Elm_Hoversel_Data *sd, Evas_Object *parent)
639 if (sd->hover_parent)
640 evas_object_event_callback_del_full
641 (sd->hover_parent, EVAS_CALLBACK_DEL, _on_parent_del, obj);
643 sd->hover_parent = parent;
644 if (sd->hover_parent)
645 evas_object_event_callback_add
646 (sd->hover_parent, EVAS_CALLBACK_DEL, _on_parent_del, obj);
649 EOLIAN static Evas_Object*
650 _elm_hoversel_hover_parent_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
652 return sd->hover_parent;
656 _elm_hoversel_horizontal_set(Eo *obj, Elm_Hoversel_Data *sd, Eina_Bool horizontal)
658 sd->horizontal = !!horizontal;
664 elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
665 elm_scroller_content_min_limit(sd->scr, EINA_FALSE, EINA_TRUE);
666 elm_scroller_bounce_set(sd->scr, EINA_TRUE, EINA_FALSE);
670 elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
671 elm_scroller_content_min_limit(sd->scr, EINA_TRUE, EINA_FALSE);
672 elm_scroller_bounce_set(sd->scr, EINA_FALSE, EINA_TRUE);
676 eo_do(obj, elm_obj_widget_theme_apply());
679 EOLIAN static Eina_Bool
680 _elm_hoversel_horizontal_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
682 return sd->horizontal;
686 _elm_hoversel_hover_begin(Eo *obj, Elm_Hoversel_Data *sd)
688 if (sd->hover) return;
694 _elm_hoversel_hover_end(Eo *obj, Elm_Hoversel_Data *sd)
697 Elm_Object_Item *eo_item;
699 const char *dismissstr;
701 if (!sd->hover) return;
703 dismissstr = edje_object_data_get(elm_layout_edje_get(sd->hover), "dismiss");
705 if (dismissstr && !strcmp(dismissstr, "on"))
707 elm_hover_dismiss(sd->hover);
715 sd->expanded = EINA_FALSE;
717 EINA_LIST_FOREACH(sd->items, l, eo_item)
719 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
722 ELM_SAFE_FREE(sd->hover, evas_object_del);
724 sd->last_location = NULL;
726 eo_do(obj, eo_event_callback_call(ELM_HOVERSEL_EVENT_DISMISSED, NULL));
727 } // for backward compatibility
730 EOLIAN static Eina_Bool
731 _elm_hoversel_expanded_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
733 return (sd->hover) ? EINA_TRUE : EINA_FALSE;
737 _elm_hoversel_clear(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
742 EINA_LIST_FOREACH_SAFE(sd->items, l, ll, it)
744 eo_do(it, elm_wdg_item_del());
748 EOLIAN static const Eina_List*
749 _elm_hoversel_items_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
755 _elm_hoversel_item_eo_base_constructor(Eo *obj, Elm_Hoversel_Item_Data *it)
757 obj = eo_do_super_ret(obj, ELM_HOVERSEL_ITEM_CLASS, obj, eo_constructor());
758 it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
763 EOLIAN static Elm_Object_Item*
764 _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
766 Eo *eo_item = eo_add(ELM_HOVERSEL_ITEM_CLASS, obj);
767 if (!eo_item) return NULL;
769 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
771 item->label = eina_stringshare_add(label);
772 item->icon_file = eina_stringshare_add(icon_file);
773 item->icon_type = icon_type;
775 WIDGET_ITEM_DATA_SET(eo_item, data);
777 sd->items = eina_list_append(sd->items, eo_item);
783 _elm_hoversel_item_icon_set(Eo *eo_item EINA_UNUSED,
784 Elm_Hoversel_Item_Data *item,
785 const char *icon_file,
786 const char *icon_group,
787 Elm_Icon_Type icon_type)
789 eina_stringshare_replace(&item->icon_file, icon_file);
790 eina_stringshare_replace(&item->icon_group, icon_group);
792 item->icon_type = icon_type;
796 _elm_hoversel_item_icon_get(Eo *eo_item EINA_UNUSED,
797 Elm_Hoversel_Item_Data *item,
798 const char **icon_file,
799 const char **icon_group,
800 Elm_Icon_Type *icon_type)
802 if (icon_file) *icon_file = item->icon_file;
803 if (icon_group) *icon_group = item->icon_group;
804 if (icon_type) *icon_type = item->icon_type;
807 static Elm_Object_Item *
808 item_focused_get(Elm_Hoversel_Data *sd)
810 Elm_Object_Item *eo_item;
813 EINA_LIST_FOREACH(sd->items, l, eo_item)
815 ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
816 if (elm_object_focus_get(VIEW(item)))
823 _key_action_move(Evas_Object *obj, const char *params)
825 ELM_HOVERSEL_DATA_GET(obj, sd);
826 const char *dir = params;
828 Elm_Object_Item *eo_litem, *eo_fitem;
829 eo_litem = eina_list_last_data_get(sd->items);
830 eo_fitem = eina_list_data_get(sd->items);
832 _elm_widget_focus_auto_show(obj);
833 if (!strcmp(dir, "down"))
835 if ((!sd->horizontal) &&
836 (item_focused_get(sd) == eo_litem))
838 ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem);
839 elm_object_focus_set(VIEW(fitem), EINA_TRUE);
842 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_DOWN);
845 else if (!strcmp(dir, "up"))
847 if ((!sd->horizontal) &&
848 (item_focused_get(sd) == eo_fitem))
850 ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem);
851 elm_object_focus_set(VIEW(litem), EINA_TRUE);
854 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_UP);
857 else if (!strcmp(dir, "left"))
859 if (sd->horizontal &&
860 (item_focused_get(sd) == eo_fitem))
862 ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem);
863 elm_object_focus_set(VIEW(litem), EINA_TRUE);
866 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_LEFT);
869 else if (!strcmp(dir, "right"))
871 if (sd->horizontal &&
872 (item_focused_get(sd) == eo_litem))
874 ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem);
875 elm_object_focus_set(VIEW(fitem), EINA_TRUE);
878 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_RIGHT);
881 else return EINA_FALSE;
885 _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
891 EOLIAN static Eina_Bool
892 _elm_hoversel_elm_widget_event(Eo *obj, Elm_Hoversel_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
895 Eina_Bool int_ret = EINA_FALSE;
896 Evas_Event_Key_Down *ev = event_info;
898 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_event(src, type, event_info));
899 if (int_ret) return EINA_FALSE;
901 if (!sd || !sd->hover) return EINA_FALSE;
902 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
903 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
905 if (!_elm_config_key_binding_call(obj, ev, key_actions))
908 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
913 _elm_hoversel_class_constructor(Eo_Class *klass)
915 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
918 EOLIAN const Elm_Atspi_Action *
919 _elm_hoversel_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *pd EINA_UNUSED)
921 static Elm_Atspi_Action atspi_actions[] = {
922 { "activate", "activate", NULL, _key_action_activate},
923 { "move,up", "move", "up", _key_action_move},
924 { "move,down", "move", "down", _key_action_move},
925 { "move,left", "move", "left", _key_action_move},
926 { "move,right", "move", "right", _key_action_move},
927 { NULL, NULL, NULL, NULL}
929 return &atspi_actions[0];
933 _elm_hoversel_auto_update_set(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd, Eina_Bool auto_update)
935 sd->auto_update = !!auto_update;
939 _elm_hoversel_auto_update_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
941 return sd->auto_update;
944 #include "elm_hoversel_item.eo.c"
945 #include "elm_hoversel.eo.c"