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
15 * Signals that you can add callbacks for are:
17 * "clicked" - the user clicked the empty space in the hover to dismiss
18 * "smart,changed" - a content object placed under the "smart"
19 * policy was replaced to a new slot direction.
22 typedef struct _Widget_Data Widget_Data;
23 typedef struct _Content_Info Content_Info;
26 # define MAX(a, b) (((a) > (b)) ? (a) : (b))
29 #define ELM_HOVER_PARTS_FOREACH unsigned int i = 0; \
30 for (i = 0; i < sizeof(wd->subs) / sizeof(wd->subs[0]); i++)
32 static const char *_directions[] = {
44 #define _HOV_LEFT (_directions[0])
45 #define _HOV_TOP_LEFT (_directions[1])
46 #define _HOV_TOP (_directions[2])
47 #define _HOV_TOP_RIGHT (_directions[2])
48 #define _HOV_RIGHT (_directions[4])
49 #define _HOV_BOTTOM_RIGHT (_directions[5])
50 #define _HOV_BOTTOM (_directions[6])
51 #define _HOV_BOTTOM_LEFT (_directions[7])
52 #define _HOV_MIDDLE (_directions[8])
62 Evas_Object *hov, *cov;
63 Evas_Object *offset, *size;
64 Evas_Object *parent, *target;
66 Content_Info subs[sizeof(_directions)/sizeof(_directions[0])];
69 static const char *widtype = NULL;
70 static void _del_pre_hook(Evas_Object *obj);
71 static void _del_hook(Evas_Object *obj);
72 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
73 static void _theme_hook(Evas_Object *obj);
74 static void _sizing_eval(Evas_Object *obj);
75 static void _reval_content(Evas_Object *obj);
76 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
77 static void _hov_show_do(Evas_Object *obj);
78 static void _hov_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
79 static void _hov_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
80 static void _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
81 static void _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
82 static void _on_focus_hook(void *data, Evas_Object *obj);
83 static void _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
84 static void _elm_hover_sub_obj_placement_eval(Evas_Object *obj);
86 static const char SIG_CLICKED[] = "clicked";
87 static const char SIG_SMART_LOCATION_CHANGED[] = "smart,changed";
88 static const Evas_Smart_Cb_Description _signals[] = {
90 {SIG_SMART_LOCATION_CHANGED, ""},
95 _del_pre_hook(Evas_Object *obj)
97 Widget_Data *wd = elm_widget_data_get(obj);
101 if (evas_object_visible_get(obj))
102 evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
103 elm_hover_target_set(obj, NULL);
104 elm_hover_parent_set(obj, NULL);
105 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
106 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
107 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
108 evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
112 _del_hook(Evas_Object *obj)
114 Widget_Data *wd = elm_widget_data_get(obj);
120 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
122 Widget_Data *wd = elm_widget_data_get(obj);
124 if (elm_widget_focus_get(obj))
126 edje_object_signal_emit(wd->cov, "elm,action,focus", "elm");
127 evas_object_focus_set(wd->cov, EINA_TRUE);
131 edje_object_signal_emit(wd->cov, "elm,action,unfocus", "elm");
132 evas_object_focus_set(wd->cov, EINA_FALSE);
137 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
139 Widget_Data *wd = elm_widget_data_get(obj);
141 edje_object_mirrored_set(wd->cov, rtl);
145 _theme_hook(Evas_Object *obj)
147 Widget_Data *wd = elm_widget_data_get(obj);
149 _elm_widget_mirrored_reload(obj);
150 _mirrored_set(obj, elm_widget_mirrored_get(obj));
151 // FIXME: hover contents doesn't seem to propagate resizes properly
152 _elm_theme_object_set(obj, wd->cov, "hover", "base", elm_widget_style_get(obj));
153 edje_object_scale_set(wd->cov, elm_widget_scale_get(obj) *
157 _elm_hover_sub_obj_placement_eval(obj);
161 if (evas_object_visible_get(wd->cov)) _hov_show_do(obj);
165 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
169 wd = elm_widget_data_get(obj);
173 edje_object_signal_emit(wd->cov, emission, source);
177 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
181 wd = elm_widget_data_get(obj);
185 edje_object_signal_callback_add(wd->hov, emission, source, func_cb, data);
189 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
193 wd = elm_widget_data_get(obj);
195 edje_object_signal_callback_del_full(wd->hov, emission, source, func_cb,
200 _elm_hover_left_space_calc(Widget_Data *wd, Evas_Coord *spc_l, Evas_Coord *spc_t, Evas_Coord *spc_r, Evas_Coord *spc_b)
202 Evas_Coord x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
205 evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
207 evas_object_geometry_get(wd->target, &x2, &y2, &w2, &h2);
210 *spc_r = (x + w) - (x2 + w2);
217 *spc_b = (y + h) - (y2 + h2);
225 _sizing_eval(Evas_Object *obj)
227 Widget_Data *wd = elm_widget_data_get(obj);
228 Evas_Coord ofs_x, x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
230 if (wd->parent) evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
231 if (wd->hov) evas_object_geometry_get(wd->hov, &x2, &y2, &w2, &h2);
233 if (elm_widget_mirrored_get(obj))
234 ofs_x = w - (x2 - x) - w2;
238 evas_object_move(wd->cov, x, y);
239 evas_object_resize(wd->cov, w, h);
240 evas_object_size_hint_min_set(wd->offset, ofs_x, y2 - y);
241 evas_object_size_hint_min_set(wd->size, w2, h2);
242 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
243 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
247 _reval_content(Evas_Object *obj)
249 Widget_Data *wd = elm_widget_data_get(obj);
253 ELM_HOVER_PARTS_FOREACH
256 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", wd->subs[i].swallow);
257 edje_object_part_swallow(wd->cov, buf, wd->subs[i].obj);
262 _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)
264 Evas_Coord c_w = 0, c_h = 0, mid_w, mid_h;
267 evas_object_size_hint_min_get(wd->smt_sub, &c_w, &c_h);
274 max = MAX(spc_t, spc_r);
275 max = MAX(max, spc_b);
280 return _HOV_TOP_RIGHT;
288 return _HOV_BOTTOM_RIGHT;
289 else if (mid_h > spc_b)
290 return _HOV_TOP_RIGHT;
296 return _HOV_BOTTOM_RIGHT;
301 max = MAX(spc_t, spc_l);
302 max = MAX(max, spc_b);
307 return _HOV_TOP_LEFT;
315 return _HOV_BOTTOM_LEFT;
316 else if (mid_h > spc_b)
317 return _HOV_TOP_LEFT;
323 return _HOV_BOTTOM_LEFT;
329 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
335 wd = elm_widget_data_get(obj);
341 if (wd->smt_sub == sub)
346 ELM_HOVER_PARTS_FOREACH
348 if (wd->subs[i].obj == sub)
350 wd->subs[i].obj = NULL;
358 _hov_show_do(Evas_Object *obj)
360 Widget_Data *wd = elm_widget_data_get(obj);
366 evas_object_show(wd->cov);
367 edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
370 ELM_HOVER_PARTS_FOREACH
376 snprintf(buf, sizeof(buf), "elm,action,slot,%s,show",
377 wd->subs[i].swallow);
378 edje_object_signal_emit(wd->cov, buf, "elm");
384 _hov_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
390 _hov_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
396 _hov_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
402 _hov_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
404 Widget_Data *wd = elm_widget_data_get(data);
408 edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
409 evas_object_hide(wd->cov);
412 ELM_HOVER_PARTS_FOREACH
418 snprintf(buf, sizeof(buf), "elm,action,slot,%s,hide",
419 wd->subs[i].swallow);
420 edje_object_signal_emit(wd->cov, buf, "elm");
426 _target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
428 Widget_Data *wd = elm_widget_data_get(data);
434 _target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
436 Widget_Data *wd = elm_widget_data_get(data);
441 _elm_hover_sub_obj_placement_eval(data);
445 _signal_dismiss(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
447 Widget_Data *wd = elm_widget_data_get(data);
449 evas_object_hide(data);
450 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
454 _parent_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
460 _parent_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
466 _parent_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
471 _parent_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
473 Widget_Data *wd = elm_widget_data_get(data);
475 evas_object_hide(wd->cov);
479 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
481 Widget_Data *wd = elm_widget_data_get(data);
483 elm_hover_parent_set(data, NULL);
488 * Adds a hover object to @p parent
490 * @param parent The parent object
491 * @return The hover object or NULL if one could not be created
496 elm_hover_add(Evas_Object *parent)
502 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
504 ELM_SET_WIDTYPE(widtype, "hover");
505 elm_widget_type_set(obj, "hover");
506 elm_widget_sub_object_add(parent, obj);
507 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
508 elm_widget_data_set(obj, wd);
509 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
510 elm_widget_theme_hook_set(obj, _theme_hook);
511 elm_widget_del_hook_set(obj, _del_hook);
512 elm_widget_can_focus_set(obj, EINA_TRUE);
513 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
514 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
515 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
517 ELM_HOVER_PARTS_FOREACH
518 wd->subs[i].swallow = _directions[i];
520 wd->hov = evas_object_rectangle_add(e);
521 evas_object_pass_events_set(wd->hov, EINA_TRUE);
522 evas_object_color_set(wd->hov, 0, 0, 0, 0);
523 elm_widget_resize_object_set(obj, wd->hov);
524 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
525 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
526 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
527 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
529 wd->cov = edje_object_add(e);
530 _elm_theme_object_set(obj, wd->cov, "hover", "base", "default");
531 elm_widget_sub_object_add(obj, wd->cov);
532 edje_object_signal_callback_add(wd->cov, "elm,action,dismiss", "",
533 _signal_dismiss, obj);
535 wd->offset = evas_object_rectangle_add(e);
536 evas_object_pass_events_set(wd->offset, EINA_TRUE);
537 evas_object_color_set(wd->offset, 0, 0, 0, 0);
538 elm_widget_sub_object_add(obj, wd->offset);
540 wd->size = evas_object_rectangle_add(e);
541 evas_object_pass_events_set(wd->size, EINA_TRUE);
542 evas_object_color_set(wd->size, 0, 0, 0, 0);
543 elm_widget_sub_object_add(obj, wd->size);
545 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
546 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
548 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
550 elm_hover_parent_set(obj, parent);
551 evas_object_smart_callbacks_descriptions_set(obj, _signals);
553 _mirrored_set(obj, elm_widget_mirrored_get(obj));
559 * Sets the target object for the hover.
561 * @param obj The hover object
562 * @param target The object to center the hover onto. The hover
563 * will take up the entire space that the target object fills.
568 elm_hover_target_set(Evas_Object *obj, Evas_Object *target)
570 ELM_CHECK_WIDTYPE(obj, widtype);
571 Widget_Data *wd = elm_widget_data_get(obj);
575 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_DEL,
577 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_MOVE,
583 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_DEL,
585 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_MOVE,
587 elm_widget_hover_object_set(target, obj);
594 * Sets the parent object for the hover.
596 * @param obj The hover object
597 * @param parent The object to locate the hover over.
602 elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
604 ELM_CHECK_WIDTYPE(obj, widtype);
605 Widget_Data *wd = elm_widget_data_get(obj);
609 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_MOVE,
611 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
612 _parent_resize, obj);
613 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_SHOW,
615 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_HIDE,
617 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL,
623 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_MOVE,
625 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE,
626 _parent_resize, obj);
627 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_SHOW,
629 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_HIDE,
631 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL,
633 // elm_widget_sub_object_add(parent, obj);
639 * Gets the target object for the hover.
641 * @param obj The hover object
642 * @return The target object of the hover.
647 elm_hover_target_get(const Evas_Object *obj)
649 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
650 Widget_Data *wd = elm_widget_data_get(obj);
651 if (!wd) return NULL;
657 * Gets the parent object for the hover.
659 * @param obj The hover object
660 * @return The parent object to locate the hover over.
665 elm_hover_parent_get(const Evas_Object *obj)
667 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
668 Widget_Data *wd = elm_widget_data_get(obj);
669 if (!wd) return NULL;
675 _elm_hover_subs_del(Widget_Data *wd)
677 ELM_HOVER_PARTS_FOREACH
681 evas_object_del(wd->subs[i].obj);
682 wd->subs[i].obj = NULL;
688 _elm_hover_sub_obj_placement_eval(Evas_Object *obj)
690 Evas_Coord spc_l, spc_r, spc_t, spc_b;
691 const char *smart_dir;
695 wd = elm_widget_data_get(obj);
699 _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
701 edje_object_part_unswallow(wd->cov, wd->smt_sub);
703 smart_dir = _elm_hover_smart_content_location_get(wd, spc_l, spc_t, spc_r,
705 evas_object_smart_callback_call(obj, SIG_SMART_LOCATION_CHANGED,
708 if (elm_widget_mirrored_get(obj))
710 if (smart_dir == _HOV_BOTTOM_LEFT)
711 smart_dir = _HOV_BOTTOM_RIGHT;
712 else if (smart_dir == _HOV_BOTTOM_RIGHT)
713 smart_dir = _HOV_BOTTOM_LEFT;
714 else if (smart_dir == _HOV_RIGHT)
715 smart_dir = _HOV_LEFT;
716 else if (smart_dir == _HOV_LEFT)
717 smart_dir = _HOV_RIGHT;
718 else if (smart_dir == _HOV_TOP_RIGHT)
719 smart_dir = _HOV_TOP_LEFT;
720 else if (smart_dir == _HOV_TOP_LEFT)
721 smart_dir = _HOV_TOP_RIGHT;
723 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", smart_dir);
724 edje_object_part_swallow(wd->cov, buf, wd->smt_sub);
728 _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
730 _elm_hover_sub_obj_placement_eval(data);
734 * Sets the content of the hover object and the direction in which
737 * Once the content object is set for a given direction, a previously
738 * set one (on the same direction) will be deleted. If you want to
739 * keep that old content object, use the elm_hover_content_unset()
742 * @param obj The hover object
743 * @param swallow The direction that the object will be displayed
744 * at. Accepted values are "left", "top-left", "top", "top-right",
745 * "right", "bottom-right", "bottom", "bottom-left", "middle" and
747 * @param content The content to place at @p swallow
749 * All directions may have contents at the same time, except for
750 * "smart". This is a special placement hint and its use case
751 * independs of the calculations coming from
752 * elm_hover_best_content_location_get(). Its use is for cases when
753 * one desires only one hover content, but with a dinamic special
754 * placement within the hover area. The content's geometry, whenever
755 * it changes, will be used to decide on a best location not
756 * extrapolating the hover's parent object view to show it in (still
757 * being the hover's target determinant of its medium part -- move and
758 * resize it to simulate finger sizes, for example). If one of the
759 * directions other than "smart" are used, a previously content set
760 * using it will be deleted, and vice-versa.
765 elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
767 ELM_CHECK_WIDTYPE(obj, widtype);
771 wd = elm_widget_data_get(obj);
775 if (!strcmp(swallow, "smart"))
777 if (wd->smt_sub != content)
779 _elm_hover_subs_del(wd);
780 wd->smt_sub = content;
785 elm_widget_sub_object_add(obj, content);
786 evas_object_event_callback_add(wd->smt_sub,
787 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
788 _elm_hover_sub_obj_placement_eval_cb,
791 _elm_hover_sub_obj_placement_eval(obj);
799 evas_object_del(wd->smt_sub);
803 ELM_HOVER_PARTS_FOREACH
805 if (!strcmp(swallow, wd->subs[i].swallow))
807 if (content == wd->subs[i].obj)
809 evas_object_del(wd->subs[i].obj);
810 wd->subs[i].obj = NULL;
816 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
817 elm_widget_sub_object_add(obj, content);
818 edje_object_part_swallow(wd->cov, buf, content);
819 wd->subs[i].obj = content;
830 * Get the content of the hover object, in a given direction.
832 * Return the content object which was set for this widget in the
835 * @param obj The hover object
836 * @param swallow The direction that the object was display at.
837 * @return The content that was being used
839 * @note See elm_hover_content_set() for more information.
844 elm_hover_content_get(const Evas_Object *obj, const char *swallow)
846 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
850 wd = elm_widget_data_get(obj);
854 if (!strcmp(swallow, "smart"))
857 ELM_HOVER_PARTS_FOREACH
858 if (!strcmp(swallow, wd->subs[i].swallow))
859 return wd->subs[i].obj;
865 _elm_hover_sub_obj_unparent(Evas_Object *obj)
869 wd = elm_widget_data_get(obj);
871 elm_widget_sub_object_del(obj, wd->smt_sub);
872 evas_object_event_callback_del_full(wd->smt_sub,
873 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
874 _elm_hover_sub_obj_placement_eval_cb,
876 edje_object_part_unswallow(wd->cov, wd->smt_sub);
881 * Unset the content of the hover object, in a given direction.
883 * Unparent and return the content object set at that direction.
885 * @param obj The hover object
886 * @param swallow The direction that the object was display at.
887 * @return The content that was being used.
889 * @note See elm_hover_content_set() for more information.
894 elm_hover_content_unset(Evas_Object *obj, const char *swallow)
896 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
900 wd = elm_widget_data_get(obj);
904 if (!strcmp(swallow, "smart"))
906 Evas_Object *content;
911 content = wd->smt_sub;
912 _elm_hover_sub_obj_unparent(obj);
916 ELM_HOVER_PARTS_FOREACH
918 if (!strcmp(swallow, wd->subs[i].swallow))
920 Evas_Object *content;
922 if (!wd->subs[i].obj)
925 content = wd->subs[i].obj;
926 elm_widget_sub_object_del(obj, wd->subs[i].obj);
927 edje_object_part_unswallow(wd->cov, wd->subs[i].obj);
928 wd->subs[i].obj = NULL;
938 * Returns the best swallow location for content in the hover.
940 * @param obj The hover object
941 * @param pref_axis The preferred orientation axis for the hover object to use
942 * @return The edje location to place content into the hover or @c
945 * @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
951 * See also elm_hover_content_set().
956 elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis)
958 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
960 Evas_Coord spc_l, spc_r, spc_t, spc_b;
963 wd = elm_widget_data_get(obj);
967 _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
969 if (pref_axis == ELM_HOVER_AXIS_HORIZONTAL)
971 if (spc_l < spc_r) return _HOV_RIGHT;
972 else return _HOV_LEFT;
974 else if (pref_axis == ELM_HOVER_AXIS_VERTICAL)
976 if (spc_t < spc_b) return _HOV_BOTTOM;
977 else return _HOV_TOP;
982 if (spc_t > spc_r) return _HOV_TOP;
983 else if (spc_b > spc_r) return _HOV_BOTTOM;
986 if (spc_t > spc_r) return _HOV_TOP;
987 else if (spc_b > spc_r) return _HOV_BOTTOM;