New hover direction: "smart".
This injects some inteligence into hovers which can then be shared between other composed hover widgets. Also introducing four new swallow slots one can place content at: the diagonal corners. Just gotta fill all the styles with those, but no time right now. SVN revision: 53642
This commit is contained in:
parent
442cb3b9da
commit
770b0df365
|
@ -5817,6 +5817,8 @@ collections {
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* TODO: replicate diagonal swallow slots to the other hover styles */
|
||||
group { name: "elm/hover/base/default";
|
||||
images {
|
||||
image: "shad_circ.png" COMP;
|
||||
|
@ -5881,16 +5883,16 @@ collections {
|
|||
rel2.offset: -1 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.right";
|
||||
part { name: "elm.swallow.slot.top-left";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 0.5;
|
||||
align: 1.0 1.0;
|
||||
rel1.to: "elm.swallow.slot.middle";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel1.relative: 0.0 0.0;
|
||||
rel1.offset: 0 0;
|
||||
rel2.to: "elm.swallow.slot.middle";
|
||||
rel2.relative: 1.0 1.0;
|
||||
rel2.offset: 0 -1;
|
||||
rel2.relative: 0.0 0.0;
|
||||
rel2.offset: -1 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.top";
|
||||
|
@ -5905,6 +5907,42 @@ collections {
|
|||
rel2.offset: -1 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.top-right";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 1.0;
|
||||
rel1.to: "elm.swallow.slot.middle";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel1.offset: 0 0;
|
||||
rel2.to: "elm.swallow.slot.middle";
|
||||
rel2.relative: 1.0 0.0;
|
||||
rel2.offset: -1 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.right";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 0.5;
|
||||
rel1.to: "elm.swallow.slot.middle";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel1.offset: 0 0;
|
||||
rel2.to: "elm.swallow.slot.middle";
|
||||
rel2.relative: 1.0 1.0;
|
||||
rel2.offset: 0 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.bottom-right";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 0.0;
|
||||
rel1.to: "elm.swallow.slot.middle";
|
||||
rel1.relative: 1.0 1.0;
|
||||
rel1.offset: 0 0;
|
||||
rel2.to: "elm.swallow.slot.middle";
|
||||
rel2.relative: 1.0 1.0;
|
||||
rel2.offset: -1 -1;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.bottom";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
|
@ -5917,6 +5955,18 @@ collections {
|
|||
rel2.offset: -1 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.bottom-left";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
align: 1.0 0.0;
|
||||
rel1.to: "elm.swallow.slot.middle";
|
||||
rel1.relative: 0.0 1.0;
|
||||
rel1.offset: 0 0;
|
||||
rel2.to: "elm.swallow.slot.middle";
|
||||
rel2.relative: 0.0 1.0;
|
||||
rel2.offset: -1 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.slot.middle";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
|
|
|
@ -895,6 +895,8 @@ extern "C" {
|
|||
*/
|
||||
/* smart callbacks called:
|
||||
* "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 _Elm_Entry_Anchor_Info Elm_Entry_Anchor_Info;
|
||||
|
|
|
@ -4,28 +4,61 @@
|
|||
/**
|
||||
* @defgroup Hover Hover
|
||||
*
|
||||
* 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",
|
||||
NULL
|
||||
};
|
||||
|
||||
#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;
|
||||
|
@ -41,27 +74,31 @@ 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(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
|
||||
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
|
||||
|
@ -103,6 +140,30 @@ _theme_hook(Evas_Object *obj)
|
|||
if (evas_object_visible_get(wd->cov)) _hov_show_do(obj);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -124,29 +185,101 @@ static void
|
|||
_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;
|
||||
|
||||
ELM_HOVER_PARTS_FOREACH
|
||||
{
|
||||
if (si->obj == sub)
|
||||
if (wd->subs[i].obj == sub)
|
||||
{
|
||||
wd->subs = eina_list_remove_list(wd->subs, l);
|
||||
eina_stringshare_del(si->swallow);
|
||||
free(si);
|
||||
break;
|
||||
wd->subs[i].obj = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,22 +288,23 @@ static void
|
|||
_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");
|
||||
}
|
||||
}
|
||||
|
@ -198,22 +332,21 @@ static void
|
|||
_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");
|
||||
}
|
||||
}
|
||||
|
@ -227,13 +360,24 @@ _target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *e
|
|||
wd->target = NULL;
|
||||
}
|
||||
|
||||
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, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -286,6 +430,10 @@ elm_hover_add(Evas_Object *parent)
|
|||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
|
||||
ELM_HOVER_PARTS_FOREACH
|
||||
wd->subs[i].swallow = _directions[i];
|
||||
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
ELM_SET_WIDTYPE(widtype, "hover");
|
||||
|
@ -329,6 +477,7 @@ elm_hover_add(Evas_Object *parent)
|
|||
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;
|
||||
|
@ -350,13 +499,19 @@ elm_hover_target_set(Evas_Object *obj, Evas_Object *target)
|
|||
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);
|
||||
}
|
||||
|
@ -444,68 +599,151 @@ elm_hover_parent_get(const Evas_Object *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(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
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(data);
|
||||
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(data, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content of the hover object and the direction in which
|
||||
* it will pop out.
|
||||
*
|
||||
* Once the content object is set, a previously set one will be deleted.
|
||||
* If you want to keep that old content object, use the
|
||||
* elm_hover_content_unset() function.
|
||||
* 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 (!strncmp(swallow, "smart", sizeof("smart")))
|
||||
{
|
||||
if (!strcmp(buf, si->swallow))
|
||||
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,
|
||||
obj);
|
||||
|
||||
_elm_hover_sub_obj_placement_eval(obj, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (wd->smt_sub)
|
||||
{
|
||||
evas_object_del(wd->smt_sub);
|
||||
wd->smt_sub = NULL;
|
||||
}
|
||||
|
||||
ELM_HOVER_PARTS_FOREACH
|
||||
{
|
||||
if (!strncmp(swallow, wd->subs[i].swallow, 1024))
|
||||
{
|
||||
if (content == si->obj) return;
|
||||
evas_object_del(si->obj);
|
||||
si->obj = NULL;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
end:
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the hover object
|
||||
* Get the content of the hover object, in a given direction.
|
||||
*
|
||||
* Return the content object which is set for this widget
|
||||
* 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 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"
|
||||
* @return The content that is being used
|
||||
* @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
|
||||
*/
|
||||
|
@ -513,32 +751,49 @@ EAPI Evas_Object *
|
|||
elm_hover_content_get(const Evas_Object *obj, const char *swallow)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Subinfo *si;
|
||||
const Eina_List *l;
|
||||
char buf[1024];
|
||||
if (!wd) return NULL;
|
||||
snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
|
||||
EINA_LIST_FOREACH(wd->subs, l, si)
|
||||
{
|
||||
if (!strcmp(buf, si->swallow))
|
||||
return si->obj;
|
||||
}
|
||||
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = elm_widget_data_get(obj);
|
||||
if (!wd)
|
||||
return NULL;
|
||||
|
||||
if (!strncmp(swallow, "smart", sizeof("smart")))
|
||||
return wd->smt_sub;
|
||||
|
||||
ELM_HOVER_PARTS_FOREACH
|
||||
if (!strncmp(swallow, wd->subs[i].swallow, 1024))
|
||||
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,
|
||||
obj);
|
||||
edje_object_part_unswallow(wd->cov, wd->smt_sub);
|
||||
wd->smt_sub = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the content of the hover object
|
||||
* Unset the content of the hover object, in a given direction.
|
||||
*
|
||||
* Unparent and return the content object which was set for this widget
|
||||
* Unparent and return the content object set at that direction.
|
||||
*
|
||||
* @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"
|
||||
* @return The content that was being used
|
||||
* @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
|
||||
*/
|
||||
|
@ -546,25 +801,43 @@ EAPI Evas_Object *
|
|||
elm_hover_content_unset(Evas_Object *obj, const char *swallow)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Subinfo *si;
|
||||
const Eina_List *l;
|
||||
char buf[1024];
|
||||
if (!wd) return NULL;
|
||||
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 NULL;
|
||||
|
||||
if (!strncmp(swallow, "smart", sizeof("smart")))
|
||||
{
|
||||
if (!strcmp(buf, si->swallow))
|
||||
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 (!strncmp(swallow, wd->subs[i].swallow, 1024))
|
||||
{
|
||||
Evas_Object *content;
|
||||
if (!si->obj) return NULL;
|
||||
content = si->obj;
|
||||
elm_widget_sub_object_del(obj, si->obj);
|
||||
edje_object_part_unswallow(wd->cov, si->obj);
|
||||
si->obj = NULL;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -572,46 +845,54 @@ elm_hover_content_unset(Evas_Object *obj, const char *swallow)
|
|||
* 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue