mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Tidying
This commit is contained in:
parent
44f36a9dae
commit
e85bc50333
8 changed files with 47 additions and 32 deletions
|
@ -1200,11 +1200,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
// Keyboard focus handling for Web overlays.
|
// Keyboard focus handling for Web overlays.
|
||||||
auto overlays = &(qApp->getOverlays());
|
auto overlays = &(qApp->getOverlays());
|
||||||
|
|
||||||
connect(overlays, &Overlays::mousePressOnOverlay, [=](const int overlayID, const PointerEvent& event) {
|
connect(overlays, &Overlays::mousePressOnOverlay, [=](unsigned int overlayID, const PointerEvent& event) {
|
||||||
setKeyboardFocusOverlay(overlayID);
|
setKeyboardFocusOverlay(overlayID);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(overlays, &Overlays::overlayDeleted, [=](const int overlayID) {
|
connect(overlays, &Overlays::overlayDeleted, [=](unsigned int overlayID) {
|
||||||
if (overlayID == _keyboardFocusedOverlay.get()) {
|
if (overlayID == _keyboardFocusedOverlay.get()) {
|
||||||
setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
|
setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
|
||||||
}
|
}
|
||||||
|
@ -3974,7 +3974,7 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setKeyboardFocusOverlay(int overlayID) {
|
void Application::setKeyboardFocusOverlay(unsigned int overlayID) {
|
||||||
if (overlayID != _keyboardFocusedOverlay.get()) {
|
if (overlayID != _keyboardFocusedOverlay.get()) {
|
||||||
_keyboardFocusedOverlay.set(overlayID);
|
_keyboardFocusedOverlay.set(overlayID);
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ public slots:
|
||||||
void setKeyboardFocusEntity(QUuid id);
|
void setKeyboardFocusEntity(QUuid id);
|
||||||
void setKeyboardFocusEntity(EntityItemID entityItemID);
|
void setKeyboardFocusEntity(EntityItemID entityItemID);
|
||||||
|
|
||||||
void setKeyboardFocusOverlay(int id);
|
void setKeyboardFocusOverlay(unsigned int overlayID);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showDesktop();
|
void showDesktop();
|
||||||
|
|
|
@ -671,9 +671,6 @@ PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay r
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::mousePressEvent(QMouseEvent* event) {
|
void Overlays::mousePressEvent(QMouseEvent* event) {
|
||||||
|
|
||||||
qDebug() << "####### Overlays::mousePressEvent()";
|
|
||||||
|
|
||||||
PerformanceTimer perfTimer("Overlays::mousePressEvent");
|
PerformanceTimer perfTimer("Overlays::mousePressEvent");
|
||||||
|
|
||||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
|
@ -686,10 +683,6 @@ void Overlays::mousePressEvent(QMouseEvent* event) {
|
||||||
if (thisOverlay) {
|
if (thisOverlay) {
|
||||||
auto pointerEvent = calculatePointerEvent(thisOverlay, ray, rayPickResult, event, PointerEvent::Press);
|
auto pointerEvent = calculatePointerEvent(thisOverlay, ray, rayPickResult, event, PointerEvent::Press);
|
||||||
emit mousePressOnOverlay(_currentClickingOnOverlayID, pointerEvent);
|
emit mousePressOnOverlay(_currentClickingOnOverlayID, pointerEvent);
|
||||||
|
|
||||||
// ####### TODO: From EntityTreeRendered ... needed?
|
|
||||||
//_lastPointerEvent = pointerEvent;
|
|
||||||
//_lastPointerEventValid = true;
|
|
||||||
} else {
|
} else {
|
||||||
emit mousePressOffOverlay();
|
emit mousePressOffOverlay();
|
||||||
}
|
}
|
||||||
|
@ -710,10 +703,6 @@ void Overlays::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
if (thisOverlay) {
|
if (thisOverlay) {
|
||||||
auto pointerEvent = calculatePointerEvent(thisOverlay, ray, rayPickResult, event, PointerEvent::Release);
|
auto pointerEvent = calculatePointerEvent(thisOverlay, ray, rayPickResult, event, PointerEvent::Release);
|
||||||
emit mouseReleaseOnOverlay(rayPickResult.overlayID, pointerEvent);
|
emit mouseReleaseOnOverlay(rayPickResult.overlayID, pointerEvent);
|
||||||
|
|
||||||
// ####### TODO: From EntityTreeRendered ... needed?
|
|
||||||
//_lastPointerEvent = pointerEvent;
|
|
||||||
//_lastPointerEventValid = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
||||||
* @namespace Overlays
|
* @namespace Overlays
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const int UNKNOWN_OVERLAY_ID = -1;
|
const unsigned int UNKNOWN_OVERLAY_ID = 0;
|
||||||
|
|
||||||
class Overlays : public QObject {
|
class Overlays : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -257,14 +257,14 @@ signals:
|
||||||
void overlayDeleted(unsigned int id);
|
void overlayDeleted(unsigned int id);
|
||||||
void panelDeleted(unsigned int id);
|
void panelDeleted(unsigned int id);
|
||||||
|
|
||||||
void mousePressOnOverlay(const int overlayID, const PointerEvent& event);
|
void mousePressOnOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
void mouseReleaseOnOverlay(const int overlayID, const PointerEvent& event);
|
void mouseReleaseOnOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
void mouseMoveOnOverlay(const int overlayID, const PointerEvent& event);
|
void mouseMoveOnOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
void mousePressOffOverlay();
|
void mousePressOffOverlay();
|
||||||
|
|
||||||
void hoverEnterOverlay(const int overlayID, const PointerEvent& event);
|
void hoverEnterOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
void hoverOverOverlay(const int overlayID, const PointerEvent& event);
|
void hoverOverOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
void hoverLeaveOverlay(const int overlayID, const PointerEvent& event);
|
void hoverLeaveOverlay(unsigned int overlayID, const PointerEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cleanupOverlaysToDelete();
|
void cleanupOverlaysToDelete();
|
||||||
|
@ -283,8 +283,8 @@ private:
|
||||||
PointerEvent calculatePointerEvent(Overlay::Pointer overlay, PickRay ray, RayToOverlayIntersectionResult rayPickResult,
|
PointerEvent calculatePointerEvent(Overlay::Pointer overlay, PickRay ray, RayToOverlayIntersectionResult rayPickResult,
|
||||||
QMouseEvent* event, PointerEvent::EventType eventType);
|
QMouseEvent* event, PointerEvent::EventType eventType);
|
||||||
|
|
||||||
int _currentClickingOnOverlayID = UNKNOWN_OVERLAY_ID;
|
unsigned int _currentClickingOnOverlayID = UNKNOWN_OVERLAY_ID;
|
||||||
int _currentHoverOverOverlayID = UNKNOWN_OVERLAY_ID;
|
unsigned int _currentHoverOverOverlayID = UNKNOWN_OVERLAY_ID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Overlays_h
|
#endif // hifi_Overlays_h
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
|
|
||||||
static const float DPI = 30.47f;
|
static const float DPI = 30.47f;
|
||||||
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
|
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
|
||||||
static float OPAQUE_ALPHA_THRESHOLD = 0.99f;
|
static const float METERS_TO_INCHES = 39.3701f;
|
||||||
|
static const float OPAQUE_ALPHA_THRESHOLD = 0.99f;
|
||||||
|
|
||||||
QString const Web3DOverlay::TYPE = "web3d";
|
QString const Web3DOverlay::TYPE = "web3d";
|
||||||
|
|
||||||
|
@ -63,6 +64,8 @@ Web3DOverlay::~Web3DOverlay() {
|
||||||
_mouseReleaseConnection = QMetaObject::Connection();
|
_mouseReleaseConnection = QMetaObject::Connection();
|
||||||
QObject::disconnect(_mouseMoveConnection);
|
QObject::disconnect(_mouseMoveConnection);
|
||||||
_mouseMoveConnection = QMetaObject::Connection();
|
_mouseMoveConnection = QMetaObject::Connection();
|
||||||
|
QObject::disconnect(_hoverLeaveConnection);
|
||||||
|
_hoverLeaveConnection = QMetaObject::Connection();
|
||||||
|
|
||||||
// The lifetime of the QML surface MUST be managed by the main thread
|
// The lifetime of the QML surface MUST be managed by the main thread
|
||||||
// Additionally, we MUST use local variables copied by value, rather than
|
// Additionally, we MUST use local variables copied by value, rather than
|
||||||
|
@ -112,7 +115,7 @@ void Web3DOverlay::render(RenderArgs* args) {
|
||||||
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
||||||
currentContext->makeCurrent(currentSurface);
|
currentContext->makeCurrent(currentSurface);
|
||||||
|
|
||||||
auto forwardPointerEvent = [=](const int overlayID, const PointerEvent& event) {
|
auto forwardPointerEvent = [=](unsigned int overlayID, const PointerEvent& event) {
|
||||||
if (overlayID == getOverlayID()) {
|
if (overlayID == getOverlayID()) {
|
||||||
handlePointerEvent(event);
|
handlePointerEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +124,27 @@ void Web3DOverlay::render(RenderArgs* args) {
|
||||||
_mousePressConnection = connect(&(qApp->getOverlays()), &Overlays::mousePressOnOverlay, forwardPointerEvent);
|
_mousePressConnection = connect(&(qApp->getOverlays()), &Overlays::mousePressOnOverlay, forwardPointerEvent);
|
||||||
_mouseReleaseConnection = connect(&(qApp->getOverlays()), &Overlays::mouseReleaseOnOverlay, forwardPointerEvent);
|
_mouseReleaseConnection = connect(&(qApp->getOverlays()), &Overlays::mouseReleaseOnOverlay, forwardPointerEvent);
|
||||||
_mouseMoveConnection = connect(&(qApp->getOverlays()), &Overlays::mouseMoveOnOverlay, forwardPointerEvent);
|
_mouseMoveConnection = connect(&(qApp->getOverlays()), &Overlays::mouseMoveOnOverlay, forwardPointerEvent);
|
||||||
|
_hoverLeaveConnection = connect(&(qApp->getOverlays()), &Overlays::hoverLeaveOverlay,
|
||||||
|
[=](unsigned int overlayID, const PointerEvent& event) {
|
||||||
|
if (this->_pressed && this->getOverlayID() == overlayID) {
|
||||||
|
// If the user mouses off the overlay while the button is down, simulate a touch end.
|
||||||
|
QTouchEvent::TouchPoint point;
|
||||||
|
point.setId(event.getID());
|
||||||
|
point.setState(Qt::TouchPointReleased);
|
||||||
|
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
|
||||||
|
QPointF windowPoint(windowPos.x, windowPos.y);
|
||||||
|
point.setScenePos(windowPoint);
|
||||||
|
point.setPos(windowPoint);
|
||||||
|
QList<QTouchEvent::TouchPoint> touchPoints;
|
||||||
|
touchPoints.push_back(point);
|
||||||
|
QTouchEvent* touchEvent = new QTouchEvent(QEvent::TouchEnd, nullptr, Qt::NoModifier, Qt::TouchPointReleased,
|
||||||
|
touchPoints);
|
||||||
|
touchEvent->setWindow(_webSurface->getWindow());
|
||||||
|
touchEvent->setDevice(&_touchDevice);
|
||||||
|
touchEvent->setTarget(_webSurface->getRootItem());
|
||||||
|
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 halfSize = getSize() / 2.0f;
|
vec2 halfSize = getSize() / 2.0f;
|
||||||
|
@ -186,7 +210,6 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float METERS_TO_INCHES = 39.3701f;
|
|
||||||
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
|
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
|
||||||
QPointF windowPoint(windowPos.x, windowPos.y);
|
QPointF windowPoint(windowPos.x, windowPos.y);
|
||||||
|
|
||||||
|
@ -197,6 +220,12 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
||||||
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent);
|
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getType() == PointerEvent::Press) {
|
||||||
|
this->_pressed = true;
|
||||||
|
} else if (event.getType() == PointerEvent::Release) {
|
||||||
|
this->_pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
QEvent::Type type;
|
QEvent::Type type;
|
||||||
Qt::TouchPointState touchPointState;
|
Qt::TouchPointState touchPointState;
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
|
@ -230,7 +259,6 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
||||||
touchEvent->setTouchPoints(touchPoints);
|
touchEvent->setTouchPoints(touchPoints);
|
||||||
touchEvent->setTouchPointStates(touchPointState);
|
touchEvent->setTouchPointStates(touchPointState);
|
||||||
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
|
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,11 +59,13 @@ private:
|
||||||
vec2 _resolution{ 640, 480 };
|
vec2 _resolution{ 640, 480 };
|
||||||
int _geometryId { 0 };
|
int _geometryId { 0 };
|
||||||
|
|
||||||
|
bool _pressed{ false };
|
||||||
QTouchDevice _touchDevice;
|
QTouchDevice _touchDevice;
|
||||||
|
|
||||||
QMetaObject::Connection _mousePressConnection;
|
QMetaObject::Connection _mousePressConnection;
|
||||||
QMetaObject::Connection _mouseReleaseConnection;
|
QMetaObject::Connection _mouseReleaseConnection;
|
||||||
QMetaObject::Connection _mouseMoveConnection;
|
QMetaObject::Connection _mouseMoveConnection;
|
||||||
|
QMetaObject::Connection _hoverLeaveConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Web3DOverlay_h
|
#endif // hifi_Web3DOverlay_h
|
||||||
|
|
|
@ -350,8 +350,6 @@ void RenderableWebEntityItem::handlePointerEvent(const PointerEvent& event) {
|
||||||
touchEvent->setTouchPoints(touchPoints);
|
touchEvent->setTouchPoints(touchPoints);
|
||||||
touchEvent->setTouchPointStates(touchPointState);
|
touchEvent->setTouchPointStates(touchPointState);
|
||||||
|
|
||||||
_lastTouchEvent = *touchEvent;
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
|
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,7 @@ private:
|
||||||
QSharedPointer<OffscreenQmlSurface> _webSurface;
|
QSharedPointer<OffscreenQmlSurface> _webSurface;
|
||||||
QMetaObject::Connection _connection;
|
QMetaObject::Connection _connection;
|
||||||
gpu::TexturePointer _texture;
|
gpu::TexturePointer _texture;
|
||||||
ivec2 _lastPress { INT_MIN };
|
|
||||||
bool _pressed{ false };
|
bool _pressed{ false };
|
||||||
QTouchEvent _lastTouchEvent { QEvent::TouchUpdate };
|
|
||||||
uint64_t _lastRenderTime{ 0 };
|
uint64_t _lastRenderTime{ 0 };
|
||||||
QTouchDevice _touchDevice;
|
QTouchDevice _touchDevice;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue