From e570710974290cf765e64098e14b44b02ca42471 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 6 Feb 2007 14:22:44 +0000 Subject: [PATCH] To fit the tooltip rectangle in the screen borders --- src/GLViewer/GLViewer_ViewPort2d.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 3055726ec..cf065aa64 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -1388,6 +1389,13 @@ void GLViewer_ViewPort2d::onMaybeTip( QPoint thePoint, QString& theText, QFont& theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height, aSize.width(), aSize.height() ); theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 ); + + QPoint aBottomRightGlobal = mapToGlobal( theTextReg.bottomRight() ); + int dx = aBottomRightGlobal.x() - QApplication::desktop()->screenGeometry().width(); + int dy = aBottomRightGlobal.y() - QApplication::desktop()->screenGeometry().height(); + dx = dx < 0 ? 0 : -dx; + dy = dy < 0 ? 0 : -dy; + theTextReg.moveBy( dx, dy ); } } } -- 2.39.2