1 #include <Elementary.h>
5 * @defgroup Hover Hover
7 * A Hover object will over its @p parent object at the @p target
8 * location. Anything in the background will be given a darker
9 * coloring to indicate that the hover object is on top (at the
12 * @note The hover object will take up the entire space of @p target
16 typedef struct _Widget_Data Widget_Data;
17 typedef struct _Content_Info Content_Info;
20 # define MAX(a, b) (((a) > (b)) ? (a) : (b))
23 #define ELM_HOVER_PARTS_FOREACH unsigned int i = 0; \
24 for (i = 0; i < sizeof(wd->subs) / sizeof(wd->subs[0]); i++)
26 static const char *_directions[] = {
38 #define _HOV_LEFT (_directions[0])
39 #define _HOV_TOP_LEFT (_directions[1])
40 #define _HOV_TOP (_directions[2])
41 #define _HOV_TOP_RIGHT (_directions[2])
42 #define _HOV_RIGHT (_directions[4])
43 #define _HOV_BOTTOM_RIGHT (_directions[5])
44 #define _HOV_BOTTOM (_directions[6])
45 #define _HOV_BOTTOM_LEFT (_directions[7])
46 #define _HOV_MIDDLE (_directions[8])
56 Evas_Object *hov, *cov;
57 Evas_Object *offset, *size;
58 Evas_Object *parent, *target;
60 Content_Info subs[sizeof(_directions)/sizeof(_directions[0])];
63 static const char *widtype = NULL;
64 static void _del_pre_hook(Evas_Object *obj);
65 static void _del_hook(Evas_Object *obj);
66 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
67 static void _theme_hook(Evas_Object *obj);
68 static void _sizing_eval(Evas_Object *obj);
69 static void _reval_content(Evas_Object *obj);
70 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
71 static void _hov_show_do(Evas_Object *obj);
72 static void _hov_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
73 static void _hov_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static void _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
75 static void _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
76 static void _on_focus_hook(void *data, Evas_Object *obj);
77 static void _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _elm_hover_sub_obj_placement_eval(Evas_Object *obj);
80 static const char SIG_CLICKED[] = "clicked";
81 static const char SIG_SMART_LOCATION_CHANGED[] = "smart,changed";
82 static const Evas_Smart_Cb_Description _signals[] = {
84 {SIG_SMART_LOCATION_CHANGED, ""},
89 _del_pre_hook(Evas_Object *obj)
91 Widget_Data *wd = elm_widget_data_get(obj);
95 if (evas_object_visible_get(obj))
96 evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
97 elm_hover_target_set(obj, NULL);
98 elm_hover_parent_set(obj, NULL);
99 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
100 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
101 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
102 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
106 _del_hook(Evas_Object *obj)
108 Widget_Data *wd = elm_widget_data_get(obj);
114 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
116 Widget_Data *wd = elm_widget_data_get(obj);
118 if (elm_widget_focus_get(obj))
120 edje_object_signal_emit(wd->cov, "elm,action,focus", "elm");
121 evas_object_focus_set(wd->cov, EINA_TRUE);
125 edje_object_signal_emit(wd->cov, "elm,action,unfocus", "elm");
126 evas_object_focus_set(wd->cov, EINA_FALSE);
131 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
133 Widget_Data *wd = elm_widget_data_get(obj);
135 edje_object_mirrored_set(wd->cov, rtl);
139 _theme_hook(Evas_Object *obj)
141 Widget_Data *wd = elm_widget_data_get(obj);
143 _elm_widget_mirrored_reload(obj);
144 _mirrored_set(obj, elm_widget_mirrored_get(obj));
145 // FIXME: hover contents doesn't seem to propagate resizes properly
146 _elm_theme_object_set(obj, wd->cov, "hover", "base", elm_widget_style_get(obj));
147 edje_object_scale_set(wd->cov, elm_widget_scale_get(obj) *
151 _elm_hover_sub_obj_placement_eval(obj);
155 if (evas_object_visible_get(wd->cov)) _hov_show_do(obj);
159 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
163 wd = elm_widget_data_get(obj);
167 edje_object_signal_emit(wd->cov, emission, source);
171 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
175 wd = elm_widget_data_get(obj);
179 edje_object_signal_callback_add(wd->hov, emission, source, func_cb, data);
183 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
187 wd = elm_widget_data_get(obj);
189 edje_object_signal_callback_del_full(wd->hov, emission, source, func_cb,
194 _elm_hover_left_space_calc(Widget_Data *wd, Evas_Coord *spc_l, Evas_Coord *spc_t, Evas_Coord *spc_r, Evas_Coord *spc_b)
196 Evas_Coord x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
199 evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
201 evas_object_geometry_get(wd->target, &x2, &y2, &w2, &h2);
204 *spc_r = (x + w) - (x2 + w2);
211 *spc_b = (y + h) - (y2 + h2);
219 _sizing_eval(Evas_Object *obj)
221 Widget_Data *wd = elm_widget_data_get(obj);
222 Evas_Coord ofs_x, x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
224 if (wd->parent) evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
225 if (wd->hov) evas_object_geometry_get(wd->hov, &x2, &y2, &w2, &h2);
227 if (elm_widget_mirrored_get(obj))
228 ofs_x = w - (x2 - x) - w2;
232 evas_object_move(wd->cov, x, y);
233 evas_object_resize(wd->cov, w, h);
234 evas_object_size_hint_min_set(wd->offset, ofs_x, y2 - y);
235 evas_object_size_hint_min_set(wd->size, w2, h2);
236 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
237 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
241 _reval_content(Evas_Object *obj)
243 Widget_Data *wd = elm_widget_data_get(obj);
247 ELM_HOVER_PARTS_FOREACH
250 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", wd->subs[i].swallow);
251 edje_object_part_swallow(wd->cov, buf, wd->subs[i].obj);
256 _elm_hover_smart_content_location_get(Widget_Data *wd, Evas_Coord spc_l, Evas_Coord spc_t, Evas_Coord spc_r, Evas_Coord spc_b)
258 Evas_Coord c_w = 0, c_h = 0, mid_w, mid_h;
261 evas_object_size_hint_min_get(wd->smt_sub, &c_w, &c_h);
268 max = MAX(spc_t, spc_r);
269 max = MAX(max, spc_b);
274 return _HOV_TOP_RIGHT;
282 return _HOV_BOTTOM_RIGHT;
283 else if (mid_h > spc_b)
284 return _HOV_TOP_RIGHT;
290 return _HOV_BOTTOM_RIGHT;
295 max = MAX(spc_t, spc_l);
296 max = MAX(max, spc_b);
301 return _HOV_TOP_LEFT;
309 return _HOV_BOTTOM_LEFT;
310 else if (mid_h > spc_b)
311 return _HOV_TOP_LEFT;
317 return _HOV_BOTTOM_LEFT;
323 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
329 wd = elm_widget_data_get(obj);
335 if (wd->smt_sub == sub)
340 ELM_HOVER_PARTS_FOREACH
342 if (wd->subs[i].obj == sub)
344 wd->subs[i].obj = NULL;
352 _hov_show_do(Evas_Object *obj)
354 Widget_Data *wd = elm_widget_data_get(obj);
360 evas_object_show(wd->cov);
361 edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
364 ELM_HOVER_PARTS_FOREACH
370 snprintf(buf, sizeof(buf), "elm,action,slot,%s,show",
371 wd->subs[i].swallow);
372 edje_object_signal_emit(wd->cov, buf, "elm");
378 _hov_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
384 _hov_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
390 _hov_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
396 _hov_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
398 Widget_Data *wd = elm_widget_data_get(data);
402 edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
403 evas_object_hide(wd->cov);
406 ELM_HOVER_PARTS_FOREACH
412 snprintf(buf, sizeof(buf), "elm,action,slot,%s,hide",
413 wd->subs[i].swallow);
414 edje_object_signal_emit(wd->cov, buf, "elm");
420 _target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
422 Widget_Data *wd = elm_widget_data_get(data);
428 _target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
430 Widget_Data *wd = elm_widget_data_get(data);
435 _elm_hover_sub_obj_placement_eval(data);
439 _signal_dismiss(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
441 Widget_Data *wd = elm_widget_data_get(data);
443 evas_object_hide(data);
444 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
448 _parent_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
454 _parent_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
460 _parent_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
465 _parent_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
467 Widget_Data *wd = elm_widget_data_get(data);
469 evas_object_hide(wd->cov);
473 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
475 Widget_Data *wd = elm_widget_data_get(data);
477 elm_hover_parent_set(data, NULL);
482 * Adds a hover object to @p parent
484 * @param parent The parent object
485 * @return The hover object or NULL if one could not be created
490 elm_hover_add(Evas_Object *parent)
496 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
498 wd = ELM_NEW(Widget_Data);
500 ELM_HOVER_PARTS_FOREACH
501 wd->subs[i].swallow = _directions[i];
503 e = evas_object_evas_get(parent);
505 obj = elm_widget_add(e);
506 ELM_SET_WIDTYPE(widtype, "hover");
507 elm_widget_type_set(obj, "hover");
508 elm_widget_sub_object_add(parent, obj);
509 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
510 elm_widget_data_set(obj, wd);
511 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
512 elm_widget_theme_hook_set(obj, _theme_hook);
513 elm_widget_del_hook_set(obj, _del_hook);
514 elm_widget_can_focus_set(obj, EINA_TRUE);
515 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
516 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
517 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
519 wd->hov = evas_object_rectangle_add(e);
520 evas_object_pass_events_set(wd->hov, EINA_TRUE);
521 evas_object_color_set(wd->hov, 0, 0, 0, 0);
522 elm_widget_resize_object_set(obj, wd->hov);
523 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
524 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
525 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
526 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
528 wd->cov = edje_object_add(e);
529 _elm_theme_object_set(obj, wd->cov, "hover", "base", "default");
530 elm_widget_sub_object_add(obj, wd->cov);
531 edje_object_signal_callback_add(wd->cov, "elm,action,dismiss", "",
532 _signal_dismiss, obj);
534 wd->offset = evas_object_rectangle_add(e);
535 evas_object_pass_events_set(wd->offset, EINA_TRUE);
536 evas_object_color_set(wd->offset, 0, 0, 0, 0);
537 elm_widget_sub_object_add(obj, wd->offset);
539 wd->size = evas_object_rectangle_add(e);
540 evas_object_pass_events_set(wd->size, EINA_TRUE);
541 evas_object_color_set(wd->size, 0, 0, 0, 0);
542 elm_widget_sub_object_add(obj, wd->size);
544 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
545 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
547 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
549 elm_hover_parent_set(obj, parent);
550 evas_object_smart_callbacks_descriptions_set(obj, _signals);
552 _mirrored_set(obj, elm_widget_mirrored_get(obj));
558 * Sets the target object for the hover.
560 * @param obj The hover object
561 * @param target The object to center the hover onto. The hover
562 * will take up the entire space that the target object fills.
567 elm_hover_target_set(Evas_Object *obj, Evas_Object *target)
569 ELM_CHECK_WIDTYPE(obj, widtype);
570 Widget_Data *wd = elm_widget_data_get(obj);
574 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_DEL,
576 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_MOVE,
582 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_DEL,
584 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_MOVE,
586 elm_widget_hover_object_set(target, obj);
593 * Sets the parent object for the hover.
595 * @param obj The hover object
596 * @param parent The object to locate the hover over.
601 elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
603 ELM_CHECK_WIDTYPE(obj, widtype);
604 Widget_Data *wd = elm_widget_data_get(obj);
608 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_MOVE,
610 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
611 _parent_resize, obj);
612 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_SHOW,
614 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_HIDE,
616 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL,
622 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_MOVE,
624 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE,
625 _parent_resize, obj);
626 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_SHOW,
628 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_HIDE,
630 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL,
632 // elm_widget_sub_object_add(parent, obj);
638 * Gets the target object for the hover.
640 * @param obj The hover object
641 * @return The target object of the hover.
646 elm_hover_target_get(const Evas_Object *obj)
648 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
649 Widget_Data *wd = elm_widget_data_get(obj);
650 if (!wd) return NULL;
656 * Gets the parent object for the hover.
658 * @param obj The hover object
659 * @return The parent object to locate the hover over.
664 elm_hover_parent_get(const Evas_Object *obj)
666 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
667 Widget_Data *wd = elm_widget_data_get(obj);
668 if (!wd) return NULL;
674 _elm_hover_subs_del(Widget_Data *wd)
676 ELM_HOVER_PARTS_FOREACH
680 evas_object_del(wd->subs[i].obj);
681 wd->subs[i].obj = NULL;
687 _elm_hover_sub_obj_placement_eval(Evas_Object *obj)
689 Evas_Coord spc_l, spc_r, spc_t, spc_b;
690 const char *smart_dir;
694 wd = elm_widget_data_get(obj);
698 _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
700 edje_object_part_unswallow(wd->cov, wd->smt_sub);
702 smart_dir = _elm_hover_smart_content_location_get(wd, spc_l, spc_t, spc_r,
704 evas_object_smart_callback_call(obj, SIG_SMART_LOCATION_CHANGED,
707 if (elm_widget_mirrored_get(obj))
709 if (smart_dir == _HOV_BOTTOM_LEFT)
710 smart_dir = _HOV_BOTTOM_RIGHT;
711 else if (smart_dir == _HOV_BOTTOM_RIGHT)
712 smart_dir = _HOV_BOTTOM_LEFT;
713 else if (smart_dir == _HOV_RIGHT)
714 smart_dir = _HOV_LEFT;
715 else if (smart_dir == _HOV_LEFT)
716 smart_dir = _HOV_RIGHT;
717 else if (smart_dir == _HOV_TOP_RIGHT)
718 smart_dir = _HOV_TOP_LEFT;
719 else if (smart_dir == _HOV_TOP_LEFT)
720 smart_dir = _HOV_TOP_RIGHT;
722 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", smart_dir);
723 edje_object_part_swallow(wd->cov, buf, wd->smt_sub);
727 _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
729 _elm_hover_sub_obj_placement_eval(data);
733 * Sets the content of the hover object and the direction in which
736 * Once the content object is set for a given direction, a previously
737 * set one (on the same direction) will be deleted. If you want to
738 * keep that old content object, use the elm_hover_content_unset()
741 * @param obj The hover object
742 * @param swallow The direction that the object will be displayed
743 * at. Accepted values are "left", "top-left", "top", "top-right",
744 * "right", "bottom-right", "bottom", "bottom-left", "middle" and
746 * @param content The content to place at @p swallow
748 * All directions may have contents at the same time, except for
749 * "smart". This is a special placement hint and its use case
750 * independs of the calculations coming from
751 * elm_hover_best_content_location_get(). Its use is for cases when
752 * one desires only one hover content, but with a dinamic special
753 * placement within the hover area. The content's geometry, whenever
754 * it changes, will be used to decide on a best location not
755 * extrapolating the hover's parent object view to show it in (still
756 * being the hover's target determinant of its medium part -- move and
757 * resize it to simulate finger sizes, for example). If one of the
758 * directions other than "smart" are used, a previously content set
759 * using it will be deleted, and vice-versa.
764 elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
766 ELM_CHECK_WIDTYPE(obj, widtype);
770 wd = elm_widget_data_get(obj);
774 if (!strcmp(swallow, "smart"))
776 if (wd->smt_sub != content)
778 _elm_hover_subs_del(wd);
779 wd->smt_sub = content;
784 elm_widget_sub_object_add(obj, content);
785 evas_object_event_callback_add(wd->smt_sub,
786 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
787 _elm_hover_sub_obj_placement_eval_cb,
790 _elm_hover_sub_obj_placement_eval(obj);
798 evas_object_del(wd->smt_sub);
802 ELM_HOVER_PARTS_FOREACH
804 if (!strcmp(swallow, wd->subs[i].swallow))
806 if (content == wd->subs[i].obj)
808 evas_object_del(wd->subs[i].obj);
809 wd->subs[i].obj = NULL;
815 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
816 elm_widget_sub_object_add(obj, content);
817 edje_object_part_swallow(wd->cov, buf, content);
818 wd->subs[i].obj = content;
829 * Get the content of the hover object, in a given direction.
831 * Return the content object which was set for this widget in the
834 * @param obj The hover object
835 * @param swallow The direction that the object was display at.
836 * @return The content that was being used
838 * @note See elm_hover_content_set() for more information.
843 elm_hover_content_get(const Evas_Object *obj, const char *swallow)
845 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
849 wd = elm_widget_data_get(obj);
853 if (!strcmp(swallow, "smart"))
856 ELM_HOVER_PARTS_FOREACH
857 if (!strcmp(swallow, wd->subs[i].swallow))
858 return wd->subs[i].obj;
864 _elm_hover_sub_obj_unparent(Evas_Object *obj)
868 wd = elm_widget_data_get(obj);
870 elm_widget_sub_object_del(obj, wd->smt_sub);
871 evas_object_event_callback_del_full(wd->smt_sub,
872 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
873 _elm_hover_sub_obj_placement_eval_cb,
875 edje_object_part_unswallow(wd->cov, wd->smt_sub);
880 * Unset the content of the hover object, in a given direction.
882 * Unparent and return the content object set at that direction.
884 * @param obj The hover object
885 * @param swallow The direction that the object was display at.
886 * @return The content that was being used.
888 * @note See elm_hover_content_set() for more information.
893 elm_hover_content_unset(Evas_Object *obj, const char *swallow)
895 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
899 wd = elm_widget_data_get(obj);
903 if (!strcmp(swallow, "smart"))
905 Evas_Object *content;
910 content = wd->smt_sub;
911 _elm_hover_sub_obj_unparent(obj);
915 ELM_HOVER_PARTS_FOREACH
917 if (!strcmp(swallow, wd->subs[i].swallow))
919 Evas_Object *content;
921 if (!wd->subs[i].obj)
924 content = wd->subs[i].obj;
925 elm_widget_sub_object_del(obj, wd->subs[i].obj);
926 edje_object_part_unswallow(wd->cov, wd->subs[i].obj);
927 wd->subs[i].obj = NULL;
937 * Returns the best swallow location for content in the hover.
939 * @param obj The hover object
940 * @param pref_axis The preferred orientation axis for the hover object to use
941 * @return The edje location to place content into the hover or @c
944 * @p pref_axis may be one of
946 * - @c ELM_HOVER_AXIS_NONE -- no prefered orientation
947 * - @c ELM_HOVER_AXIS_HORIZONTAL -- horizontal
948 * - @c ELM_HOVER_AXIS_VERTICAL -- vertical
949 * - @c ELM_HOVER_AXIS_BOTH -- both
952 * See also elm_hover_content_set().
957 elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis)
959 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
961 Evas_Coord spc_l, spc_r, spc_t, spc_b;
964 wd = elm_widget_data_get(obj);
968 _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
970 if (pref_axis == ELM_HOVER_AXIS_HORIZONTAL)
972 if (spc_l < spc_r) return _HOV_RIGHT;
973 else return _HOV_LEFT;
975 else if (pref_axis == ELM_HOVER_AXIS_VERTICAL)
977 if (spc_t < spc_b) return _HOV_BOTTOM;
978 else return _HOV_TOP;
983 if (spc_t > spc_r) return _HOV_TOP;
984 else if (spc_b > spc_r) return _HOV_BOTTOM;
987 if (spc_t > spc_r) return _HOV_TOP;
988 else if (spc_b > spc_r) return _HOV_BOTTOM;