History

Modify InteractiveWindow positions in C++ instead of JS, resulting in huge speedup

Zach Fox committed 7 years ago

Commit 19acd761 parent 609f6f97 files · +212 −74Browse files

Showing the changes to interface/src/scripting/DesktopScriptingInterface.cpp (1 of 7 files). Show all

Unified · Split

interface/src/scripting/DesktopScriptingInterface.cpp+19−0
@@ -52,6 +52,21 @@ static const QVariantMap DOCK_AREA { · 51 unmodified lines
5252 { "RIGHT", DockArea::RIGHT }
5353 };
5454
55+/**jsdoc
56+ * The possible "relative position anchors" of an <code>InteractiveWindow</code>. Used when defining the `relativePosition` property of an `InteractiveWindow`.
57+ * @typedef {object} InteractiveWindow.RelativePositionAnchors
58+ * @property {InteractiveWindow.RelativePositionAnchor} TOP_LEFT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the top left of the Interface window.
59+ * @property {InteractiveWindow.RelativePositionAnchor} TOP_RIGHT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the top right of the Interface window.
60+ * @property {InteractiveWindow.RelativePositionAnchor} BOTTOM_RIGHT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the bottom right of the Interface window.
61+ * @property {InteractiveWindow.RelativePositionAnchor} BOTTOM_LEFT - Specifies that the `relativePosition` of the `InteractiveWindow` will be offset from the bottom left of the Interface window.
62+ */
63+static const QVariantMap RELATIVE_POSITION_ANCHOR {
64+ { "TOP_LEFT", RelativePositionAnchor::TOP_LEFT },
65+ { "TOP_RIGHT", RelativePositionAnchor::TOP_RIGHT },
66+ { "BOTTOM_RIGHT", RelativePositionAnchor::BOTTOM_RIGHT },
67+ { "BOTTOM_LEFT", RelativePositionAnchor::BOTTOM_LEFT }
68+};
69+
5570 DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted)
5671 : QObject(parent), _restricted(restricted) { }
5772
@@ -99,6 +114,10 @@ QVariantMap DesktopScriptingInterface::getDockArea() { · 41 unmodified lines
99114 return DOCK_AREA;
100115 }
101116
117+QVariantMap DesktopScriptingInterface::getRelativePositionAnchor() {
118+ return RELATIVE_POSITION_ANCHOR;
119+}
120+
102121 void DesktopScriptingInterface::setHUDAlpha(float alpha) {
103122 qApp->getApplicationCompositor().setAlpha(alpha);
104123 }