#include <Elementary.h>
#include "elm_priv.h"
-/**
- * @defgroup Hover Hover
- * @ingroup Elementary
- *
- * 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.
- *
- * Signals that you can add callbacks for are:
- *
- * "clicked" - the user clicked the empty space in the hover to dismiss
- * "smart,changed" - a content object placed under the "smart"
- * policy was replaced to a new slot direction.
- */
-
typedef struct _Widget_Data Widget_Data;
typedef struct _Content_Info Content_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 void _content_set_hook(Evas_Object *obj, const char *swallow, Evas_Object *content);
+static Evas_Object * _content_get_hook(const Evas_Object *obj, const char *swallow);
+static Evas_Object * _content_unset_hook(Evas_Object *obj, const char *swallow);
static const char SIG_CLICKED[] = "clicked";
static const char SIG_SMART_LOCATION_CHANGED[] = "smart,changed";
_sizing_eval(data);
}
-/**
- * Adds a hover object to @p parent
- *
- * @param parent The parent object
- * @return The hover object or NULL if one could not be created
- *
- * @ingroup Hover
- */
EAPI Evas_Object *
elm_hover_add(Evas_Object *parent)
{
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);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
ELM_HOVER_PARTS_FOREACH
wd->subs[i].swallow = _directions[i];
return obj;
}
-/**
- * Sets the target object for the hover.
- *
- * @param obj The hover object
- * @param target The object to center the hover onto. The hover
- * will take up the entire space that the target object fills.
- *
- * @ingroup Hover
- */
EAPI void
elm_hover_target_set(Evas_Object *obj, Evas_Object *target)
{
}
-/**
- * Sets the parent object for the hover.
- *
- * @param obj The hover object
- * @param parent The object to locate the hover over.
- *
- * @ingroup Hover
- */
EAPI void
elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
{
_sizing_eval(obj);
}
-/**
- * Gets the target object for the hover.
- *
- * @param obj The hover object
- * @return The target object of the hover.
- *
- * @ingroup Hover
- */
EAPI Evas_Object *
elm_hover_target_get(const Evas_Object *obj)
{
return wd->target;
}
-/**
- * Gets the parent object for the hover.
- *
- * @param obj The hover object
- * @return The parent object to locate the hover over.
- *
- * @ingroup Hover
- */
EAPI Evas_Object *
elm_hover_parent_get(const Evas_Object *obj)
{
_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 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)
+static void
+_elm_hover_sub_obj_unparent(Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ 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;
+}
+EAPI const char *
+elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+
+ Evas_Coord spc_l, spc_r, spc_t, spc_b;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd)
- return;
+ 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 _HOV_RIGHT;
+ else return _HOV_LEFT;
+ }
+ else if (pref_axis == ELM_HOVER_AXIS_VERTICAL)
+ {
+ if (spc_t < spc_b) return _HOV_BOTTOM;
+ else return _HOV_TOP;
+ }
+
+ if (spc_l < spc_r)
+ {
+ 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 _HOV_TOP;
+ else if (spc_b > spc_r) return _HOV_BOTTOM;
+ return _HOV_LEFT;
+}
+
+EAPI void
+elm_hover_dismiss(Evas_Object *obj)
+{
+ Widget_Data *wd;
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ edje_object_signal_emit(wd->cov, "elm,action,dismiss", "");
+}
+
+static void
+_content_set_hook(Evas_Object *obj, const char *swallow, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
if (!strcmp(swallow, "smart"))
{
break;
}
}
-
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)
+static Evas_Object *
+_content_get_hook(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;
+ Widget_Data *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;
+ 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)
+static Evas_Object *
+_content_unset_hook(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;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
if (!strcmp(swallow, "smart"))
{
- Evas_Object *content;
-
- if (!wd->smt_sub)
- return NULL;
-
- content = wd->smt_sub;
+ if (!wd->smt_sub) return NULL;
+ Evas_Object *content = wd->smt_sub;
_elm_hover_sub_obj_unparent(obj);
return content;
}
{
if (!strcmp(swallow, wd->subs[i].swallow))
{
- Evas_Object *content;
-
- if (!wd->subs[i].obj)
- return NULL;
-
- content = wd->subs[i].obj;
+ if (!wd->subs[i].obj) return NULL;
+ Evas_Object *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 NULL;
}
-
-/**
- * Returns the best swallow location for content in the hover.
- *
- * @param obj The hover object
- * @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
- * - @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
- *
- * 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) NULL;
-
- Evas_Coord spc_l, spc_r, spc_t, spc_b;
- 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 _HOV_RIGHT;
- else return _HOV_LEFT;
- }
- else if (pref_axis == ELM_HOVER_AXIS_VERTICAL)
- {
- if (spc_t < spc_b) return _HOV_BOTTOM;
- else return _HOV_TOP;
- }
-
- if (spc_l < spc_r)
- {
- 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 _HOV_TOP;
- else if (spc_b > spc_r) return _HOV_BOTTOM;
- return _HOV_LEFT;
-}