diff options
author | Minkyu Kang <mk7.kang@samsung.com> | 2017-02-27 20:13:06 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-02-27 20:13:06 +0900 |
commit | a2dd9fc99dbddc1c6612381d0544c7ced17965ec (patch) | |
tree | c170555c3495dfdeb5f453dea7d2609b38da798f /src | |
parent | 62455a8d414b9df787806f1f4527ecde47957c20 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/elementary/test.c | 2 | ||||
-rw-r--r-- | src/bin/elementary/test_tooltip.c | 57 | ||||
-rw-r--r-- | src/lib/elementary/els_tooltip.c | 54 |
3 files changed, 109 insertions, 4 deletions
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); | |||
219 | void test_tooltip(void *data, Evas_Object *obj, void *event_info); | 219 | void test_tooltip(void *data, Evas_Object *obj, void *event_info); |
220 | void test_tooltip2(void *data, Evas_Object *obj, void *event_info); | 220 | void test_tooltip2(void *data, Evas_Object *obj, void *event_info); |
221 | void test_tooltip3(void *data, Evas_Object *obj, void *event_info); | 221 | void test_tooltip3(void *data, Evas_Object *obj, void *event_info); |
222 | void test_tooltip4(void *data, Evas_Object *obj, void *event_info); | ||
222 | void test_cursor(void *data, Evas_Object *obj, void *event_info); | 223 | void test_cursor(void *data, Evas_Object *obj, void *event_info); |
223 | void test_cursor2(void *data, Evas_Object *obj, void *event_info); | 224 | void test_cursor2(void *data, Evas_Object *obj, void *event_info); |
224 | void test_cursor3(void *data, Evas_Object *obj, void *event_info); | 225 | void test_cursor3(void *data, Evas_Object *obj, void *event_info); |
@@ -932,6 +933,7 @@ add_tests: | |||
932 | ADD_TEST(NULL, "Popups", "Tooltip", test_tooltip); | 933 | ADD_TEST(NULL, "Popups", "Tooltip", test_tooltip); |
933 | ADD_TEST(NULL, "Popups", "Tooltip 2", test_tooltip2); | 934 | ADD_TEST(NULL, "Popups", "Tooltip 2", test_tooltip2); |
934 | ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3); | 935 | ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3); |
936 | ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4); | ||
935 | ADD_TEST(NULL, "Popups", "Popup", test_popup); | 937 | ADD_TEST(NULL, "Popups", "Popup", test_popup); |
936 | 938 | ||
937 | //------------------------------// | 939 | //------------------------------// |
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, | |||
743 | evas_object_resize(win, 300, 300); | 743 | evas_object_resize(win, 300, 300); |
744 | evas_object_show(win); | 744 | evas_object_show(win); |
745 | } | 745 | } |
746 | |||
747 | void | ||
748 | test_tooltip4(void *data EINA_UNUSED, | ||
749 | Evas_Object *obj EINA_UNUSED, | ||
750 | void *event_info EINA_UNUSED) | ||
751 | { | ||
752 | Evas_Object *win, *bt; | ||
753 | |||
754 | win = elm_win_util_standard_add("tooltip4", "Tooltip 4"); | ||
755 | elm_win_autodel_set(win, EINA_TRUE); | ||
756 | evas_object_resize(win, 300, 300); | ||
757 | evas_object_show(win); | ||
758 | |||
759 | bt = elm_button_add(win); | ||
760 | elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!"); | ||
761 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_BOTTOM); | ||
762 | evas_object_resize(bt, 30, 30); | ||
763 | evas_object_move(bt, 5, 5); | ||
764 | evas_object_show(bt); | ||
765 | |||
766 | bt = elm_button_add(win); | ||
767 | elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!"); | ||
768 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_BOTTOM); | ||
769 | evas_object_resize(bt, 30, 30); | ||
770 | evas_object_move(bt, 250, 5); | ||
771 | evas_object_show(bt); | ||
772 | |||
773 | bt = elm_button_add(win); | ||
774 | elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!"); | ||
775 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_TOP); | ||
776 | evas_object_resize(bt, 30, 30); | ||
777 | evas_object_move(bt, 25, 265); | ||
778 | evas_object_show(bt); | ||
779 | |||
780 | bt = elm_button_add(win); | ||
781 | elm_object_tooltip_text_set(bt, "Tooltip!!!!!!!!!!!!!!!!!!"); | ||
782 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_TOP); | ||
783 | evas_object_resize(bt, 30, 30); | ||
784 | evas_object_move(bt, 235, 265); | ||
785 | evas_object_show(bt); | ||
786 | |||
787 | bt = elm_button_add(win); | ||
788 | elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L, | ||
789 | _tt_icon_del); | ||
790 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_RIGHT); | ||
791 | evas_object_resize(bt, 30, 30); | ||
792 | evas_object_move(bt, 135, 5); | ||
793 | evas_object_show(bt); | ||
794 | |||
795 | bt = elm_button_add(win); | ||
796 | elm_object_tooltip_content_cb_set(bt, _tt_icon, (void *)123L, | ||
797 | _tt_icon_del); | ||
798 | elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_LEFT); | ||
799 | evas_object_resize(bt, 30, 30); | ||
800 | evas_object_move(bt, 135, 255); | ||
801 | evas_object_show(bt); | ||
802 | } | ||
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, | |||
284 | Evas_Coord tw, Evas_Coord th, Evas_Coord cw, Evas_Coord ch) | 284 | Evas_Coord tw, Evas_Coord th, Evas_Coord cw, Evas_Coord ch) |
285 | { | 285 | { |
286 | Evas_Coord mx, my; | 286 | Evas_Coord mx, my; |
287 | Evas_Coord dx, dy; | ||
288 | Evas_Coord tcw, tch; | ||
289 | Evas_Coord px, py; | ||
287 | 290 | ||
288 | switch (tt->orient) | 291 | switch (tt->orient) |
289 | { | 292 | { |
@@ -345,11 +348,54 @@ _elm_tooltip_reconfigure_orient(Elm_Tooltip *tt, | |||
345 | return; | 348 | return; |
346 | } | 349 | } |
347 | 350 | ||
348 | if (mx < 0) mx = 0; | 351 | evas_object_geometry_get(tt->content, NULL, NULL, &tcw, &tch); |
349 | else if (mx + tw > cw) mx = cw - tw; | 352 | if (tcw <= 0 || tcw > tw) tcw = tw; |
353 | if (tch <= 0 || tch > th) tch = th; | ||
350 | 354 | ||
351 | if (my < 0) my = 0; | 355 | px = (tw - tcw) / 2; |
352 | else if (my + th > ch) my = ch - th; | 356 | py = (th - tch) / 2; |
357 | |||
358 | if (mx < 0) | ||
359 | { | ||
360 | dx = -mx; | ||
361 | mx = -(px / 2); | ||
362 | if (tt->rel_pos.x == 0.5) | ||
363 | { | ||
364 | tt->rel_pos.x = 0.5 - dx / (double)tcw; | ||
365 | if (tt->rel_pos.x < 0.0) tt->rel_pos.x = 0.0; | ||
366 | } | ||
367 | } | ||
368 | else if (mx + tw > cw) | ||
369 | { | ||
370 | dx = mx + tw - cw; | ||
371 | mx = cw - tw + px / 2; | ||
372 | if (tt->rel_pos.x == 0.5) | ||
373 | { | ||
374 | tt->rel_pos.x = 0.5 + dx / (double)tcw; | ||
375 | if (tt->rel_pos.x > 1.0) tt->rel_pos.x = 1.0; | ||
376 | } | ||
377 | } | ||
378 | |||
379 | if (my < 0) | ||
380 | { | ||
381 | dy = -my; | ||
382 | my = -(py / 2); | ||
383 | if (tt->rel_pos.y == 0.5) | ||
384 | { | ||
385 | tt->rel_pos.y = 0.5 - dy / (double)tch; | ||
386 | if (tt->rel_pos.y < 0.0) tt->rel_pos.y = 0.0; | ||
387 | } | ||
388 | } | ||
389 | else if (my + th > ch) | ||
390 | { | ||
391 | dy = my + th - ch; | ||
392 | my = ch - th + py / 2; | ||
393 | if (tt->rel_pos.y == 0.5) | ||
394 | { | ||
395 | tt->rel_pos.y = 0.5 + dy / (double)tch; | ||
396 | if (tt->rel_pos.y > 1.0) tt->rel_pos.y = 1.0; | ||
397 | } | ||
398 | } | ||
353 | 399 | ||
354 | evas_object_move(tt->tooltip, mx, my); | 400 | evas_object_move(tt->tooltip, mx, my); |
355 | evas_object_show(tt->tooltip); | 401 | evas_object_show(tt->tooltip); |