mirror of https://github.com/qt/qt3d.git
Rename to QMouseInput to QMouseHandler
also: - rename property controller to sourceDevice - remove protected ctor - move other protected methods to dpointer Change-Id: Ibce97ec4ab7927ec2bb758f3e872691d52e3c785 Task-Id: QTBUG-51443 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
619466455f
commit
c3ed77c7af
|
|
@ -100,8 +100,8 @@ Entity {
|
|||
scale: sphere1.scaleFactor
|
||||
}
|
||||
|
||||
property MouseInput mouseInput : MouseInput {
|
||||
controller: mouseController
|
||||
property MouseHandler mouseHandler : MouseHandler {
|
||||
sourceDevice: mouseController
|
||||
|
||||
onClicked: {
|
||||
//Signal not implemented yet
|
||||
|
|
@ -120,6 +120,6 @@ Entity {
|
|||
}
|
||||
}
|
||||
|
||||
components: [sphereMesh, material, transform, mouseInput]
|
||||
components: [sphereMesh, material, transform, mouseHandler]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ QEntityPrivate::QEntityPrivate()
|
|||
backend aspect will be able to interpret and process an Entity by
|
||||
recognizing which components it is made up of. One aspect may decide to only
|
||||
process entities composed of a single Qt3DCore::QTransform component whilst
|
||||
another may focus on Qt3DCore::QMouseInput.
|
||||
another may focus on Qt3DCore::QMouseHandler.
|
||||
|
||||
\sa Qt3DCore::QComponent, Qt3DCore::QTransform
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ HEADERS += \
|
|||
$$PWD/assignkeyboardfocusjob_p.h \
|
||||
$$PWD/keyeventdispatcherjob_p.h \
|
||||
$$PWD/mousecontroller_p.h \
|
||||
$$PWD/mouseinput_p.h \
|
||||
$$PWD/mousehandler_p.h \
|
||||
$$PWD/mouseeventdispatcherjob_p.h \
|
||||
$$PWD/mouseeventfilter_p.h \
|
||||
$$PWD/axisinput_p.h \
|
||||
|
|
@ -37,7 +37,7 @@ SOURCES += \
|
|||
$$PWD/assignkeyboardfocusjob.cpp \
|
||||
$$PWD/keyeventdispatcherjob.cpp \
|
||||
$$PWD/mousecontroller.cpp \
|
||||
$$PWD/mouseinput.cpp \
|
||||
$$PWD/mousehandler.cpp \
|
||||
$$PWD/mouseeventfilter.cpp \
|
||||
$$PWD/mouseeventdispatcherjob.cpp \
|
||||
$$PWD/axisinput.cpp \
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Input {
|
|||
class KeyboardController;
|
||||
class KeyboardInput;
|
||||
class MouseController;
|
||||
class MouseInput;
|
||||
class MouseHandler;
|
||||
class Axis;
|
||||
class AxisActionHandler;
|
||||
class AxisInput;
|
||||
|
|
@ -76,7 +76,7 @@ class GenericDeviceBackendNode;
|
|||
typedef Qt3DCore::QHandle<KeyboardController, 8> HKeyboardController;
|
||||
typedef Qt3DCore::QHandle<KeyboardInput, 16> HKeyboardInput;
|
||||
typedef Qt3DCore::QHandle<MouseController, 8> HMouseController;
|
||||
typedef Qt3DCore::QHandle<MouseInput, 16> HMouseInput;
|
||||
typedef Qt3DCore::QHandle<MouseHandler, 16> HMouseHandler;
|
||||
typedef Qt3DCore::QHandle<Axis, 16> HAxis;
|
||||
typedef Qt3DCore::QHandle<AxisActionHandler, 16> HAxisActionHandler;
|
||||
typedef Qt3DCore::QHandle<AxisSetting, 16> HAxisSetting;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
#include <Qt3DInput/private/keyboardcontroller_p.h>
|
||||
#include <Qt3DInput/private/keyboardinput_p.h>
|
||||
#include <Qt3DInput/private/mousecontroller_p.h>
|
||||
#include <Qt3DInput/private/mouseinput_p.h>
|
||||
#include <Qt3DInput/private/mousehandler_p.h>
|
||||
#include <Qt3DCore/private/qresourcemanager_p.h>
|
||||
#include <Qt3DInput/private/actioninput_p.h>
|
||||
#include <Qt3DInput/private/inputsequence_p.h>
|
||||
|
|
@ -104,7 +104,7 @@ public:
|
|||
};
|
||||
|
||||
class MouseInputManager : public Qt3DCore::QResourceManager<
|
||||
MouseInput,
|
||||
MouseHandler,
|
||||
Qt3DCore::QNodeId,
|
||||
16,
|
||||
Qt3DCore::ArrayAllocatingPolicy>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "mouseeventdispatcherjob_p.h"
|
||||
#include "inputhandler_p.h"
|
||||
#include "mouseinput_p.h"
|
||||
#include "mousehandler_p.h"
|
||||
#include "inputmanagers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -62,7 +62,7 @@ void MouseEventDispatcherJob::setInputHandler(InputHandler *handler)
|
|||
|
||||
void MouseEventDispatcherJob::run()
|
||||
{
|
||||
MouseInput *input = m_inputHandler->mouseInputManager()->lookupResource(m_mouseInput);
|
||||
MouseHandler *input = m_inputHandler->mouseInputManager()->lookupResource(m_mouseInput);
|
||||
if (input) {
|
||||
Q_FOREACH (const QT_PREPEND_NAMESPACE(QMouseEvent) &e, m_events) {
|
||||
// Send events to frontend
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mouseinput_p.h"
|
||||
#include "mousehandler_p.h"
|
||||
#include "mousecontroller_p.h"
|
||||
#include "inputmanagers_p.h"
|
||||
#include "inputhandler_p.h"
|
||||
|
||||
#include <Qt3DInput/qmouseinput.h>
|
||||
#include <Qt3DInput/qmousehandler.h>
|
||||
#include <Qt3DInput/qmousecontroller.h>
|
||||
#include <Qt3DCore/qscenepropertychange.h>
|
||||
#include <Qt3DCore/qbackendscenepropertychange.h>
|
||||
|
|
@ -54,36 +54,36 @@ using namespace Qt3DCore;
|
|||
namespace Qt3DInput {
|
||||
namespace Input {
|
||||
|
||||
MouseInput::MouseInput()
|
||||
MouseHandler::MouseHandler()
|
||||
: QBackendNode(ReadWrite)
|
||||
, m_enabled(false)
|
||||
, m_inputHandler(Q_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
MouseInput::~MouseInput()
|
||||
MouseHandler::~MouseHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void MouseInput::updateFromPeer(Qt3DCore::QNode *peer)
|
||||
void MouseHandler::updateFromPeer(Qt3DCore::QNode *peer)
|
||||
{
|
||||
QMouseInput *input = static_cast<QMouseInput *>(peer);
|
||||
if (input->controller() != Q_NULLPTR)
|
||||
setController(input->controller()->id());
|
||||
QMouseHandler *input = static_cast<QMouseHandler *>(peer);
|
||||
if (input->sourceDevice() != Q_NULLPTR)
|
||||
setController(input->sourceDevice()->id());
|
||||
m_enabled = input->isEnabled();
|
||||
}
|
||||
|
||||
Qt3DCore::QNodeId MouseInput::mouseController() const
|
||||
Qt3DCore::QNodeId MouseHandler::mouseController() const
|
||||
{
|
||||
return m_mouseController;
|
||||
}
|
||||
|
||||
void MouseInput::setInputHandler(InputHandler *handler)
|
||||
void MouseHandler::setInputHandler(InputHandler *handler)
|
||||
{
|
||||
m_inputHandler = handler;
|
||||
}
|
||||
|
||||
void MouseInput::mouseEvent(const QMouseEventPtr &event)
|
||||
void MouseHandler::mouseEvent(const QMouseEventPtr &event)
|
||||
{
|
||||
QBackendScenePropertyChangePtr e(new QBackendScenePropertyChange(NodeUpdated, peerUuid()));
|
||||
e->setTargetNode(peerUuid());
|
||||
|
|
@ -92,7 +92,7 @@ void MouseInput::mouseEvent(const QMouseEventPtr &event)
|
|||
notifyObservers(e);
|
||||
}
|
||||
|
||||
void MouseInput::wheelEvent(const QWheelEventPtr &event)
|
||||
void MouseHandler::wheelEvent(const QWheelEventPtr &event)
|
||||
{
|
||||
QBackendScenePropertyChangePtr e(new QBackendScenePropertyChange(NodeUpdated, peerUuid()));
|
||||
e->setTargetNode(peerUuid());
|
||||
|
|
@ -101,7 +101,7 @@ void MouseInput::wheelEvent(const QWheelEventPtr &event)
|
|||
notifyObservers(e);
|
||||
}
|
||||
|
||||
void MouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
|
||||
void MouseHandler::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
|
||||
{
|
||||
if (e->type() == NodeUpdated) {
|
||||
QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
|
||||
|
|
@ -114,7 +114,7 @@ void MouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
|
|||
}
|
||||
}
|
||||
|
||||
void MouseInput::setController(Qt3DCore::QNodeId controller)
|
||||
void MouseHandler::setController(Qt3DCore::QNodeId controller)
|
||||
{
|
||||
if (!m_mouseController.isNull()) {
|
||||
MouseController *controller = m_inputHandler->mouseControllerManager()->lookupResource(m_mouseController);
|
||||
|
|
@ -129,25 +129,25 @@ void MouseInput::setController(Qt3DCore::QNodeId controller)
|
|||
}
|
||||
}
|
||||
|
||||
MouseInputFunctor::MouseInputFunctor(InputHandler *handler)
|
||||
MouseHandlerFunctor::MouseHandlerFunctor(InputHandler *handler)
|
||||
: m_handler(handler)
|
||||
{
|
||||
}
|
||||
|
||||
Qt3DCore::QBackendNode *MouseInputFunctor::create(Qt3DCore::QNode *frontend) const
|
||||
Qt3DCore::QBackendNode *MouseHandlerFunctor::create(Qt3DCore::QNode *frontend) const
|
||||
{
|
||||
MouseInput *input = m_handler->mouseInputManager()->getOrCreateResource(frontend->id());
|
||||
MouseHandler *input = m_handler->mouseInputManager()->getOrCreateResource(frontend->id());
|
||||
input->setInputHandler(m_handler);
|
||||
input->setPeer(frontend);
|
||||
return input;
|
||||
}
|
||||
|
||||
Qt3DCore::QBackendNode *MouseInputFunctor::get(Qt3DCore::QNodeId id) const
|
||||
Qt3DCore::QBackendNode *MouseHandlerFunctor::get(Qt3DCore::QNodeId id) const
|
||||
{
|
||||
return m_handler->mouseInputManager()->lookupResource(id);
|
||||
}
|
||||
|
||||
void MouseInputFunctor::destroy(Qt3DCore::QNodeId id) const
|
||||
void MouseHandlerFunctor::destroy(Qt3DCore::QNodeId id) const
|
||||
{
|
||||
m_handler->mouseInputManager()->releaseResource(id);
|
||||
}
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_INPUT_MOUSEINPUT_H
|
||||
#define QT3DINPUT_INPUT_MOUSEINPUT_H
|
||||
#ifndef QT3DINPUT_INPUT_MOUSEHANDLER_H
|
||||
#define QT3DINPUT_INPUT_MOUSEHANDLER_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
|
|
@ -61,11 +61,11 @@ namespace Input {
|
|||
|
||||
class InputHandler;
|
||||
|
||||
class MouseInput : public Qt3DCore::QBackendNode
|
||||
class MouseHandler : public Qt3DCore::QBackendNode
|
||||
{
|
||||
public:
|
||||
MouseInput();
|
||||
~MouseInput();
|
||||
MouseHandler();
|
||||
~MouseHandler();
|
||||
|
||||
void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE;
|
||||
Qt3DCore::QNodeId mouseController() const;
|
||||
|
|
@ -85,10 +85,10 @@ private:
|
|||
InputHandler *m_inputHandler;
|
||||
};
|
||||
|
||||
class MouseInputFunctor : public Qt3DCore::QBackendNodeMapper
|
||||
class MouseHandlerFunctor : public Qt3DCore::QBackendNodeMapper
|
||||
{
|
||||
public:
|
||||
explicit MouseInputFunctor(InputHandler *handler);
|
||||
explicit MouseHandlerFunctor(InputHandler *handler);
|
||||
|
||||
Qt3DCore::QBackendNode *create(Qt3DCore::QNode *frontend) const Q_DECL_OVERRIDE;
|
||||
Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const Q_DECL_OVERRIDE;
|
||||
|
|
@ -103,4 +103,4 @@ private:
|
|||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // MOUSEINPUT_H
|
||||
#endif // QT3DINPUT_INPUT_MOUSEHANDLER_H
|
||||
|
|
@ -7,8 +7,8 @@ HEADERS += \
|
|||
$$PWD/qinputaspect_p.h \
|
||||
$$PWD/qkeyevent.h \
|
||||
$$PWD/qmousecontroller.h \
|
||||
$$PWD/qmouseinput.h \
|
||||
$$PWD/qmouseinput_p.h \
|
||||
$$PWD/qmousehandler.h \
|
||||
$$PWD/qmousehandler_p.h \
|
||||
$$PWD/qmousecontroller_p.h \
|
||||
$$PWD/qmouseevent.h \
|
||||
$$PWD/qinputdeviceplugin.h \
|
||||
|
|
@ -37,7 +37,7 @@ SOURCES += \
|
|||
$$PWD/qkeyboardcontroller.cpp \
|
||||
$$PWD/qkeyboardinput.cpp \
|
||||
$$PWD/qkeyevent.cpp \
|
||||
$$PWD/qmouseinput.cpp \
|
||||
$$PWD/qmousehandler.cpp \
|
||||
$$PWD/qmousecontroller.cpp \
|
||||
$$PWD/qmouseevent.cpp \
|
||||
$$PWD/qinputdeviceplugin.cpp \
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@
|
|||
#include "keyboardcontroller_p.h"
|
||||
#include "keyboardinput_p.h"
|
||||
#include "mousecontroller_p.h"
|
||||
#include "mouseinput_p.h"
|
||||
#include "mousehandler_p.h"
|
||||
#include <Qt3DInput/qkeyboardcontroller.h>
|
||||
#include <Qt3DInput/qkeyboardinput.h>
|
||||
#include <Qt3DInput/qmousecontroller.h>
|
||||
#include <Qt3DInput/qmouseinput.h>
|
||||
#include <Qt3DInput/qmousehandler.h>
|
||||
#include <Qt3DInput/qinputdeviceintegration.h>
|
||||
#include <Qt3DInput/qgenericinputdevice.h>
|
||||
#include <Qt3DInput/qinputsettings.h>
|
||||
|
|
@ -113,7 +113,7 @@ QInputAspect::QInputAspect(QObject *parent)
|
|||
registerBackendType<QKeyboardController>(QBackendNodeMapperPtr(new Input::KeyboardControllerFunctor(this, d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QKeyboardInput>(QBackendNodeMapperPtr(new Input::KeyboardInputFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QMouseController>(QBackendNodeMapperPtr(new Input::MouseControllerFunctor(this, d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QMouseInput>(QBackendNodeMapperPtr(new Input::MouseInputFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QMouseHandler>(QBackendNodeMapperPtr(new Input::MouseHandlerFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QAxis>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Axis, Input::AxisManager>(d_func()->m_inputHandler->axisManager())));
|
||||
registerBackendType<QAxisInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisInput, Input::AxisInputManager>(d_func()->m_inputHandler->axisInputManager())));
|
||||
registerBackendType<QAxisSetting>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisSetting, Input::AxisSettingManager>(d_func()->m_inputHandler->axisSettingManager())));
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ QMouseControllerPrivate::QMouseControllerPrivate()
|
|||
* \instantiates Qt3DInput::QMouseController
|
||||
* \inqmlmodule Qt3D.Input
|
||||
* \since 5.5
|
||||
* \brief Delegates mouse events to the attached MouseInput objects.
|
||||
* \brief Delegates mouse events to the attached MouseHandler objects.
|
||||
* \TODO
|
||||
* \sa MouseInput
|
||||
* \sa MouseHandler
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -67,10 +67,10 @@ QMouseControllerPrivate::QMouseControllerPrivate()
|
|||
* \inmodule Qt3DInput
|
||||
*
|
||||
* \brief QMouseController is in charge of dispatching mouse events to
|
||||
* attached QMouseInput objects.
|
||||
* attached QMouseHandler objects.
|
||||
*
|
||||
* \since 5.5
|
||||
* \sa QMouseInput
|
||||
* \sa QMouseHandler
|
||||
*/
|
||||
QMouseController::QMouseController(QNode *parent)
|
||||
: QAbstractPhysicalDevice(*new QMouseControllerPrivate, parent)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Qt3DInput {
|
||||
|
||||
class QMouseControllerPrivate;
|
||||
class QMouseInput;
|
||||
class QMouseHandler;
|
||||
|
||||
class QT3DINPUTSHARED_EXPORT QMouseController : public Qt3DInput::QAbstractPhysicalDevice
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Qt3DInput {
|
|||
* traversing the view, originating from the mouse position intersects with one
|
||||
* or more elements of the scene.
|
||||
*
|
||||
* \sa KeyEvent, WheelEvent, MouseInput
|
||||
* \sa KeyEvent, WheelEvent, MouseHandler
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -76,7 +76,7 @@ namespace Qt3DInput {
|
|||
*
|
||||
* \since 5.5
|
||||
*
|
||||
* \sa QKeyEvent, QWheelEvent, QMouseInput
|
||||
* \sa QKeyEvent, QWheelEvent, QMouseHandler
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ QMouseEvent::Modifiers QMouseEvent::modifier() const
|
|||
*
|
||||
* Mouse wheel events occur when the mouse wheel is rotated.
|
||||
*
|
||||
* \sa KeyEvent, MouseEvent, MouseInput
|
||||
* \sa KeyEvent, MouseEvent, MouseHandler
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ QMouseEvent::Modifiers QMouseEvent::modifier() const
|
|||
*
|
||||
* \since 5.5
|
||||
*
|
||||
* \sa QKeyEvent, QMouseEvent, QMouseInput
|
||||
* \sa QKeyEvent, QMouseEvent, QMouseHandler
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmouseinput.h"
|
||||
#include "qmouseinput_p.h"
|
||||
#include "qmousehandler.h"
|
||||
#include "qmousehandler_p.h"
|
||||
#include "qmousecontroller.h"
|
||||
#include "qmouseevent.h"
|
||||
#include <Qt3DCore/qbackendscenepropertychange.h>
|
||||
|
|
@ -49,17 +49,44 @@ using namespace Qt3DCore;
|
|||
|
||||
namespace Qt3DInput {
|
||||
/*! \internal */
|
||||
QMouseInputPrivate::QMouseInputPrivate()
|
||||
QMouseHandlerPrivate::QMouseHandlerPrivate()
|
||||
: QComponentPrivate()
|
||||
, m_controller(Q_NULLPTR)
|
||||
, m_sourceDevice(Q_NULLPTR)
|
||||
, m_containsMouse(false)
|
||||
{
|
||||
m_shareable = false;
|
||||
}
|
||||
|
||||
void QMouseHandlerPrivate::mouseEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_Q(QMouseHandler);
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
if (event->wasHeld())
|
||||
emit q->pressAndHold(event);
|
||||
else
|
||||
emit q->pressed(event);
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
emit q->released(event);
|
||||
break;
|
||||
case Qt::TapGesture:
|
||||
emit q->clicked(event);
|
||||
break;
|
||||
case QEvent::MouseButtonDblClick:
|
||||
emit q->doubleClicked(event);
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
emit q->positionChanged(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \qmltype MouseInput
|
||||
* \instantiates Qt3DInput::QMouseInput
|
||||
* \qmltype MouseHandler
|
||||
* \instantiates Qt3DInput::QMouseHandler
|
||||
* \inqmlmodule Qt3D.Input
|
||||
* \since 5.5
|
||||
* \brief Provides mouse event notification
|
||||
|
|
@ -69,7 +96,7 @@ QMouseInputPrivate::QMouseInputPrivate()
|
|||
*/
|
||||
|
||||
/*!
|
||||
* \class Qt3DInput::QMouseInput
|
||||
* \class Qt3DInput::QMouseHandler
|
||||
* \inmodule Qt3DInput
|
||||
*
|
||||
* \brief Provides a means of being notified about mouse events when attached to
|
||||
|
|
@ -77,91 +104,93 @@ QMouseInputPrivate::QMouseInputPrivate()
|
|||
*
|
||||
* \since 5.5
|
||||
*
|
||||
* \note QMouseInput components shouldn't be shared, not respecting that
|
||||
* \note QMouseHandler components shouldn't be shared, not respecting that
|
||||
* condition will most likely result in undefined behaviors.
|
||||
*
|
||||
* \sa QMouseController
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Constructs a new QMouseInput instance with parent \a parent.
|
||||
* Constructs a new QMouseHandler instance with parent \a parent.
|
||||
*/
|
||||
QMouseInput::QMouseInput(QNode *parent)
|
||||
: QComponent(*new QMouseInputPrivate, parent)
|
||||
QMouseHandler::QMouseHandler(QNode *parent)
|
||||
: QComponent(*new QMouseHandlerPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Destroys this QMouseHandler object
|
||||
*/
|
||||
QMouseInput::QMouseInput(QMouseInputPrivate &dd, QNode *parent)
|
||||
: QComponent(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QMouseInput object
|
||||
*/
|
||||
QMouseInput::~QMouseInput()
|
||||
QMouseHandler::~QMouseHandler()
|
||||
{
|
||||
QNode::cleanup();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Sets the mouse controller of the QMouseInput instance to \a controller.
|
||||
* Sets the mouse source device of the QMouseHandler instance to \a sourceDevice.
|
||||
*/
|
||||
void QMouseInput::setController(QMouseController *controller)
|
||||
void QMouseHandler::setSourceDevice(QMouseController *sourceDevice)
|
||||
{
|
||||
Q_D(QMouseInput);
|
||||
if (d->m_controller != controller) {
|
||||
d->m_controller = controller;
|
||||
emit controllerChanged(controller);
|
||||
Q_D(QMouseHandler);
|
||||
if (d->m_sourceDevice != sourceDevice) {
|
||||
d->m_sourceDevice = sourceDevice;
|
||||
emit sourceDeviceChanged(sourceDevice);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the current mouse controller of the QMouseInput instance.
|
||||
* Returns the current mouse source device of the QMouseHandler instance.
|
||||
*/
|
||||
QMouseController *QMouseInput::controller() const
|
||||
QMouseController *QMouseHandler::sourceDevice() const
|
||||
{
|
||||
Q_D(const QMouseInput);
|
||||
return d->m_controller;
|
||||
Q_D(const QMouseHandler);
|
||||
return d->m_sourceDevice;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns \c true if the QMouseInput currently contains the mouse.
|
||||
* Returns \c true if the QMouseHandler currently contains the mouse.
|
||||
*
|
||||
* \note In this context, contains mean that the ray originating from the
|
||||
* mouse is intersecting with the Qt3DCore::QEntity that aggregates the current
|
||||
* QMouseInput instance component.
|
||||
* QMouseHandler instance component.
|
||||
*/
|
||||
bool QMouseInput::containsMouse() const
|
||||
bool QMouseHandler::containsMouse() const
|
||||
{
|
||||
Q_D(const QMouseInput);
|
||||
Q_D(const QMouseHandler);
|
||||
return d->m_containsMouse;
|
||||
}
|
||||
|
||||
void QMouseInput::copy(const QNode *ref)
|
||||
void QMouseHandler::setContainsMouse(bool contains)
|
||||
{
|
||||
Q_D(QMouseInput);
|
||||
const QMouseInput *refInput = static_cast<const QMouseInput *>(ref);
|
||||
Q_D(QMouseHandler);
|
||||
if (contains != d->m_containsMouse) {
|
||||
d->m_containsMouse = contains;
|
||||
emit containsMouseChanged(contains);
|
||||
}
|
||||
}
|
||||
|
||||
void QMouseHandler::copy(const QNode *ref)
|
||||
{
|
||||
Q_D(QMouseHandler);
|
||||
const QMouseHandler *refInput = static_cast<const QMouseHandler *>(ref);
|
||||
d->m_containsMouse = refInput->containsMouse();
|
||||
|
||||
// TODO: We may want to store the controller id and only send a clone when we are the parent
|
||||
// of the controller.
|
||||
// Perhaps it's time to investigate sending a "kernel" or "seed" over to the backend rather
|
||||
// than a complete clone.
|
||||
if (refInput && refInput->controller() && refInput->controller()->parent() == ref)
|
||||
d->m_controller = static_cast<QMouseController *>(QNode::clone(refInput->controller()));
|
||||
if (refInput && refInput->sourceDevice() && refInput->sourceDevice()->parent() == ref)
|
||||
d->m_sourceDevice = static_cast<QMouseController *>(QNode::clone(refInput->sourceDevice()));
|
||||
}
|
||||
|
||||
void QMouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
|
||||
void QMouseHandler::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
|
||||
{
|
||||
Q_D(QMouseHandler);
|
||||
QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
|
||||
if (e->type() == NodeUpdated) {
|
||||
if (e->propertyName() == QByteArrayLiteral("mouse")) {
|
||||
QMouseEventPtr ev = e->value().value<QMouseEventPtr>();
|
||||
mouseEvent(ev.data());
|
||||
d->mouseEvent(ev.data());
|
||||
} else if (e->propertyName() == QByteArrayLiteral("wheel")) {
|
||||
QWheelEventPtr ev = e->value().value<QWheelEventPtr>();
|
||||
emit wheel(ev.data());
|
||||
|
|
@ -169,41 +198,6 @@ void QMouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
|
|||
}
|
||||
}
|
||||
|
||||
void QMouseInput::mouseEvent(QMouseEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
if (event->wasHeld())
|
||||
emit pressAndHold(event);
|
||||
else
|
||||
emit pressed(event);
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
emit released(event);
|
||||
break;
|
||||
case Qt::TapGesture:
|
||||
emit clicked(event);
|
||||
break;
|
||||
case QEvent::MouseButtonDblClick:
|
||||
emit doubleClicked(event);
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
emit positionChanged(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QMouseInput::setContainsMouse(bool contains)
|
||||
{
|
||||
Q_D(QMouseInput);
|
||||
if (contains != d->m_containsMouse) {
|
||||
d->m_containsMouse = contains;
|
||||
emit containsMouseChanged(contains);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_QMOUSEINPUT_H
|
||||
#define QT3DINPUT_QMOUSEINPUT_H
|
||||
#ifndef QT3DINPUT_QMOUSEHANDLER_H
|
||||
#define QT3DINPUT_QMOUSEHANDLER_H
|
||||
|
||||
#include <Qt3DInput/qt3dinput_global.h>
|
||||
#include <Qt3DInput/qmouseevent.h>
|
||||
|
|
@ -49,26 +49,26 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Qt3DInput {
|
||||
|
||||
class QMouseController;
|
||||
class QMouseInputPrivate;
|
||||
class QMouseHandlerPrivate;
|
||||
|
||||
class QT3DINPUTSHARED_EXPORT QMouseInput : public Qt3DCore::QComponent
|
||||
class QT3DINPUTSHARED_EXPORT QMouseHandler : public Qt3DCore::QComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt3DInput::QMouseController *controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(Qt3DInput::QMouseController *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged)
|
||||
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
|
||||
|
||||
public:
|
||||
explicit QMouseInput(QNode *parent = 0);
|
||||
~QMouseInput();
|
||||
explicit QMouseHandler(QNode *parent = 0);
|
||||
~QMouseHandler();
|
||||
|
||||
QMouseController *controller() const;
|
||||
QMouseController *sourceDevice() const;
|
||||
bool containsMouse() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setController(QMouseController *controller);
|
||||
void setSourceDevice(QMouseController *sourceDevice);
|
||||
|
||||
Q_SIGNALS:
|
||||
void controllerChanged(QMouseController *controller);
|
||||
void sourceDeviceChanged(QMouseController *sourceDevice);
|
||||
void containsMouseChanged(bool containsMouse);
|
||||
|
||||
void clicked(Qt3DInput::QMouseEvent *mouse);
|
||||
|
|
@ -85,19 +85,17 @@ Q_SIGNALS:
|
|||
void wheel(Qt3DInput::QWheelEvent *wheel);
|
||||
|
||||
protected:
|
||||
QMouseInput(QMouseInputPrivate &dd, Qt3DCore::QNode *parent = 0);
|
||||
void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
|
||||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
|
||||
void mouseEvent(Qt3DInput::QMouseEvent *event);
|
||||
void setContainsMouse(bool contains);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QMouseInput)
|
||||
QT3D_CLONEABLE(QMouseInput)
|
||||
Q_DECLARE_PRIVATE(QMouseHandler)
|
||||
QT3D_CLONEABLE(QMouseHandler)
|
||||
};
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DINPUT_QMOUSEINPUT_H
|
||||
#endif // QT3DINPUT_QMOUSEHANDLER_H
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_QMOUSEINPUT_P_H
|
||||
#define QT3DINPUT_QMOUSEINPUT_P_H
|
||||
#ifndef QT3DINPUT_QMOUSEHANDLER_P_H
|
||||
#define QT3DINPUT_QMOUSEHANDLER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
|
|
@ -57,23 +57,25 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
namespace Qt3DInput {
|
||||
|
||||
class QMouseInput;
|
||||
class QMouseHandler;
|
||||
class QMouseController;
|
||||
|
||||
class QMouseInputPrivate : public Qt3DCore::QComponentPrivate
|
||||
class QMouseHandlerPrivate : public Qt3DCore::QComponentPrivate
|
||||
{
|
||||
public:
|
||||
QMouseInputPrivate();
|
||||
QMouseHandlerPrivate();
|
||||
|
||||
QMouseController *m_controller;
|
||||
QMouseController *m_sourceDevice;
|
||||
bool m_containsMouse;
|
||||
|
||||
Q_DECLARE_PUBLIC(QMouseInput)
|
||||
void mouseEvent(Qt3DInput::QMouseEvent *event);
|
||||
|
||||
Q_DECLARE_PUBLIC(QMouseHandler)
|
||||
};
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DINPUT_QMOUSEINPUT_P_H
|
||||
#endif // QT3DINPUT_QMOUSEHANDLER_P_H
|
||||
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
#include <Qt3DInput/qkeyboardinput.h>
|
||||
#include <Qt3DInput/qkeyevent.h>
|
||||
#include <Qt3DInput/qmousecontroller.h>
|
||||
#include <Qt3DInput/qmouseinput.h>
|
||||
#include <Qt3DInput/qmousehandler.h>
|
||||
#include <Qt3DInput/qmouseevent.h>
|
||||
|
||||
#include <Qt3DInput/qaxis.h>
|
||||
|
|
@ -79,7 +79,7 @@ void Qt3DQuick3DInputPlugin::registerTypes(const char *uri)
|
|||
|
||||
qmlRegisterUncreatableType<Qt3DInput::QMouseEvent>(uri, 2, 0, "MouseEvent", QStringLiteral("Events cannot be created"));
|
||||
qmlRegisterUncreatableType<Qt3DInput::QWheelEvent>(uri, 2, 0, "WheelEvent", QStringLiteral("Events cannot be created"));
|
||||
qmlRegisterType<Qt3DInput::QMouseInput>(uri, 2, 0, "MouseInput");
|
||||
qmlRegisterType<Qt3DInput::QMouseHandler>(uri, 2, 0, "MouseHandler");
|
||||
qmlRegisterType<Qt3DInput::QMouseController>(uri, 2, 0, "MouseController");
|
||||
|
||||
qmlRegisterExtendedType<Qt3DInput::QLogicalDevice, Qt3DInput::Input::Quick::Quick3DLogicalDevice>(uri, 2, 0, "LogicalDevice");
|
||||
|
|
|
|||
Loading…
Reference in New Issue