forked from enlightenment/efl
elm hoversel: Clean up sizing_eval function
This commit is contained in:
parent
1270ddb3ed
commit
383bf1969e
|
@ -242,8 +242,7 @@ _sizing_eval(void *data)
|
||||||
int max_size = 0;
|
int max_size = 0;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
Evas_Coord box_w = -1, box_h = -1;
|
Evas_Coord box_w = -1, box_h = -1;
|
||||||
Evas_Coord x, y, w, h, xx, yy, ww, hh;
|
Eina_Rectangle base, adjusted, parent;
|
||||||
Evas_Coord obj_x, obj_y, obj_w;
|
|
||||||
|
|
||||||
ELM_HOVERSEL_DATA_GET(obj, sd);
|
ELM_HOVERSEL_DATA_GET(obj, sd);
|
||||||
|
|
||||||
|
@ -267,96 +266,90 @@ _sizing_eval(void *data)
|
||||||
|
|
||||||
if (sd->horizontal)
|
if (sd->horizontal)
|
||||||
{
|
{
|
||||||
ww = (max_size > 0) ? MIN(box_w, max_size) : box_w ;
|
adjusted.w = (max_size > 0) ? MIN(box_w, max_size) : box_w ;
|
||||||
hh = box_h;
|
adjusted.h = box_h;
|
||||||
|
|
||||||
evas_object_size_hint_min_set(sd->spacer, ww, hh);
|
|
||||||
|
|
||||||
if (!sd->last_location)
|
|
||||||
sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_HORIZONTAL);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ww = box_w;
|
adjusted.w = box_w;
|
||||||
hh = (max_size > 0) ? MIN(box_h, max_size) : box_h ;
|
adjusted.h = (max_size > 0) ? MIN(box_h, max_size) : box_h ;
|
||||||
|
|
||||||
evas_object_size_hint_min_set(sd->spacer, ww, hh);
|
|
||||||
|
|
||||||
if (!sd->last_location)
|
|
||||||
sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_VERTICAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_object_geometry_get(sd->hover_parent, &x, &y, &w, &h);
|
evas_object_size_hint_min_set(sd->spacer, adjusted.w, adjusted.h);
|
||||||
|
if (!sd->last_location)
|
||||||
|
sd->last_location = elm_hover_best_content_location_get(sd->hover, !sd->horizontal + 1);
|
||||||
|
|
||||||
|
evas_object_geometry_get(sd->hover_parent, &parent.x, &parent.y, &parent.w, &parent.h);
|
||||||
if (efl_isa(sd->hover_parent, EFL_UI_WIN_CLASS))
|
if (efl_isa(sd->hover_parent, EFL_UI_WIN_CLASS))
|
||||||
{
|
{
|
||||||
x = 0;
|
parent.x = 0;
|
||||||
y = 0;
|
parent.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", sd->last_location);
|
snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", sd->last_location);
|
||||||
edje_object_part_geometry_get(elm_layout_edje_get(sd->hover), buf, &xx, &yy, NULL, NULL);
|
edje_object_part_geometry_get(elm_layout_edje_get(sd->hover), buf, &adjusted.x, &adjusted.y, NULL, NULL);
|
||||||
xx += x;
|
adjusted.x += parent.x;
|
||||||
yy += y;
|
adjusted.y += parent.y;
|
||||||
|
|
||||||
evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, NULL);
|
evas_object_geometry_get(obj, &base.x, &base.y, &base.w, NULL);
|
||||||
|
|
||||||
if (sd->horizontal)
|
if (sd->horizontal)
|
||||||
{
|
{
|
||||||
if (!strcmp(sd->last_location, "left"))
|
if (!strcmp(sd->last_location, "left"))
|
||||||
{
|
{
|
||||||
xx = x;
|
adjusted.x = parent.x;
|
||||||
if ((xx + ww) > obj_x)
|
if ((adjusted.x + adjusted.w) > base.x)
|
||||||
ww = obj_x - xx;
|
adjusted.w = base.x - adjusted.x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((xx + ww) > (x + w))
|
if ((adjusted.x + adjusted.w) > (parent.x + parent.w))
|
||||||
ww = (x + w) - xx;
|
adjusted.w = (parent.x + parent.w) - adjusted.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yy < 0) yy = y;
|
if (adjusted.y < 0) adjusted.y = parent.y;
|
||||||
if ((yy + hh) > (y + h))
|
if ((adjusted.y + adjusted.h) > (parent.y + parent.h))
|
||||||
hh = (y + h) - yy;
|
adjusted.h = (parent.y + parent.h) - adjusted.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!strcmp(sd->last_location, "top"))
|
if (!strcmp(sd->last_location, "top"))
|
||||||
{
|
{
|
||||||
yy = y;
|
adjusted.y = parent.y;
|
||||||
if ((yy + hh) > obj_y)
|
if ((adjusted.y + adjusted.h) > base.y)
|
||||||
hh = obj_y - yy;
|
adjusted.h = base.y - adjusted.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((yy + hh) > (y + h))
|
if ((adjusted.y + adjusted.h) > (parent.y + parent.h))
|
||||||
hh = (y + h) - yy;
|
adjusted.h = (parent.y + parent.h) - adjusted.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xx < 0) xx = x;
|
if (adjusted.x < 0) adjusted.x = parent.x;
|
||||||
if ((xx + ww) > (x + w))
|
if ((adjusted.x + adjusted.w) > (parent.x + parent.w))
|
||||||
{
|
{
|
||||||
if ((obj_x + obj_w - x) > ((x + w) - obj_x))
|
if ((base.x + base.w - parent.x) > ((parent.x + parent.w) - base.x))
|
||||||
{
|
{
|
||||||
if (elm_obj_widget_mirrored_get(obj))
|
if (elm_widget_mirrored_get(obj))
|
||||||
elm_obj_layout_signal_emit(sd->hover, "elm,state,align,right", "elm");
|
elm_object_signal_emit(sd->hover, "elm,state,align,right", "elm");
|
||||||
else
|
else
|
||||||
elm_obj_layout_signal_emit(sd->hover, "elm,state,align,default", "elm");
|
elm_object_signal_emit(sd->hover, "elm,state,align,default", "elm");
|
||||||
|
|
||||||
if ((obj_x + obj_w - ww) < x)
|
if ((base.x + base.w - adjusted.w) < parent.x)
|
||||||
ww = obj_x + obj_w - x;
|
adjusted.w = base.x + base.w - parent.x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (elm_obj_widget_mirrored_get(obj))
|
if (elm_widget_mirrored_get(obj))
|
||||||
elm_obj_layout_signal_emit(sd->hover, "elm,state,align,default", "elm");
|
elm_object_signal_emit(sd->hover, "elm,state,align,default", "elm");
|
||||||
else
|
else
|
||||||
elm_obj_layout_signal_emit(sd->hover, "elm,state,align,right", "elm");
|
elm_object_signal_emit(sd->hover, "elm,state,align,right", "elm");
|
||||||
|
|
||||||
ww = (x + w) - xx;
|
adjusted.w = (parent.x + parent.w) - adjusted.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
evas_object_size_hint_min_set(sd->spacer, ww, hh);
|
evas_object_size_hint_min_set(sd->spacer, adjusted.w, adjusted.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue