16 #ifndef hifi_InteractiveWindow_h
17 #define hifi_InteractiveWindow_h
19 #include <QtCore/QObject>
20 #include <QtCore/QPointer>
22 #include <ui/QmlWrapper.h>
24 #include <glm/glm.hpp>
25 #include <GLMHelpers.h>
26 #include <ScriptValue.h>
30 class QmlWindowProxy :
public QmlWrapper {
34 QmlWindowProxy(QObject* qmlObject, QObject* parent =
nullptr);
36 Q_INVOKABLE
void parentNativeWindowToMainWindow();
38 QObject* getQmlWindow()
const {
return _qmlWindow; }
44 class InteractiveWindowProxy :
public QObject {
47 InteractiveWindowProxy(){}
50 void emitScriptEvent(
const QVariant& scriptMessage);
51 void emitWebEvent(
const QVariant& webMessage);
55 void scriptEventReceived(
const QVariant& message);
56 void webEventReceived(
const QVariant& message);
59 namespace InteractiveWindowEnums {
77 enum InteractiveWindowFlags : uint8_t {
79 CloseButtonHides = 1 << 1
81 Q_ENUM_NS(InteractiveWindowFlags);
98 enum InteractiveWindowPresentationMode {
102 Q_ENUM_NS(InteractiveWindowPresentationMode);
145 enum RelativePositionAnchor {
152 Q_ENUM_NS(RelativePositionAnchor);
155 using namespace InteractiveWindowEnums;
185 class InteractiveWindow :
public QObject {
188 Q_PROPERTY(QString title READ getTitle WRITE setTitle)
189 Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
190 Q_PROPERTY(RelativePositionAnchor relativePositionAnchor READ getRelativePositionAnchor WRITE setRelativePositionAnchor)
191 Q_PROPERTY(glm::vec2 relativePosition READ getRelativePosition WRITE setRelativePosition)
192 Q_PROPERTY(glm::vec2 size READ getSize WRITE setSize)
193 Q_PROPERTY(
bool visible READ isVisible WRITE setVisible)
194 Q_PROPERTY(
int presentationMode READ getPresentationMode WRITE setPresentationMode)
197 InteractiveWindow(
const QString& sourceUrl,
const QVariantMap& properties,
bool restricted);
198 ~InteractiveWindow();
202 Q_INVOKABLE QString getTitle()
const;
203 Q_INVOKABLE
void setTitle(
const QString& title);
205 Q_INVOKABLE glm::vec2 getPosition()
const;
206 Q_INVOKABLE
void setPosition(
const glm::vec2& position);
208 RelativePositionAnchor _relativePositionAnchor{ RelativePositionAnchor::NO_ANCHOR };
209 Q_INVOKABLE RelativePositionAnchor getRelativePositionAnchor()
const;
210 Q_INVOKABLE
void setRelativePositionAnchor(
const RelativePositionAnchor& position);
214 glm::vec2 _relativePosition{ 0.0f, 0.0f };
215 Q_INVOKABLE glm::vec2 getRelativePosition()
const;
216 Q_INVOKABLE
void setRelativePosition(
const glm::vec2& position);
218 Q_INVOKABLE
void setPositionUsingRelativePositionAndAnchor(
const QRect& mainWindowGeometry);
220 bool _isFullScreenWindow{
false };
221 Q_INVOKABLE
void repositionAndResizeFullScreenWindow();
223 Q_INVOKABLE glm::vec2 getSize()
const;
224 Q_INVOKABLE
void setSize(
const glm::vec2& size);
226 Q_INVOKABLE
void setVisible(
bool visible);
227 Q_INVOKABLE
bool isVisible()
const;
229 Q_INVOKABLE
void setPresentationMode(
int presentationMode);
230 Q_INVOKABLE
int getPresentationMode()
const;
232 Q_INVOKABLE
void parentNativeWindowToMainWindow();
283 void sendToQml(
const QVariant& message);
295 void emitScriptEvent(
const QVariant& scriptMessage);
302 void emitWebEvent(
const QVariant& webMessage);
308 Q_INVOKABLE
void close();
314 Q_INVOKABLE
void show();
320 Q_INVOKABLE
void raise();
329 void visibleChanged();
336 void positionChanged();
350 void presentationModeChanged();
374 void fromQml(
const QVariant& message);
383 void scriptEventReceived(
const QVariant& message);
392 void webEventReceived(
const QVariant& message);
400 void qmlToScript(
const QVariant& message);
402 void forwardKeyPressEvent(
int key,
int modifiers);
403 void forwardKeyReleaseEvent(
int key,
int modifiers);
404 void emitMainWindowResizeEvent();
405 void onMainWindowGeometryChanged(QRect geometry);
408 std::shared_ptr<QmlWindowProxy> _qmlWindowProxy;
409 std::shared_ptr<DockWidget> _dockWidget {
nullptr };
410 std::unique_ptr<InteractiveWindowProxy, std::function<void(InteractiveWindowProxy*)>> _interactiveWindowProxy;
413 typedef InteractiveWindow* InteractiveWindowPointer;
416 bool interactiveWindowPointerFromScriptValue(
const ScriptValue&
object, InteractiveWindowPointer& out);
418 void registerInteractiveWindowMetaType(
ScriptEngine* engine);
420 Q_DECLARE_METATYPE(InteractiveWindowPointer)
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40