summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-28 01:32:40 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-28 01:32:40 +0000
commitb5de44b9fe696f209edfe7fe5aa474919f7ecd52 (patch)
tree8462be8399fb530185c1f999c4c36775b33374ab
parenta96869921cdd9a3eeb09290dafb1cc90e23d48db (diff)
now apply style correctly to free size tooltips, and remember that time I said that I was done with tt position calculations? I lied. this commit is the pinnacle of tooltip position calculating technology. also inverts position of tooltip so it doesn't get stupidly hidden by the pointer
SVN revision: 61833
-rw-r--r--src/lib/els_tooltip.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/lib/els_tooltip.c b/src/lib/els_tooltip.c
index 35fe37c50..876949fe9 100644
--- a/src/lib/els_tooltip.c
+++ b/src/lib/els_tooltip.c
@@ -117,7 +117,6 @@ _elm_tooltip_show(Elm_Tooltip *tt)
117 elm_win_override_set(tt->tt_win, EINA_TRUE); 117 elm_win_override_set(tt->tt_win, EINA_TRUE);
118 tt->tt_evas = evas_object_evas_get(tt->tt_win); 118 tt->tt_evas = evas_object_evas_get(tt->tt_win);
119 tt->tooltip = edje_object_add(tt->tt_evas); 119 tt->tooltip = edje_object_add(tt->tt_evas);
120 evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
121 evas_object_move(tt->tooltip, 0, 0); 120 evas_object_move(tt->tooltip, 0, 0);
122 elm_win_resize_object_add(tt->tt_win, tt->tooltip); 121 elm_win_resize_object_add(tt->tt_win, tt->tooltip);
123#ifdef HAVE_ELEMENTARY_X 122#ifdef HAVE_ELEMENTARY_X
@@ -138,7 +137,6 @@ _elm_tooltip_show(Elm_Tooltip *tt)
138 evas_object_event_callback_add 137 evas_object_event_callback_add
139 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt); 138 (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, _elm_tooltip_obj_mouse_move_cb, tt);
140 139
141 evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
142 tt->changed_style = EINA_TRUE; 140 tt->changed_style = EINA_TRUE;
143 _elm_tooltip_reconfigure_job_start(tt); 141 _elm_tooltip_reconfigure_job_start(tt);
144} 142}
@@ -260,7 +258,7 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
260 { 258 {
261 const char *style = tt->style ? tt->style : "default"; 259 const char *style = tt->style ? tt->style : "default";
262 const char *str; 260 const char *str;
263 if (!_elm_theme_object_set(tt->owner, tt->tooltip, "tooltip", "base", style)) 261 if (!_elm_theme_object_set(tt->tt_win ? NULL : tt->owner, tt->tooltip, "tooltip", "base", style))
264 { 262 {
265 ERR("Could not apply the theme to the tooltip! style=%s", style); 263 ERR("Could not apply the theme to the tooltip! style=%s", style);
266 if (tt->tt_win) evas_object_del(tt->tt_win); 264 if (tt->tt_win) evas_object_del(tt->tt_win);
@@ -313,7 +311,7 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
313 evas_object_pass_events_set(tt->tooltip, EINA_TRUE); 311 evas_object_pass_events_set(tt->tooltip, EINA_TRUE);
314 tt->changed_style = EINA_FALSE; 312 tt->changed_style = EINA_FALSE;
315 if (tt->tooltip) 313 if (tt->tooltip)
316 edje_object_part_swallow(tt->tooltip, "elm.swallow.content", 314 edje_object_part_swallow(tt->tooltip, "elm.swallow.content",
317 tt->content); 315 tt->content);
318 316
319 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm"); 317 edje_object_signal_emit(tt->tooltip, "elm,action,show", "elm");
@@ -382,7 +380,6 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
382 ox += x; 380 ox += x;
383 oy += y; 381 oy += y;
384 } 382 }
385
386 else 383 else
387 evas_pointer_canvas_xy_get(tt->evas, &px, &py); 384 evas_pointer_canvas_xy_get(tt->evas, &px, &py);
388 385
@@ -390,51 +387,60 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
390 (px <= ox + ow) && (py <= oy + oh)); 387 (px <= ox + ow) && (py <= oy + oh));
391 if (inside_eventarea) 388 if (inside_eventarea)
392 { 389 {
393 tx = px; 390 tx = px - tw;
394 ty = py; 391 ty = py - th;
395
396 if (tx + tw + tt->pad.x < cw) tx += tt->pad.x;
397 if (ty + th + tt->pad.y < ch) ty += tt->pad.y;
398 } 392 }
399 else 393 else
400 { 394 {
401 tx = ox + (ow / 2) - (tw / 2); 395 tx = ox + (ow / 2) - (tw / 2);
402 if (ch < (th + oy + oh)) ty = oy - th; 396 if (0 > (th - oy - oh)) ty = oy + th;
403 else ty = oy + oh; 397 else ty = oy - oh;
404 } 398 }
405 399
406 if (tx + tw > cw) 400 if (tx < 0)
407 { 401 {
408 if (abs(tx - tw) < (tx + tw) - cw) 402 if (abs((tx + 2 * tw) - cw) < abs(tx))
409 tx -= tw; 403 tx += tw;
410 } 404 }
411 else if ((tx < px) && (px < tx + tw)) 405 else if ((tx > px) && (px > tx))
412 { 406 {
413 if (0 < tx - tw) 407 if (tx + tw < cw)
414 tx -= tw; 408 tx += tw;
415 } 409 }
416 if (ty + th > ch) 410 if (ty < 0)
417 { 411 {
418 if (abs(ty - th) < (ty + th) - ch) 412 if (abs((ty + 2 * th) - ch) < abs(ty))
419 ty -= th; 413 ty += th;
420 } 414 }
421 else if ((ty < py) && (py < ty + th)) 415 else if ((ty > py) && (py > ty))
422 { 416 {
423 if (0 < ty - th) 417 if (ty + th < ch)
424 ty -= th; 418 ty += th;
419 }
420 if (inside_eventarea)
421 {
422 if ((tx == px) && ((tx + tw + tt->pad.x < cw) || (tx + tw > cw))) tx += tt->pad.x;
423 else if ((tx - tt->pad.x > 0) || (tx < 0)) tx -= tt->pad.x;
424 if ((ty == py) && ((ty + th + tt->pad.y < ch) || (ty + th > ch))) ty += tt->pad.y;
425 else if ((ty - tt->pad.y > 0) || (ty < 0)) ty -= tt->pad.y;
425 } 426 }
426
427 if (tt->pad.bx * 2 + tw < cw) 427 if (tt->pad.bx * 2 + tw < cw)
428 { 428 {
429 if (tx < tt->pad.bx) tx = tt->pad.bx; 429 if (tx < tt->pad.bx) tx = tt->pad.bx;
430 else if (tx + tw >= cw - tt->pad.bx) tx = cw - tw - tt->pad.bx; 430 else if ((tx >= tw) && (tx + tt->pad.bx <= cw)) tx += tt->pad.bx;
431 else if (tx - tt->pad.bx >= 0) tx -= tt->pad.bx;
431 } 432 }
433 else if (tx < 0) tx -= tt->pad.bx;
434 else if (tx > cw) tx += tt->pad.bx;
432 435
433 if (tt->pad.by * 2 + th < ch) 436 if (tt->pad.by * 2 + th < ch)
434 { 437 {
435 if (ty < tt->pad.by) ty = tt->pad.by; 438 if (ty < tt->pad.by) ty = tt->pad.by;
436 else if (ty + th >= ch - tt->pad.by) ty = ch - th - tt->pad.by; 439 else if ((ty >= th) && (ty + tt->pad.by <= ch)) ty += tt->pad.by;
440 else if (ty - tt->pad.by >= 0) ty -= tt->pad.by;
437 } 441 }
442 else if (ty < 0) ty -= tt->pad.by;
443 else if (ty > ch) ty += tt->pad.by;
438 444
439 evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty); 445 evas_object_move(tt->tt_win ? : tt->tooltip, tx, ty);
440 evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th); 446 evas_object_resize(tt->tt_win ? : tt->tooltip, tw, th);