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
52 { "RIGHT", DockArea::RIGHT }52 { "RIGHT", DockArea::RIGHT }
53};53};
54 54
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 */
63static 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
55DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted) 70DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted)
56 : QObject(parent), _restricted(restricted) { }71 : QObject(parent), _restricted(restricted) { }
57 72
@@ -99,6 +114,10 @@ QVariantMap DesktopScriptingInterface::getDockArea() { · 41 unmodified lines
99 return DOCK_AREA;114 return DOCK_AREA;
100}115}
101 116
117QVariantMap DesktopScriptingInterface::getRelativePositionAnchor() {
118 return RELATIVE_POSITION_ANCHOR;
119}
120
102void DesktopScriptingInterface::setHUDAlpha(float alpha) {121void DesktopScriptingInterface::setHUDAlpha(float alpha) {
103 qApp->getApplicationCompositor().setAlpha(alpha);122 qApp->getApplicationCompositor().setAlpha(alpha);
104}123}