Showing the changes to interface/src/scripting/WindowScriptingInterface.h (1 of 3 files). Show all
Unified · Split
| @@ -33,6 +33,19 @@ QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const Custom · 32 unmodified lines | |||
| 33 | void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result); | 33 | void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result); |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | /**jsdoc | ||
| 37 | * The Window API provides various facilities not covered elsewhere. | ||
| 38 | * | ||
| 39 | * @namespace Window | ||
| 40 | * @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other | ||
| 41 | * chrome), in pixels. <em>Read-only.</em> | ||
| 42 | * @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other | ||
| 43 | * chrome) plus the height of the menu bar, in pixels. <em>Read-only.</em> | ||
| 44 | * @property {object} location - Provides facilities for working with your current metaverse location. See {@link location}. | ||
| 45 | * @property {number} x - The x coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em> | ||
| 46 | * @property {number} y - The y coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em> | ||
| 47 | */ | ||
| 48 | |||
| 36 | class WindowScriptingInterface : public QObject, public Dependency { | 49 | class WindowScriptingInterface : public QObject, public Dependency { |
| 37 | Q_OBJECT | 50 | Q_OBJECT |
| 38 | Q_PROPERTY(int innerWidth READ getInnerWidth) | 51 | Q_PROPERTY(int innerWidth READ getInnerWidth) |
| @@ -48,63 +61,615 @@ public: · 9 unmodified lines | |||
| 48 | int getY(); | 61 | int getY(); |
| 49 | 62 | ||
| 50 | public slots: | 63 | public slots: |
| 64 | |||
| 65 | /**jsdoc | ||
| 66 | * Check if the Interface window has focus. | ||
| 67 | * @function Window.hasFocus | ||
| 68 | * @returns {boolean} <code>true</code> if the Interface window has focus, otherwise <code>false</code>. | ||
| 69 | */ | ||
| 51 | QScriptValue hasFocus(); | 70 | QScriptValue hasFocus(); |
| 71 | |||
| 72 | /**jsdoc | ||
| 73 | * Make the Interface window have focus. | ||
| 74 | * @function Window.setFocus | ||
| 75 | */ | ||
| 52 | void setFocus(); | 76 | void setFocus(); |
| 77 | |||
| 78 | /**jsdoc | ||
| 79 | * Raise the Interface window if it is minimized, and give it focus. | ||
| 80 | * @function Window.raiseMainWindow | ||
| 81 | */ | ||
| 53 | void raiseMainWindow(); | 82 | void raiseMainWindow(); |
| 83 | |||
| 84 | /**jsdoc | ||
| 85 | * Display a dialog with the specified message and an "OK" button. The dialog is non-modal; the script continues without | ||
| 86 | * waiting for a user response. | ||
| 87 | * @function Window.alert | ||
| 88 | * @param {string} message="" - The message to display. | ||
| 89 | * @example <caption>Display a friendly greeting.</caption> | ||
| 90 | * Window.alert("Welcome!"); | ||
| 91 | * print("Script continues without waiting"); | ||
| 92 | */ | ||
| 54 | void alert(const QString& message = ""); | 93 | void alert(const QString& message = ""); |
| 94 | |||
| 95 | /**jsdoc | ||
| 96 | * Prompt the user to confirm something. Displays a modal dialog with a message plus "Yes" and "No" buttons. | ||
| 97 | * responds. | ||
| 98 | * @function Window.confirm | ||
| 99 | * @param {string} message="" - The question to display. | ||
| 100 | * @returns {boolean} <code>true</code> if the user selects "Yes", otherwise <code>false</code>. | ||
| 101 | * @example <caption>Ask the user a question requiring a yes/no answer.</caption> | ||
| 102 | * var answer = Window.confirm("Are you sure?"); | ||
| 103 | * print(answer); // true or false | ||
| 104 | */ | ||
| 55 | QScriptValue confirm(const QString& message = ""); | 105 | QScriptValue confirm(const QString& message = ""); |
| 106 | |||
| 107 | /**jsdoc | ||
| 108 | * Prompt the user to enter some text. Displays a modal dialog with a message and a text box, plus "OK" and "Cancel" | ||
| 109 | * buttons. | ||
| 110 | * @function Window.prompt | ||
| 111 | * @param {string} message - The question to display. | ||
| 112 | * @param {string} defaultText - The default answer text. | ||
| 113 | * @returns {string} The text that the user entered if they select "OK", otherwise "". | ||
| 114 | * @example <caption>Ask the user a question requiring a text answer.</caption> | ||
| 115 | * var answer = Window.prompt("Question", "answer"); | ||
| 116 | * if (answer === "") { | ||
| 117 | * print("User canceled"); | ||
| 118 | * } else { | ||
| 119 | * print("User answer: " + answer); | ||
| 120 | * } | ||
| 121 | */ | ||
| 56 | QScriptValue prompt(const QString& message, const QString& defaultText); | 122 | QScriptValue prompt(const QString& message, const QString& defaultText); |
| 123 | |||
| 124 | /**jsdoc | ||
| 125 | * Prompt the user to enter some text. Displays a non-modal dialog with a message and a text box, plus "OK" and "Cancel" | ||
| 126 | * buttons. A {@link Window.promptTextChanged|promptTextChanged} signal is emitted when the user OKs the dialog; no signal | ||
| 127 | * is emitted if the user cancels the dialog. | ||
| 128 | * @function Window.promptAsync | ||
| 129 | * @param {string} message - The question to display. | ||
| 130 | * @param {string} defaultText - The default answer text. | ||
| 131 | * @example <caption>Ask the user a question requiring a text answer without waiting for the answer.</caption> | ||
| 132 | * function onPromptTextChanged(text) { | ||
| 133 | * print("User answer: " + text); | ||
| 134 | * } | ||
| 135 | * Window.promptTextChanged.connect(onPromptTextChanged); | ||
| 136 | * | ||
| 137 | * Window.promptAsync("Question", "answer"); | ||
| 138 | * print("Script continues without waiting"); | ||
| 139 | */ | ||
| 57 | void promptAsync(const QString& message = "", const QString& defaultText = ""); | 140 | void promptAsync(const QString& message = "", const QString& defaultText = ""); |
| 141 | |||
| 142 | /**jsdoc | ||
| 143 | * Prompt the user for input in a custom, modal dialog. | ||
| 144 | * @deprecated This funtion is deprecated and will be removed. | ||
| 145 | * @function Window.customPrompt | ||
| 146 | * @param {object} config - Configures the modal dialog. | ||
| 147 | * @returns {object} The user's response. | ||
| 148 | */ | ||
| 58 | CustomPromptResult customPrompt(const QVariant& config); | 149 | CustomPromptResult customPrompt(const QVariant& config); |
| 150 | |||
| 151 | /**jsdoc | ||
| 152 | * Prompt the user to choose a directory. Displays a modal dialog that navigates the directory tree. | ||
| 153 | * @function Window.browseDir | ||
| 154 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 155 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 156 | * @returns {string} The path of the directory if one is chosen, otherwise <code>null</code>. | ||
| 157 | * @example <caption>Ask the user to choose a directory.</caption> | ||
| 158 | * var directory = Window.browseDir("Select Directory", Paths.resources); | ||
| 159 | * print("Directory: " + directory); | ||
| 160 | */ | ||
| 59 | QScriptValue browseDir(const QString& title = "", const QString& directory = ""); | 161 | QScriptValue browseDir(const QString& title = "", const QString& directory = ""); |
| 162 | |||
| 163 | /**jsdoc | ||
| 164 | * Prompt the user to choose a directory. Displays a non-modal dialog that navigates the directory tree. A | ||
| 165 | * {@link Window.browseDirChanged|browseDirChanged} signal is emitted when a directory is chosen; no signal is emitted if | ||
| 166 | * the user cancels the dialog. | ||
| 167 | * @function Window.browseDirAsync | ||
| 168 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 169 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 170 | * @example <caption>Ask the user to choose a directory without waiting for the answer.</caption> | ||
| 171 | * function onBrowseDirChanged(directory) { | ||
| 172 | * print("Directory: " + directory); | ||
| 173 | * } | ||
| 174 | * Window.browseDirChanged.connect(onBrowseDirChanged); | ||
| 175 | * | ||
| 176 | * Window.browseDirAsync("Select Directory", Paths.resources); | ||
| 177 | * print("Script continues without waiting"); | ||
| 178 | */ | ||
| 60 | void browseDirAsync(const QString& title = "", const QString& directory = ""); | 179 | void browseDirAsync(const QString& title = "", const QString& directory = ""); |
| 180 | |||
| 181 | /**jsdoc | ||
| 182 | * Prompt the user to choose a file. Displays a modal dialog that navigates the directory tree. | ||
| 183 | * @function Window.browse | ||
| 184 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 185 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 186 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 187 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 188 | * @returns {string} The path and name of the file if one is chosen, otherwise <code>null</code>. | ||
| 189 | * @example <caption>Ask the user to choose an image file.</caption> | ||
| 190 | * var file = Window.browse("Select Image File", Paths.resources, "Images (*.png *.jpg *.svg)"); | ||
| 191 | * print("File: " + file); | ||
| 192 | */ | ||
| 61 | QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 193 | QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 194 | |||
| 195 | /**jsdoc | ||
| 196 | * Prompt the user to choose a file. Displays a non-modal dialog that navigates the directory tree. A | ||
| 197 | * {@link Window.openFileChanged|openFileChanged} signal is emitted when a file is chosen; no signal is emitted if the user | ||
| 198 | * cancels the dialog. | ||
| 199 | * @function Window.browseAsync | ||
| 200 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 201 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 202 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 203 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 204 | * @example <caption>Ask the user to choose an image file without waiting for the answer.</caption> | ||
| 205 | * function onOpenFileChanged(file) { | ||
| 206 | * print("File: " + file); | ||
| 207 | * } | ||
| 208 | * Window.openFileChanged.connect(onOpenFileChanged); | ||
| 209 | * | ||
| 210 | * Window.browseAsync("Select Image File", Paths.resources, "Images (*.png *.jpg *.svg)"); | ||
| 211 | * print("Script continues without waiting"); | ||
| 212 | */ | ||
| 62 | void browseAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 213 | void browseAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 214 | |||
| 215 | /**jsdoc | ||
| 216 | * Prompt the user to specify the path and name of a file to save to. Displays a model dialog that navigates the directory | ||
| 217 | * tree and allows the user to type in a file name. | ||
| 218 | * @function Window.save | ||
| 219 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 220 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 221 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 222 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 223 | * @returns {string} The path and name of the file is one is specified, otherwise <code>null</code>. If a single file type | ||
| 224 | * is specified in the nameFilter, that file type extension is automatically appended to the result when appropriate. | ||
| 225 | * @example <caption>Ask the user to specify a file to save to.</caption> | ||
| 226 | * var file = Window.save("Save to JSON file", Paths.resources, "*.json"); | ||
| 227 | * print("File: " + file); | ||
| 228 | */ | ||
| 63 | QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 229 | QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 230 | |||
| 231 | /**jsdoc | ||
| 232 | * Prompt the user to specify the path and name of a file to save to. Displays a non-model dialog that navigates the | ||
| 233 | * directory tree and allows the user to type in a file name. A {@link Window.saveFileChanged|saveFileChanged} signal is | ||
| 234 | * emitted when a file is specified; no signal is emitted if the user cancels the dialog. | ||
| 235 | * @function Window.saveAsync | ||
| 236 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 237 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 238 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 239 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 240 | * @example <caption>Ask the user to specify a file to save to without waiting for an answer.</caption> | ||
| 241 | * function onSaveFileChanged(file) { | ||
| 242 | * print("File: " + file); | ||
| 243 | * } | ||
| 244 | * Window.saveFileChanged.connect(onSaveFileChanged); | ||
| 245 | * | ||
| 246 | * Window.saveAsync("Save to JSON file", Paths.resources, "*.json"); | ||
| 247 | * print("Script continues without waiting"); | ||
| 248 | */ | ||
| 64 | void saveAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 249 | void saveAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 250 | |||
| 251 | /**jsdoc | ||
| 252 | * Prompt the user to choose an Asset Server item. Displays a modal dialog that navigates the tree of assets on the Asset | ||
| 253 | * Server. | ||
| 254 | * @function Window.browseAssets | ||
| 255 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 256 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 257 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 258 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 259 | * @returns {string} The path and name of the asset if one is chosen, otherwise <code>null</code>. | ||
| 260 | * @example <caption>Ask the user to select an FBX asset.</caption> | ||
| 261 | * var asset = Window.browseAssets("Select FBX File", "/", "*.fbx"); | ||
| 262 | * print("FBX file: " + asset); | ||
| 263 | */ | ||
| 65 | QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 264 | QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 265 | |||
| 266 | /**jsdoc | ||
| 267 | * Prompt the user to choose an Asset Server item. Displays a non-modal dialog that navigates the tree of assets on the | ||
| 268 | * Asset Server. A {@link Window.assetsDirChanged|assetsDirChanged} signal is emitted when an asset is chosen; no signal is | ||
| 269 | * emitted if the user cancels the dialog. | ||
| 270 | * @function Window.browseAssetsAsync | ||
| 271 | * @param {string} title="" - The title to display at the top of the dialog. | ||
| 272 | * @param {string} directory="" - The initial directory to start browsing at. | ||
| 273 | * @param {string} nameFilter="" - The types of files to display. Examples: <code>"*.json"</code> and | ||
| 274 | * <code>"Images (*.png *.jpg *.svg)"</code>. All files are displayed if a filter isn't specified. | ||
| 275 | * @example | ||
| 276 | * function onAssetsDirChanged(asset) { | ||
| 277 | * print("FBX file: " + asset); | ||
| 278 | * } | ||
| 279 | * Window.assetsDirChanged.connect(onAssetsDirChanged); | ||
| 280 | * | ||
| 281 | * Window.browseAssetsAsync("Select FBX File", "/", "*.fbx"); | ||
| 282 | * print("Script continues without waiting"); | ||
| 283 | */ | ||
| 66 | void browseAssetsAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); | 284 | void browseAssetsAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); |
| 285 | |||
| 286 | /**jsdoc | ||
| 287 | * Open the Asset Browser dialog. If a file to upload is specified, the user is prompted to enter the folder and name to | ||
| 288 | * map the file to on the asset server. | ||
| 289 | * @function Window.showAssetServer | ||
| 290 | * @param {string} uploadFile="" - The path and name of a file to upload to the asset server. | ||
| 291 | * @example <caption>Upload a file to the asset server.</caption> | ||
| 292 | * var file = Window.browse("Select File to Add to Asset Server", Paths.resources); | ||
| 293 | * print("File: " + file); | ||
| 294 | * Window.showAssetServer(file); | ||
| 295 | */ | ||
| 67 | void showAssetServer(const QString& upload = ""); | 296 | void showAssetServer(const QString& upload = ""); |
| 297 | |||
| 298 | /**jsdoc | ||
| 299 | * Get Interface's build number. | ||
| 300 | * @function Window.checkVersion | ||
| 301 | * @returns {string} - Interface's build number. | ||
| 302 | */ | ||
| 68 | QString checkVersion(); | 303 | QString checkVersion(); |
| 304 | |||
| 305 | /**jsdoc | ||
| 306 | * Copies text to the operating system's clipboard. | ||
| 307 | * @function Window.copyToClipboard | ||
| 308 | * @param {string} text - The text to copy to the operating system's clipboard. | ||
| 309 | */ | ||
| 69 | void copyToClipboard(const QString& text); | 310 | void copyToClipboard(const QString& text); |
| 311 | |||
| 312 | /**jsdoc | ||
| 313 | * Takes a snapshot of the current Interface view from the primary camera. When a still image only is captured, | ||
| 314 | * {@link Window.stillSnapshotTaken|stillSnapshotTaken} is emitted; when a still image plus moving images are captured, | ||
| 315 | * {@link Window.processingGifStarted|processingGifStarted} and {@link Window.processingGifCompleted|processingGifCompleted} | ||
| 316 | * are emitted. The path to store the snapshots and the length of the animated GIF to capture are specified in Settings > | ||
| 317 | * General > Snapshots. | ||
| 318 | * @function Window.takeSnapshot | ||
| 319 | * @param {boolean} notify=true - This value is passed on through the {@link Window.stillSnapshotTaken|stillSnapshotTaken} | ||
| 320 | * signal. | ||
| 321 | * @param {boolean} includeAnimated=false - If <code>true</code>, a moving image is captured as an animated GIF in addition | ||
| 322 | * to a still image. | ||
| 323 | * @param {number} aspectRatio=0 - The width/height ratio of the snapshot required. If the value is <code>0</code> the | ||
| 324 | * full resolution is used (window dimensions in desktop mode; HMD display dimensions in HMD mode), otherwise one or | ||
| 325 | * other dimension is adjusted in order to match the aspect ratio. | ||
| 326 | * @example <caption>Using the snapshot function and signals.</caption> | ||
| 327 | * function onStillSnapshottaken(path, notify) { | ||
| 328 | * print("Still snapshot taken: " + path); | ||
| 329 | * print("Notify: " + notify); | ||
| 330 | * } | ||
| 331 | * | ||
| 332 | * function onProcessingGifStarted(stillPath) { | ||
| 333 | * print("Still snapshot taken: " + stillPath); | ||
| 334 | * } | ||
| 335 | * | ||
| 336 | * function onProcessingGifCompleted(animatedPath) { | ||
| 337 | * print("Animated snapshot taken: " + animatedPath); | ||
| 338 | * } | ||
| 339 | * | ||
| 340 | * Window.stillSnapshotTaken.connect(onStillSnapshottaken); | ||
| 341 | * Window.processingGifStarted.connect(onProcessingGifStarted); | ||
| 342 | * Window.processingGifCompleted.connect(onProcessingGifCompleted); | ||
| 343 | * | ||
| 344 | * var notify = true; | ||
| 345 | * var animated = true; | ||
| 346 | * var aspect = 1920 / 1080; | ||
| 347 | * Window.takeSnapshot(notify, animated, aspect); | ||
| 348 | */ | ||
| 70 | void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f); | 349 | void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f); |
| 350 | |||
| 351 | /**jsdoc | ||
| 352 | * Takes a still snapshot of the current view from the secondary camera that can be set up through the {@link Render} API. | ||
| 353 | * @function Window.takeSecondaryCameraSnapshot | ||
| 354 | */ | ||
| 71 | void takeSecondaryCameraSnapshot(); | 355 | void takeSecondaryCameraSnapshot(); |
| 356 | |||
| 357 | /**jsdoc | ||
| 358 | * Emit a {@link Window.connectionAdded|connectionAdded} or a {@link Window.connectionError|connectionError} signal that | ||
| 359 | * indicates whether or not you successfully made a user connection. | ||
| 360 | * @function Window.makeConnection | ||
| 361 | * @param {boolean} success - If <code>true</code> then {@link Window.connectionAdded|connectionAdded} is emitted, otherwise | ||
| 362 | * {@link Window.connectionError|connectionError} is emitted. | ||
| 363 | * @param {string} description - Descriptive text about the connection success or error. This is sent in the signal emitted. | ||
| 364 | */ | ||
| 72 | void makeConnection(bool success, const QString& userNameOrError); | 365 | void makeConnection(bool success, const QString& userNameOrError); |
| 366 | |||
| 367 | /**jsdoc | ||
| 368 | * Display a notification message. Notifications are displayed in panels by the default script, nofications.js. An | ||
| 369 | * {@link Window.announcement|announcement} signal is emitted when this function is called. | ||
| 370 | * @function Window.displayAnnouncement | ||
| 371 | * @param {string} message - The announcement message. | ||
| 372 | * @example <caption>Send and capture an announcement message.</caption> | ||
| 373 | * function onAnnouncement(message) { | ||
| 374 | * // The message is also displayed as a notification by notifications.js. | ||
| 375 | * print("Announcement: " + message); | ||
| 376 | * } | ||
| 377 | * Window.announcement.connect(onAnnouncement); | ||
| 378 | * | ||
| 379 | * Window.displayAnnouncement("Hello"); | ||
| 380 | */ | ||
| 73 | void displayAnnouncement(const QString& message); | 381 | void displayAnnouncement(const QString& message); |
| 382 | |||
| 383 | /**jsdoc | ||
| 384 | * Prepare a snapshot ready for sharing. A {@link Window.snapshotShared|snapshotShared} signal is emitted when the snapshot | ||
| 385 | * has been prepared. | ||
| 386 | * @function Window.shareSnapshot | ||
| 387 | * @param {string} path - The path and name of the image file to share. | ||
| 388 | * @param {string} href="" - The metaverse location where the snapshot was taken. | ||
| 389 | */ | ||
| 74 | void shareSnapshot(const QString& path, const QUrl& href = QUrl("")); | 390 | void shareSnapshot(const QString& path, const QUrl& href = QUrl("")); |
| 391 | |||
| 392 | /**jsdoc | ||
| 393 | * Check to see if physics is active for you in the domain you're visiting - there is a delay between your arrival at a | ||
| 394 | * domain and physics becoming active for you in that domain. | ||
| 395 | * @function Window.isPhysicsEnabled | ||
| 396 | * @returns {boolean} <code>true</code> if physics is currently active for you, otherwise <code>false</code>. | ||
| 397 | * @example <caption>Wait for physics to be enabled when you change domains.</caption> | ||
| 398 | * function checkForPhysics() { | ||
| 399 | * var isPhysicsEnabled = Window.isPhysicsEnabled(); | ||
| 400 | * print("Physics enabled: " + isPhysicsEnabled); | ||
| 401 | * if (!isPhysicsEnabled) { | ||
| 402 | * Script.setTimeout(checkForPhysics, 1000); | ||
| 403 | * } | ||
| 404 | * } | ||
| 405 | * | ||
| 406 | * function onDomainChanged(domain) { | ||
| 407 | * print("Domain changed: " + domain); | ||
| 408 | * Script.setTimeout(checkForPhysics, 1000); | ||
| 409 | * } | ||
| 410 | * | ||
| 411 | * Window.domainChanged.connect(onDomainChanged); | ||
| 412 | */ | ||
| 75 | bool isPhysicsEnabled(); | 413 | bool isPhysicsEnabled(); |
| 414 | |||
| 415 | /**jsdoc | ||
| 416 | * Set what to show on the PC display: normal view or entity camera view. The entity camera is configured using | ||
| 417 | * {@link Camera.setCameraEntity} and {@link Camera|Camera.mode}. | ||
| 418 | * @function Window.setDisplayTexture | ||
| 419 | * @param {Window.DisplayTexture} name - The view to display. | ||
| 420 | * @returns {boolean} <code>true</code> if the display texture was successfully set, otherwise <code>false</code>. | ||
| 421 | */ | ||
| 422 | // See spectatorCamera.js for Valid parameter values. | ||
| 423 | /**jsdoc | ||
| 424 | * <p>The views that may be displayed on the PC display.</p> | ||
| 425 | * <table> | ||
| 426 | * <thead> | ||
| 427 | * <tr> | ||
| 428 | * <th>Value</th> | ||
| 429 | * <th>View Displayed</th> | ||
| 430 | * </tr> | ||
| 431 | * </thead> | ||
| 432 | * <tbody> | ||
| 433 | * <tr> | ||
| 434 | * <td><code>""</code></td> | ||
| 435 | * <td>Normal view.</td> | ||
| 436 | * </tr> | ||
| 437 | * <tr> | ||
| 438 | * <td><code>"resource://spectatorCameraFrame"</code></td> | ||
| 439 | * <td>Entity camera view.</td> | ||
| 440 | * </tr> | ||
| 441 | * </tbody> | ||
| 442 | * </table> | ||
| 443 | * @typedef Window.DisplayTexture | ||
| 444 | */ | ||
| 76 | bool setDisplayTexture(const QString& name); | 445 | bool setDisplayTexture(const QString& name); |
| 446 | |||
| 447 | /**jsdoc | ||
| 448 | * Check if a 2D point is within the drawable area of the HUD overlay. | ||
| 449 | * @function Window.isPointOnDesktopWindow | ||
| 450 | * @param {Vec2} point - The point to check in HMD display coordinates. | ||
| 451 | * @returns {boolean} <code>true</code> if the point is within the window or HUD, otherwise <code>false</code>. | ||
| 452 | */ | ||
| 77 | bool isPointOnDesktopWindow(QVariant point); | 453 | bool isPointOnDesktopWindow(QVariant point); |
| 454 | |||
| 455 | /**jsdoc | ||
| 456 | * Get the size of the drawable area of the Interface window if in desktop mode or the HMD display if in HMD mode. | ||
| 457 | * @function Window.getDeviceSize | ||
| 458 | * @returns {Vec2} The width and height of the Interface window or HMD display, in pixels. | ||
| 459 | */ | ||
| 78 | glm::vec2 getDeviceSize() const; | 460 | glm::vec2 getDeviceSize() const; |
| 79 | 461 | ||
| 462 | /**jsdoc | ||
| 463 | * Open a non-modal message box that can have a variety of button combinations. See also, | ||
| 464 | * {@link Window.updateMessageBox|updateMessageBox} and {@link Window.closeMessageBox|closeMessageBox}. | ||
| 465 | * @function Window.openMessageBox | ||
| 466 | * @param {string} title - The title to display for the message box. | ||
| 467 | * @param {string} text - Text to display in the message box. | ||
| 468 | * @param {Window.MessageBoxButton} buttons - The buttons to display on the message box; one or more button values added | ||
| 469 | * together. | ||
| 470 | * @param {Window.MessageBoxButton} defaultButton - The button that has focus when the message box is opened. | ||
| 471 | * @returns {number} The ID of the message box created. | ||
| 472 | * @example <caption>Ask the user whether that want to reset something.</caption> | ||
| 473 | * var messageBox; | ||
| 474 | * var resetButton = 0x4000000; | ||
| 475 | * var cancelButton = 0x400000; | ||
| 476 | * | ||
| 477 | * function onMessageBoxClosed(id, button) { | ||
| 478 | * if (id === messageBox) { | ||
| 479 | * if (button === resetButton) { | ||
| 480 | * print("Reset"); | ||
| 481 | * } else { | ||
| 482 | * print("Don't reset"); | ||
| 483 | * } | ||
| 484 | * } | ||
| 485 | * } | ||
| 486 | * Window.messageBoxClosed.connect(onMessageBoxClosed); | ||
| 487 | * | ||
| 488 | * messageBox = Window.openMessageBox("Reset Something", | ||
| 489 | * "Do you want to reset something?", | ||
| 490 | * resetButton + cancelButton, cancelButton); | ||
| 491 | */ | ||
| 80 | int openMessageBox(QString title, QString text, int buttons, int defaultButton); | 492 | int openMessageBox(QString title, QString text, int buttons, int defaultButton); |
| 493 | |||
| 494 | /**jsdoc | ||
| 495 | * Update the content of a message box that was opened with {@link Window.openMessageBox|openMessageBox}. | ||
| 496 | * @function Window.updateMessageBox | ||
| 497 | * @param {number} id - The ID of the message box. | ||
| 498 | * @param {string} title - The title to display for the message box. | ||
| 499 | * @param {string} text - Text to display in the message box. | ||
| 500 | * @param {Window.MessageBoxButton} buttons - The buttons to display on the message box; one or more button values added | ||
| 501 | * together. | ||
| 502 | * @param {Window.MessageBoxButton} defaultButton - The button that has focus when the message box is opened. | ||
| 503 | */ | ||
| 81 | void updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton); | 504 | void updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton); |
| 505 | |||
| 506 | /**jsdoc | ||
| 507 | * Close a message box that was opened with {@link Window.openMessageBox|openMessageBox}. | ||
| 508 | * @function Window.closeMessageBox | ||
| 509 | * @param {number} id - The ID of the message box. | ||
| 510 | */ | ||
| 82 | void closeMessageBox(int id); | 511 | void closeMessageBox(int id); |
| 83 | 512 | ||
| 84 | private slots: | 513 | private slots: |
| 85 | void onMessageBoxSelected(int button); | 514 | void onMessageBoxSelected(int button); |
| 86 | 515 | ||
| 87 | signals: | 516 | signals: |
| 88 | void domainChanged(const QString& domainHostname); | 517 | |
| 518 | /**jsdoc | ||
| 519 | * Triggered when you change the domain you're visiting. <strong>Warning:</strong> Is not emitted if you go to domain that | ||
| 520 | * isn't running. | ||
| 521 | * @function Window.domainChanged | ||
| 522 | * @param {string} domain - The domain's IP address. | ||
| 523 | * @returns {Signal} | ||
| 524 | */ | ||
| 525 | void domainChanged(const QString& domain); | ||
| 526 | |||
| 527 | /**jsdoc | ||
| 528 | * Triggered when you try to navigate to a *.svo or *.svo.json URL in a Web browser within Interface. | ||
| 529 | * @function Window.svoImportRequested | ||
| 530 | * @param {string} url - The URL of the SVO file to import/ | ||
| 531 | * @returns {Signal} | ||
| 532 | */ | ||
| 89 | void svoImportRequested(const QString& url); | 533 | void svoImportRequested(const QString& url); |
| 534 | |||
| 535 | /**jsdoc | ||
| 536 | * Triggered when you try to visit a domain but are refused connection. | ||
| 537 | * @function Window.domainConnectionRefused | ||
| 538 | * @param {string} reasonMessage - A description of the refusal. | ||
| 539 | * @param {Window.ConnectionRefusedReason} reasonCode - Integer number that enumerates the reason for the refusal. | ||
| 540 | * @param {string} extraInfo - Extra information about the refusal. | ||
| 541 | * @returns {Signal} | ||
| 542 | */ | ||
| 90 | void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); | 543 | void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); |
| 544 | |||
| 545 | /**jsdoc | ||
| 546 | * Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot}} with | ||
| 547 | * <code>includeAnimated = false</code>. | ||
| 548 | * @function Window.stillSnapshotTaken | ||
| 549 | * @param {string} pathStillSnapshot - The path and name of the snapshot image file. | ||
| 550 | * @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSnapshot|takeSnapshot} | ||
| 551 | * was called with. | ||
| 552 | * @returns {Signal} | ||
| 553 | */ | ||
| 91 | void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify); | 554 | void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify); |
| 555 | |||
| 556 | /**jsdoc | ||
| 557 | * Triggered when a snapshot submitted via {@link Window.shareSnapshot|shareSnapshot} is ready for sharing. The snapshot | ||
| 558 | * may then be shared via the {@link Account.metaverseServerURL} Web API. | ||
| 559 | * @function Window.snapshotShared | ||
| 560 | * @param {boolean} isError - <code>true</code> if an error was encountered preparing the snapshot for sharing, otherwise | ||
| 561 | * <code>false</code>. | ||
| 562 | * @param {string} reply - JSON-formatted information about the snapshot. | ||
| 563 | * @returns {Signal} | ||
| 564 | */ | ||
| 92 | void snapshotShared(bool isError, const QString& reply); | 565 | void snapshotShared(bool isError, const QString& reply); |
| 566 | |||
| 567 | /**jsdoc | ||
| 568 | * Triggered when the snapshot images have been captured by {@link Window.takeSnapshot|takeSnapshot} and the GIF is | ||
| 569 | * starting to be processed. | ||
| 570 | * @function Window.processingGifStarted | ||
| 571 | * @param {string} pathStillSnapshot - The path and name of the still snapshot image file. | ||
| 572 | * @returns {Signal} | ||
| 573 | */ | ||
| 93 | void processingGifStarted(const QString& pathStillSnapshot); | 574 | void processingGifStarted(const QString& pathStillSnapshot); |
| 575 | |||
| 576 | /**jsdoc | ||
| 577 | * Triggered when a GIF has been prepared of the snapshot images captured by {@link Window.takeSnapshot|takeSnapshot}. | ||
| 578 | * @function Window.processingGifCompleted | ||
| 579 | * @param {string} pathAnimatedSnapshot - The path and name of the moving snapshot GIF file. | ||
| 580 | * @returns {Signal} | ||
| 581 | */ | ||
| 94 | void processingGifCompleted(const QString& pathAnimatedSnapshot); | 582 | void processingGifCompleted(const QString& pathAnimatedSnapshot); |
| 95 | 583 | ||
| 584 | |||
| 585 | /**jsdoc | ||
| 586 | * Triggered when you've successfully made a user connection. | ||
| 587 | * @function Window.connectionAdded | ||
| 588 | * @param {string} message - A description of the success. | ||
| 589 | * @returns {Signal} | ||
| 590 | */ | ||
| 96 | void connectionAdded(const QString& connectionName); | 591 | void connectionAdded(const QString& connectionName); |
| 592 | |||
| 593 | /**jsdoc | ||
| 594 | * Triggered when you failed to make a user connection. | ||
| 595 | * @function Window.connectionError | ||
| 596 | * @param {string} message - A description of the error. | ||
| 597 | * @returns {Signal} | ||
| 598 | */ | ||
| 97 | void connectionError(const QString& errorString); | 599 | void connectionError(const QString& errorString); |
| 600 | |||
| 601 | /**jsdoc | ||
| 602 | * Triggered when a message is announced by {@link Window.displayAnnouncement|displayAnnouncement}. | ||
| 603 | * @function Window.announcement | ||
| 604 | * @param {string} message - The message text. | ||
| 605 | * @returns {Signal} | ||
| 606 | */ | ||
| 98 | void announcement(const QString& message); | 607 | void announcement(const QString& message); |
| 99 | 608 | ||
| 609 | |||
| 610 | /**jsdoc | ||
| 611 | * Triggered when the user closes a message box that was opened with {@link Window.openMessageBox|openMessageBox}. | ||
| 612 | * @function Window.messageBoxClosed | ||
| 613 | * @param {number} id - The ID of the message box that was closed. | ||
| 614 | * @param {number} button - The button that the user clicked. If the user presses Esc the Cancel button value is returned, | ||
| 615 | * whether or not the Cancel button is displayed in the message box. | ||
| 616 | * @returns {Signal} | ||
| 617 | */ | ||
| 100 | void messageBoxClosed(int id, int button); | 618 | void messageBoxClosed(int id, int button); |
| 619 | |||
| 620 | /**jsdoc | ||
| 621 | * Triggered when the user chooses a directory in a {@link Window.browseDirAsync|browseDirAsync} dialog. | ||
| 622 | * @function Window.browseDirChanged | ||
| 623 | * @param {string} directory - The directory the user chose in the dialog. | ||
| 624 | * @returns {Signal} | ||
| 625 | */ | ||
| 101 | void browseDirChanged(QString browseDir); | 626 | void browseDirChanged(QString browseDir); |
| 627 | |||
| 628 | /**jsdoc | ||
| 629 | * Triggered when the user chooses an asset in a {@link Window.browseAssetsAsync|browseAssetsAsync} dialog. | ||
| 630 | * @function Window.assetsDirChanged | ||
| 631 | * @param {string} asset - The path and name of the asset the user chose in the dialog. | ||
| 632 | * @returns {Signal} | ||
| 633 | */ | ||
| 102 | void assetsDirChanged(QString assetsDir); | 634 | void assetsDirChanged(QString assetsDir); |
| 635 | |||
| 636 | /**jsdoc | ||
| 637 | * Triggered when the user specifies a file in a {@link Window.saveAsync|saveAsync} dialog. | ||
| 638 | * @function Window.saveFileChanged | ||
| 639 | * @param {string} filename - The path and name of the file that the user specified in the dialog. | ||
| 640 | * @returns {Signal} | ||
| 641 | */ | ||
| 103 | void saveFileChanged(QString filename); | 642 | void saveFileChanged(QString filename); |
| 643 | |||
| 644 | /**jsdoc | ||
| 645 | * Triggered when the user chooses a file in a {@link Window.browseAsync|browseAsync} dialog. | ||
| 646 | * @function Window.openFileChanged | ||
| 647 | * @param {string} filename - The path and name of the file the user chose in the dialog. | ||
| 648 | * @returns {Signal} | ||
| 649 | */ | ||
| 104 | void openFileChanged(QString filename); | 650 | void openFileChanged(QString filename); |
| 651 | |||
| 652 | /**jsdoc | ||
| 653 | * Triggered when the user OKs a {@link Window.promptAsync|promptAsync} dialog. | ||
| 654 | * @function Window.promptTextChanged | ||
| 655 | * @param {string} text - The text the user entered in the dialog. | ||
| 656 | * @returns {Signal} | ||
| 657 | */ | ||
| 105 | void promptTextChanged(QString text); | 658 | void promptTextChanged(QString text); |
| 106 | 659 | ||
| 107 | // triggered when window size or position changes | 660 | |
| 661 | /**jsdoc | ||
| 662 | * Triggered when the position or size of the Interface window changes. | ||
| 663 | * @function Window.geometryChanged | ||
| 664 | * @param {Rect} geometry - The position and size of the drawable area of the Interface window. | ||
| 665 | * @returns {Signal} | ||
| 666 | * @example <caption>Report the position of size of the Interface window when it changes.</caption> | ||
| 667 | * function onWindowGeometryChanged(rect) { | ||
| 668 | * print("Window geometry: " + JSON.stringify(rect)); | ||
| 669 | * } | ||
| 670 | * | ||
| 671 | * Window.geometryChanged.connect(onWindowGeometryChanged); | ||
| 672 | */ | ||
| 108 | void geometryChanged(QRect geometry); | 673 | void geometryChanged(QRect geometry); |
| 109 | 674 | ||
| 110 | private: | 675 | private: |