tooltip now calcs position more effectively during ADJUST(FLIP)
authorMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 8 Dec 2014 01:08:36 +0000 (20:08 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 8 Dec 2014 01:22:30 +0000 (20:22 -0500)
src/lib/els_tooltip.c

index 79b1494aa7a8afb0c987c39a0d77e2e724593253..7d68cf0feb0f1e580119d828617bb32f534556a7 100644 (file)
@@ -455,15 +455,23 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
    TTDBG("ADJUST (POINTER):  tx=%d,ty=%d\n", tx, ty);
    if ((tx < 0) || (tx + tw > cw))
      {
-        /* if we're offscreen, try to flip over the Y axis */
-        if ((tx < 0) && (abs((tx + 2 * tw) - cw) < abs(tx)))
-          tx += tw;
+        if (tx < 0)
+          {
+             /* if we're offscreen to the left, try to flip over the Y axis */
+             if (abs((tx + 2 * tw) - cw) < abs(tx))
+               tx += tw;
+             else
+               tx = 0;
+          }
         else if (tx + tw > cw)
           {
              int test_x = tx - tw;
 
+             /* if we're offscreen to the right, try to flip over the Y axis */
              if ((test_x >= 0) || (tx + tw - cw > abs(test_x)))
                tx -= tw;
+             else
+               tx = cw - tw;
           }
      }
    else if ((tx > px) && (px > tw))
@@ -473,15 +481,23 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
      }
    if ((ty < 0) || (ty + th > ch))
      {
-        /* if we're offscreen, try to flip over the X axis */
-        if ((ty < 0) && (abs((ty + 2 * th) - ch) < abs(ty)))
-          ty += th;
+        if (ty < 0)
+          {
+             /* if we're offscreen to the top, try to flip over the X axis */
+             if (abs((ty + 2 * th) - ch) < abs(ty))
+               ty += th;
+             else
+               ty = 0;
+          }
         else if (ty + th > ch)
           {
              int test_y = ty - th;
 
+             /* if we're offscreen to the bottom, try to flip over the X axis */
              if ((test_y >= 0) || (ty + th - ch > abs(test_y)))
                ty -= th;
+             else
+               ty = ch - th;
           }
      }
    else if ((ty > py) && (py > th))