Commit 57bdc15c authored by Jan Möbius's avatar Jan Möbius
Browse files

Fixed some bugs in cursor handling

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8160 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 11273de7
...@@ -86,7 +86,7 @@ void Core::applyOptions(){ ...@@ -86,7 +86,7 @@ void Core::applyOptions(){
coreWidget_->showLogger( OpenFlipper::Options::loggerState() ); coreWidget_->showLogger( OpenFlipper::Options::loggerState() );
// gl mouse cursor // gl mouse cursor
coreWidget_->setGlCursor( OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() ); coreWidget_->setForceNativeCursor( OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
// Prepare Picking Debugger Flag // Prepare Picking Debugger Flag
ACG::SceneGraph::PickTarget target; ACG::SceneGraph::PickTarget target;
......
...@@ -1027,9 +1027,9 @@ void CoreWidget::slotActivateExaminer() ...@@ -1027,9 +1027,9 @@ void CoreWidget::slotActivateExaminer()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Use native or gl painted cursor /// Use native or gl painted cursor
void CoreWidget::setGlCursor ( bool _state ) void CoreWidget::setForceNativeCursor ( bool _state )
{ {
cursorPainter_->setForceNative (!_state); cursorPainter_->setForceNative (_state);
} }
//============================================================================= //=============================================================================
......
...@@ -365,7 +365,7 @@ public: ...@@ -365,7 +365,7 @@ public:
void showToolbox( bool _state ); void showToolbox( bool _state );
/// Use native or gl painted cursor /// Use native or gl painted cursor
void setGlCursor ( bool _state ); void setForceNativeCursor ( bool _state );
private: private:
OpenFlipper::Options::LoggerState loggerState_; OpenFlipper::Options::LoggerState loggerState_;
......
...@@ -179,7 +179,7 @@ void CoreWidget::dropEvent ( QDropEvent* _event ) { ...@@ -179,7 +179,7 @@ void CoreWidget::dropEvent ( QDropEvent* _event ) {
return; return;
} }
emit log(LOGERR , tr("Unknown drop event! Unable to handle the dropped data!")); emit log(LOGERR , tr("Unknown drop event! Unable to handle the dropped data! Received data: %1").arg(view));
} }
......
...@@ -83,9 +83,10 @@ void CursorPainter::setCursor (const QCursor &_cursor) ...@@ -83,9 +83,10 @@ void CursorPainter::setCursor (const QCursor &_cursor)
nativeCursor_ = _cursor; nativeCursor_ = _cursor;
cursorToCursor (); cursorToCursor ();
cursorToTexture (); cursorToTexture ();
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_) if (!(initialized_ && enabled_ && hasCursor_) || forceNative_) {
foreach (glViewer *v, views_) foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_); v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -112,11 +113,13 @@ void CursorPainter::initializeGL() ...@@ -112,11 +113,13 @@ void CursorPainter::initializeGL()
{ {
foreach (glViewer *v, views_) foreach (glViewer *v, views_)
v->setCursor (Qt::BlankCursor); v->setCursor (Qt::BlankCursor);
} }
else else
{ {
foreach (glViewer *v, views_) foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_); v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
} }
} }
...@@ -216,7 +219,7 @@ void CursorPainter::setEnabled(bool _enabled) ...@@ -216,7 +219,7 @@ void CursorPainter::setEnabled(bool _enabled)
foreach (glViewer *v, views_) foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_); v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
} }
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -230,14 +233,17 @@ bool CursorPainter::enabled() ...@@ -230,14 +233,17 @@ bool CursorPainter::enabled()
void CursorPainter::cursorToTexture() void CursorPainter::cursorToTexture()
{ {
if (!initialized_)
if (!initialized_) {
return; return;
}
unsigned char buf[4096]; unsigned char buf[4096];
QImage cImg; QImage cImg;
hasCursor_ = false; hasCursor_ = false;
///\todo Handle whats this cursor! And possibly switch all cursors to bitmap cursors!
switch (nativeCursor_.shape()) switch (nativeCursor_.shape())
{ {
case Qt::ArrowCursor: case Qt::ArrowCursor:
...@@ -250,12 +256,20 @@ void CursorPainter::cursorToTexture() ...@@ -250,12 +256,20 @@ void CursorPainter::cursorToTexture()
xOff_ = 7; xOff_ = 7;
yOff_ = 1; yOff_ = 1;
break; break;
default: case Qt::BitmapCursor:
xOff_ = nativeCursor_.hotSpot().x();
yOff_ = nativeCursor_.hotSpot().y();
cImg = QImage(( nativeCursor_.pixmap().toImage() ) );
break;
default:
std::cerr << "cursorToTexture: Unknown cursor shape!" << nativeCursor_.shape() << std::endl;
return; return;
} }
if (cImg.width () != 32 || cImg.height () != 32) if (cImg.width () != 32 || cImg.height () != 32) {
std::cerr << "cursorToTexture: Dimension error" << nativeCursor_.shape() << std::endl;
return; return;
}
// convert ARGB QImage to RGBA for gl // convert ARGB QImage to RGBA for gl
int index = 0; int index = 0;
...@@ -300,10 +314,12 @@ QRectF CursorPainter::cursorBoundingBox() ...@@ -300,10 +314,12 @@ QRectF CursorPainter::cursorBoundingBox()
void CursorPainter::setForceNative(bool _enabled) void CursorPainter::setForceNative(bool _enabled)
{ {
forceNative_ = _enabled; forceNative_ = _enabled;
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_) if (!(initialized_ && enabled_ && hasCursor_) || forceNative_)
{ {
foreach (glViewer *v, views_) foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_); v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
} }
else else
{ {
......
...@@ -1477,10 +1477,13 @@ void glViewer::grabGLArea() ...@@ -1477,10 +1477,13 @@ void glViewer::grabGLArea()
{ {
glareaGrabbed_ = true; glareaGrabbed_ = true;
if (cursorPainter_) if (cursorPainter_) {
cursorPainter_->setCursor(Qt::BlankCursor); cursorPainter_->setCursor(Qt::BlankCursor);
else std::cerr << "grabGLArea: Blanking cursorpainter cursor" << std::endl;
} else {
setCursor(Qt::BlankCursor); setCursor(Qt::BlankCursor);
std::cerr << "grabGLArea: Blanking qt cursor" << std::endl;
}
grabMouse(); grabMouse();
grabKeyboard(); grabKeyboard();
} }
...@@ -1492,10 +1495,13 @@ void glViewer::releaseGLArea() ...@@ -1492,10 +1495,13 @@ void glViewer::releaseGLArea()
ungrabMouse(); ungrabMouse();
ungrabKeyboard(); ungrabKeyboard();
if (cursorPainter_) if (cursorPainter_) {
cursorPainter_->setCursor(Qt::ArrowCursor); cursorPainter_->setCursor(Qt::ArrowCursor);
else std::cerr << "grabGLArea: Setting cursorPainter cursor to arrow" << std::endl;
} else {
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
std::cerr << "grabGLArea: Setting qt cursor to arrow" << std::endl;
}
} }
......
...@@ -73,7 +73,7 @@ SimpleGLGraphicsScene::SimpleGLGraphicsScene () : ...@@ -73,7 +73,7 @@ SimpleGLGraphicsScene::SimpleGLGraphicsScene () :
initialized_(false) initialized_(false)
{ {
cursorPainter_ = new CursorPainter (this); cursorPainter_ = new CursorPainter (this);
cursorPainter_->setEnabled( OpenFlipperSettings().value("Core/Gui/glViewer/glMouse",true).toBool() ); cursorPainter_->setEnabled( OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment