File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2443,12 +2443,27 @@ void Skin::drawTooltip(Widget* widget, bool atMouse)
24432443 irr::gui::ScalableFont* font = GUIEngine::getSmallFont ();
24442444 core::dimension2d<u32 > size =
24452445 font->getDimension (widget->getTooltipText ().c_str ());
2446+
24462447 core::position2di pos (widget->m_x + 15 , widget->m_y + widget->m_h );
2448+ const core::dimension2d<u32 > screen_size = irr_driver->getActualScreenSize ();
2449+ const int margin = 10 ; // Space from screen edges so tooltip doesn't get cut off
24472450
24482451 if (atMouse)
24492452 {
2450- pos = irr_driver->getDevice ()->getCursorControl ()->getPosition ()
2451- + core::position2di (10 - size.Width / 2 , 20 );
2453+ pos = irr_driver->getDevice ()->getCursorControl ()->getPosition ();
2454+ pos.X -= size.Width / 2 ;
2455+ pos.Y += 20 ;
2456+ }
2457+
2458+ // Fix horizontal position
2459+ if (pos.X + (int )size.Width > (int )screen_size.Width - margin)
2460+ {
2461+ pos.X = (int )screen_size.Width - size.Width - margin;
2462+ }
2463+
2464+ if (pos.X < margin)
2465+ {
2466+ pos.X = margin;
24522467 }
24532468
24542469 core::recti r (pos, size);
You can’t perform that action at this time.
0 commit comments