forked from enlightenment/efl
elementary/ctxpopup - patched by kimcinoo@gmail.com
Dear All, Hi! Previously, the ctxpopup have used only direction up or down if there is no enough area to display. So, there was some dead codes and TODO list for this.. By using wd->horizontal, we can decide between "up/down" and "left/right" If elc_ctxpopup is horizontal, "up/down" is more proper than "left/right" and vice versa. Sincerely, Shinwoo Kim. SVN revision: 62420
This commit is contained in:
parent
49843b1dad
commit
b88a8a186a
|
@ -388,21 +388,16 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
|
||||||
//In this case, all directions are invalid because of lack of space.
|
//In this case, all directions are invalid because of lack of space.
|
||||||
if (idx == 4)
|
if (idx == 4)
|
||||||
{
|
{
|
||||||
//TODO 1: Find the largest space direction.
|
|
||||||
Evas_Coord length[2];
|
Evas_Coord length[2];
|
||||||
|
|
||||||
|
if(!wd->horizontal)
|
||||||
|
{
|
||||||
length[0] = pos.y - hover_area.y;
|
length[0] = pos.y - hover_area.y;
|
||||||
length[1] = (hover_area.y + hover_area.h) - pos.y;
|
length[1] = (hover_area.y + hover_area.h) - pos.y;
|
||||||
|
|
||||||
if (length[0] > length[1])
|
if (length[0] > length[1])
|
||||||
idx = ELM_CTXPOPUP_DIRECTION_UP;
|
|
||||||
else
|
|
||||||
idx = ELM_CTXPOPUP_DIRECTION_DOWN;
|
|
||||||
|
|
||||||
//TODO 2: determine x , y
|
|
||||||
switch (idx)
|
|
||||||
{
|
{
|
||||||
case ELM_CTXPOPUP_DIRECTION_UP:
|
// ELM_CTXPOPUP_DIRECTION_UP
|
||||||
_adjust_pos_x(&pos, &base_size, &hover_area);
|
_adjust_pos_x(&pos, &base_size, &hover_area);
|
||||||
pos.y -= base_size.y;
|
pos.y -= base_size.y;
|
||||||
arrow = ELM_CTXPOPUP_DIRECTION_DOWN;
|
arrow = ELM_CTXPOPUP_DIRECTION_DOWN;
|
||||||
|
@ -411,8 +406,26 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
|
||||||
base_size.y -= ((hover_area.y + arrow_size.y) - pos.y);
|
base_size.y -= ((hover_area.y + arrow_size.y) - pos.y);
|
||||||
pos.y = hover_area.y + arrow_size.y;
|
pos.y = hover_area.y + arrow_size.y;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case ELM_CTXPOPUP_DIRECTION_LEFT:
|
else
|
||||||
|
{
|
||||||
|
//ELM_CTXPOPUP_DIRECTION_DOWN
|
||||||
|
_adjust_pos_x(&pos, &base_size, &hover_area);
|
||||||
|
arrow = ELM_CTXPOPUP_DIRECTION_UP;
|
||||||
|
if (pos.y + arrow_size.y + base_size.y >
|
||||||
|
hover_area.y + hover_area.h)
|
||||||
|
base_size.y -=
|
||||||
|
((pos.y + arrow_size.y + base_size.y) -
|
||||||
|
(hover_area.y + hover_area.h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
length[0] = pos.x - hover_area.x;
|
||||||
|
length[1] = (hover_area.x + hover_area.w) - pos.x;
|
||||||
|
if (length[0] > length[1])
|
||||||
|
{
|
||||||
|
//ELM_CTXPOPUP_DIRECTION_LEFT
|
||||||
_adjust_pos_y(&pos, &base_size, &hover_area);
|
_adjust_pos_y(&pos, &base_size, &hover_area);
|
||||||
pos.x -= base_size.x;
|
pos.x -= base_size.x;
|
||||||
arrow = ELM_CTXPOPUP_DIRECTION_RIGHT;
|
arrow = ELM_CTXPOPUP_DIRECTION_RIGHT;
|
||||||
|
@ -421,8 +434,10 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
|
||||||
base_size.x -= ((hover_area.x + arrow_size.x) - pos.x);
|
base_size.x -= ((hover_area.x + arrow_size.x) - pos.x);
|
||||||
pos.x = hover_area.x + arrow_size.x;
|
pos.x = hover_area.x + arrow_size.x;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case ELM_CTXPOPUP_DIRECTION_RIGHT:
|
else
|
||||||
|
{
|
||||||
|
//ELM_CTXPOPUP_DIRECTION_RIGHT
|
||||||
_adjust_pos_y(&pos, &base_size, &hover_area);
|
_adjust_pos_y(&pos, &base_size, &hover_area);
|
||||||
arrow = ELM_CTXPOPUP_DIRECTION_LEFT;
|
arrow = ELM_CTXPOPUP_DIRECTION_LEFT;
|
||||||
if (pos.x + arrow_size.x + base_size.x >
|
if (pos.x + arrow_size.x + base_size.x >
|
||||||
|
@ -430,21 +445,11 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
|
||||||
base_size.x -=
|
base_size.x -=
|
||||||
((pos.x + arrow_size.x + base_size.x) -
|
((pos.x + arrow_size.x + base_size.x) -
|
||||||
(hover_area.x + hover_area.w));
|
(hover_area.x + hover_area.w));
|
||||||
break;
|
|
||||||
case ELM_CTXPOPUP_DIRECTION_DOWN:
|
|
||||||
_adjust_pos_x(&pos, &base_size, &hover_area);
|
|
||||||
arrow = ELM_CTXPOPUP_DIRECTION_UP;
|
|
||||||
if (pos.y + arrow_size.y + base_size.y >
|
|
||||||
hover_area.y + hover_area.h)
|
|
||||||
base_size.y -=
|
|
||||||
((pos.y + arrow_size.y + base_size.y) -
|
|
||||||
(hover_area.y + hover_area.h));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//Final position and size.
|
//Final position and size.
|
||||||
rect->x = pos.x;
|
rect->x = pos.x;
|
||||||
rect->y = pos.y;
|
rect->y = pos.y;
|
||||||
|
|
Loading…
Reference in New Issue