MCPcopy Create free account
hub / github.com/davisking/dlib / show_tooltip

Method show_tooltip

dlib/gui_widgets/base_widgets.h:640–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638 };
639
640 void show_tooltip (
641 )
642 {
643 auto_mutex M(m);
644 long x, y;
645 // if the mouse has moved since we started the timer then
646 // keep waiting until the user stops moving it
647 if (lastx != stuff->x || lasty != stuff->y)
648 {
649 stuff->x = lastx;
650 stuff->y = lasty;
651 return;
652 }
653
654 unsigned long display_width, display_height;
655 // stop the timer
656 stuff->tt_timer.stop();
657 parent.get_pos(x,y);
658 x += lastx+15;
659 y += lasty+15;
660
661 // make sure the tooltip isn't going to be off the screen
662 parent.get_display_size(display_width, display_height);
663 rectangle wrect(move_rect(stuff->win.rect_all,x,y));
664 rectangle srect(display_width, display_height);
665 if (srect.contains(wrect) == false)
666 {
667 rectangle temp(srect.intersect(wrect));
668 x -= wrect.width()-temp.width();
669 y -= wrect.height()-temp.height();
670 }
671
672 stuff->win.set_pos(x,y);
673 stuff->win.show();
674 }
675
676 // put all this stuff in data so we can arrange to only
677 // construct it when someone is actually using the tooltip widget

Callers

nothing calls this directly

Calls 7

move_rectFunction · 0.85
containsMethod · 0.45
intersectMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
set_posMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected