mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
Modify InteractiveWindow positions in C++ instead of JS, resulting in huge speedup
This commit is contained in:
parent
609f6f9a25
commit
19acd76854
7 changed files with 212 additions and 74 deletions
|
@ -52,6 +52,21 @@ static const QVariantMap DOCK_AREA {
|
||||||
{ "RIGHT", DockArea::RIGHT }
|
{ "RIGHT", DockArea::RIGHT }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* The possible "relative position anchors" of an <code>InteractiveWindow</code>. Used when defining the `relativePosition` property of an `InteractiveWindow`.
|
||||||
|
* @typedef {object} InteractiveWindow.RelativePositionAnchors
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchor} TOP_LEFT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the top left of the Interface window.
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchor} TOP_RIGHT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the top right of the Interface window.
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchor} BOTTOM_RIGHT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the bottom right of the Interface window.
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchor} BOTTOM_LEFT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the bottom left of the Interface window.
|
||||||
|
*/
|
||||||
|
static const QVariantMap RELATIVE_POSITION_ANCHOR {
|
||||||
|
{ "TOP_LEFT", RelativePositionAnchor::TOP_LEFT },
|
||||||
|
{ "TOP_RIGHT", RelativePositionAnchor::TOP_RIGHT },
|
||||||
|
{ "BOTTOM_RIGHT", RelativePositionAnchor::BOTTOM_RIGHT },
|
||||||
|
{ "BOTTOM_LEFT", RelativePositionAnchor::BOTTOM_LEFT }
|
||||||
|
};
|
||||||
|
|
||||||
DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted)
|
DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted)
|
||||||
: QObject(parent), _restricted(restricted) { }
|
: QObject(parent), _restricted(restricted) { }
|
||||||
|
|
||||||
|
@ -99,6 +114,10 @@ QVariantMap DesktopScriptingInterface::getDockArea() {
|
||||||
return DOCK_AREA;
|
return DOCK_AREA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap DesktopScriptingInterface::getRelativePositionAnchor() {
|
||||||
|
return RELATIVE_POSITION_ANCHOR;
|
||||||
|
}
|
||||||
|
|
||||||
void DesktopScriptingInterface::setHUDAlpha(float alpha) {
|
void DesktopScriptingInterface::setHUDAlpha(float alpha) {
|
||||||
qApp->getApplicationCompositor().setAlpha(alpha);
|
qApp->getApplicationCompositor().setAlpha(alpha);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
* @property {InteractiveWindow.DockAreas} DockArea - The possible docking locations of an {@link InteractiveWindow}: top,
|
* @property {InteractiveWindow.DockAreas} DockArea - The possible docking locations of an {@link InteractiveWindow}: top,
|
||||||
* bottom, left, or right of the Interface window.
|
* bottom, left, or right of the Interface window.
|
||||||
* <em>Read-only.</em>
|
* <em>Read-only.</em>
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchors} RelativePositionAnchor - The possible "relative position anchors" for an {@link InteractiveWindow}: top left,
|
||||||
|
* top right, bottom right, or bottom left of the Interface window.
|
||||||
|
* <em>Read-only.</em>
|
||||||
*/
|
*/
|
||||||
class DesktopScriptingInterface : public QObject, public Dependency {
|
class DesktopScriptingInterface : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,6 +53,7 @@ class DesktopScriptingInterface : public QObject, public Dependency {
|
||||||
|
|
||||||
Q_PROPERTY(QVariantMap PresentationMode READ getPresentationMode CONSTANT FINAL)
|
Q_PROPERTY(QVariantMap PresentationMode READ getPresentationMode CONSTANT FINAL)
|
||||||
Q_PROPERTY(QVariantMap DockArea READ getDockArea CONSTANT FINAL)
|
Q_PROPERTY(QVariantMap DockArea READ getDockArea CONSTANT FINAL)
|
||||||
|
Q_PROPERTY(QVariantMap RelativePositionAnchor READ getRelativePositionAnchor CONSTANT FINAL)
|
||||||
Q_PROPERTY(int ALWAYS_ON_TOP READ flagAlwaysOnTop CONSTANT FINAL)
|
Q_PROPERTY(int ALWAYS_ON_TOP READ flagAlwaysOnTop CONSTANT FINAL)
|
||||||
Q_PROPERTY(int CLOSE_BUTTON_HIDES READ flagCloseButtonHides CONSTANT FINAL)
|
Q_PROPERTY(int CLOSE_BUTTON_HIDES READ flagCloseButtonHides CONSTANT FINAL)
|
||||||
|
|
||||||
|
@ -106,7 +110,7 @@ private:
|
||||||
Q_INVOKABLE InteractiveWindowPointer createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread);
|
Q_INVOKABLE InteractiveWindowPointer createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread);
|
||||||
|
|
||||||
static QVariantMap getDockArea();
|
static QVariantMap getDockArea();
|
||||||
|
static QVariantMap getRelativePositionAnchor();
|
||||||
Q_INVOKABLE static QVariantMap getPresentationMode();
|
Q_INVOKABLE static QVariantMap getPresentationMode();
|
||||||
const bool _restricted;
|
const bool _restricted;
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,9 @@ static const char* const ADDITIONAL_FLAGS_PROPERTY = "additionalFlags";
|
||||||
static const char* const OVERRIDE_FLAGS_PROPERTY = "overrideFlags";
|
static const char* const OVERRIDE_FLAGS_PROPERTY = "overrideFlags";
|
||||||
static const char* const SOURCE_PROPERTY = "source";
|
static const char* const SOURCE_PROPERTY = "source";
|
||||||
static const char* const TITLE_PROPERTY = "title";
|
static const char* const TITLE_PROPERTY = "title";
|
||||||
|
static const char* const RELATIVE_POSITION_ANCHOR_PROPERTY = "relativePositionAnchor";
|
||||||
|
static const char* const RELATIVE_POSITION_PROPERTY = "relativePosition";
|
||||||
|
static const char* const IS_FULL_SCREEN_WINDOW = "isFullScreenWindow";
|
||||||
static const char* const POSITION_PROPERTY = "position";
|
static const char* const POSITION_PROPERTY = "position";
|
||||||
static const char* const INTERACTIVE_WINDOW_POSITION_PROPERTY = "interactiveWindowPosition";
|
static const char* const INTERACTIVE_WINDOW_POSITION_PROPERTY = "interactiveWindowPosition";
|
||||||
static const char* const SIZE_PROPERTY = "size";
|
static const char* const SIZE_PROPERTY = "size";
|
||||||
|
@ -112,6 +115,14 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) {
|
||||||
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::onMainWindowGeometryChanged(QRect geometry) {
|
||||||
|
if (_isFullScreenWindow) {
|
||||||
|
repositionAndResizeFullScreenWindow();
|
||||||
|
} else {
|
||||||
|
setPositionUsingRelativePositionAndAnchor(geometry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InteractiveWindow::emitMainWindowResizeEvent() {
|
void InteractiveWindow::emitMainWindowResizeEvent() {
|
||||||
emit qApp->getWindow()->windowGeometryChanged(qApp->getWindow()->geometry());
|
emit qApp->getWindow()->windowGeometryChanged(qApp->getWindow()->geometry());
|
||||||
}
|
}
|
||||||
|
@ -184,22 +195,32 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
*/
|
*/
|
||||||
if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) {
|
if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) {
|
||||||
DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt();
|
DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt();
|
||||||
|
int tempWidth = 0;
|
||||||
|
int tempHeight = 0;
|
||||||
switch (dockedArea) {
|
switch (dockedArea) {
|
||||||
case DockArea::TOP:
|
case DockArea::TOP:
|
||||||
dockArea = Qt::TopDockWidgetArea;
|
dockArea = Qt::TopDockWidgetArea;
|
||||||
_dockWidget->setFixedHeight(windowSize.height());
|
tempHeight = windowSize.height();
|
||||||
|
_dockWidget->setFixedHeight(tempHeight);
|
||||||
|
qApp->getWindow()->setDockedWidgetRelativePositionOffset(QSize(0, -tempHeight));
|
||||||
break;
|
break;
|
||||||
case DockArea::BOTTOM:
|
case DockArea::BOTTOM:
|
||||||
dockArea = Qt::BottomDockWidgetArea;
|
dockArea = Qt::BottomDockWidgetArea;
|
||||||
_dockWidget->setFixedHeight(windowSize.height());
|
tempHeight = windowSize.height();
|
||||||
|
_dockWidget->setFixedHeight(tempHeight);
|
||||||
|
qApp->getWindow()->setDockedWidgetRelativePositionOffset(QSize(0, tempHeight));
|
||||||
break;
|
break;
|
||||||
case DockArea::LEFT:
|
case DockArea::LEFT:
|
||||||
dockArea = Qt::LeftDockWidgetArea;
|
dockArea = Qt::LeftDockWidgetArea;
|
||||||
_dockWidget->setFixedWidth(windowSize.width());
|
tempWidth = windowSize.width();
|
||||||
|
_dockWidget->setFixedWidth(tempWidth);
|
||||||
|
qApp->getWindow()->setDockedWidgetRelativePositionOffset(QSize(-tempWidth, 0));
|
||||||
break;
|
break;
|
||||||
case DockArea::RIGHT:
|
case DockArea::RIGHT:
|
||||||
dockArea = Qt::RightDockWidgetArea;
|
dockArea = Qt::RightDockWidgetArea;
|
||||||
_dockWidget->setFixedWidth(windowSize.width());
|
tempWidth = windowSize.width();
|
||||||
|
_dockWidget->setFixedWidth(tempWidth);
|
||||||
|
qApp->getWindow()->setDockedWidgetRelativePositionOffset(QSize(tempWidth, 0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -255,6 +276,9 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
if (properties.contains(TITLE_PROPERTY)) {
|
if (properties.contains(TITLE_PROPERTY)) {
|
||||||
object->setProperty(TITLE_PROPERTY, properties[TITLE_PROPERTY].toString());
|
object->setProperty(TITLE_PROPERTY, properties[TITLE_PROPERTY].toString());
|
||||||
}
|
}
|
||||||
|
if (properties.contains(VISIBLE_PROPERTY)) {
|
||||||
|
object->setProperty(VISIBLE_PROPERTY, properties[INTERACTIVE_WINDOW_VISIBLE_PROPERTY].toBool());
|
||||||
|
}
|
||||||
if (properties.contains(SIZE_PROPERTY)) {
|
if (properties.contains(SIZE_PROPERTY)) {
|
||||||
const auto size = vec2FromVariant(properties[SIZE_PROPERTY]);
|
const auto size = vec2FromVariant(properties[SIZE_PROPERTY]);
|
||||||
object->setProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY, QSize(size.x, size.y));
|
object->setProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY, QSize(size.x, size.y));
|
||||||
|
@ -263,8 +287,21 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
const auto position = vec2FromVariant(properties[POSITION_PROPERTY]);
|
const auto position = vec2FromVariant(properties[POSITION_PROPERTY]);
|
||||||
object->setProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY, QPointF(position.x, position.y));
|
object->setProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY, QPointF(position.x, position.y));
|
||||||
}
|
}
|
||||||
if (properties.contains(VISIBLE_PROPERTY)) {
|
if (properties.contains(RELATIVE_POSITION_ANCHOR_PROPERTY)) {
|
||||||
object->setProperty(VISIBLE_PROPERTY, properties[INTERACTIVE_WINDOW_VISIBLE_PROPERTY].toBool());
|
_relativePositionAnchor = static_cast<RelativePositionAnchor>(properties[RELATIVE_POSITION_ANCHOR_PROPERTY].toInt());
|
||||||
|
}
|
||||||
|
if (properties.contains(RELATIVE_POSITION_PROPERTY)) {
|
||||||
|
_relativePosition = vec2FromVariant(properties[RELATIVE_POSITION_PROPERTY]);
|
||||||
|
setPositionUsingRelativePositionAndAnchor(qApp->getWindow()->geometry());
|
||||||
|
}
|
||||||
|
if (properties.contains(IS_FULL_SCREEN_WINDOW)) {
|
||||||
|
_isFullScreenWindow = properties[IS_FULL_SCREEN_WINDOW].toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isFullScreenWindow) {
|
||||||
|
QRect geo = qApp->getWindow()->geometry();
|
||||||
|
object->setProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY, QPointF(geo.x(), geo.y()));
|
||||||
|
object->setProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY, QSize(geo.width(), geo.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The qmlToScript method handles the thread-safety of this call. Because the QVariant argument
|
// The qmlToScript method handles the thread-safety of this call. Because the QVariant argument
|
||||||
|
@ -288,6 +325,8 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
connect(object, SIGNAL(interactiveWindowVisibleChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
connect(object, SIGNAL(interactiveWindowVisibleChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||||
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &InteractiveWindow::onMainWindowGeometryChanged, Qt::QueuedConnection);
|
||||||
|
|
||||||
QUrl sourceURL{ sourceUrl };
|
QUrl sourceURL{ sourceUrl };
|
||||||
// If the passed URL doesn't correspond to a known scheme, assume it's a local file path
|
// If the passed URL doesn't correspond to a known scheme, assume it's a local file path
|
||||||
|
@ -414,6 +453,87 @@ void InteractiveWindow::setPosition(const glm::vec2& position) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::setNativeWindowPosition(const glm::vec2& position) {
|
||||||
|
if (!_qmlWindowProxy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto qmlWindow = _qmlWindowProxy->getQmlWindow();
|
||||||
|
|
||||||
|
if (!qmlWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindowProperty = qmlWindow->property("nativeWindow");
|
||||||
|
if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindow = qvariant_cast<QQuickWindow*>(nativeWindowProperty);
|
||||||
|
|
||||||
|
nativeWindow->setPosition(QPoint(position.x, position.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
RelativePositionAnchor InteractiveWindow::getRelativePositionAnchor() const {
|
||||||
|
return _relativePositionAnchor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::setRelativePositionAnchor(const RelativePositionAnchor& relativePositionAnchor) {
|
||||||
|
_relativePositionAnchor = relativePositionAnchor;
|
||||||
|
setPositionUsingRelativePositionAndAnchor(qApp->getWindow()->geometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 InteractiveWindow::getRelativePosition() const {
|
||||||
|
return _relativePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::setRelativePosition(const glm::vec2& relativePosition) {
|
||||||
|
_relativePosition = relativePosition;
|
||||||
|
setPositionUsingRelativePositionAndAnchor(qApp->getWindow()->geometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::setPositionUsingRelativePositionAndAnchor(const QRect& mainWindowGeometry) {
|
||||||
|
RelativePositionAnchor relativePositionAnchor = getRelativePositionAnchor();
|
||||||
|
glm::vec2 relativePosition = getRelativePosition();
|
||||||
|
|
||||||
|
glm::vec2 newPosition;
|
||||||
|
|
||||||
|
switch (relativePositionAnchor) {
|
||||||
|
case RelativePositionAnchor::TOP_LEFT:
|
||||||
|
newPosition.x = mainWindowGeometry.x() + relativePosition.x;
|
||||||
|
newPosition.y = mainWindowGeometry.y() + relativePosition.y;
|
||||||
|
break;
|
||||||
|
case RelativePositionAnchor::TOP_RIGHT:
|
||||||
|
newPosition.x = mainWindowGeometry.x() + mainWindowGeometry.width() - relativePosition.x;
|
||||||
|
newPosition.y = mainWindowGeometry.y() + relativePosition.y;
|
||||||
|
break;
|
||||||
|
case RelativePositionAnchor::BOTTOM_RIGHT:
|
||||||
|
newPosition.x = mainWindowGeometry.x() + mainWindowGeometry.width() - relativePosition.x;
|
||||||
|
newPosition.y = mainWindowGeometry.y() + mainWindowGeometry.height() - relativePosition.y;
|
||||||
|
break;
|
||||||
|
case RelativePositionAnchor::BOTTOM_LEFT:
|
||||||
|
newPosition.x = mainWindowGeometry.x() + relativePosition.x;
|
||||||
|
newPosition.y = mainWindowGeometry.y() + mainWindowGeometry.height() - relativePosition.y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we include the dimensions of the docked widget!
|
||||||
|
QSize dockedWidgetRelativePositionOffset = qApp->getWindow()->getDockedWidgetRelativePositionOffset();
|
||||||
|
newPosition.x = newPosition.x + dockedWidgetRelativePositionOffset.width();
|
||||||
|
newPosition.y = newPosition.y + dockedWidgetRelativePositionOffset.height();
|
||||||
|
|
||||||
|
if (_qmlWindowProxy) {
|
||||||
|
QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, INTERACTIVE_WINDOW_POSITION_PROPERTY),
|
||||||
|
Q_ARG(QVariant, QPointF(newPosition.x, newPosition.y)));
|
||||||
|
}
|
||||||
|
setNativeWindowPosition(newPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::repositionAndResizeFullScreenWindow() {
|
||||||
|
QRect windowGeometry = qApp->getWindow()->geometry();
|
||||||
|
|
||||||
|
setNativeWindowPosition(glm::vec2(windowGeometry.x(), windowGeometry.y()));
|
||||||
|
setNativeWindowSize(glm::vec2(windowGeometry.width(), windowGeometry.height()));
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec2 InteractiveWindow::getSize() const {
|
glm::vec2 InteractiveWindow::getSize() const {
|
||||||
if (!_qmlWindowProxy) {
|
if (!_qmlWindowProxy) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -430,6 +550,26 @@ void InteractiveWindow::setSize(const glm::vec2& size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::setNativeWindowSize(const glm::vec2& size) {
|
||||||
|
if (!_qmlWindowProxy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto qmlWindow = _qmlWindowProxy->getQmlWindow();
|
||||||
|
|
||||||
|
if (!qmlWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindowProperty = qmlWindow->property("nativeWindow");
|
||||||
|
if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindow = qvariant_cast<QQuickWindow*>(nativeWindowProperty);
|
||||||
|
|
||||||
|
nativeWindow->setWidth(size.x);
|
||||||
|
nativeWindow->setHeight(size.y);
|
||||||
|
}
|
||||||
|
|
||||||
QString InteractiveWindow::getTitle() const {
|
QString InteractiveWindow::getTitle() const {
|
||||||
if (!_qmlWindowProxy) {
|
if (!_qmlWindowProxy) {
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -89,6 +89,14 @@ namespace InteractiveWindowEnums {
|
||||||
RIGHT
|
RIGHT
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(DockArea);
|
Q_ENUM_NS(DockArea);
|
||||||
|
|
||||||
|
enum RelativePositionAnchor {
|
||||||
|
TOP_LEFT,
|
||||||
|
TOP_RIGHT,
|
||||||
|
BOTTOM_RIGHT,
|
||||||
|
BOTTOM_LEFT
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(RelativePositionAnchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace InteractiveWindowEnums;
|
using namespace InteractiveWindowEnums;
|
||||||
|
@ -121,6 +129,8 @@ class InteractiveWindow : public QObject {
|
||||||
|
|
||||||
Q_PROPERTY(QString title READ getTitle WRITE setTitle)
|
Q_PROPERTY(QString title READ getTitle WRITE setTitle)
|
||||||
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
|
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
|
||||||
|
Q_PROPERTY(RelativePositionAnchor relativePositionAnchor READ getRelativePositionAnchor WRITE setRelativePositionAnchor)
|
||||||
|
Q_PROPERTY(glm::vec2 relativePosition READ getRelativePosition WRITE setRelativePosition)
|
||||||
Q_PROPERTY(glm::vec2 size READ getSize WRITE setSize)
|
Q_PROPERTY(glm::vec2 size READ getSize WRITE setSize)
|
||||||
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
|
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
|
||||||
Q_PROPERTY(int presentationMode READ getPresentationMode WRITE setPresentationMode)
|
Q_PROPERTY(int presentationMode READ getPresentationMode WRITE setPresentationMode)
|
||||||
|
@ -136,9 +146,26 @@ private:
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec2 getPosition() const;
|
Q_INVOKABLE glm::vec2 getPosition() const;
|
||||||
Q_INVOKABLE void setPosition(const glm::vec2& position);
|
Q_INVOKABLE void setPosition(const glm::vec2& position);
|
||||||
|
Q_INVOKABLE void setNativeWindowPosition(const glm::vec2& position);
|
||||||
|
|
||||||
|
RelativePositionAnchor _relativePositionAnchor{ RelativePositionAnchor::TOP_LEFT };
|
||||||
|
Q_INVOKABLE RelativePositionAnchor getRelativePositionAnchor() const;
|
||||||
|
Q_INVOKABLE void setRelativePositionAnchor(const RelativePositionAnchor& position);
|
||||||
|
|
||||||
|
// This "relative position" is relative to the "relative position anchor" and excludes the window frame.
|
||||||
|
// This position will ALWAYS include the geometry of a docked widget, if one is present.
|
||||||
|
glm::vec2 _relativePosition{ 0.0f, 0.0f };
|
||||||
|
Q_INVOKABLE glm::vec2 getRelativePosition() const;
|
||||||
|
Q_INVOKABLE void setRelativePosition(const glm::vec2& position);
|
||||||
|
|
||||||
|
Q_INVOKABLE void setPositionUsingRelativePositionAndAnchor(const QRect& mainWindowGeometry);
|
||||||
|
|
||||||
|
bool _isFullScreenWindow{ false };
|
||||||
|
Q_INVOKABLE void repositionAndResizeFullScreenWindow();
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec2 getSize() const;
|
Q_INVOKABLE glm::vec2 getSize() const;
|
||||||
Q_INVOKABLE void setSize(const glm::vec2& size);
|
Q_INVOKABLE void setSize(const glm::vec2& size);
|
||||||
|
Q_INVOKABLE void setNativeWindowSize(const glm::vec2& size);
|
||||||
|
|
||||||
Q_INVOKABLE void setVisible(bool visible);
|
Q_INVOKABLE void setVisible(bool visible);
|
||||||
Q_INVOKABLE bool isVisible() const;
|
Q_INVOKABLE bool isVisible() const;
|
||||||
|
@ -320,6 +347,7 @@ protected slots:
|
||||||
void forwardKeyPressEvent(int key, int modifiers);
|
void forwardKeyPressEvent(int key, int modifiers);
|
||||||
void forwardKeyReleaseEvent(int key, int modifiers);
|
void forwardKeyReleaseEvent(int key, int modifiers);
|
||||||
void emitMainWindowResizeEvent();
|
void emitMainWindowResizeEvent();
|
||||||
|
void onMainWindowGeometryChanged(QRect geometry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QmlWindowProxy> _qmlWindowProxy;
|
std::shared_ptr<QmlWindowProxy> _qmlWindowProxy;
|
||||||
|
|
|
@ -24,6 +24,10 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
static QWindow* findMainWindow();
|
static QWindow* findMainWindow();
|
||||||
|
|
||||||
|
// This offset is used for positioning children window relative to the main window.
|
||||||
|
void setDockedWidgetRelativePositionOffset(const QSize& newOffset) { _dockedWidgetRelativePositionOffset.setWidth(newOffset.width()); _dockedWidgetRelativePositionOffset.setHeight(newOffset.height()); }
|
||||||
|
QSize getDockedWidgetRelativePositionOffset() { return _dockedWidgetRelativePositionOffset; }
|
||||||
public slots:
|
public slots:
|
||||||
void restoreGeometry();
|
void restoreGeometry();
|
||||||
void saveGeometry();
|
void saveGeometry();
|
||||||
|
@ -46,6 +50,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Setting::Handle<QRect> _windowGeometry;
|
Setting::Handle<QRect> _windowGeometry;
|
||||||
Setting::Handle<int> _windowState;
|
Setting::Handle<int> _windowState;
|
||||||
|
QSize _dockedWidgetRelativePositionOffset{ 0, 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__MainWindow__) */
|
#endif /* defined(__hifi__MainWindow__) */
|
||||||
|
|
|
@ -444,11 +444,6 @@ function updateEmoteIndicatorIcon(iconURL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onGeometryChanged(rect) {
|
|
||||||
updateEmoteAppBarPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function onWindowMinimizedChanged(isMinimized) {
|
function onWindowMinimizedChanged(isMinimized) {
|
||||||
isWindowMinimized = isMinimized;
|
isWindowMinimized = isMinimized;
|
||||||
maybeChangeEmoteIndicatorVisibility(!isMinimized);
|
maybeChangeEmoteIndicatorVisibility(!isMinimized);
|
||||||
|
@ -536,10 +531,11 @@ function showEmoteAppBar() {
|
||||||
x: EMOTE_APP_BAR_WIDTH_PX,
|
x: EMOTE_APP_BAR_WIDTH_PX,
|
||||||
y: EMOTE_APP_BAR_HEIGHT_PX
|
y: EMOTE_APP_BAR_HEIGHT_PX
|
||||||
},
|
},
|
||||||
position: {
|
relativePosition: {
|
||||||
x: Window.x + EMOTE_APP_BAR_LEFT_MARGIN,
|
x: EMOTE_APP_BAR_LEFT_MARGIN,
|
||||||
y: Window.y + Window.innerHeight - EMOTE_APP_BAR_BOTTOM_MARGIN
|
y: EMOTE_APP_BAR_BOTTOM_MARGIN
|
||||||
},
|
},
|
||||||
|
relativePositionAnchor: Desktop.RelativePositionAnchor.BOTTOM_LEFT,
|
||||||
overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS
|
overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -612,7 +608,6 @@ function setup() {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
Window.minimizedChanged.connect(onWindowMinimizedChanged);
|
Window.minimizedChanged.connect(onWindowMinimizedChanged);
|
||||||
Window.geometryChanged.connect(onGeometryChanged);
|
|
||||||
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
||||||
|
|
||||||
getSounds();
|
getSounds();
|
||||||
|
@ -655,7 +650,6 @@ function unload() {
|
||||||
maybeDeleteRemoteIndicatorTimeout();
|
maybeDeleteRemoteIndicatorTimeout();
|
||||||
|
|
||||||
Window.minimizedChanged.disconnect(onWindowMinimizedChanged);
|
Window.minimizedChanged.disconnect(onWindowMinimizedChanged);
|
||||||
Window.geometryChanged.disconnect(onGeometryChanged);
|
|
||||||
HMD.displayModeChanged.disconnect(onDisplayModeChanged);
|
HMD.displayModeChanged.disconnect(onDisplayModeChanged);
|
||||||
|
|
||||||
if (keyPressSignalsConnected) {
|
if (keyPressSignalsConnected) {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
|
|
||||||
// START CONFIG OPTIONS
|
// START CONFIG OPTIONS
|
||||||
var DOCKED_QML_SUPPORTED = true;
|
|
||||||
var TOOLBAR_NAME = "com.highfidelity.interface.toolbar.system";
|
var TOOLBAR_NAME = "com.highfidelity.interface.toolbar.system";
|
||||||
var DEFAULT_SCRIPTS_PATH_PREFIX = ScriptDiscoveryService.defaultScriptsPath + "/";
|
var DEFAULT_SCRIPTS_PATH_PREFIX = ScriptDiscoveryService.defaultScriptsPath + "/";
|
||||||
// END CONFIG OPTIONS
|
// END CONFIG OPTIONS
|
||||||
|
@ -378,14 +377,7 @@ function displayInitialLaunchWindow() {
|
||||||
initialLaunchWindow = Desktop.createWindow(INITIAL_LAUNCH_QML_PATH, {
|
initialLaunchWindow = Desktop.createWindow(INITIAL_LAUNCH_QML_PATH, {
|
||||||
title: INITIAL_LAUNCH_WINDOW_TITLE,
|
title: INITIAL_LAUNCH_WINDOW_TITLE,
|
||||||
presentationMode: INITIAL_LAUNCH_PRESENTATION_MODE,
|
presentationMode: INITIAL_LAUNCH_PRESENTATION_MODE,
|
||||||
size: {
|
isFullScreenWindow: true,
|
||||||
x: Window.innerWidth,
|
|
||||||
y: Window.innerHeight + TOP_BAR_HEIGHT_PX
|
|
||||||
},
|
|
||||||
position: {
|
|
||||||
x: Window.x,
|
|
||||||
y: Window.y
|
|
||||||
},
|
|
||||||
overrideFlags: INITIAL_WINDOW_FLAGS
|
overrideFlags: INITIAL_WINDOW_FLAGS
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -413,14 +405,7 @@ function displaySecondLaunchWindow() {
|
||||||
secondLaunchWindow = Desktop.createWindow(SECOND_LAUNCH_QML_PATH, {
|
secondLaunchWindow = Desktop.createWindow(SECOND_LAUNCH_QML_PATH, {
|
||||||
title: SECOND_LAUNCH_WINDOW_TITLE,
|
title: SECOND_LAUNCH_WINDOW_TITLE,
|
||||||
presentationMode: SECOND_LAUNCH_PRESENTATION_MODE,
|
presentationMode: SECOND_LAUNCH_PRESENTATION_MODE,
|
||||||
size: {
|
isFullScreenWindow: true,
|
||||||
x: Window.innerWidth,
|
|
||||||
y: Window.innerHeight + TOP_BAR_HEIGHT_PX
|
|
||||||
},
|
|
||||||
position: {
|
|
||||||
x: Window.x,
|
|
||||||
y: Window.y
|
|
||||||
},
|
|
||||||
overrideFlags: SECOND_WINDOW_FLAGS
|
overrideFlags: SECOND_WINDOW_FLAGS
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -581,16 +566,9 @@ function loadSimplifiedTopBar() {
|
||||||
y: TOP_BAR_HEIGHT_PX
|
y: TOP_BAR_HEIGHT_PX
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (DOCKED_QML_SUPPORTED) {
|
windowProps.presentationWindowInfo = {
|
||||||
windowProps.presentationWindowInfo = {
|
dockArea: Desktop.DockArea.TOP
|
||||||
dockArea: Desktop.DockArea.TOP
|
};
|
||||||
};
|
|
||||||
} else {
|
|
||||||
windowProps.position = {
|
|
||||||
x: Window.x,
|
|
||||||
y: Window.y
|
|
||||||
};
|
|
||||||
}
|
|
||||||
topBarWindow = Desktop.createWindow(TOP_BAR_QML_PATH, windowProps);
|
topBarWindow = Desktop.createWindow(TOP_BAR_QML_PATH, windowProps);
|
||||||
|
|
||||||
topBarWindow.fromQml.connect(onMessageFromTopBar);
|
topBarWindow.fromQml.connect(onMessageFromTopBar);
|
||||||
|
@ -655,36 +633,6 @@ function onHMDInputDeviceMutedChanged(isMuted) {
|
||||||
function onGeometryChanged(rect) {
|
function onGeometryChanged(rect) {
|
||||||
updateInputDeviceMutedOverlay(Audio.muted);
|
updateInputDeviceMutedOverlay(Audio.muted);
|
||||||
updateOutputDeviceMutedOverlay(isOutputMuted());
|
updateOutputDeviceMutedOverlay(isOutputMuted());
|
||||||
if (topBarWindow && !DOCKED_QML_SUPPORTED) {
|
|
||||||
topBarWindow.size = {
|
|
||||||
"x": rect.width,
|
|
||||||
"y": TOP_BAR_HEIGHT_PX
|
|
||||||
};
|
|
||||||
topBarWindow.position = {
|
|
||||||
"x": rect.x,
|
|
||||||
"y": rect.y
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (initialLaunchWindow) {
|
|
||||||
initialLaunchWindow.size = {
|
|
||||||
"x": Window.innerWidth,
|
|
||||||
"y": Window.innerHeight + TOP_BAR_HEIGHT_PX
|
|
||||||
};
|
|
||||||
initialLaunchWindow.position = {
|
|
||||||
"x": rect.x,
|
|
||||||
"y": rect.y
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (secondLaunchWindow) {
|
|
||||||
secondLaunchWindow.size = {
|
|
||||||
"x": Window.innerWidth,
|
|
||||||
"y": Window.innerHeight + TOP_BAR_HEIGHT_PX
|
|
||||||
};
|
|
||||||
secondLaunchWindow.position = {
|
|
||||||
"x": rect.x,
|
|
||||||
"y": rect.y
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var initialLaunchWindowIsMinimized = false;
|
var initialLaunchWindowIsMinimized = false;
|
||||||
|
|
Loading…
Reference in a new issue