From dc976794d9c35d59ac4664008e1d84d5cc348952 Mon Sep 17 00:00:00 2001 From: Tats Date: Tue, 21 Oct 2014 20:16:23 +0000 Subject: [PATCH] Added crosshair in fullscreen mode (automatic). --- DestinationGLCanvas.cpp | 17 ++++++++++++++++- DestinationGLCanvas.h | 6 ++++++ OutputGLWindow.cpp | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index ee6646d..5f8e1d2 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -22,7 +22,8 @@ #include "MainWindow.h" DestinationGLCanvas::DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget) -: MapperGLCanvas(mainWindow, parent, shareWidget) +: MapperGLCanvas(mainWindow, parent, shareWidget), + _displayCrosshair(false) { } @@ -58,5 +59,19 @@ void DestinationGLCanvas::doDraw(QPainter* painter) } glPopMatrix(); + + // Display crosshair cursor. + if (_displayCrosshair) + { + const QPoint& cursorPosition = QCursor::pos(); + const QRect& geo = geometry(); + if (geo.contains(cursorPosition)) + { + painter->setPen(MM::CONTROL_COLOR); + painter->drawLine(cursorPosition.x(), 0, cursorPosition.x(), geo.height()); + painter->drawLine(0, cursorPosition.y(), geo.width(), cursorPosition.y()); + } + } + } diff --git a/DestinationGLCanvas.h b/DestinationGLCanvas.h index cfd270a..bbd5d45 100644 --- a/DestinationGLCanvas.h +++ b/DestinationGLCanvas.h @@ -36,8 +36,14 @@ public: virtual Shape* getShapeFromMappingId(uid mappingId); + void setDisplayCrosshair(bool displayCrosshair) { + _displayCrosshair = displayCrosshair; + } + private: virtual void doDraw(QPainter* painter); + + bool _displayCrosshair; }; #endif /* DESTINATIONGLCANVAS_H_ */ diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp index 2b68991..d39ac6c 100644 --- a/OutputGLWindow.cpp +++ b/OutputGLWindow.cpp @@ -89,6 +89,10 @@ void OutputGLWindow::keyPressEvent(QKeyEvent *event) void OutputGLWindow::setFullScreen(bool fullscreen) { + // Activate crosshair in fullscreen mode. + setCursorVisible(!fullscreen); + canvas->setDisplayCrosshair(fullscreen); + // NOTE: The showFullScreen() method does not work well under Ubuntu Linux. The code below fixes the issue. // Notice that there might be problems with the fullscreen in other OS / window managers. If so, please add // the code to fix those issues here.