Files
JiboOs/docs/rendering/gui/ComponentGroup.js
2026-03-16 13:53:01 +02:00

265 lines
11 KiB
JavaScript

/**
* DO NOT ADD TO DIRECTLY
*
* Object serving as hash table for child Components using the Component's id variable as a key.
* To add components use [addComponent()]{@link jibo.face.views.ComponentGroup#addComponent}
* @name jibo.face.views.ComponentGroup#componentLibrary
* @type {Object}
* @protected
*/
/**
* DO NOT ADD TO DIRECTLY
*
* Array of child Components.
* To add components use [addComponent()]{@link jibo.face.views.ComponentGroup#addComponent}
* @name jibo.face.views.ComponentGroup#componentList
* @type {jibo.face.views.Component[]}
* @protected
*/
/**
* DO NOT WRITE DIRECTLY
*
* Array of config Objects (generally derived from JSON).
* Gets defined within various creation methods.
* @name jibo.face.views.ComponentGroup#componentConfigs
* @type {any[]}
* @protected
*/
/**
* Container for displays, is set within [createDisplay()]{@link jibo.face.views.Component#createDisplay}
* which receives the container as a parameter.
* @name jibo.face.views.ComponentGroup#container
* @type {PIXI.Container}
* @protected
*/
/**
* List of Components that have registered to be updated.
* @name jibo.face.views.ComponentGroup#_updateRegistry
* @type {jibo.face.views.Component[]}
* @private
*/
/**
* Get the number of child components.
* @name jibo.face.views.ComponentGroup#componentsTotal
* @type {number}
* @readOnly
*/
/**
* List of assets required by the ComponentGroup and its Component children.
* Compiles list of all assets on each call.
* @name jibo.face.views.ComponentGroup#assetDescriptors
* @type {jibo.face.views~AssetDescriptor[]}
* @readOnly
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Compiles together required assets for the ComponentGroup and its children.
* @name jibo.face.views.ComponentGroup#groupAssetDescriptors
* @type {jibo.face.views~AssetDescriptor[]}
* @readonly
* @protected
*/
/**
* Turn the interactivity of the child components off or on.
* @method jibo.face.views.ComponentGroup#lockInput
* @param {boolean} flag - Flag to turn interactivity on or off.
*/
/**
* Turn the interactivity of the child components off or on.
* @method jibo.face.views.ComponentGroup#lockChildInput
* @param {boolean} flag - Flag to turn interactivity on or off.
* @protected
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Update configuration Object to reflect the current configuration state.
* This ensures that when the Component is recreated from its configuration it reflects its last state.
* @method jibo.face.views.ComponentGroup#updateConfig
* @param {Object} configObject Configuration Object to update.
* @returns {any} The given configuration Object with any required values updates applied.
*/
/**
* Add component to this ComponentGroup, allows parent and child to reference to each other.
* @method jibo.face.views.ComponentGroup#addComponent
* @param {jibo.face.views.Component} component The Component to add this group's component list and library.
* @param {String} [componentId] The id to assign to the Component, if specified will overwrite existing id,
* if none is specified an id will be automatically generated and assigned.
* @returns {jibo.face.views.Component} The given Component.
*/
/**
* Get index of Component within the ComponentGroup's component list.
* @method jibo.face.views.ComponentGroup#getIndexOfComponent
* @param {jibo.face.views.Component} component - Component to check for index.
* @returns {number} Index of the Component in the component list
*/
/**
* Remove ComponentGroup's reference to a Component.
* This does not destroy the Component or remove its assets from the manifest.
* It only removes it from the ComponentGroup array and hash that reference it.
* @method jibo.face.views.ComponentGroup#removeComponent
* @param {jibo.face.views.Component|Number|String} componentDeterminer Provide Component, index of component, or id of component to remove.
* @returns {jibo.face.views.Component} The Component being removed.
*/
/**
* Retrieve a child Component by its id.
* @method jibo.face.views.ComponentGroup#getComponentById
* @param {String} componentId The ID of the component to retrieve.
* @returns {jibo.face.views.Component} The retrieved component.
*/
/**
* Retrieve a child Component by its index.
* @method jibo.face.views.ComponentGroup#getComponentByIndex
* @param {number} index The index of the component to retrieve.
* @returns {jibo.face.views.Component} The retrieved component.
*/
/**
* Returns first component found in Component tree that returns `true` for given test.
* Iterates downward, breadth-first search, starting from this ComponentGroup.
* @method jibo.face.views.ComponentGroup#findComponent
* @param {Function} testFunction - Function must take a Component parameter and return a boolean,
* passing an additional Object to test against is optional.
* @param {any} [against] - Object to test against.
* @return {jibo.face.views.Component} First Component found that the testFunction return `true` for.
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Frame enter loop update.
* Calls update method of any child that has registered for updates.
* @method jibo.face.views.ComponentGroup#update
* @param {number} elapsed Time in milliseconds since the last frame update.
*/
/**
* Register for the given component's update method to be called.
* @method jibo.face.views.ComponentGroup#registerComponentUpdate
* @param {jibo.face.views.Component} component The component to update.
*/
/**
* Stop the given component's update method from getting called.
* @method jibo.face.views.ComponentGroup#unregisterComponentUpdate
* @param {jibo.face.views.Component} component The Component to stop providing updates to.
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Create this Component's display as well as calling createDisplay on all child Components.
* This method should should 'visualize' the component, creating DisplayObjects and adding them the container.
* @method jibo.face.views.ComponentGroup#createDisplay
* @param {PIXI.Container} container Is ultimately a child of the stage.
* @param {any} assets Object passed back from loader namespace load method,
* refer to loader namespace within jibo for details.
*/
/**
* Called by parent ComponentGroup once parent has finished its loading and setup,
* calls ready on all child Components.
* Allows opportunity to do additional setup that may depend on other components.
*
* ATTENTION: This should not be called directly; the top level [View]{@link jibo.face.views.View}
* will call this, which will recurse through Component tree.
* @method jibo.face.views.ComponentGroup#ready
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Method for `open` transition.
* Iterates through components and calls their open method.
* Method is responsible for calling the callback in all situations.
*
* ATTENTION : This should not be called directly; {@link jibo.face.views}
* will manage when Components should open during the view process.
* @method jibo.face.views.ComponentGroup#open
* @param {Function} callback Function to be called once open is complete.
* @param {String} transitionType String used to determine way Component opens,
* refer to ViewManager for constants used
* @param {number} [duration = ViewManager.TRANS_TIME] Duration of the transition.
*/
/**
* FOR OVERRIDE ONLY. DO NOT CALL.
*
* Method for `close` transition.
* Iterates through components and calls their close method.
* Method is responsible for calling the callback in all situations.
*
* ATTENTION : This should not be called directly; {@link jibo.face.views}
* will manage when Components should close during the view process.
* @method jibo.face.views.ComponentGroup#close
* @param {Function} callback Function to be called once close is complete.
* @param {String} [transitionType] String used to determine way Component closes,
* refer to ViewManager for constants used.
* @param {number} [duration = ViewManager.TRANS_TIME] Duration of the transition.
*/
/**
* Call open method on all component children.
* Iterates through components and calls their open method, passing given transitionType.
* Method is responsible for calling the callback in all situations.
* @method jibo.face.views.ComponentGroup#openChildren
* @param {Function} callback Function called once all component children have completed their open.
* @param {String} transitionType Transition type passed to all component children.
* @param {number} [duration = ViewManager.TRANS_TIME] Duration of the transition.
* @protected
*/
/**
* Call close method on all component children.
* Iterates through components and calls their close method.
* Method is responsible for calling the callback in all situations.
* @method jibo.face.views.ComponentGroup#closeChildren
* @param {Function} callback Function called once all component children have completed their close.
* @param {String} transitionType Transition type passed to all component children.
* @param {number} [duration = ViewManager.TRANS_TIME] Duration of the transition.
* @protected
*/
/**
* Method to bubble actions up from Components.
* Actions pass through this method up to next ComponentGroup parent, ultimately reaching the ViewManager.
* Passing action up through parents allows each to augment or block the action if desired.
* @method jibo.face.views.ComponentGroup#actionHandler
* @param {jibo.face.views.ActionData} action Contains string for type of action and data Object
* with any pertinent data dependent on action type.
* @param {jibo.face.views.Component} [fromComponent] The component that triggered the action (if applicable).
*/
/**
* Method to pass actions downward to Components.
* Passing actions through parent chain allows parents to interrupt and augment actions.
* @method jibo.face.views.ComponentGroup#actionEnactor
* @param {jibo.face.views.ActionData} action Contains string for type of action and data Object
* with any pertinent data dependent on action type.
* @return {boolean} `true` if action is acted on by this ComponentGroup or any of its ComponentGroup children.
*/
/**
* Handler for when transitions are all complete.
* @method jibo.face.views.ComponentGroup#transitionComplete
* @param {Function} callback The callback triggered once all components have completed their transitions.
* @param {Error} [err] Error returns if there is an issue with the asynchronous method.
* @param {any[]} [results] Results returned from asynchronous method, will be empty.
* @private
*/