hoversel: fix hover position in hoversel, when it goes out of the viewport

Summary:
Hoversel Widget is designed in such a way that it accepts top/bottom/left/right directions , internally it uses hover widget which does not take care if its content goes of it's parent (Elm_Win in most cases) . this patch ensures that the drop-down content remains restricted in visible hover_parent. it would fix  T2965
Signed-off-by: divyesh purohit <div.purohit@samsung.com>
Signed-off-by: Jee-Yong Um <conr2d@gmail.com>

Test Plan:
Open entry widget and right click to show a hoversel widget, check if the hoversel or hover content goes out of the window.

this is what hoversel would look like after this patch {F27551}

Screenshots of top-left / top-right/ bottom-left and bottom-right corners in entry after this patch

{F27553}

{F27554}

{F27555}

{F27557}

Reviewers: shilpasingh, conr2d, raster, cedric, Hermet

Subscribers: rajeshps, govi

Projects: #elementary

Maniphest Tasks: T2965

Differential Revision: https://phab.enlightenment.org/D3513

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
divyesh purohit 2016-01-04 15:08:49 -08:00 committed by Cedric BAIL
parent d305e2790a
commit 666bc393eb
4 changed files with 168 additions and 56 deletions

View File

@ -1069,7 +1069,7 @@ group { name: "elm/button/base/hoversel_vertical_entry/default";
image { "base"; nomouse;
desc { "default";
fixed: 1 1;
rel1.offset: -6 0;
rel1.offset: 0 0;
image.normal: "vgrad_med_dark.png";
fill.smooth: 0;
TILED_HORIZ(120)
@ -1174,7 +1174,7 @@ group { name: "elm/button/base/hoversel_vertical_entry/default";
color_class: "hoversel_text";
color3: 255 255 255 255;
text { font: FN; size: 10;
align: -1 0.5;
align: 0.0 0.5;
min: 0 0;
text_class: "button";
}

View File

@ -445,6 +445,24 @@ group { name: "elm/hover/base/hoversel_vertical/default";
// max_size limits the maximum size of expanded hoversel
// when it's scrollable.
//data.item: "max_size" "60";
script {
public visible = 0;
public right = 0;
public topshow2() {
if (get_int(right) == 0)
run_program(PROGRAM:"topshow_default");
else
run_program(PROGRAM:"topshow_right");
set_int(visible, 1);
}
public bottomshow2() {
if (get_int(right) == 0)
run_program(PROGRAM:"bottomshow_default");
else
run_program(PROGRAM:"bottomshow_right");
set_int(visible, 1);
}
}
parts {
part { name: "elm.swallow.offset"; type: SWALLOW;
description { state: "default" 0.0;
@ -466,11 +484,11 @@ group { name: "elm/hover/base/hoversel_vertical/default";
description { state: "default" 0.0;
rel1.to_x: "limit0";
rel1.to_y: "elm.swallow.slot.top";
rel1.offset: -10 -6;
rel1.offset: -2 -4;
rel2.to_x: "limit1";
rel2.to_y: "elm.swallow.slot.middle";
rel2.relative: 1.0 0.0;
rel2.offset: 9 5;
rel2.offset: 9 4;
image {
normal: "button_normal.png";
border: 7 7 7 7;
@ -481,10 +499,10 @@ group { name: "elm/hover/base/hoversel_vertical/default";
rel1.to_x: "limit0";
rel1.to_y: "elm.swallow.slot.middle";
rel1.relative: 0.0 1.0;
rel1.offset: -10 -4;
rel1.offset: -2 -4;
rel2.to_x: "limit1";
rel2.to_y: "elm.swallow.slot.bottom";
rel2.offset: 9 5;
rel2.offset: 9 4;
image {
normal: "button_normal.png";
border: 7 7 7 7;
@ -558,7 +576,7 @@ group { name: "elm/hover/base/hoversel_vertical/default";
clip_to: "topclip";
description { state: "default" 0.0;
visible: 1;
align: 0.5 0.0;
align: 0.0 0.0;
rel1.to: "elm.swallow.slot.middle";
rel1.relative: 0.0 0.0;
rel1.offset: 0 -1;
@ -568,7 +586,17 @@ group { name: "elm/hover/base/hoversel_vertical/default";
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
align: 0.5 1.0;
align: 0.0 1.0;
}
description { state: "right" 0.0;
inherit: "default" 0.0;
align: 1.0 0.0;
rel2.offset: -9 0;
}
description { state: "right_visible" 0.0;
inherit: "default" 0.0;
align: 1.0 1.0;
rel2.offset: -9 0;
}
}
part { name: "bottomclip"; type: RECT;
@ -580,7 +608,7 @@ group { name: "elm/hover/base/hoversel_vertical/default";
part { name: "elm.swallow.slot.bottom"; type: SWALLOW;
clip_to: "bottomclip";
description { state: "default" 0.0;
align: 0.5 1.0;
align: 0.0 1.0;
rel1.to: "elm.swallow.slot.middle";
rel1.relative: 0.0 1.0;
rel1.offset: 0 2;
@ -590,7 +618,17 @@ group { name: "elm/hover/base/hoversel_vertical/default";
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
align: 0.5 0.0;
align: 0.0 0.0;
}
description { state: "right" 0.0;
inherit: "default" 0.0;
align: 1.0 1.0;
rel2.offset: -9 0;
}
description { state: "right_visible" 0.0;
inherit: "default" 0.0;
align: 1.0 0.0;
rel2.offset: -9 0;
}
}
part { name: "elm.swallow.slot.middle";
@ -621,45 +659,114 @@ group { name: "elm/hover/base/hoversel_vertical/default";
program { name: "hidefinished";
action: SIGNAL_EMIT "elm,action,hide,finished" "elm";
}
program { name: "topshow";
signal: "elm,action,slot,top,show"; source: "elm";
action: STATE_SET "visible" 0.0;
transition: DECELERATE 0.5;
target: "elm.swallow.slot.top";
script {
set_state(PART:"limit0", "visible", 0.0);
set_state(PART:"limit1", "visible", 0.0);
set_state(PART:"button_image", "default", 0.0);
topshow2();
}
}
program { name: "topshow3";
signal: "elm,action,slot,top,show"; source: "elm";
action: STATE_SET "default" 0.0;
target: "button_image";
target: "limit0";
target: "limit1";
program { name: "topshow_default";
action: STATE_SET "visible" 0.0;
target: "elm.swallow.slot.top";
transition: DECELERATE 0.5;
}
program { name: "topshow_right";
action: STATE_SET "right_visible" 0.0;
target: "elm.swallow.slot.top";
transition: DECELERATE 0.5;
}
program { name: "tophide";
signal: "elm,action,slot,top,hide"; source: "elm";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.5;
target: "elm.swallow.slot.top";
signal: "elm,action,slot,top,hide";
source: "elm";
script {
if (get_int(right) == 0)
run_program(PROGRAM:"tophide_default");
else
run_program(PROGRAM:"tophide_right");
set_int(visible, 0);
}
}
program { name: "tophide_default";
action: STATE_SET "default" 0.0;
target: "elm.swallow.slot.top";
transition: DECELERATE 0.5;
}
program { name: "tophide_right";
action: STATE_SET "right" 0.0;
target: "elm.swallow.slot.top";
transition: DECELERATE 0.5;
}
program { name: "bottomshow";
signal: "elm,action,slot,bottom,show"; source: "elm";
action: STATE_SET "visible" 0.0;
transition: DECELERATE 0.5;
target: "elm.swallow.slot.bottom";
script {
set_state(PART:"limit0", "bottom", 0.0);
set_state(PART:"limit1", "bottom", 0.0);
set_state(PART:"button_image", "bottom", 0.0);
bottomshow2();
}
}
program { name: "bottomshow3";
signal: "elm,action,slot,bottom,show"; source: "elm";
action: STATE_SET "bottom" 0.0;
target: "button_image";
target: "limit0";
target: "limit1";
program { name: "bottomshow_default";
action: STATE_SET "visible" 0.0;
target: "elm.swallow.slot.bottom";
transition: DECELERATE 0.5;
}
program { name: "bottomshow_right";
action: STATE_SET "right_visible" 0.0;
target: "elm.swallow.slot.bottom";
transition: DECELERATE 0.5;
}
program { name: "bottomhide";
signal: "elm,action,slot,bottom,hide"; source: "elm";
script {
if (get_int(right) == 0) {
run_program(PROGRAM:"bottomhide_default");
}
else {
run_program(PROGRAM:"bottomhide_right");
}
set_int(visible, 0);
}
}
program { name: "bottomhide_default";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.5;
target: "elm.swallow.slot.bottom";
transition: DECELERATE 0.5;
}
program { name: "bottomhide_right";
action: STATE_SET "right" 0.0;
target: "elm.swallow.slot.bottom";
transition: DECELERATE 0.5;
}
program { name: "align_right";
signal: "elm,state,align,right"; source: "elm";
script {
set_int(right, 1);
if (get_int(visible) == 0) {
set_state(PART:"elm.swallow.slot.top", "right", 0.0);
set_state(PART:"elm.swallow.slot.bottom", "right", 0.0);
}
else {
set_state(PART:"elm.swallow.slot.top", "right_visible", 0.0);
set_state(PART:"elm.swallow.slot.bottom", "right_visible", 0.0);
}
}
}
program { name: "align_default";
signal: "elm,state,align,default"; source: "elm";
script {
set_int(right, 0);
if (get_int(visible) == 0) {
set_state(PART:"elm.swallow.slot.top", "default", 0.0);
set_state(PART:"elm.swallow.slot.bottom", "default", 0.0);
}
else {
set_state(PART:"elm.swallow.slot.top", "visible", 0.0);
set_state(PART:"elm.swallow.slot.bottom", "visible", 0.0);
}
}
}
}
}
@ -701,7 +808,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
description { state: "default" 0.0;
rel1.to_x: "elm.swallow.slot.left";
rel1.to_y: "elm.swallow.slot.left";
rel1.offset: -10 -10;
rel1.offset: -10 0;
rel2.to_x: "elm.swallow.slot.middle";
rel2.to_y: "elm.swallow.slot.left";
rel2.relative: 0.0 1.0;
@ -716,7 +823,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
rel1.to_x: "elm.swallow.slot.middle";
rel1.to_y: "elm.swallow.slot.right";
rel1.relative: 1.0 0.0;
rel1.offset: -5 -10;
rel1.offset: -5 0;
rel2.to_x: "elm.swallow.slot.right";
rel2.to_y: "elm.swallow.slot.right";
rel2.offset: 10 9;
@ -737,7 +844,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
part { name: "elm.swallow.slot.left"; type: SWALLOW;
clip_to: "leftclip";
description { state: "default" 0.0;
align: 0.0 0.5;
align: 0.0 0.0;
rel1.to: "elm.swallow.slot.middle";
rel1.relative: 0.0 0.0;
rel1.offset: -1 0;
@ -749,7 +856,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
inherit: "default" 0.0;
rel1.offset: -7 0;
rel2.offset: -7 -1;
align: 1.0 0.5;
align: 1.0 0.0;
}
}
part { name: "rightclip"; type: RECT;
@ -761,7 +868,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
part { name: "elm.swallow.slot.right"; type: SWALLOW;
clip_to: "rightclip";
description { state: "default" 0.0;
align: 1.0 0.5;
align: 1.0 0.0;
rel1.to: "elm.swallow.slot.middle";
rel1.relative: 1.0 0.0;
rel1.offset: 0 0;
@ -773,7 +880,7 @@ group { name: "elm/hover/base/hoversel_horizontal/default";
inherit: "default" 0.0;
rel1.offset: 6 0;
rel2.offset: -6 -1;
align: 0.0 0.5;
align: 0.0 0.0;
}
}
part { name: "elm.swallow.slot.middle"; type: SWALLOW;

View File

@ -334,9 +334,20 @@ _resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
if (xx < 0) xx = x;
if ((xx + ww) > (x + w))
ww = (x + w) - xx;
{
if ((obj_x + obj_w - x) > ((x + w) - obj_x))
{
elm_layout_signal_emit(sd->hover, "elm,state,align,right", "elm");
if ((obj_x + obj_w - ww) < x)
ww = obj_x + obj_w - x;
}
else
{
elm_layout_signal_emit(sd->hover, "elm,state,align,default", "elm");
ww = (x + w) - xx;
}
}
}
evas_object_size_hint_min_set(sd->spacer, ww, hh);
}

View File

@ -1235,13 +1235,13 @@ _elm_entry_elm_widget_sub_object_del(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, E
static void
_hoversel_position(Evas_Object *obj)
{
Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h;
ELM_ENTRY_DATA_GET(obj, sd);
cx = cy = 0;
cw = ch = 1;
evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
if (sd->use_down)
{
cx = sd->downx - x;
@ -1254,18 +1254,12 @@ _hoversel_position(Evas_Object *obj)
(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
evas_object_size_hint_min_get(sd->hoversel, &mw, &mh);
if (cw < mw)
{
cx += (cw - mw) / 2;
cw = mw;
}
if (ch < mh)
{
cy += (ch - mh) / 2;
ch = mh;
}
if (cx + mw > w)
cx = w - mw;
if (cy + mh > h)
cy = h - mh;
evas_object_move(sd->hoversel, x + cx, y + cy);
evas_object_resize(sd->hoversel, cw, ch);
evas_object_resize(sd->hoversel, mw, mh);
}
static void