elementary tooltip: adjust arrow if tooltip was moved

Summary:
If orientation is TOP, BOTTOM, LEFT and RIGHT and
tooltip was moved due to located out of screen,
adjust location of arrow so that can indicate right position.

Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>

Test Plan: elementary_test -to tooltip4

Reviewers: cedric, Hermet, jpeg

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D4554
This commit is contained in:
Minkyu Kang 2017-02-27 20:13:06 +09:00 committed by Jean-Philippe Andre
parent 62455a8d41
commit a2dd9fc99d
3 changed files with 109 additions and 4 deletions

View File

@ -219,6 +219,7 @@ void test_anim(void *data, Evas_Object *obj, void *event_info);
void test_tooltip(void *data, Evas_Object *obj, void *event_info);
void test_tooltip2(void *data, Evas_Object *obj, void *event_info);
void test_tooltip3(void *data, Evas_Object *obj, void *event_info);
void test_tooltip4(void *data, Evas_Object *obj, void *event_info);
void test_cursor(void *data, Evas_Object *obj, void *event_info);
void test_cursor2(void *data, Evas_Object *obj, void *event_info);
void test_cursor3(void *data, Evas_Object *obj, void *event_info);
@ -932,6 +933,7 @@ add_tests:
ADD_TEST(NULL, "Popups", "Tooltip", test_tooltip);
ADD_TEST(NULL, "Popups", "Tooltip 2", test_tooltip2);
ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3);
ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
ADD_TEST(NULL, "Popups", "Popup", test_popup);
//------------------------------//

View File

@ -743,3 +743,60 @@ test_tooltip3(void *data EINA_UNUSED,
evas_object_resize(win, 300, 300);
evas_object_show(win);
}
void
test_tooltip4(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *bt;
win = elm_win_util_standard_add("tooltip4", "Tooltip 4");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_resize(win, 300, 300);
evas_object_show(win);
bt = elm_button_add(win);
elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!");
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_BOTTOM);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 5, 5);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!");
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_BOTTOM);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 250, 5);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!");
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_TOP);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 25, 265);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!");
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_TOP);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 235, 265);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
_tt_icon_del);
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_RIGHT);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 135, 5);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L,
_tt_icon_del);
elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_LEFT);
evas_object_resize(bt, 30, 30);
evas_object_move(bt, 135, 255);
evas_object_show(bt);
}

View File

@ -284,6 +284,9 @@ _elm_tooltip_reconfigure_orient(Elm_Tooltip *tt,
Evas_Coord tw, Evas_Coord th, Evas_Coord cw, Evas_Coord ch)
{
Evas_Coord mx, my;
Evas_Coord dx, dy;
Evas_Coord tcw, tch;
Evas_Coord px, py;
switch (tt->orient)
{
@ -345,11 +348,54 @@ _elm_tooltip_reconfigure_orient(Elm_Tooltip *tt,
return;
}
if (mx < 0) mx = 0;
else if (mx + tw > cw) mx = cw - tw;
evas_object_geometry_get(tt->content, NULL, NULL, &tcw, &tch);
if (tcw <= 0 || tcw > tw) tcw = tw;
if (tch <= 0 || tch > th) tch = th;
if (my < 0) my = 0;
else if (my + th > ch) my = ch - th;
px = (tw - tcw) / 2;
py = (th - tch) / 2;
if (mx < 0)
{
dx = -mx;
mx = -(px / 2);
if (tt->rel_pos.x == 0.5)
{
tt->rel_pos.x = 0.5 - dx / (double)tcw;
if (tt->rel_pos.x < 0.0) tt->rel_pos.x = 0.0;
}
}
else if (mx + tw > cw)
{
dx = mx + tw - cw;
mx = cw - tw + px / 2;
if (tt->rel_pos.x == 0.5)
{
tt->rel_pos.x = 0.5 + dx / (double)tcw;
if (tt->rel_pos.x > 1.0) tt->rel_pos.x = 1.0;
}
}
if (my < 0)
{
dy = -my;
my = -(py / 2);
if (tt->rel_pos.y == 0.5)
{
tt->rel_pos.y = 0.5 - dy / (double)tch;
if (tt->rel_pos.y < 0.0) tt->rel_pos.y = 0.0;
}
}
else if (my + th > ch)
{
dy = my + th - ch;
my = ch - th + py / 2;
if (tt->rel_pos.y == 0.5)
{
tt->rel_pos.y = 0.5 + dy / (double)tch;
if (tt->rel_pos.y > 1.0) tt->rel_pos.y = 1.0;
}
}
evas_object_move(tt->tooltip, mx, my);
evas_object_show(tt->tooltip);