diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c index 479474a965..e3d9dc6413 100644 --- a/src/bin/elementary/test.c +++ b/src/bin/elementary/test.c @@ -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); //------------------------------// diff --git a/src/bin/elementary/test_tooltip.c b/src/bin/elementary/test_tooltip.c index 23290671e8..e105b1ef65 100644 --- a/src/bin/elementary/test_tooltip.c +++ b/src/bin/elementary/test_tooltip.c @@ -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); +} 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);