Merge remote-tracking branch 'aesylwinn/FixFocus'

pull/1/head
Marc Zinnschlag 9 years ago
commit 3dce406829

@ -308,6 +308,17 @@ namespace CSVRender
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
}
void FreeCameraController::resetInput()
{
mFast = false;
mLeft = false;
mRight = false;
mForward = false;
mBackward = false;
mRollLeft = false;
mRollRight = false;
}
void FreeCameraController::yaw(double value)
{
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp);
@ -535,6 +546,17 @@ namespace CSVRender
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
}
void OrbitCameraController::resetInput()
{
mFast = false;
mLeft = false;
mRight =false;
mUp = false;
mDown = false;
mRollLeft = false;
mRollRight = false;
}
void OrbitCameraController::onActivate()
{
mInitialized = false;

@ -51,6 +51,8 @@ namespace CSVRender
virtual void update(double dt) = 0;
virtual void resetInput() = 0;
protected:
virtual void onActivate(){}
@ -87,6 +89,8 @@ namespace CSVRender
void update(double dt);
void resetInput();
private:
void yaw(double value);
@ -126,6 +130,8 @@ namespace CSVRender
void update(double dt);
void resetInput();
private:
void onActivate();

@ -175,6 +175,7 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
// Recieve mouse move event even if mouse button is not pressed
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
/// \todo make shortcut configurable
QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
@ -291,6 +292,11 @@ void SceneWidget::mouseMoveEvent (QMouseEvent *event)
mPrevMouseY = event->y();
}
void SceneWidget::focusOutEvent (QFocusEvent *event)
{
mCurrentCamControl->resetInput();
}
void SceneWidget::wheelEvent(QWheelEvent *event)
{
mCurrentCamControl->handleMouseMoveEvent("t-navi", event->delta(), 0);

@ -96,6 +96,7 @@ namespace CSVRender
virtual void wheelEvent (QWheelEvent *event);
virtual void keyPressEvent (QKeyEvent *event);
virtual void keyReleaseEvent (QKeyEvent *event);
virtual void focusOutEvent (QFocusEvent *event);
/// \return Is \a key a button mapping setting? (ignored otherwise)
virtual bool storeMappingSetting (const CSMPrefs::Setting *setting);

@ -245,7 +245,6 @@ bool GraphicsWindowQt::init( QWidget* parent, const QGLWidget* shareWidget, Qt::
// initialize widget properties
_widget->setAutoBufferSwap( false );
_widget->setMouseTracking( true );
_widget->setFocusPolicy( Qt::WheelFocus );
_widget->setGraphicsWindow( this );
useCursor( _traits->useCursor );

Loading…
Cancel
Save