mirror of
https://github.com/lubosz/overte.git
synced 2025-04-17 00:57:44 +02:00
started to move WebEntityAPIHelper from RenderableWebEntityItem to OffscreenQmlSurface
This commit is contained in:
parent
25786f273d
commit
ef8c2a2888
4 changed files with 60 additions and 50 deletions
|
@ -38,35 +38,6 @@ static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND;
|
|||
static int MAX_WINDOW_SIZE = 4096;
|
||||
static float OPAQUE_ALPHA_THRESHOLD = 0.99f;
|
||||
|
||||
void WebEntityAPIHelper::synthesizeKeyPress(QString key) {
|
||||
if (_renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->synthesizeKeyPress(key);
|
||||
}
|
||||
}
|
||||
|
||||
void WebEntityAPIHelper::emitScriptEvent(const QVariant& message) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
} else {
|
||||
emit scriptEventReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
void WebEntityAPIHelper::emitWebEvent(const QVariant& message) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
} else {
|
||||
// special case to handle raising and lowering the virtual keyboard
|
||||
if (message.type() == QVariant::String && message.toString() == "_RAISE_KEYBOARD" && _renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->setKeyboardRaised(true);
|
||||
} else if (message.type() == QVariant::String && message.toString() == "_LOWER_KEYBOARD" && _renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->setKeyboardRaised(false);
|
||||
} else {
|
||||
emit webEventReceived(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityItemPointer RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity{ new RenderableWebEntityItem(entityID) };
|
||||
entity->setProperties(properties);
|
||||
|
|
|
@ -13,36 +13,18 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QTouchEvent>
|
||||
#include <PointerEvent.h>
|
||||
#include <gl/OffscreenQmlSurface.h>
|
||||
|
||||
#include <WebEntityItem.h>
|
||||
|
||||
#include "RenderableEntityItem.h"
|
||||
|
||||
class OffscreenQmlSurface;
|
||||
|
||||
class QWindow;
|
||||
class QObject;
|
||||
class EntityTreeRenderer;
|
||||
class RenderableWebEntityItem;
|
||||
|
||||
class WebEntityAPIHelper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
void setRenderableWebEntityItem(RenderableWebEntityItem* renderableWebEntityItem) {
|
||||
_renderableWebEntityItem = renderableWebEntityItem;
|
||||
}
|
||||
Q_INVOKABLE void synthesizeKeyPress(QString key);
|
||||
|
||||
// event bridge
|
||||
public slots:
|
||||
void emitScriptEvent(const QVariant& scriptMessage);
|
||||
void emitWebEvent(const QVariant& webMessage);
|
||||
signals:
|
||||
void scriptEventReceived(const QVariant& message);
|
||||
void webEventReceived(const QVariant& message);
|
||||
|
||||
protected:
|
||||
RenderableWebEntityItem* _renderableWebEntityItem{ nullptr };
|
||||
};
|
||||
|
||||
class RenderableWebEntityItem : public WebEntityItem {
|
||||
public:
|
||||
|
@ -86,7 +68,6 @@ private:
|
|||
QTouchEvent _lastTouchEvent { QEvent::TouchUpdate };
|
||||
uint64_t _lastRenderTime{ 0 };
|
||||
QTouchDevice _touchDevice;
|
||||
WebEntityAPIHelper* _webEntityAPIHelper;
|
||||
|
||||
QMetaObject::Connection _mousePressConnection;
|
||||
QMetaObject::Connection _mouseReleaseConnection;
|
||||
|
|
|
@ -829,4 +829,37 @@ void OffscreenQmlSurface::setFocusText(bool newFocusText) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void WebEntityAPIHelper::synthesizeKeyPress(QString key) {
|
||||
if (_renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->synthesizeKeyPress(key);
|
||||
}
|
||||
}
|
||||
|
||||
void WebEntityAPIHelper::emitScriptEvent(const QVariant& message) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
} else {
|
||||
emit scriptEventReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
void WebEntityAPIHelper::emitWebEvent(const QVariant& message) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
||||
} else {
|
||||
// special case to handle raising and lowering the virtual keyboard
|
||||
if (message.type() == QVariant::String && message.toString() == "_RAISE_KEYBOARD" && _renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->setKeyboardRaised(true);
|
||||
} else if (message.type() == QVariant::String && message.toString() == "_LOWER_KEYBOARD" && _renderableWebEntityItem) {
|
||||
_renderableWebEntityItem->setKeyboardRaised(false);
|
||||
} else {
|
||||
emit webEventReceived(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "OffscreenQmlSurface.moc"
|
||||
|
|
|
@ -28,6 +28,28 @@ class QQuickItem;
|
|||
|
||||
class OffscreenQmlRenderThread;
|
||||
|
||||
|
||||
class WebEntityAPIHelper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
void setRenderableWebEntityItem(RenderableWebEntityItem* renderableWebEntityItem) {
|
||||
_renderableWebEntityItem = renderableWebEntityItem;
|
||||
}
|
||||
Q_INVOKABLE void synthesizeKeyPress(QString key);
|
||||
|
||||
// event bridge
|
||||
public slots:
|
||||
void emitScriptEvent(const QVariant& scriptMessage);
|
||||
void emitWebEvent(const QVariant& webMessage);
|
||||
signals:
|
||||
void scriptEventReceived(const QVariant& message);
|
||||
void webEventReceived(const QVariant& message);
|
||||
|
||||
protected:
|
||||
RenderableWebEntityItem* _renderableWebEntityItem{ nullptr };
|
||||
};
|
||||
|
||||
|
||||
class OffscreenQmlSurface : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
||||
|
@ -69,6 +91,9 @@ public:
|
|||
QPointF mapToVirtualScreen(const QPointF& originalPoint, QObject* originalWidget);
|
||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||
|
||||
// XXX make private
|
||||
WebEntityAPIHelper* _webEntityAPIHelper;
|
||||
|
||||
signals:
|
||||
void textureUpdated(unsigned int texture);
|
||||
void focusObjectChanged(QObject* newFocus);
|
||||
|
|
Loading…
Reference in a new issue