mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-04 02:40:43 +02:00
Merge pull request #16380 from zfox23/fixAnchorlessWindows
DEV-2471: Fix an issue with InteractiveWindow anchors that caused windows without anchors to move when the Interface window geometry changes
This commit is contained in:
commit
99aeb4aa2f
3 changed files with 12 additions and 3 deletions
|
@ -55,12 +55,14 @@ static const QVariantMap DOCK_AREA {
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* The possible "relative position anchors" of an <code>InteractiveWindow</code>. Used when defining the `relativePosition` property of an `InteractiveWindow`.
|
* The possible "relative position anchors" of an <code>InteractiveWindow</code>. Used when defining the `relativePosition` property of an `InteractiveWindow`.
|
||||||
* @typedef {object} InteractiveWindow.RelativePositionAnchors
|
* @typedef {object} InteractiveWindow.RelativePositionAnchors
|
||||||
|
* @property {InteractiveWindow.RelativePositionAnchor} NO_ANCHOR - Specifies that the position of the `InteractiveWindow` will not be relative to any part of the Interface window.
|
||||||
* @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_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} 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_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.
|
* @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 {
|
static const QVariantMap RELATIVE_POSITION_ANCHOR {
|
||||||
|
{ "NO_ANCHOR", RelativePositionAnchor::NO_ANCHOR },
|
||||||
{ "TOP_LEFT", RelativePositionAnchor::TOP_LEFT },
|
{ "TOP_LEFT", RelativePositionAnchor::TOP_LEFT },
|
||||||
{ "TOP_RIGHT", RelativePositionAnchor::TOP_RIGHT },
|
{ "TOP_RIGHT", RelativePositionAnchor::TOP_RIGHT },
|
||||||
{ "BOTTOM_RIGHT", RelativePositionAnchor::BOTTOM_RIGHT },
|
{ "BOTTOM_RIGHT", RelativePositionAnchor::BOTTOM_RIGHT },
|
||||||
|
|
|
@ -116,9 +116,10 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractiveWindow::onMainWindowGeometryChanged(QRect geometry) {
|
void InteractiveWindow::onMainWindowGeometryChanged(QRect geometry) {
|
||||||
|
// This handler is only connected `if (_isFullScreenWindow || _relativePositionAnchor != RelativePositionAnchor::NONE)`.
|
||||||
if (_isFullScreenWindow) {
|
if (_isFullScreenWindow) {
|
||||||
repositionAndResizeFullScreenWindow();
|
repositionAndResizeFullScreenWindow();
|
||||||
} else {
|
} else if (_relativePositionAnchor != RelativePositionAnchor::NO_ANCHOR) {
|
||||||
setPositionUsingRelativePositionAndAnchor(geometry);
|
setPositionUsingRelativePositionAndAnchor(geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,7 +327,9 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (_isFullScreenWindow || _relativePositionAnchor != RelativePositionAnchor::NO_ANCHOR) {
|
||||||
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &InteractiveWindow::onMainWindowGeometryChanged, Qt::QueuedConnection);
|
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
|
||||||
|
@ -494,6 +497,9 @@ void InteractiveWindow::setPositionUsingRelativePositionAndAnchor(const QRect& m
|
||||||
newPosition.x = mainWindowGeometry.x() + relativePosition.x;
|
newPosition.x = mainWindowGeometry.x() + relativePosition.x;
|
||||||
newPosition.y = mainWindowGeometry.y() + mainWindowGeometry.height() - relativePosition.y;
|
newPosition.y = mainWindowGeometry.y() + mainWindowGeometry.height() - relativePosition.y;
|
||||||
break;
|
break;
|
||||||
|
case RelativePositionAnchor::NO_ANCHOR:
|
||||||
|
// No-op.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we include the dimensions of the docked widget!
|
// Make sure we include the dimensions of the docked widget!
|
||||||
|
|
|
@ -91,6 +91,7 @@ namespace InteractiveWindowEnums {
|
||||||
Q_ENUM_NS(DockArea);
|
Q_ENUM_NS(DockArea);
|
||||||
|
|
||||||
enum RelativePositionAnchor {
|
enum RelativePositionAnchor {
|
||||||
|
NO_ANCHOR,
|
||||||
TOP_LEFT,
|
TOP_LEFT,
|
||||||
TOP_RIGHT,
|
TOP_RIGHT,
|
||||||
BOTTOM_RIGHT,
|
BOTTOM_RIGHT,
|
||||||
|
@ -147,7 +148,7 @@ 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);
|
||||||
|
|
||||||
RelativePositionAnchor _relativePositionAnchor{ RelativePositionAnchor::TOP_LEFT };
|
RelativePositionAnchor _relativePositionAnchor{ RelativePositionAnchor::NO_ANCHOR };
|
||||||
Q_INVOKABLE RelativePositionAnchor getRelativePositionAnchor() const;
|
Q_INVOKABLE RelativePositionAnchor getRelativePositionAnchor() const;
|
||||||
Q_INVOKABLE void setRelativePositionAnchor(const RelativePositionAnchor& position);
|
Q_INVOKABLE void setRelativePositionAnchor(const RelativePositionAnchor& position);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue