From a2dd9fc99dbddc1c6612381d0544c7ced17965ec Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Mon, 27 Feb 2017 20:13:06 +0900 Subject: 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 Test Plan: elementary_test -to tooltip4 Reviewers: cedric, Hermet, jpeg Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D4554 --- src/lib/elementary/els_tooltip.c | 54 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'src/lib/elementary') diff --git a/src/lib/elementary/els_tooltip.c b/src/lib/elementary/els_tooltip.c index 4357336359..89febf6647 100644 --- a/src/lib/elementary/els_tooltip.c +++ b/src/lib/elementary/els_tooltip.c @@ -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); -- cgit v1.2.1