/** * Callback given to view process methods, called once process completes successfully. * @callback jibo.face.views~ViewCallback * @param [view] {jibo.face.views.View} View associated with view process, not all view processes return a View. * @param [done] {Function} ONLY used for the onLoaded callback within [changeView()]{@link jibo.face.views#changeView}. * Not specifying this parameter on the onLoaded callback makes it synchronous. * Specifying makes the callback asynchronous and requires that `done()` be called at some point within the method. */ /** * @interface jibo.face.views~ChangeOptions * @description Interface for changing view process options. * @prop {Boolean} [remove] - `true` to remove current element. * This is exclusive from the other `remove*` methods, with the order of override: `removeAll > removeTo > removeToInclude > remove` * @prop {Boolean} [removeAll] - `true` to remove all views down to root. * This is exclusive from the other `remove*` methods, with the order of override: `removeAll > removeTo > removeToInclude > remove` * @prop {String} [options.removeTo] - Id of a view within the stack, all views above it will be removed. * This is exclusive from the other `remove*` methods, with the order of override: `removeAll > removeTo > removeToInclude > remove` * @prop {String} [options.removeToInclude] - Id of a view within the stack, that view and all views above it will be removed. * This is exclusive from the other `remove*` methods, with the order of override: `removeAll > removeTo > removeToInclude > remove` * @prop {Boolean} [leaveEmpty] - `true` to prevent next view in stack from opening and leaving the display empty. * Setting to `true` overrides `addView`. * @prop {String|jibo.face.views.View|any} [addView] - Add view, can specify a path to config file, instantiated View, or view config Object. * @prop {jibo.face.views.PauseOverlay#PauseOptions} [pause] - If when adding the next view the current view should be paused. If so, how. * @prop {String} [transitionClose] - Type of transition the current View should use to close. * @prop {String} [transitionOpen] - Type of transition the next View should use to open. */ /** * @interface jibo.face.views~AssetDescriptor * @description Interface for asset description objects, used in conjunction with [loader]{@link jibo.loader}. * @prop {String} id - Id of asset, should be unique within cache. * @prop {String} type - Type of asset, for valid types refer to [loader]{@link jibo.loader}. * @prop {String} src - URI of asset. * @prop {Boolean} [upload] - If `true` will also load to GPU. * @prop {String} [cache] - Cache asset is associated with. Will use the loader's currently default cache unless otherwise specified. */ /** * @typedef jibo.face.views~STACK_DIRECTION * @description Enum - For use with `View.addTransition` & `View.applyTransitions` * to define transitions by the way the view stack will change. * @prop 1 ADD * @prop 2 REMOVE * @prop 3 SWAP */ /** * @typedef jibo.face.views~TRANSITION * @description Static class with static members that describe possible transitions for views. * @prop UP Transition type for view to move up. * @prop DOWN Transition type for view to move down. * @prop LEFT Transition type for view to move left. * @prop RIGHT Transition type for view to move right. * @prop IN Transition type for view to fade and scale in from center of screen. * @prop OUT Transition type for view to fade and scale out from center of screens. * @prop EYE Transition type for view to or from eye. * @prop NONE Transition type for no transition. */ /** * @class ViewManager * @description Everything in this class is now accessible as part of {@link jibo.face.views}. * Please update your code to use the `face.views` namespace instead of the `ViewManager` class. * @memberof jibo.face.views * @deprecated Since 7.4.1 * @see jibo.face.views */ /** * Manages the creation and transition of the GUI. * @namespace jibo.face.views */ /** * Default duration, in milliseconds, of open and close view transitions. * @type {number} * @private */ /** * Top level container. * @name jibo.face.views#stage * @type {PIXI.Container} */ /** * If the view manager is disabled, in which case all view changes will fail immediately. * This will only be used when the WebGL context is lost. * @name jibo.face.views#disabled * @type {boolean} * @private */ /** * If movement should be disabled due to screen taps - don't want to move around once the GUI * has begun to be used. * @name jibo.face.views#_disableMovement * @type {boolean} * @private */ /** * Array of ViewStates in order of the view hierarchy. * @name jibo.face.views#_viewStates * @type {Array} * @private */ /** * Class to assist in creation of Views and Components. * @name jibo.face.views#_creator * @type {jibo.face.views.ComponentCreator} * @private */ /** * Class to manage interactions. * @name jibo.face.views#_interactionManager * @type {jibo.face.views.TouchManager} * @private */ /** * Handle to the Menu attention mode pushed with a GUI view. * @name jibo.face.views#_menuMode * @type {jibo.attention.AttentionModeHandle} * @private */ /** * Event dispatched when the View is going to close because of a 'back' command. * Currently closing a View and going back to the previous view is triggered by a swipe down. * The same constant is statically accessible via `View.BACK`, but duplicated here for convenience. * @type {string} * @name jibo.face.views#BACK * @constant * @readOnly */ /** * Option for setting custom transitions. * Use with `View.addTransition` for transitions to be used when opening from or closing to an empty screen. * The same constant is statically accessible via `View.EMPTY`, but duplicated here for convenience. * @type {string} * @name jibo.face.views.EMPTY * @readOnly */ /** * Option for setting custom transitions. * Use with `View.addTransition` for transitions to be used when opening over a paused view or closing while being paused. * The same constant is statically accessible via `View.PAUSED`, but duplicated here for convenience. * @type {string} * @name jibo.face.views.PAUSED * @readOnly */ /** * Current top-level view. * @name jibo.face.views#currentView * @type {jibo.face.views.View} * @readOnly */ /** * Class to assist in creation of Views and Components. * @name jibo.face.views#creator * @type {jibo.face.views.ComponentCreator} * @readOnly */ /** * Maintains view processes. * @name jibo.face.views#_viewProcess * @type {jibo.face.views.ViewProcess} * @private */ /** * Source for global events related to GUI processes. * @name jibo.face.views#_events * @type {jibo.face.views.ViewGlobalEvents} * @private */ /** * Black gradient border at edge of screen, layered above ViewManager stage. * @name jibo.face.views#_border * @type {PIXI.Container} * @private */ /** * Image that exist above all displays and the border, there can only be one watermark at a time. * Use for things like remote mode indication. * @name jibo.face.views#_waterMark * @type {PIXI.Container} * @private */ /** * Flag to keep track of visibility of border. * @name jibo.face.views#_borderVisibility * @type {Boolean} * @private */ /** * Visibility of border. * @name jibo.face.views#borderVisible * @param {Boolean} visible Determines border's visibility */ /** * Will return the total number of views in the view stack. * @name jibo.face.views#viewStackLength * @type {number} * @readOnly */ /** * Determines if views are currently in process. * @name jibo.face.views#viewsInProcess * @type {boolean} * @readOnly */ /** * Create a View by specifying the class and the configuration. * @method jibo.face.views#createView * @param {Object|String} [viewDeterminer] Can be the Class or name of Class of the the view to create. * @param {Object} [config] Config can be an Object or a string of the path to the JSON file for the config. * @param {Boolean} [open=false] If true continue process of adding and opening the view. * @param {jibo.face.views~ViewCallback} [onOpenComplete] Callback for when View has finished opening, will only be used if the open flag is set to true. * @param {String} [openTransition=TRANSITION.UP] Type of transition to open view. * @param {String} [closeTransition=TRANSITION.UP] Type of transition to close view. * @return {jibo.face.views.View} The View created. */ /** * Create a View from only the View's configuration path. * Unlike the the createView method, this method does not require the view class to be specified, * instead the view class is derived from the configuration file. * This method does not return the View directly, but rather through the provided callback. * If the open flag is set to true the callback will be fire when the View is created, and opened, * if not the callback is fire as soon as the View class is created. * @method jibo.face.views#createViewFromConfigPath * @param {String} configPath Path to the configuration for the view. * @param {Boolean} [open=false] If true continue process of adding and opening the view, callback will be fired after View finishes opening. * @param {jibo.face.views~ViewCallback} callback Callback that returns the View * @param {String} [openTransition=TRANSITION.UP] Type of transition to open view. * @param {String} [closeTransition=TRANSITION.UP] Type of transition to close view. */ /** * Add the view that is at the top of the stack. * This is generally used when there is no current view present * (i.e. to create the first eye view, or when a view was removed to empty) * @method jibo.face.views#addViewNextInStack * @param {jibo.face.views~ViewCallback} callback Callback that returns the View * @param {String} [openTransition=TRANSITION.UP] Type of transition to open view. * @param {String} [closeTransition=TRANSITION.UP] Type of transition to close view. * @param {Function} [onFailure] Callback for if process does not complete */ /** * Passes {@link jibo.face.views.ActionData} to the current {@link jibo.face.views.View} and its children. * @method jibo.face.views#actionEnactor * @param {jibo.face.views.ActionData} action - The action to be passed. * @return {boolean} `true` if action is acted on by the current View or any of its ComponentGroup children. */ /** * Process for changing views, takes a config that defines process particulars. * @example * Option examples * * 'Example of closing all views and leave display empty' * { * removeAll: true, * leaveEmpty: true, * } * * 'Example of opening view lower in the view stack and having it fade in' * { * removeTo: 'myView', * transitionOpen: "trans_in" * } * * 'Example of closing current view and leaving display empty' * { * remove: true, * leaveEmpty: true * } * * 'Example of opening a new view while pausing the view beneath it but fully hiding it using standard overlay tween' * { * addView: "resources/views/myViewConfig.json", * pause:{ * "alpha": 1, * } * } * * 'Example of removing all views above a particular view in the stack and then opening that view, using view's id' * { * removeTo: "myView" * } * * 'Example of removing a particular view and all views above it in the stack, then adding a new view.' * { * removeToInclude: "myView", * addView: "resources/views/myViewConfig.json" * } * * @method jibo.face.views#changeView * @param {jibo.face.views~ChangeOptions} options - Options for view change process. * @param {jibo.face.views~ViewCallback} [onComplete] Callback when process completes, gives the current view as a parameter. * @param {Function} [onFailure] Callback for if process does not complete. * @param {jibo.face.views~ViewCallback} [onLoaded] Callback when next view has loaded, use to augment view prior to it opening. */ /** * Add a new {@link jibo.face.views.View} to the hierarchy. * Adding process involves disposing of or pausing current view and storing its state. * @method jibo.face.views#addView * @param {jibo.face.views.View | string} view - Info for the view to load, can pass the View class directly, * or pass a string that is the path to the config file defining the View. * @param {jibo.face.views~ViewCallback} [onAdded] Callback when process completes, gives the current view as a parameter. * @param {String} [openTransition = TRANSITION.UP] Type of transition the next View should use to open. * @param {String} [closeTransition = TRANSITION.UP] Type of transition the current View should use to close. * @param {Function} [onFailure] Callback for if process does not complete. */ /** * Remove current {@link jibo.face.views.View} and open the View beneath it in the stack. * Removal process involves disposing of current view and recreating prior View using its stored ViewState. * If top most view was pausing the previous view then we don't need to recreate it, only un-pause it. * @method jibo.face.views#removeView * @param {jibo.face.views~ViewCallback} [onRemoved] Callback when process completes, gives the current view as a parameter. * @param {String} [openTransition = TRANSITION.DOWN] Type of transition the next View should use to open. * @param {String} [closeTransition = TRANSITION.DOWN] Type of transition the current View should use to close. * @param {Function} [onFailure] Callback for if process does not complete. */ /** * Force open the eye view and clear the view stack. * @method jibo.face.views#forceEyeView * @param {jibo.face.views~ViewCallback} [onOpenCallback] called once eyeView is opened or if it is already open, returns the EyeView as a parameter. * @param {Function} [onPressCallback] handler for when EyeView is pressed, if nothing is specified will remove any existing callbacks. * @param {String} [openTransition=TRANSITION.IN] Type of transition to open view. * @param {String} [closeTransition=TRANSITION.UP] Type of transition to close view. * @param {Function} [onFailure] Callback for if process does not complete. */ /** * If there is an active process attempting to make the EyeView the current view we want to try not to interrupt that process as it has the same purpose as forceEyeView. * We determine if that is the state of the process if a closing view is defined (so we know that the EyeView is not what the process may be closing) * AND the current view (which is an EyeView) has a status indicating it is going to open, basically that it is loaded but not yet open. */ /** * Clear the view stack, if current view is of category EYE leave the eye as the current view, * if any other category remove call views and leave the current view empty. * @method jibo.face.views#viewStackCleanup * @param {jibo.face.views~TRANSITION} [closeTransition=TRANSITION.DOWN] Type of transition to close the current view. * @returns {Promise} */ /** * Check if a view exists with a given ID, and can be used as `removeTo` or `removeToInclude` * in [changeView]{@link jibo.face.views#changeView}. * @method jibo.face.views#hasView * @param {String} id View ID to look for. * @returns {Boolean} `true` if a View exists with the given ID. */ /** * Resets the TRANS_TIME to default, or transTime if specified * @method jibo.face.views#resetTransTime * @param {number} [transTime] Optional time in milliseconds to set the TRANS_TIME to */ /** * Handles process failure or interruption. * Cleans up current process. and queue stack. * If queue has members, start process for top most member and clean up any below it. * @method jibo.face.views#viewProcessFailure * @param {jibo.face.views.ViewProcess} process Active view process * @private */ /** * This allows us to more logically recover from an interruption in the case where the interrupting process will remove the current view. * Interrupting a process normally destroys the current view involved immediately, which would skip it's close transition. * In the case where the interrupting process will attempt to remove the current view, * we want to allow it to do so, so we prevent the process fail from destroying the current view so that the next process can close and destroy it naturally. */ /** * Add a new {@link jibo.face.views.View} to the view hierarchy and display. * Adding process involves disposing of or pausing current view and storing its state. * @method jibo.face.views#add * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} nextView - View to add and make current. * @param {jibo.face.views.PauseOverlay#PauseOptions} [pauseOptions] - Pause options, defined within change view options.ß * @param {String} [openTransition = TRANSITION.UP] Type of transition the next View should use to open. * @param {String} [closeTransition = TRANSITION.UP] Type of transition the current View should use to close. * @private */ /** * Remove current {@link jibo.face.views.View} from the hierarchy and display. * @method jibo.face.views#remove * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} [nextView] - View to add after current view is closed. * @param {boolean} leaveEmpty - If next view in stack should be opened after current view closes, if 'true' display is left empty. * @param {String} [openTransition = TRANSITION.UP] Type of transition the next View should use to open. * @param {String} [closeTransition = TRANSITION.UP] Type of transition the current View should use to close. * @returns {Promise} * @private */ /** * Close all currently active views and open the 'root' view ({@link jibo.face.views.EyeView}). * @method jibo.face.views#removeToRoot * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} [nextView] - View to add above root view after current views and stack have been cleared. * @param {boolean} leaveEmpty - If root View should be opened after close completes, if 'true' display is left empty. * @param {String} [closeTransition = TRANSITION.DOWN] Type of transition the current View should use to close. * @param {String} [openTransition = TRANSITION.DOWN] Type of transition the next View should use to open. * @returns {Promise} * @private */ /** * Close all currently active views and open the 'root' view ({@link jibo.face.views.EyeView}). * @method jibo.face.views#removeToRoot * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} [nextView] - View to add above root view after current views and stack have been cleared. * @param {boolean} leaveEmpty - If root View should be opened after close completes, if 'true' display is left empty. * @param {String} [closeTransition = TRANSITION.DOWN] Type of transition the current View should use to close. * @param {String} [openTransition = TRANSITION.DOWN] Type of transition the next View should use to open. * @returns {Promise} * @private */ /** * Load and open View. * @param {jibo.face.views.ViewProcess} process Active view process. * @method jibo.face.views#openView * @param {jibo.face.views.View}view - View to open. * @param {string} openTransition - Type of transition view will open with. * @returns {Promise} * @private */ /** * Close and destroy View. * Does not take into account any paused Views that may be associated with the given view. * @method jibo.face.views#closeView * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} view - View to close. * @param {string} [closeTransition] - Type of transition view will close with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @param {boolean} [destroyViews = true] - if 'true' views will be destroyed. * @param {boolean} [toPaused = false] - if view is closing over a paused if 'true' views will be destroyed. * @returns {Promise} * @private */ /** * Close and open separate views. * Supports async behavior, making sure the view being opened has been fully loaded and prepped before opening. * @method jibo.face.views#closeAndOpenViews * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} nextView - View to open. * @param {jibo.face.views.View} closeView - View to close. * @param {string} [openTransition] - Type of transition next view will open with. * @param {string} [closeTransition] - Type of transition closing view will close with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @returns {Promise} * @private */ /** * Close and destroy given view and all paused views beneath it, and open next view. * Supports async behavior, making sure the view being opened has been fully loaded and prepped before opening. * method jibo.face.views#closeWithPausedAndOpenViews * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} nextView - View to open. * @param {jibo.face.views.View} closeView - View to close. * @param {string} [openTransition] - Type of transition next view will open with. * @param {string} [closeTransition] - Type of transition closing view will close with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @param {jibo.face.views~STACK_DIRECTION} [stackDirection] - Specifies the stack direction associated with the transition, if undefined does not take stack direction into account * STACK_DIRECTION.UP indicates view is being added to stack. * STACK_DIRECTION.DOWN indicates view is being removed. * STACK_DIRECTION.SWAP indicates the views are being swapped and there is no change to the stack size. * @returns {Promise} * @private */ /** * Close and destroy given view's paused views. * method jibo.face.views#closePaused * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} view - View whose paused views to close. * @param {string} [closeTransition] - Type of transition Views will open with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @param {boolean} [destroyViews = true] - if 'true' views will be destroyed. * @returns {Promise} * @private */ /** * Close and destroy given view and all paused views beneath it. * method jibo.face.views#closeViewWithPaused * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} view - View to close. * @param {string} [closeTransition] - Type of transition Views will open with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @param {boolean} [destroyViews = true] - if 'true' views will be destroyed. * @returns {Promise} * @private */ /** * Close a list of views. * Generally used to close a view and the pause chain beneath it. * @method jibo.face.views#closeGroup * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View[]} closingViews - Array of Views to close in order of stack, with lowest at 0. * @param {string} [closeTransition] - Type of transition Views will open with. * @param {boolean} [addToStack = false] - if 'true' closed views are added to the view stack. * @param {boolean} [destroyViews = true] - if 'true' views will be destroyed. * @returns {Promise} * @private */ /** * Pause current view and open next above it. * method jibo.face.views#pauseThenOpen * @param {jibo.face.views.ViewProcess} process Active view process. * @param {jibo.face.views.View} nextView - View to open. * @param {jibo.face.views.View} pausingView - View to pause. * @param {jibo.face.views.PauseOverlay#PauseOptions} [pauseOptions] - Specific pause options, if undefined falls back to nextView.pauseOptions. * @param {string} [openTransition] - Type of transition nextView will open with. * @returns {Promise} * @private */ /** * Helper to sets transitions for opening and closing views. * @param {jibo.face.views.views.View} nextView - View that will be opening * @param {jibo.face.views.views.View} closingView - View that will be closing. * @param {jibo.face.views~STACK_DIRECTION} [stackDirection] - Specifies the stack direction associated with the transition, if undefined does not take stack direction into account * STACK_DIRECTION.UP indicates view is being added to stack. * STACK_DIRECTION.DOWN indicates view is being removed. * STACK_DIRECTION.SWAP indicates the views are being swapped and there is no change to the stack size. */ /** * Returns the View from the top of the stack of ViewStates. * @method jibo.face.views#popViewFromStack * @return {jibo.face.views.View} * @private */ /** * Converts given View to ViewState and adds to top of the stack of ViewStates. * Given View must be in acceptable state to be converted to ViewState, otherwise it will not be added to stack. * @method jibo.face.views#pushViewToStack} * @private */ /** * Converts given View and its paused View chain to ViewStates and adds them to the stack of ViewStates in the right order. * Views must be in acceptable state to be converted to ViewState, otherwise they will not be added to stack. * @method jibo.face.views#pushViewWithPausedToStack * @private */ /** * Clear view stack so only root ViewState remains. * If the currentView given is an EyeView remove all view states, * otherwise leave EyeView ViewState as the only view state in view stack. * @method jibo.face.views#clearViewStack * @param {jibo.face.views.View} [currentView] - The view that is or will be the current view. * @private */ /** * Update the attention mode, ensuring that it is a Menu mode when a GUI view is active, and * deactivating our Menu mode if it is no longer a GUI. * @method jibo.face.views#updateAttentionMode * @param {jibo.face.views.View} [view] - The view that is or will be the current view. * @private */ /** * Set PIXI's texture garbage collection to auto garbage collect or manually collect. only run when an Eye view is active. * @method jibo.face.views#setTextureGC * @param {boolean} [autoOn] - If `true` texture garbage collection is set to auto, if 'false' it is set to manual * @private */ /** * Using supplied assets creates a border around the screen. * Placed above ViewManager.stage so that everything created within ViewManager will be beneath it. * @method jibo.face.views#createBorder * @param {PIXI.Texture} cornerTexture - asset for corner * @param {PIXI.Texture} edgeTexture - asset for edge * @private */ /** * Register default GUI classes. * @method jibo.face.views#registerDefaults * @private */ /** * Check if given views are in a valid state (e.g. not destroyed) * @method jibo.face.views#checkViewsValid * @private */ /** * Log view process and view status events, useful for debugging. * @method jibo.face.views#logEvents * @private */