Commit e086fce8 authored by Jan Möbius's avatar Jan Möbius

Dennis: Use system cursor painting if stereo mode is not active.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6815 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2366e5bf
......@@ -180,7 +180,8 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// gl widget as parent to make sure that the CursorPainter will be deleted before
cursorPainter_ = new CursorPainter (glWidget_);
cursorPainter_->setEnabled (OpenFlipper::Options::glMouse ());
cursorPainter_->setForceNative (!OpenFlipper::Options::glMouse ());
cursorPainter_->setEnabled (stereoActive_);
glScene_->setCursorPainter (cursorPainter_);
centerWidget_ = new QGraphicsWidget;
......@@ -932,7 +933,7 @@ void CoreWidget::slotActivateExaminer()
/// Use native or gl painted cursor
void CoreWidget::setGlCursor ( bool _state )
{
cursorPainter_->setEnabled (_state);
cursorPainter_->setForceNative (!_state);
}
//=============================================================================
......
......@@ -74,6 +74,8 @@ void CoreWidget::slotToggleStereoMode()
stereoButton_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"mono.png") );
}
cursorPainter_->setEnabled (stereoActive_);
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->setStereoMode(stereoActive_);
}
......
......@@ -60,6 +60,7 @@ CursorPainter::CursorPainter (QObject *_parent) :
initialized_(false),
enabled_(false),
mouseIn_(false),
forceNative_(false),
texture_(0),
hasCursor_(false)
{
......@@ -79,11 +80,12 @@ CursorPainter::~CursorPainter ()
void CursorPainter::setCursor (const QCursor &_cursor)
{
cursor_ = _cursor;
nativeCursor_ = _cursor;
cursorToCursor ();
cursorToTexture ();
if (!(initialized_ && enabled_ && hasCursor_))
if (!(initialized_ && enabled_ && hasCursor_) || forceNative_)
foreach (glViewer *v, views_)
v->setCursor (cursor_);
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
//-----------------------------------------------------------------------------
......@@ -106,7 +108,7 @@ void CursorPainter::initializeGL()
cursorToTexture ();
if (enabled_ && hasCursor_)
if (enabled_ && hasCursor_ && !forceNative_)
{
foreach (glViewer *v, views_)
v->setCursor (Qt::BlankCursor);
......@@ -114,7 +116,7 @@ void CursorPainter::initializeGL()
else
{
foreach (glViewer *v, views_)
v->setCursor (cursor_);
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
}
......@@ -212,7 +214,7 @@ void CursorPainter::setEnabled(bool _enabled)
else
{
foreach (glViewer *v, views_)
v->setCursor (cursor_);
v->setCursor ((forceNative_)? nativeCursor_ : cursor_);
}
}
}
......@@ -221,7 +223,7 @@ void CursorPainter::setEnabled(bool _enabled)
bool CursorPainter::enabled()
{
return initialized_ && enabled_ && hasCursor_ && mouseIn_;
return initialized_ && enabled_ && hasCursor_ && mouseIn_ && !forceNative_;
}
//-----------------------------------------------------------------------------
......@@ -236,7 +238,7 @@ void CursorPainter::cursorToTexture()
hasCursor_ = false;
switch (cursor_.shape())
switch (nativeCursor_.shape())
{
case Qt::ArrowCursor:
cImg.load (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"cursor_arrow.png");
......@@ -295,5 +297,50 @@ 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
{
foreach (glViewer *v, views_)
v->setCursor (Qt::BlankCursor);
}
}
void CursorPainter::cursorToCursor()
{
QPixmap pix;
switch (nativeCursor_.shape())
{
case Qt::ArrowCursor:
pix.load (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"cursor_arrow.png");
if (!pix.isNull() && pix.width() == 32 && pix.height() == 32)
{
cursor_ = QCursor (pix, 0, 0);
}
else
cursor_ = nativeCursor_;
break;
case Qt::PointingHandCursor:
pix.load (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"cursor_hand.png");
if (!pix.isNull() && pix.width() == 32 && pix.height() == 32)
{
cursor_ = QCursor (pix, 7, 1);
}
else
cursor_ = nativeCursor_;
break;
default:
cursor_ = nativeCursor_;
return;
}
}
......@@ -88,6 +88,9 @@ class DLLEXPORT CursorPainter : public QObject
/// Enabled/Disables gl cursor painting
void setEnabled (bool _enabled);
/// Enabled/Disables native cursors
void setForceNative (bool _enabled);
/// Returns true if cursor painting is enabled and compatible cursor is set
bool enabled ();
......@@ -100,9 +103,11 @@ class DLLEXPORT CursorPainter : public QObject
private:
// Create a texture for the cursor
void cursorToTexture ();
void cursorToCursor ();
private:
QCursor cursor_;
QCursor nativeCursor_;
QPointF cursorPos_;
bool initialized_;
......@@ -111,6 +116,7 @@ class DLLEXPORT CursorPainter : public QObject
bool enabled_;
bool mouseIn_;
bool forceNative_;
// x and y offset between click position and texture (hotspot)
int xOff_;
......
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