Commit 2e563c68 authored by Jan Möbius's avatar Jan Möbius

Fixed some bugs in cursor handling

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8160 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9db29566
......@@ -86,7 +86,7 @@ void Core::applyOptions(){
coreWidget_->showLogger( OpenFlipper::Options::loggerState() );
// 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
ACG::SceneGraph::PickTarget target;
......
......@@ -1027,9 +1027,9 @@ void CoreWidget::slotActivateExaminer()
//-----------------------------------------------------------------------------
/// 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:
void showToolbox( bool _state );
/// Use native or gl painted cursor
void setGlCursor ( bool _state );
void setForceNativeCursor ( bool _state );
private:
OpenFlipper::Options::LoggerState loggerState_;
......
......@@ -179,7 +179,7 @@ void CoreWidget::dropEvent ( QDropEvent* _event ) {
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)
nativeCursor_ = _cursor;
cursorToCursor ();
cursorToTexture ();
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_)
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_) {
foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
}
//-----------------------------------------------------------------------------
......@@ -112,11 +113,13 @@ void CursorPainter::initializeGL()
{
foreach (glViewer *v, views_)
v->setCursor (Qt::BlankCursor);
}
else
{
foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
}
......@@ -216,7 +219,7 @@ void CursorPainter::setEnabled(bool _enabled)
foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
}
}
}
//-----------------------------------------------------------------------------
......@@ -230,14 +233,17 @@ bool CursorPainter::enabled()
void CursorPainter::cursorToTexture()
{
if (!initialized_)
if (!initialized_) {
return;
}
unsigned char buf[4096];
QImage cImg;
hasCursor_ = false;
///\todo Handle whats this cursor! And possibly switch all cursors to bitmap cursors!
switch (nativeCursor_.shape())
{
case Qt::ArrowCursor:
......@@ -250,12 +256,20 @@ void CursorPainter::cursorToTexture()
xOff_ = 7;
yOff_ = 1;
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;
}
if (cImg.width () != 32 || cImg.height () != 32)
if (cImg.width () != 32 || cImg.height () != 32) {
std::cerr << "cursorToTexture: Dimension error" << nativeCursor_.shape() << std::endl;
return;
}
// convert ARGB QImage to RGBA for gl
int index = 0;
......@@ -300,10 +314,12 @@ QRectF CursorPainter::cursorBoundingBox()
void CursorPainter::setForceNative(bool _enabled)
{
forceNative_ = _enabled;
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_)
{
foreach (glViewer *v, views_)
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
else
{
......
......@@ -1477,10 +1477,13 @@ void glViewer::grabGLArea()
{
glareaGrabbed_ = true;
if (cursorPainter_)
if (cursorPainter_) {
cursorPainter_->setCursor(Qt::BlankCursor);
else
std::cerr << "grabGLArea: Blanking cursorpainter cursor" << std::endl;
} else {
setCursor(Qt::BlankCursor);
std::cerr << "grabGLArea: Blanking qt cursor" << std::endl;
}
grabMouse();
grabKeyboard();
}
......@@ -1492,10 +1495,13 @@ void glViewer::releaseGLArea()
ungrabMouse();
ungrabKeyboard();
if (cursorPainter_)
if (cursorPainter_) {
cursorPainter_->setCursor(Qt::ArrowCursor);
else
std::cerr << "grabGLArea: Setting cursorPainter cursor to arrow" << std::endl;
} else {
setCursor(Qt::ArrowCursor);
std::cerr << "grabGLArea: Setting qt cursor to arrow" << std::endl;
}
}
......
......@@ -73,7 +73,7 @@ SimpleGLGraphicsScene::SimpleGLGraphicsScene () :
initialized_(false)
{
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