forked from Jibo-Revival-Group/JiboOs
208 lines
6.6 KiB
JavaScript
208 lines
6.6 KiB
JavaScript
|
|
/**
|
||
|
|
* @description Interface for describing default values of the list elements that will be shown in the MenuView.
|
||
|
|
* @interface jibo.face.views.MenuView~ListDefaultData
|
||
|
|
* @extends jibo.face.views.MenuButton~MenuButtonOptions
|
||
|
|
* @property {String} [menuButtonType] The name of the MenuButton type that will be generated in the list.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @description Interface - Configuration values for creating a MenuView.
|
||
|
|
* @interface jibo.face.views.MenuView~MenuViewOptions
|
||
|
|
* @extends jibo.face.views.View~ViewOptions
|
||
|
|
* @prop {String} [title] - Position of the element on the screen.
|
||
|
|
* @prop {jibo.face.views.MenuView~ListDefaultData} [listDefault] - Default values that will be applied to list elements upon creation.
|
||
|
|
* @prop {jibo.face.views.MenuButton~MenuButtonOptions[]} [list] - Structure specifying the contents of the list. Its values override those given in {~listDefault}.
|
||
|
|
* @prop {Boolean} [useEyeTransitions] - Flag indicating whether eyeTransitions should be used.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* View designed to display standard list menus.
|
||
|
|
*
|
||
|
|
* Takes a simplified JSON configuration. Example:
|
||
|
|
* ```json
|
||
|
|
* {
|
||
|
|
* "viewConfig": {
|
||
|
|
* "type": "MenuView",
|
||
|
|
* "id": "my_menu",
|
||
|
|
* "title": "Menu Title",
|
||
|
|
* "progress": { //setting to true will use default values, setting to false prevent creation
|
||
|
|
* "width" : 500,
|
||
|
|
* "height": 20,
|
||
|
|
* "backgroundColor": "0xff892f",
|
||
|
|
* "progressColor": "0x1E90FF",
|
||
|
|
* "position": {
|
||
|
|
* "x": "390",
|
||
|
|
* "y": "170",
|
||
|
|
* "margin" : {
|
||
|
|
* "x": 100|LEFT|CENTER|RIGHT,
|
||
|
|
* "y": 100|TOP|CENTER|BOTTOM
|
||
|
|
* }
|
||
|
|
* }
|
||
|
|
* },
|
||
|
|
* "listDefault": {
|
||
|
|
* "menuButtonType": "SkillButton"
|
||
|
|
* },
|
||
|
|
* "list": [
|
||
|
|
* {
|
||
|
|
* "id": "mySkill",
|
||
|
|
* "label": "My SKill",
|
||
|
|
* "colors": ["0xff892f", "0xaf4123"],
|
||
|
|
* "iconSrc": "resources/icons/mySkill.png",
|
||
|
|
* "action": {
|
||
|
|
* "type": "event",
|
||
|
|
* "data": {
|
||
|
|
* "event": "openSkill"
|
||
|
|
* "skill": "mySkill"
|
||
|
|
* }
|
||
|
|
* }
|
||
|
|
* }
|
||
|
|
* ]
|
||
|
|
* }
|
||
|
|
* }
|
||
|
|
* ```
|
||
|
|
* @class MenuView
|
||
|
|
* @extends jibo.face.views.View
|
||
|
|
* @memberof jibo.face.views
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default value for X padding of the listProgress.
|
||
|
|
* @name jibo.face.views.MenuView.LISTPROGRESS_LEFT_MARGIN
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Default value for Y padding of the listProgress.
|
||
|
|
* @name jibo.face.views.MenuView.LISTPROGRESS_BOTTOM_MARGIN
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Margin value for X padding on either side of title to edge of screen.
|
||
|
|
* @name jibo.face.views.MenuView.TITLE_MARGIN
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Buffer value for Y padding beween bottom of title and top of list buttons.
|
||
|
|
* @name jibo.face.views.MenuView.TITLE_BUFFER
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Maximum height of title text.
|
||
|
|
* @name jibo.face.views.MenuView.TITLE_HEIGHT
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Maximum height of button label text.
|
||
|
|
* @name jibo.face.views.MenuView.LABEL_HEIGHT
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A constant specified by design
|
||
|
|
* @name jibo.face.views.MenuView#MENU_LABEL_BUFFER
|
||
|
|
* @private
|
||
|
|
* @type {number}
|
||
|
|
* @readOnly
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The default class identifier.
|
||
|
|
* Generally used to register the class.
|
||
|
|
* @name jibo.face.views.MenuView.DEFAULT_TYPE
|
||
|
|
* @type {String}
|
||
|
|
* @readOnly
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* List for the MenuView.
|
||
|
|
* @name jibo.face.views.MenuView#list
|
||
|
|
* @public
|
||
|
|
* @readOnly
|
||
|
|
* @type {jibo.face.views.List}
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Title for the MenuView, only created if specified.
|
||
|
|
* @name jibo.face.views.MenuView#titleLabel
|
||
|
|
* @public
|
||
|
|
* @readOnly
|
||
|
|
* @type {jibo.face.views.Label}
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* FOR OVERRIDE ONLY. DO NOT CALL.
|
||
|
|
*
|
||
|
|
* Create and add components for List.
|
||
|
|
* @method jibo.face.views.MenuView#createListComponents
|
||
|
|
* @param {jibo.face.views.List} list The List components components will be added to.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Add eye specific transitions for use when this instance of MenuView opens from or closes to an EyeView.
|
||
|
|
* Call on instance of MenuView prior to starting a change view process.
|
||
|
|
* @method jibo.face.views.MenuView#addEyeTransitions
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Apply List config update values (pageIndex, indexOfAction) directly to view config.
|
||
|
|
* This occurs because MenuView does not use a standard component configuration,
|
||
|
|
* instead storing List related data directly to its viewConfig.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* FOR OVERRIDE ONLY. DO NOT CALL EXTERNALLY.
|
||
|
|
*
|
||
|
|
* Determine y positions for the menu elements, as they are relative to each other.
|
||
|
|
* @method jibo.face.views.MenuView#positionComponents
|
||
|
|
* @param {number} [overrideTitleHeight] Override the calculated title height (or if there is no title but you want more spacing).
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Positions button labels according to list start position to match buttons location on the screen
|
||
|
|
* @method jibo.face.views.MenuView#positionButtonLabels
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Update the button labels to match the list elements.
|
||
|
|
* Enacts the Label close and open transitions by default.
|
||
|
|
* @method jibo.face.views.MenuView#updateButtonLabels
|
||
|
|
* @param {Boolean} [labelRemovalNeeded = false] Flag indicating that we need to remove label component
|
||
|
|
* and reposition labels
|
||
|
|
* @param {Boolean} [playTransition = true] Flag determining if close and open transitions will be used,
|
||
|
|
* if false updates the text without any transitions.
|
||
|
|
* @param {number} [duration = 200] Duration of the transition.
|
||
|
|
* @protected
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Calls the close transition on all of the button labels.
|
||
|
|
* @method jibo.face.views.MenuView#fadeOutButtonLabels
|
||
|
|
* @param {number} [duration = 100] Duration of the transition.
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Manages eye tween aspect of the close to eye transition.
|
||
|
|
* @method jibo.face.views.MenuView#eyeOpenTransition
|
||
|
|
* @param {Function} callback - Callback fired when eye completes tween.
|
||
|
|
* @param {number} duration - Duration of the transition.
|
||
|
|
* @private
|
||
|
|
*/
|