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 _mirrored_set(obj, elm_widget_mirrored_get(obj));
144 // FIXME: hover contents doesn't seem to propagate resizes properly
145 _elm_theme_object_set(obj, wd->cov, "hover", "base", elm_widget_style_get(obj));
146 edje_object_scale_set(wd->cov, elm_widget_scale_get(obj) *
150 _elm_hover_sub_obj_placement_eval(obj);
154 if (evas_object_visible_get(wd->cov)) _hov_show_do(obj);
158 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
162 wd = elm_widget_data_get(obj);
166 edje_object_signal_emit(wd->cov, emission, source);
170 _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)
174 wd = elm_widget_data_get(obj);
178 edje_object_signal_callback_add(wd->hov, emission, source, func_cb, data);
182 _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)
186 wd = elm_widget_data_get(obj);
188 edje_object_signal_callback_del_full(wd->hov, emission, source, func_cb,
193 _elm_hover_left_space_calc(Widget_Data *wd, Evas_Coord *spc_l, Evas_Coord *spc_t, Evas_Coord *spc_r, Evas_Coord *spc_b)
195 Evas_Coord x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
198 evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
200 evas_object_geometry_get(wd->target, &x2, &y2, &w2, &h2);
203 *spc_r = (x + w) - (x2 + w2);
210 *spc_b = (y + h) - (y2 + h2);
218 _sizing_eval(Evas_Object *obj)
220 Widget_Data *wd = elm_widget_data_get(obj);
221 Evas_Coord ofs_x, x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
223 if (wd->parent) evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
224 if (wd->hov) evas_object_geometry_get(wd->hov, &x2, &y2, &w2, &h2);
226 if (elm_widget_mirrored_get(obj))
227 ofs_x = w - (x2 - x) - w2;
231 evas_object_move(wd->cov, x, y);
232 evas_object_resize(wd->cov, w, h);
233 evas_object_size_hint_min_set(wd->offset, ofs_x, y2 - y);
234 evas_object_size_hint_min_set(wd->size, w2, h2);
235 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
236 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
240 _reval_content(Evas_Object *obj)
242 Widget_Data *wd = elm_widget_data_get(obj);
246 ELM_HOVER_PARTS_FOREACH
249 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", wd->subs[i].swallow);
250 edje_object_part_swallow(wd->cov, buf, wd->subs[i].obj);
255 _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)
257 Evas_Coord c_w = 0, c_h = 0, mid_w, mid_h;
260 evas_object_size_hint_min_get(wd->smt_sub, &c_w, &c_h);
267 max = MAX(spc_t, spc_r);
268 max = MAX(max, spc_b);
273 return _HOV_TOP_RIGHT;
281 return _HOV_BOTTOM_RIGHT;
282 else if (mid_h > spc_b)
283 return _HOV_TOP_RIGHT;
289 return _HOV_BOTTOM_RIGHT;
294 max = MAX(spc_t, spc_l);
295 max = MAX(max, spc_b);
300 return _HOV_TOP_LEFT;
308 return _HOV_BOTTOM_LEFT;
309 else if (mid_h > spc_b)
310 return _HOV_TOP_LEFT;
316 return _HOV_BOTTOM_LEFT;
322 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
328 wd = elm_widget_data_get(obj);
334 if (wd->smt_sub == sub)
339 ELM_HOVER_PARTS_FOREACH
341 if (wd->subs[i].obj == sub)
343 wd->subs[i].obj = NULL;
351 _hov_show_do(Evas_Object *obj)
353 Widget_Data *wd = elm_widget_data_get(obj);
359 evas_object_show(wd->cov);
360 edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
363 ELM_HOVER_PARTS_FOREACH
369 snprintf(buf, sizeof(buf), "elm,action,slot,%s,show",
370 wd->subs[i].swallow);
371 edje_object_signal_emit(wd->cov, buf, "elm");
377 _hov_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
383 _hov_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
389 _hov_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
395 _hov_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
397 Widget_Data *wd = elm_widget_data_get(data);
401 edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
402 evas_object_hide(wd->cov);
405 ELM_HOVER_PARTS_FOREACH
411 snprintf(buf, sizeof(buf), "elm,action,slot,%s,hide",
412 wd->subs[i].swallow);
413 edje_object_signal_emit(wd->cov, buf, "elm");
419 _target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
421 Widget_Data *wd = elm_widget_data_get(data);
427 _target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
429 Widget_Data *wd = elm_widget_data_get(data);
434 _elm_hover_sub_obj_placement_eval(data);
438 _signal_dismiss(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
440 Widget_Data *wd = elm_widget_data_get(data);
442 evas_object_hide(data);
443 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
447 _parent_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
453 _parent_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
459 _parent_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
464 _parent_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
466 Widget_Data *wd = elm_widget_data_get(data);
468 evas_object_hide(wd->cov);
472 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
474 Widget_Data *wd = elm_widget_data_get(data);
476 elm_hover_parent_set(data, NULL);
481 * Adds a hover object to @p parent
483 * @param parent The parent object
484 * @return The hover object or NULL if one could not be created
489 elm_hover_add(Evas_Object *parent)
495 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
497 wd = ELM_NEW(Widget_Data);
499 ELM_HOVER_PARTS_FOREACH
500 wd->subs[i].swallow = _directions[i];
502 e = evas_object_evas_get(parent);
504 obj = elm_widget_add(e);
505 ELM_SET_WIDTYPE(widtype, "hover");
506 elm_widget_type_set(obj, "hover");
507 elm_widget_sub_object_add(parent, obj);
508 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
509 elm_widget_data_set(obj, wd);
510 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
511 elm_widget_theme_hook_set(obj, _theme_hook);
512 elm_widget_del_hook_set(obj, _del_hook);
513 elm_widget_can_focus_set(obj, EINA_TRUE);
514 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
515 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
516 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
518 wd->hov = evas_object_rectangle_add(e);
519 evas_object_pass_events_set(wd->hov, EINA_TRUE);
520 evas_object_color_set(wd->hov, 0, 0, 0, 0);
521 elm_widget_resize_object_set(obj, wd->hov);
522 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
523 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
524 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
525 evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
527 wd->cov = edje_object_add(e);
528 _elm_theme_object_set(obj, wd->cov, "hover", "base", "default");
529 elm_widget_sub_object_add(obj, wd->cov);
530 edje_object_signal_callback_add(wd->cov, "elm,action,dismiss", "",
531 _signal_dismiss, obj);
533 wd->offset = evas_object_rectangle_add(e);
534 evas_object_pass_events_set(wd->offset, EINA_TRUE);
535 evas_object_color_set(wd->offset, 0, 0, 0, 0);
536 elm_widget_sub_object_add(obj, wd->offset);
538 wd->size = evas_object_rectangle_add(e);
539 evas_object_pass_events_set(wd->size, EINA_TRUE);
540 evas_object_color_set(wd->size, 0, 0, 0, 0);
541 elm_widget_sub_object_add(obj, wd->size);
543 edje_object_part_swallow(wd->cov, "elm.swallow.offset", wd->offset);
544 edje_object_part_swallow(wd->cov, "elm.swallow.size", wd->size);
546 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
548 elm_hover_parent_set(obj, parent);
549 evas_object_smart_callbacks_descriptions_set(obj, _signals);
551 _mirrored_set(obj, elm_widget_mirrored_get(obj));
557 * Sets the target object for the hover.
559 * @param obj The hover object
560 * @param target The object to center the hover onto. The hover
561 * will take up the entire space that the target object fills.
566 elm_hover_target_set(Evas_Object *obj, Evas_Object *target)
568 ELM_CHECK_WIDTYPE(obj, widtype);
569 Widget_Data *wd = elm_widget_data_get(obj);
573 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_DEL,
575 evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_MOVE,
581 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_DEL,
583 evas_object_event_callback_add(wd->target, EVAS_CALLBACK_MOVE,
585 elm_widget_hover_object_set(target, obj);
592 * Sets the parent object for the hover.
594 * @param obj The hover object
595 * @param parent The object to locate the hover over.
600 elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
602 ELM_CHECK_WIDTYPE(obj, widtype);
603 Widget_Data *wd = elm_widget_data_get(obj);
607 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_MOVE,
609 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
610 _parent_resize, obj);
611 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_SHOW,
613 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_HIDE,
615 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL,
621 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_MOVE,
623 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE,
624 _parent_resize, obj);
625 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_SHOW,
627 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_HIDE,
629 evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL,
631 // elm_widget_sub_object_add(parent, obj);
637 * Gets the target object for the hover.
639 * @param obj The hover object
640 * @return The target object of the hover.
645 elm_hover_target_get(const Evas_Object *obj)
647 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
648 Widget_Data *wd = elm_widget_data_get(obj);
649 if (!wd) return NULL;
655 * Gets the parent object for the hover.
657 * @param obj The hover object
658 * @return The parent object to locate the hover over.
663 elm_hover_parent_get(const Evas_Object *obj)
665 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
666 Widget_Data *wd = elm_widget_data_get(obj);
667 if (!wd) return NULL;
673 _elm_hover_subs_del(Widget_Data *wd)
675 ELM_HOVER_PARTS_FOREACH
679 evas_object_del(wd->subs[i].obj);
680 wd->subs[i].obj = NULL;
686 _elm_hover_sub_obj_placement_eval(Evas_Object *obj)
688 Evas_Coord spc_l, spc_r, spc_t, spc_b;
689 const char *smart_dir;
693 wd = elm_widget_data_get(obj);
697 _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
699 edje_object_part_unswallow(wd->cov, wd->smt_sub);
701 smart_dir = _elm_hover_smart_content_location_get(wd, spc_l, spc_t, spc_r,
703 evas_object_smart_callback_call(obj, SIG_SMART_LOCATION_CHANGED,
706 if (elm_widget_mirrored_get(obj))
708 if (smart_dir == _HOV_BOTTOM_LEFT)
709 smart_dir = _HOV_BOTTOM_RIGHT;
710 else if (smart_dir == _HOV_BOTTOM_RIGHT)
711 smart_dir = _HOV_BOTTOM_LEFT;
712 else if (smart_dir == _HOV_RIGHT)
713 smart_dir = _HOV_LEFT;
714 else if (smart_dir == _HOV_LEFT)
715 smart_dir = _HOV_RIGHT;
716 else if (smart_dir == _HOV_TOP_RIGHT)
717 smart_dir = _HOV_TOP_LEFT;
718 else if (smart_dir == _HOV_TOP_LEFT)
719 smart_dir = _HOV_TOP_RIGHT;
721 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", smart_dir);
722 edje_object_part_swallow(wd->cov, buf, wd->smt_sub);
726 _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
728 _elm_hover_sub_obj_placement_eval(data);
732 * Sets the content of the hover object and the direction in which
735 * Once the content object is set for a given direction, a previously
736 * set one (on the same direction) will be deleted. If you want to
737 * keep that old content object, use the elm_hover_content_unset()
740 * @param obj The hover object
741 * @param swallow The direction that the object will be displayed
742 * at. Accepted values are "left", "top-left", "top", "top-right",
743 * "right", "bottom-right", "bottom", "bottom-left", "middle" and
745 * @param content The content to place at @p swallow
747 * All directions may have contents at the same time, except for
748 * "smart". This is a special placement hint and its use case
749 * independs of the calculations coming from
750 * elm_hover_best_content_location_get(). Its use is for cases when
751 * one desires only one hover content, but with a dinamic special
752 * placement within the hover area. The content's geometry, whenever
753 * it changes, will be used to decide on a best location not
754 * extrapolating the hover's parent object view to show it in (still
755 * being the hover's target determinant of its medium part -- move and
756 * resize it to simulate finger sizes, for example). If one of the
757 * directions other than "smart" are used, a previously content set
758 * using it will be deleted, and vice-versa.
763 elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
765 ELM_CHECK_WIDTYPE(obj, widtype);
769 wd = elm_widget_data_get(obj);
773 if (!strcmp(swallow, "smart"))
775 if (wd->smt_sub != content)
777 _elm_hover_subs_del(wd);
778 wd->smt_sub = content;
783 elm_widget_sub_object_add(obj, content);
784 evas_object_event_callback_add(wd->smt_sub,
785 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
786 _elm_hover_sub_obj_placement_eval_cb,
789 _elm_hover_sub_obj_placement_eval(obj);
797 evas_object_del(wd->smt_sub);
801 ELM_HOVER_PARTS_FOREACH
803 if (!strcmp(swallow, wd->subs[i].swallow))
805 if (content == wd->subs[i].obj)
807 evas_object_del(wd->subs[i].obj);
808 wd->subs[i].obj = NULL;
814 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
815 elm_widget_sub_object_add(obj, content);
816 edje_object_part_swallow(wd->cov, buf, content);
817 wd->subs[i].obj = content;
828 * Get the content of the hover object, in a given direction.
830 * Return the content object which was set for this widget in the
833 * @param obj The hover object
834 * @param swallow The direction that the object was display at.
835 * @return The content that was being used
837 * @note See elm_hover_content_set() for more information.
842 elm_hover_content_get(const Evas_Object *obj, const char *swallow)
844 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
848 wd = elm_widget_data_get(obj);
852 if (!strcmp(swallow, "smart"))
855 ELM_HOVER_PARTS_FOREACH
856 if (!strcmp(swallow, wd->subs[i].swallow))
857 return wd->subs[i].obj;
863 _elm_hover_sub_obj_unparent(Evas_Object *obj)
867 wd = elm_widget_data_get(obj);
869 elm_widget_sub_object_del(obj, wd->smt_sub);
870 evas_object_event_callback_del_full(wd->smt_sub,
871 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
872 _elm_hover_sub_obj_placement_eval_cb,
874 edje_object_part_unswallow(wd->cov, wd->smt_sub);
879 * Unset the content of the hover object, in a given direction.
881 * Unparent and return the content object set at that direction.
883 * @param obj The hover object
884 * @param swallow The direction that the object was display at.
885 * @return The content that was being used.
887 * @note See elm_hover_content_set() for more information.
892 elm_hover_content_unset(Evas_Object *obj, const char *swallow)
894 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
898 wd = elm_widget_data_get(obj);
902 if (!strcmp(swallow, "smart"))
904 Evas_Object *content;
909 content = wd->smt_sub;
910 _elm_hover_sub_obj_unparent(obj);
914 ELM_HOVER_PARTS_FOREACH
916 if (!strcmp(swallow, wd->subs[i].swallow))
918 Evas_Object *content;
920 if (!wd->subs[i].obj)
923 content = wd->subs[i].obj;
924 elm_widget_sub_object_del(obj, wd->subs[i].obj);
925 edje_object_part_unswallow(wd->cov, wd->subs[i].obj);
926 wd->subs[i].obj = NULL;
936 * Returns the best swallow location for content in the hover.
938 * @param obj The hover object
939 * @param pref_axis The preferred orientation axis for the hover object to use
940 * @return The edje location to place content into the hover or @c
943 * @p pref_axis may be one of
945 * - @c ELM_HOVER_AXIS_NONE -- no prefered orientation
946 * - @c ELM_HOVER_AXIS_HORIZONTAL -- horizontal
947 * - @c ELM_HOVER_AXIS_VERTICAL -- vertical
948 * - @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;