* @defgroup Hover Hover
* @ingroup Elementary
*
- * A Hover object will over over the @p Parent object at the @p Target
- * location. Anything in the background will be given a darker coloring
- * to indicate that the hover object is on top.
+ * A Hover object will over its @p parent object at the @p target
+ * location. Anything in the background will be given a darker
+ * coloring to indicate that the hover object is on top (at the
+ * default theme).
*
- * NOTE: The hover object will take up the entire space of @p Target object.
+ * @note The hover object will take up the entire space of @p target
+ * object.
*/
typedef struct _Widget_Data Widget_Data;
-typedef struct _Subinfo Subinfo;
+typedef struct _Content_Info Content_Info;
+
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#define ELM_HOVER_PARTS_FOREACH unsigned int i = 0; \
+ for (i = 0; i < sizeof(wd->subs) / sizeof(wd->subs[0]); i++)
+
+static const char *_directions[] = {
+ "left",
+ "top-left",
+ "top",
+ "top-right",
+ "right",
+ "bottom-right",
+ "bottom",
+ "bottom-left",
+ "middle"
+};
+
+#define _HOV_LEFT (_directions[0])
+#define _HOV_TOP_LEFT (_directions[1])
+#define _HOV_TOP (_directions[2])
+#define _HOV_TOP_RIGHT (_directions[2])
+#define _HOV_RIGHT (_directions[4])
+#define _HOV_BOTTOM_RIGHT (_directions[5])
+#define _HOV_BOTTOM (_directions[6])
+#define _HOV_BOTTOM_LEFT (_directions[7])
+#define _HOV_MIDDLE (_directions[8])
+
+struct _Content_Info
+{
+ const char *swallow;
+ Evas_Object *obj;
+};
struct _Widget_Data
{
Evas_Object *hov, *cov;
Evas_Object *offset, *size;
Evas_Object *parent, *target;
- Eina_List *subs;
-};
-
-struct _Subinfo
-{
- const char *swallow;
- Evas_Object *obj;
+ Evas_Object *smt_sub;
+ Content_Info subs[sizeof(_directions)/sizeof(_directions[0])];
};
static const char *widtype = NULL;
static void _hov_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _on_focus_hook(void *data, Evas_Object *obj);
+static void _elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _elm_hover_sub_obj_placement_eval(Evas_Object *obj);
+
+static const char SIG_CLICKED[] = "clicked";
+static const char SIG_SMART_LOCATION_CHANGED[] = "smart,changed";
+static const Evas_Smart_Cb_Description _signals[] = {
+ {SIG_CLICKED, ""},
+ {SIG_SMART_LOCATION_CHANGED, ""},
+ {NULL, NULL}
+};
static void
_del_pre_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- Subinfo *si;
- if (!wd) return;
+ if (!wd)
+ return;
+
if (evas_object_visible_get(obj))
- evas_object_smart_callback_call(obj, "clicked", NULL);
+ evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
elm_hover_target_set(obj, NULL);
elm_hover_parent_set(obj, NULL);
evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_SHOW, _hov_show, obj);
evas_object_event_callback_del_full(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
-
- EINA_LIST_FREE(wd->subs, si)
- {
- eina_stringshare_del(si->swallow);
- free(si);
- }
}
static void
}
static void
+_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (elm_widget_focus_get(obj))
+ {
+ edje_object_signal_emit(wd->cov, "elm,action,focus", "elm");
+ evas_object_focus_set(wd->cov, EINA_TRUE);
+ }
+ else
+ {
+ edje_object_signal_emit(wd->cov, "elm,action,unfocus", "elm");
+ evas_object_focus_set(wd->cov, EINA_FALSE);
+ }
+}
+
+static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- // FIXME: hover contents doesnt seem to propagate resizes properly
+ // FIXME: hover contents doesn't seem to propagate resizes properly
_elm_theme_object_set(obj, wd->cov, "hover", "base", elm_widget_style_get(obj));
edje_object_scale_set(wd->cov, elm_widget_scale_get(obj) *
_elm_config->scale);
- _reval_content(obj);
+
+ if (wd->smt_sub)
+ _elm_hover_sub_obj_placement_eval(obj);
+ else
+ _reval_content(obj);
_sizing_eval(obj);
if (evas_object_visible_get(wd->cov)) _hov_show_do(obj);
}
+static void
+_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return;
+
+ edje_object_signal_emit(wd->cov, emission, source);
+}
+
+static void
+_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)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return;
+
+ edje_object_signal_callback_add(wd->hov, emission, source, func_cb, data);
+}
+
+static void
+_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)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+
+ edje_object_signal_callback_del_full(wd->hov, emission, source, func_cb,
+ data);
+}
+
+static void
+_elm_hover_left_space_calc(Widget_Data *wd, Evas_Coord *spc_l, Evas_Coord *spc_t, Evas_Coord *spc_r, Evas_Coord *spc_b)
+{
+ Evas_Coord x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
+
+ if (wd->parent)
+ evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
+ if (wd->target)
+ evas_object_geometry_get(wd->target, &x2, &y2, &w2, &h2);
+
+ *spc_l = x2 - x;
+ *spc_r = (x + w) - (x2 + w2);
+ if (*spc_l < 0)
+ *spc_l = 0;
+ if (*spc_r < 0)
+ *spc_r = 0;
+
+ *spc_t = y2 - y;
+ *spc_b = (y + h) - (y2 + h2);
+ if (*spc_t < 0)
+ *spc_t = 0;
+ if (*spc_b < 0)
+ *spc_b = 0;
+}
static void
_sizing_eval(Evas_Object *obj)
_reval_content(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- const Eina_List *l;
- const Subinfo *si;
- if (!wd) return;
- EINA_LIST_FOREACH(wd->subs, l, si)
- edje_object_part_swallow(wd->cov, si->swallow, si->obj);
+ if (!wd)
+ return;
+
+ ELM_HOVER_PARTS_FOREACH
+ {
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", wd->subs[i].swallow);
+ edje_object_part_swallow(wd->cov, buf, wd->subs[i].obj);
+ }
+}
+
+static const char *
+_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)
+{
+ Evas_Coord c_w = 0, c_h = 0, mid_w, mid_h;
+ int max;
+
+ evas_object_size_hint_min_get(wd->smt_sub, &c_w, &c_h);
+ mid_w = c_w / 2;
+ mid_h = c_h / 2;
+
+ if (spc_l > spc_r)
+ goto left;
+
+ max = MAX(spc_t, spc_r);
+ max = MAX(max, spc_b);
+
+ if (max == spc_t)
+ {
+ if (mid_w > spc_l)
+ return _HOV_TOP_RIGHT;
+
+ return _HOV_TOP;
+ }
+
+ if (max == spc_r)
+ {
+ if (mid_h > spc_t)
+ return _HOV_BOTTOM_RIGHT;
+ else if (mid_h > spc_b)
+ return _HOV_TOP_RIGHT;
+
+ return _HOV_RIGHT;
+ }
+
+ if (mid_h > spc_l)
+ return _HOV_BOTTOM_RIGHT;
+
+ return _HOV_BOTTOM;
+
+left:
+ max = MAX(spc_t, spc_l);
+ max = MAX(max, spc_b);
+
+ if (max == spc_t)
+ {
+ if (mid_w > spc_r)
+ return _HOV_TOP_LEFT;
+
+ return _HOV_TOP;
+ }
+
+ if (max == spc_l)
+ {
+ if (mid_h > spc_t)
+ return _HOV_BOTTOM_LEFT;
+ else if (mid_h > spc_b)
+ return _HOV_TOP_LEFT;
+
+ return _HOV_LEFT;
+ }
+
+ if (mid_h > spc_r)
+ return _HOV_BOTTOM_LEFT;
+
+ return _HOV_BOTTOM;
}
static void
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Object *sub = event_info;
- Eina_List *l;
- Subinfo *si;
- if (!wd) return;
- EINA_LIST_FOREACH(wd->subs, l, si)
+ Widget_Data *wd;
+ Evas_Object *sub;
+
+ sub = event_info;
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return;
+
+ if (wd->smt_sub)
{
- if (si->obj == sub)
- {
- wd->subs = eina_list_remove_list(wd->subs, l);
- eina_stringshare_del(si->swallow);
- free(si);
- break;
- }
+ if (wd->smt_sub == sub)
+ wd->smt_sub = NULL;
+ }
+ else
+ {
+ ELM_HOVER_PARTS_FOREACH
+ {
+ if (wd->subs[i].obj == sub)
+ {
+ wd->subs[i].obj = NULL;
+ break;
+ }
+ }
}
}
_hov_show_do(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- const Eina_List *l;
- const Subinfo *si;
- if (!wd) return;
+ if (!wd)
+ return;
+
if (wd->cov)
{
evas_object_show(wd->cov);
edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
}
- EINA_LIST_FOREACH(wd->subs, l, si)
+
+ ELM_HOVER_PARTS_FOREACH
{
char buf[1024];
- if (!strncmp(si->swallow, "elm.swallow.slot.", 17))
+ if (wd->subs[i].obj)
{
snprintf(buf, sizeof(buf), "elm,action,slot,%s,show",
- si->swallow + 17);
+ wd->subs[i].swallow);
edje_object_signal_emit(wd->cov, buf, "elm");
}
}
_hov_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(data);
- const Eina_List *l;
- const Subinfo *si;
if (!wd) return;
if (wd->cov)
{
edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
evas_object_hide(wd->cov);
}
- EINA_LIST_FOREACH(wd->subs, l, si)
+
+ ELM_HOVER_PARTS_FOREACH
{
char buf[1024];
- if (!strncmp(si->swallow, "elm.swallow.slot.", 17))
+ if (wd->subs[i].obj)
{
snprintf(buf, sizeof(buf), "elm,action,slot,%s,hide",
- si->swallow + 17);
+ wd->subs[i].swallow);
edje_object_signal_emit(wd->cov, buf, "elm");
}
}
}
static void
+_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd)
+ return;
+
+ _sizing_eval(data);
+ _elm_hover_sub_obj_placement_eval(data);
+}
+
+static void
_signal_dismiss(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
evas_object_hide(data);
- evas_object_smart_callback_call(data, "clicked", NULL);
+ evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
}
static void
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
- if (wd) evas_object_hide(wd->cov);
+ evas_object_hide(wd->cov);
}
static void
Evas *e;
Widget_Data *wd;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+
wd = ELM_NEW(Widget_Data);
+
+ ELM_HOVER_PARTS_FOREACH
+ wd->subs[i].swallow = _directions[i];
+
e = evas_object_evas_get(parent);
+ if (!e) return NULL;
obj = elm_widget_add(e);
ELM_SET_WIDTYPE(widtype, "hover");
elm_widget_type_set(obj, "hover");
elm_widget_sub_object_add(parent, obj);
+ elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_del_hook_set(obj, _del_hook);
+ elm_widget_can_focus_set(obj, EINA_TRUE);
+ elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+ elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
+ elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
wd->hov = evas_object_rectangle_add(e);
- evas_object_pass_events_set(wd->hov, 1);
+ evas_object_pass_events_set(wd->hov, EINA_TRUE);
evas_object_color_set(wd->hov, 0, 0, 0, 0);
elm_widget_resize_object_set(obj, wd->hov);
evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
_signal_dismiss, obj);
wd->offset = evas_object_rectangle_add(e);
- evas_object_pass_events_set(wd->offset, 1);
+ evas_object_pass_events_set(wd->offset, EINA_TRUE);
evas_object_color_set(wd->offset, 0, 0, 0, 0);
elm_widget_sub_object_add(obj, wd->offset);
wd->size = evas_object_rectangle_add(e);
- evas_object_pass_events_set(wd->size, 1);
+ evas_object_pass_events_set(wd->size, EINA_TRUE);
evas_object_color_set(wd->size, 0, 0, 0, 0);
elm_widget_sub_object_add(obj, wd->size);
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+ elm_hover_parent_set(obj, parent);
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
_sizing_eval(obj);
return obj;
}
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->target)
- evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_DEL,
- _target_del, obj);
+ {
+ evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_DEL,
+ _target_del, obj);
+ evas_object_event_callback_del_full(wd->target, EVAS_CALLBACK_MOVE,
+ _target_move, obj);
+ }
wd->target = target;
if (wd->target)
{
evas_object_event_callback_add(wd->target, EVAS_CALLBACK_DEL,
_target_del, obj);
+ evas_object_event_callback_add(wd->target, EVAS_CALLBACK_MOVE,
+ _target_move, obj);
elm_widget_hover_object_set(target, obj);
_sizing_eval(obj);
}
*
* @param obj The hover object
* @return The target object of the hover.
- *
+ *
* @ingroup Hover
*/
EAPI Evas_Object *
-elm_hover_target_get(Evas_Object *obj)
+elm_hover_target_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
* @ingroup Hover
*/
EAPI Evas_Object *
-elm_hover_parent_get(Evas_Object *obj)
+elm_hover_parent_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
return wd->parent;
}
+static void
+_elm_hover_subs_del(Widget_Data *wd)
+{
+ ELM_HOVER_PARTS_FOREACH
+ {
+ if (wd->subs[i].obj)
+ {
+ evas_object_del(wd->subs[i].obj);
+ wd->subs[i].obj = NULL;
+ }
+ }
+}
+
+static void
+_elm_hover_sub_obj_placement_eval(Evas_Object *obj)
+{
+ Evas_Coord spc_l, spc_r, spc_t, spc_b;
+ const char *smart_dir;
+ Widget_Data *wd;
+ char buf[1024];
+
+ wd = elm_widget_data_get(obj);
+ if (!wd->smt_sub)
+ return;
+
+ _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
+
+ edje_object_part_unswallow(wd->cov, wd->smt_sub);
+
+ smart_dir = _elm_hover_smart_content_location_get(wd, spc_l, spc_t, spc_r,
+ spc_b);
+ evas_object_smart_callback_call(obj, SIG_SMART_LOCATION_CHANGED,
+ (void *)smart_dir);
+
+ snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", smart_dir);
+ edje_object_part_swallow(wd->cov, buf, wd->smt_sub);
+}
+
+static void
+_elm_hover_sub_obj_placement_eval_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ _elm_hover_sub_obj_placement_eval(data);
+}
+
/**
* Sets the content of the hover object and the direction in which
* it will pop out.
*
+ * Once the content object is set for a given direction, a previously
+ * set one (on the same direction) will be deleted. If you want to
+ * keep that old content object, use the elm_hover_content_unset()
+ * function.
+ *
* @param obj The hover object
- * @param swallow The direction that the object will display in. Multiple
- * objects can have the same swallow location. Objects placed in the same
- * swallow will be placed starting at the middle of the hover and ending
- * farther from the middle.
- * Accepted values are "left" "right" "top" "bottom" "middle"
+ * @param swallow The direction that the object will be displayed
+ * at. Accepted values are "left", "top-left", "top", "top-right",
+ * "right", "bottom-right", "bottom", "bottom-left", "middle" and
+ * "smart".
* @param content The content to place at @p swallow
*
+ * All directions may have contents at the same time, except for
+ * "smart". This is a special placement hint and its use case
+ * independs of the calculations coming from
+ * elm_hover_best_content_location_get(). Its use is for cases when
+ * one desires only one hover content, but with a dinamic special
+ * placement within the hover area. The content's geometry, whenever
+ * it changes, will be used to decide on a best location not
+ * extrapolating the hover's parent object view to show it in (still
+ * being the hover's target determinant of its medium part -- move and
+ * resize it to simulate finger sizes, for example). If one of the
+ * directions other than "smart" are used, a previously content set
+ * using it will be deleted, and vice-versa.
+ *
* @ingroup Hover
*/
EAPI void
elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- Subinfo *si;
- const Eina_List *l;
- char buf[1024];
- if (!wd) return;
- snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
- EINA_LIST_FOREACH(wd->subs, l, si)
+
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return;
+
+ if (!strcmp(swallow, "smart"))
+ {
+ if (wd->smt_sub != content)
+ {
+ _elm_hover_subs_del(wd);
+ wd->smt_sub = content;
+ }
+
+ if (content)
+ {
+ elm_widget_sub_object_add(obj, content);
+ evas_object_event_callback_add(wd->smt_sub,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _elm_hover_sub_obj_placement_eval_cb,
+ obj);
+
+ _elm_hover_sub_obj_placement_eval(obj);
+ }
+
+ goto end;
+ }
+
+ if (wd->smt_sub)
+ {
+ evas_object_del(wd->smt_sub);
+ wd->smt_sub = NULL;
+ }
+
+ ELM_HOVER_PARTS_FOREACH
{
- if (!strcmp(buf, si->swallow))
+ if (!strcmp(swallow, wd->subs[i].swallow))
{
- if (content == si->obj) return;
- elm_widget_sub_object_del(obj, si->obj);
+ if (content == wd->subs[i].obj)
+ return;
+ evas_object_del(wd->subs[i].obj);
+ wd->subs[i].obj = NULL;
+
+ if (content)
+ {
+ char buf[1024];
+
+ snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
+ elm_widget_sub_object_add(obj, content);
+ edje_object_part_swallow(wd->cov, buf, content);
+ wd->subs[i].obj = content;
+ }
break;
}
}
- if (content)
+
+ end:
+ _sizing_eval(obj);
+}
+
+/**
+ * Get the content of the hover object, in a given direction.
+ *
+ * Return the content object which was set for this widget in the
+ * given direction.
+ *
+ * @param obj The hover object
+ * @param swallow The direction that the object was display at.
+ * @return The content that was being used
+ *
+ * @note See elm_hover_content_set() for more information.
+ *
+ * @ingroup Hover
+ */
+EAPI Evas_Object *
+elm_hover_content_get(const Evas_Object *obj, const char *swallow)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return NULL;
+
+ if (!strcmp(swallow, "smart"))
+ return wd->smt_sub;
+
+ ELM_HOVER_PARTS_FOREACH
+ if (!strcmp(swallow, wd->subs[i].swallow))
+ return wd->subs[i].obj;
+
+ return NULL;
+}
+
+static void
+_elm_hover_sub_obj_unparent(Evas_Object *obj)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+
+ elm_widget_sub_object_del(obj, wd->smt_sub);
+ evas_object_event_callback_del_full(wd->smt_sub,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _elm_hover_sub_obj_placement_eval_cb,
+ obj);
+ edje_object_part_unswallow(wd->cov, wd->smt_sub);
+ wd->smt_sub = NULL;
+}
+
+/**
+ * Unset the content of the hover object, in a given direction.
+ *
+ * Unparent and return the content object set at that direction.
+ *
+ * @param obj The hover object
+ * @param swallow The direction that the object was display at.
+ * @return The content that was being used.
+ *
+ * @note See elm_hover_content_set() for more information.
+ *
+ * @ingroup Hover
+ */
+EAPI Evas_Object *
+elm_hover_content_unset(Evas_Object *obj, const char *swallow)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return NULL;
+
+ if (!strcmp(swallow, "smart"))
{
- elm_widget_sub_object_add(obj, content);
- edje_object_part_swallow(wd->cov, buf, content);
- si = ELM_NEW(Subinfo);
- si->swallow = eina_stringshare_add(buf);
- si->obj = content;
- wd->subs = eina_list_append(wd->subs, si);
- _sizing_eval(obj);
+ Evas_Object *content;
+
+ if (!wd->smt_sub)
+ return NULL;
+
+ content = wd->smt_sub;
+ _elm_hover_sub_obj_unparent(obj);
+ return content;
+ }
+
+ ELM_HOVER_PARTS_FOREACH
+ {
+ if (!strcmp(swallow, wd->subs[i].swallow))
+ {
+ Evas_Object *content;
+
+ if (!wd->subs[i].obj)
+ return NULL;
+
+ content = wd->subs[i].obj;
+ elm_widget_sub_object_del(obj, wd->subs[i].obj);
+ edje_object_part_unswallow(wd->cov, wd->subs[i].obj);
+ wd->subs[i].obj = NULL;
+
+ return content;
+ }
}
+
+ return NULL;
}
/**
* Returns the best swallow location for content in the hover.
*
* @param obj The hover object
- * @return The edje location to place content into the hover.
- * See also elm_hover_content_set()
+ * @param pref_axis The preferred orientation axis for the hover object to use
+ * @return The edje location to place content into the hover or @c
+ * NULL, on errors.
+ *
+ * @p pref_axis may be one of
+ * <ul>
+ * - @c ELM_HOVER_AXIS_NONE -- no prefered orientation
+ * - @c ELM_HOVER_AXIS_HORIZONTAL -- horizontal
+ * - @c ELM_HOVER_AXIS_VERTICAL -- vertical
+ * - @c ELM_HOVER_AXIS_BOTH -- both
+ * </ul>
+ *
+ * See also elm_hover_content_set().
*
* @ingroup Hover
*/
EAPI const char *
elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis)
{
- ELM_CHECK_WIDTYPE(obj, widtype) "left";
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord x = 0, y = 0, w = 0, h = 0, x2 = 0, y2 = 0, w2 = 0, h2 = 0;
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+
Evas_Coord spc_l, spc_r, spc_t, spc_b;
- if (!wd) return "left";
- if (wd->parent) evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
- if (wd->target) evas_object_geometry_get(wd->target, &x2, &y2, &w2, &h2);
- spc_l = x2 - x;
- spc_r = (x + w) - (x2 + w2);
- if (spc_l < 0) spc_l = 0;
- if (spc_r < 0) spc_r = 0;
- spc_t = y2 - y;
- spc_b = (y + h) - (y2 + h2);
- if (spc_t < 0) spc_t = 0;
- if (spc_b < 0) spc_b = 0;
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd)
+ return NULL;
+
+ _elm_hover_left_space_calc(wd, &spc_l, &spc_t, &spc_r, &spc_b);
+
if (pref_axis == ELM_HOVER_AXIS_HORIZONTAL)
{
- if (spc_l < spc_r) return "right";
- else return "left";
+ if (spc_l < spc_r) return _HOV_RIGHT;
+ else return _HOV_LEFT;
}
else if (pref_axis == ELM_HOVER_AXIS_VERTICAL)
{
- if (spc_t < spc_b) return "bottom";
- else return "top";
+ if (spc_t < spc_b) return _HOV_BOTTOM;
+ else return _HOV_TOP;
}
+
if (spc_l < spc_r)
{
- if (spc_t > spc_r) return "top";
- else if (spc_b > spc_r) return "bottom";
- return "right";
+ if (spc_t > spc_r) return _HOV_TOP;
+ else if (spc_b > spc_r) return _HOV_BOTTOM;
+ return _HOV_RIGHT;
}
- if (spc_t > spc_r) return "top";
- else if (spc_b > spc_r) return "bottom";
- return "left";
+ if (spc_t > spc_r) return _HOV_TOP;
+ else if (spc_b > spc_r) return _HOV_BOTTOM;
+ return _HOV_LEFT;
}