mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
Merge pull request #109 from JoneLau/new-3d
make some modifications to editor inspector and add example for ui
This commit is contained in:
@@ -30,7 +30,7 @@ import { Component} from '../../../components/component';
|
||||
import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../../core/data/class-decorator';
|
||||
import Event from '../../../core/event/event';
|
||||
import { lerp } from '../../../core/utils/misc';
|
||||
import { Color, Vec3 } from '../../../core/value-types/index';
|
||||
import { Color, Vec3, Enum } from '../../../core/value-types/index';
|
||||
import * as math from '../../../core/vmath/index';
|
||||
import { Node } from '../../../scene-graph';
|
||||
import { SpriteComponent } from './sprite-component';
|
||||
@@ -41,34 +41,34 @@ import { EventTouch } from '../../../core/platform/event-manager';
|
||||
* !#zh 过渡类型
|
||||
* @enum Button.Transition
|
||||
*/
|
||||
const Transition = cc.Enum({
|
||||
enum Transition {
|
||||
/**
|
||||
* !#en The none type.
|
||||
* !#zh 不做任何过渡
|
||||
* @property {Number} NONE
|
||||
*/
|
||||
NONE: 0,
|
||||
NONE = 0,
|
||||
|
||||
/**
|
||||
* !#en The color type.
|
||||
* !#zh 颜色过渡
|
||||
* @property {Number} COLOR
|
||||
*/
|
||||
COLOR: 1,
|
||||
COLOR = 1,
|
||||
|
||||
/**
|
||||
* !#en The sprite type.
|
||||
* !#zh 精灵过渡
|
||||
* @property {Number} SPRITE
|
||||
*/
|
||||
SPRITE: 2,
|
||||
SPRITE = 2,
|
||||
/**
|
||||
* !#en The scale type
|
||||
* !#zh 缩放过渡
|
||||
* @property {Number} SCALE
|
||||
*/
|
||||
SCALE: 3,
|
||||
});
|
||||
SCALE = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en
|
||||
@@ -129,7 +129,7 @@ const Transition = cc.Enum({
|
||||
@executionOrder(100)
|
||||
@menu('UI/Button')
|
||||
@executeInEditMode
|
||||
export default class ButtonComponent extends Component {
|
||||
export class ButtonComponent extends Component {
|
||||
|
||||
/**
|
||||
* !#en
|
||||
@@ -193,7 +193,7 @@ export default class ButtonComponent extends Component {
|
||||
return this._transition;
|
||||
}
|
||||
|
||||
set transition (value: number) {
|
||||
set transition(value: Transition) {
|
||||
if (this._transition === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import { ccclass, executeInEditMode, executionOrder, menu, property } from '../.
|
||||
import Rect from '../../../core/value-types/rect';
|
||||
import Size from '../../../core/value-types/size';
|
||||
import { GFXClearFlag } from '../../../gfx/define';
|
||||
import { Camera } from '../../../renderer/scene/camera';
|
||||
import { Camera, ICameraInfo } from '../../../renderer/scene/camera';
|
||||
|
||||
/**
|
||||
* !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
|
||||
@@ -109,15 +109,15 @@ export class CanvasComponent extends Component {
|
||||
}
|
||||
|
||||
get visibility () {
|
||||
if (this._camere) {
|
||||
return this._camere.view.visibility;
|
||||
if (this._camera) {
|
||||
return this._camera.view.visibility;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
get camera () {
|
||||
return this._camere;
|
||||
return this._camera;
|
||||
}
|
||||
|
||||
public static views = [];
|
||||
@@ -138,8 +138,8 @@ export class CanvasComponent extends Component {
|
||||
|
||||
private _thisOnResized: Function | null = null;
|
||||
|
||||
private _camere: Camera | null = null;
|
||||
private _cameraInfo: object | null = null;
|
||||
private _camera: Camera | null = null;
|
||||
private _cameraInfo: ICameraInfo | null = null;
|
||||
|
||||
// /**
|
||||
// * !#en Current active canvas, the scene should only have one active canvas at the same time.
|
||||
@@ -194,23 +194,25 @@ export class CanvasComponent extends Component {
|
||||
public onEnable () {
|
||||
this._cameraInfo = {
|
||||
name: 'ui',
|
||||
clearFlags: GFXClearFlag.DEPTH | GFXClearFlag.STENCIL,
|
||||
node: this.node,
|
||||
stencil: 0,
|
||||
projection: CameraComponent.ProjectionType.ORTHO,
|
||||
fov: 45,
|
||||
stencil: 0,
|
||||
orthoHeight: 10,
|
||||
far: 4096,
|
||||
near: 0.1,
|
||||
near: -0.1,
|
||||
color: cc.color(255, 0, 0, 1),
|
||||
clearFlags: GFXClearFlag.DEPTH | GFXClearFlag.STENCIL,
|
||||
rect: new Rect(0, 0, 1, 1),
|
||||
color: cc.color(255, 255, 255, 255),
|
||||
};
|
||||
this._camere = this._getRenderScene().createCamera(this._cameraInfo);
|
||||
depth: 1
|
||||
} as ICameraInfo;
|
||||
this._camera = this._getRenderScene().createCamera(this._cameraInfo);
|
||||
cc.director.root.ui.addScreen(this);
|
||||
}
|
||||
|
||||
public onDisable () {
|
||||
if (this._camere) {
|
||||
this._getRenderScene().destroyCamera(this._cameraInfo);
|
||||
if (this._camera) {
|
||||
this._getRenderScene().destroyCamera(this._camera);
|
||||
cc.director.root.ui.removeScreen(this);
|
||||
}
|
||||
}
|
||||
@@ -243,10 +245,10 @@ export class CanvasComponent extends Component {
|
||||
//
|
||||
|
||||
public alignWithScreen () {
|
||||
if (this._camere) {
|
||||
this._camere.resize(cc.game.canvas.width, cc.game.canvas.height);
|
||||
this._camere.orthoHeight = cc.game.canvas.height / cc.view._scaleY / 2;
|
||||
const viewport = this._camere.viewport;
|
||||
if (this._camera) {
|
||||
this._camera.resize(cc.game.canvas.width, cc.game.canvas.height);
|
||||
this._camera.orthoHeight = cc.game.canvas.height / cc.view._scaleY / 2;
|
||||
const viewport = this._camera.viewport;
|
||||
viewport.x = viewport.y = 0;
|
||||
viewport.width = cc.game.canvas.width;
|
||||
viewport.height = cc.game.canvas.height;
|
||||
|
||||
@@ -672,7 +672,7 @@ export class EditBoxComponent extends Component {
|
||||
textLabel.string = displayText;
|
||||
if (this._impl) {
|
||||
this._impl.setString(text);
|
||||
if (!this._impl._editing && !this.stayOnTop) {
|
||||
if (!this._impl.editing && !this.stayOnTop) {
|
||||
this._showLabels();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import macro from '../../../../core/platform/CCMacro';
|
||||
import * as Types from './types';
|
||||
import * as math from '../../../../core/vmath';
|
||||
import { Size, Color } from '../../../../core/value-types';
|
||||
import { Node } from '../../../../scene-graph';
|
||||
import { EditBoxComponent} from './edit-box-component';
|
||||
import { Node } from '../../../../scene-graph/node';
|
||||
const InputMode = Types.InputMode;
|
||||
const InputFlag = Types.InputFlag;
|
||||
const KeyboardReturnType = Types.KeyboardReturnType;
|
||||
@@ -50,7 +50,7 @@ let _matrix = cc.mat4();
|
||||
let _matrix_temp = cc.mat4();
|
||||
let _vec3 = cc.v3();
|
||||
|
||||
let _currentEditBoxImpl = null;
|
||||
let _currentEditBoxImpl: EditBoxImpl | null= null;
|
||||
|
||||
// polyfill
|
||||
let polyfill = {
|
||||
@@ -82,25 +82,61 @@ function getKeyboardReturnType(type) {
|
||||
|
||||
@ccclass
|
||||
export class EditBoxImpl {
|
||||
_delegate: EditBoxComponent | null = null;
|
||||
_inputMode= -1;
|
||||
_inputFlag= -1;
|
||||
_returnType= KeyboardReturnType.DEFAULT;
|
||||
_maxLength= 50;
|
||||
_text = '';
|
||||
_placeholderText = '';
|
||||
_alwaysOnTop = false;
|
||||
_size: Size = cc.size();
|
||||
_node: Node = null;
|
||||
_editing = false;
|
||||
__eventListeners: object = {};
|
||||
__fullscreen = false;
|
||||
__autoResize = false;
|
||||
__rotateScreen = false;
|
||||
__orientationChanged: Function | null = null;
|
||||
_edTxt: HTMLElement | null = null;
|
||||
_textColor: Color = Color.WHITE;
|
||||
_edFontSize = 14;
|
||||
private _delegate: EditBoxComponent | null = null;
|
||||
private _inputMode= -1;
|
||||
private _inputFlag= -1;
|
||||
private _returnType = KeyboardReturnType.DEFAULT;
|
||||
private _maxLength= 50;
|
||||
private _text = '';
|
||||
private _placeholderText = '';
|
||||
private _alwaysOnTop = false;
|
||||
private _size: Size = cc.size();
|
||||
private _node: Node | null = null;
|
||||
private _editing = false;
|
||||
private __eventListeners: any = {};
|
||||
private __fullscreen = false;
|
||||
private __autoResize = false;
|
||||
private __rotateScreen = false;
|
||||
private __orientationChanged: any;
|
||||
private _edTxt: HTMLElement | null = null;
|
||||
private _textColor: Color = Color.WHITE;
|
||||
private _edFontSize = 14;
|
||||
|
||||
get text() {
|
||||
return this._text;
|
||||
}
|
||||
|
||||
set text(value: string) {
|
||||
this._text = value;
|
||||
}
|
||||
|
||||
get textColor() {
|
||||
return this._textColor;
|
||||
}
|
||||
|
||||
get fontSize() {
|
||||
return this._edFontSize;
|
||||
}
|
||||
|
||||
set returnType(value: Types.KeyboardReturnType) {
|
||||
this._returnType = value;
|
||||
}
|
||||
|
||||
get alwayOnTop() {
|
||||
return this._alwaysOnTop;
|
||||
}
|
||||
|
||||
set editing(value: boolean) {
|
||||
this._editing = value;
|
||||
}
|
||||
|
||||
get delegate() {
|
||||
return this._delegate;
|
||||
}
|
||||
|
||||
get eventListeners() {
|
||||
return this.__eventListeners;
|
||||
}
|
||||
|
||||
onEnable() {
|
||||
if (!this._edTxt) {
|
||||
@@ -316,7 +352,7 @@ export class EditBoxImpl {
|
||||
|
||||
_updateDomInputType() {
|
||||
let inputMode = this._inputMode;
|
||||
let edTxt = this._edTxt;
|
||||
let edTxt = this._edTxt as HTMLInputElement;
|
||||
if (!edTxt) return;
|
||||
|
||||
if (this._inputFlag === InputFlag.PASSWORD) {
|
||||
@@ -356,15 +392,18 @@ export class EditBoxImpl {
|
||||
_updateMatrix() {
|
||||
if (!this._edTxt) return;
|
||||
|
||||
let node = this._node,
|
||||
scaleX = cc.view._scaleX, scaleY = cc.view._scaleY,
|
||||
viewport = cc.view._viewportRect,
|
||||
dpr = cc.view._devicePixelRatio;
|
||||
const node = this._node;
|
||||
let scaleX = cc.view._scaleX;
|
||||
let scaleY = cc.view._scaleY;
|
||||
const viewport = cc.view._viewportRect;
|
||||
const dpr = cc.view._devicePixelRatio;
|
||||
|
||||
node.getWorldMatrix(_matrix);
|
||||
let contentSize = node._contentSize;
|
||||
_vec3.x = -node._anchorPoint.x * contentSize.width;
|
||||
_vec3.y = -node._anchorPoint.y * contentSize.height;
|
||||
node!.getWorldMatrix(_matrix);
|
||||
const transform = node!.uiTransfromComp
|
||||
if (transform) {
|
||||
_vec3.x = -transform.anchorX.x * transform.width;
|
||||
_vec3.y = -transform.anchorY.y * transform.height;
|
||||
}
|
||||
|
||||
math.mat4.translate(_matrix, _matrix, _vec3);
|
||||
|
||||
@@ -376,7 +415,7 @@ export class EditBoxImpl {
|
||||
// else {
|
||||
// camera = cc.Camera.findCamera(node);
|
||||
// }
|
||||
let renderComp = node.getComponent(cc.RenderComponent);
|
||||
let renderComp = node!.getComponent(cc.RenderComponent);
|
||||
if (!renderComp) {
|
||||
return false;
|
||||
}
|
||||
@@ -422,7 +461,7 @@ export class EditBoxImpl {
|
||||
}
|
||||
|
||||
_adjustEditBoxPosition() {
|
||||
this._node.getWorldMatrix(_matrix);
|
||||
this._node!.getWorldMatrix(_matrix);
|
||||
let y = _matrix.m13;
|
||||
let windowHeight = cc.visibleRect.height;
|
||||
let windowWidth = cc.visibleRect.width;
|
||||
@@ -484,7 +523,9 @@ export class EditBoxImpl {
|
||||
this.__rotateScreen = false;
|
||||
}
|
||||
|
||||
window.removeEventListener('orientationchange', this.__orientationChanged);
|
||||
if (this.__orientationChanged) {
|
||||
window.removeEventListener('orientationchange', this.__orientationChanged);
|
||||
}
|
||||
|
||||
if (this.__fullscreen) {
|
||||
cc.view.enableAutoFullScreen(true);
|
||||
@@ -506,11 +547,11 @@ export class EditBoxImpl {
|
||||
tmpEdTxt.type = 'text';
|
||||
tmpEdTxt.style.fontSize = this._edFontSize + 'px';
|
||||
tmpEdTxt.style.color = '#000000';
|
||||
tmpEdTxt.style.border = 0;
|
||||
tmpEdTxt.style.border = '0px';
|
||||
tmpEdTxt.style.background = 'transparent';
|
||||
tmpEdTxt.style.width = '100%';
|
||||
tmpEdTxt.style.height = '100%';
|
||||
tmpEdTxt.style.active = 0;
|
||||
// tmpEdTxt.style.active = 0;
|
||||
tmpEdTxt.style.outline = 'medium';
|
||||
tmpEdTxt.style.padding = '0';
|
||||
tmpEdTxt.style.textTransform = 'uppercase';
|
||||
@@ -519,7 +560,7 @@ export class EditBoxImpl {
|
||||
tmpEdTxt.style.bottom = "0px";
|
||||
tmpEdTxt.style.left = LEFT_PADDING + "px";
|
||||
tmpEdTxt.style['-moz-appearance'] = 'textfield';
|
||||
tmpEdTxt.style.className = "cocosEditBox";
|
||||
tmpEdTxt.className = "cocosEditBox";
|
||||
tmpEdTxt.style.fontFamily = 'Arial';
|
||||
|
||||
registerInputEventListener(tmpEdTxt, this);
|
||||
@@ -531,24 +572,24 @@ export class EditBoxImpl {
|
||||
this.removeDom();
|
||||
|
||||
let tmpEdTxt = this._edTxt = document.createElement('textarea');
|
||||
tmpEdTxt.type = 'text';
|
||||
// tmpEdTxt.type = 'text';
|
||||
tmpEdTxt.style.fontSize = this._edFontSize + 'px';
|
||||
tmpEdTxt.style.color = '#000000';
|
||||
tmpEdTxt.style.border = '0';
|
||||
tmpEdTxt.style.background = 'transparent';
|
||||
tmpEdTxt.style.width = '100%';
|
||||
tmpEdTxt.style.height = '100%';
|
||||
tmpEdTxt.style.active = 0;
|
||||
// tmpEdTxt.style.active = 0;
|
||||
tmpEdTxt.style.outline = 'medium';
|
||||
tmpEdTxt.style.padding = '0';
|
||||
tmpEdTxt.style.resize = 'none';
|
||||
tmpEdTxt.style.textTransform = 'uppercase';
|
||||
tmpEdTxt.style.overflow_y = 'scroll';
|
||||
tmpEdTxt.style.overflowY = 'scroll';
|
||||
tmpEdTxt.style.display = 'none';
|
||||
tmpEdTxt.style.position = "absolute";
|
||||
tmpEdTxt.style.bottom = "0px";
|
||||
tmpEdTxt.style.left = LEFT_PADDING + "px";
|
||||
tmpEdTxt.style.className = "cocosEditBox";
|
||||
tmpEdTxt.className = "cocosEditBox";
|
||||
tmpEdTxt.style.fontFamily = 'Arial';
|
||||
|
||||
registerInputEventListener(tmpEdTxt, this, true);
|
||||
@@ -601,7 +642,7 @@ function _inputValueHandle(input, editBoxImpl) {
|
||||
|
||||
function registerInputEventListener(tmpEdTxt: HTMLElement, editBoxImpl: EditBoxImpl, isTextarea = false) {
|
||||
let inputLock = false;
|
||||
let cbs = editBoxImpl.__eventListeners;
|
||||
let cbs = editBoxImpl.eventListeners;
|
||||
cbs.compositionstart = function () {
|
||||
inputLock = true;
|
||||
};
|
||||
@@ -622,19 +663,19 @@ function registerInputEventListener(tmpEdTxt: HTMLElement, editBoxImpl: EditBoxI
|
||||
tmpEdTxt.addEventListener('input', cbs.input);
|
||||
|
||||
cbs.focus = function () {
|
||||
this.style.fontSize = editBoxImpl._edFontSize + 'px';
|
||||
this.style.color = editBoxImpl._textColor.toCSS('rgba');
|
||||
this.style.fontSize = editBoxImpl.fontSize + 'px';
|
||||
this.style.color = editBoxImpl.textColor.toCSS('rgba');
|
||||
// When stayOnTop, input will swallow touch event
|
||||
if (editBoxImpl._alwaysOnTop) {
|
||||
editBoxImpl._editing = true;
|
||||
if (editBoxImpl.alwayOnTop) {
|
||||
editBoxImpl.editing = true;
|
||||
}
|
||||
|
||||
if (cc.sys.isMobile) {
|
||||
editBoxImpl._beginEditingOnMobile();
|
||||
}
|
||||
|
||||
if (editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingDidBegan) {
|
||||
editBoxImpl._delegate.editBoxEditingDidBegan();
|
||||
if (editBoxImpl.delegate && editBoxImpl.delegate.editBoxEditingDidBegan) {
|
||||
editBoxImpl.delegate.editBoxEditingDidBegan();
|
||||
}
|
||||
|
||||
};
|
||||
@@ -644,11 +685,11 @@ function registerInputEventListener(tmpEdTxt: HTMLElement, editBoxImpl: EditBoxI
|
||||
if (e.keyCode === macro.KEY.enter) {
|
||||
e.stopPropagation();
|
||||
|
||||
if (editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingReturn) {
|
||||
editBoxImpl._delegate.editBoxEditingReturn();
|
||||
if (editBoxImpl.delegate && editBoxImpl.delegate.editBoxEditingReturn) {
|
||||
editBoxImpl.delegate.editBoxEditingReturn();
|
||||
}
|
||||
if (!isTextarea) {
|
||||
editBoxImpl._text = this.value;
|
||||
editBoxImpl.text = this.value;
|
||||
editBoxImpl._endEditing();
|
||||
cc.game.canvas.focus();
|
||||
}
|
||||
@@ -657,7 +698,7 @@ function registerInputEventListener(tmpEdTxt: HTMLElement, editBoxImpl: EditBoxI
|
||||
tmpEdTxt.addEventListener('keypress', cbs.keypress);
|
||||
|
||||
cbs.blur = function () {
|
||||
editBoxImpl._text = this.value;
|
||||
editBoxImpl.text = this.value;
|
||||
editBoxImpl._endEditing();
|
||||
};
|
||||
tmpEdTxt.addEventListener('blur', cbs.blur);
|
||||
|
||||
@@ -28,44 +28,44 @@
|
||||
* @readonly
|
||||
* @enum EditBox.KeyboardReturnType
|
||||
*/
|
||||
let KeyboardReturnType = cc.Enum({
|
||||
export enum KeyboardReturnType {
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 默认
|
||||
* @property {Number} DEFAULT
|
||||
*/
|
||||
DEFAULT: 0,
|
||||
DEFAULT = 0,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 完成类型
|
||||
* @property {Number} DONE
|
||||
*/
|
||||
DONE: 1,
|
||||
DONE = 1,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 发送类型
|
||||
* @property {Number} SEND
|
||||
*/
|
||||
SEND: 2,
|
||||
SEND = 2,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 搜索类型
|
||||
* @property {Number} SEARCH
|
||||
*/
|
||||
SEARCH: 3,
|
||||
SEARCH = 3,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 跳转类型
|
||||
* @property {Number} GO
|
||||
*/
|
||||
GO: 4,
|
||||
GO = 4,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 下一个类型
|
||||
* @property {Number} NEXT
|
||||
*/
|
||||
NEXT: 5
|
||||
});
|
||||
NEXT = 5
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
|
||||
@@ -73,37 +73,37 @@ let KeyboardReturnType = cc.Enum({
|
||||
* @readonly
|
||||
* @enum EditBox.InputMode
|
||||
*/
|
||||
let InputMode = cc.Enum({
|
||||
export enum InputMode {
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 用户可以输入任何文本,包括换行符。
|
||||
* @property {Number} ANY
|
||||
*/
|
||||
ANY: 0,
|
||||
ANY = 0,
|
||||
/**
|
||||
* !#en The user is allowed to enter an e-mail address.
|
||||
* !#zh 允许用户输入一个电子邮件地址。
|
||||
* @property {Number} EMAIL_ADDR
|
||||
*/
|
||||
EMAIL_ADDR: 1,
|
||||
EMAIL_ADDR = 1,
|
||||
/**
|
||||
* !#en The user is allowed to enter an integer value.
|
||||
* !#zh 允许用户输入一个整数值。
|
||||
* @property {Number} NUMERIC
|
||||
*/
|
||||
NUMERIC: 2,
|
||||
NUMERIC = 2,
|
||||
/**
|
||||
* !#en The user is allowed to enter a phone number.
|
||||
* !#zh 允许用户输入一个电话号码。
|
||||
* @property {Number} PHONE_NUMBER
|
||||
*/
|
||||
PHONE_NUMBER: 3,
|
||||
PHONE_NUMBER = 3,
|
||||
/**
|
||||
* !#en The user is allowed to enter a URL.
|
||||
* !#zh 允许用户输入一个 URL。
|
||||
* @property {Number} URL
|
||||
*/
|
||||
URL: 4,
|
||||
URL = 4,
|
||||
/**
|
||||
* !#en
|
||||
* The user is allowed to enter a real number value.
|
||||
@@ -112,14 +112,14 @@ let InputMode = cc.Enum({
|
||||
* 允许用户输入一个实数。
|
||||
* @property {Number} DECIMAL
|
||||
*/
|
||||
DECIMAL: 5,
|
||||
DECIMAL = 5,
|
||||
/**
|
||||
* !#en The user is allowed to enter any text, except for line breaks.
|
||||
* !#zh 除了换行符以外,用户可以输入任何文本。
|
||||
* @property {Number} SINGLE_LINE
|
||||
*/
|
||||
SINGLE_LINE: 6
|
||||
});
|
||||
SINGLE_LINE = 6
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en Enum for the EditBox's input flags
|
||||
@@ -127,7 +127,7 @@ let InputMode = cc.Enum({
|
||||
* @readonly
|
||||
* @enum EditBox.InputFlag
|
||||
*/
|
||||
let InputFlag = cc.Enum({
|
||||
export enum InputFlag {
|
||||
/**
|
||||
* !#en
|
||||
* Indicates that the text entered is confidential data that should be
|
||||
@@ -136,7 +136,7 @@ let InputFlag = cc.Enum({
|
||||
* 表明输入的文本是保密的数据,任何时候都应该隐藏起来,它隐含了 EDIT_BOX_INPUT_FLAG_SENSITIVE。
|
||||
* @property {Number} PASSWORD
|
||||
*/
|
||||
PASSWORD: 0,
|
||||
PASSWORD = 0,
|
||||
/**
|
||||
* !#en
|
||||
* Indicates that the text entered is sensitive data that the
|
||||
@@ -148,7 +148,7 @@ let InputFlag = cc.Enum({
|
||||
* 一个信用卡号码就是一个敏感数据的例子。
|
||||
* @property {Number} SENSITIVE
|
||||
*/
|
||||
SENSITIVE: 1,
|
||||
SENSITIVE = 1,
|
||||
/**
|
||||
* !#en
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
@@ -157,7 +157,7 @@ let InputFlag = cc.Enum({
|
||||
* 这个标志用来指定在文本编辑的时候,是否把每一个单词的首字母大写。
|
||||
* @property {Number} INITIAL_CAPS_WORD
|
||||
*/
|
||||
INITIAL_CAPS_WORD: 2,
|
||||
INITIAL_CAPS_WORD = 2,
|
||||
/**
|
||||
* !#en
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
@@ -166,18 +166,17 @@ let InputFlag = cc.Enum({
|
||||
* 这个标志用来指定在文本编辑是否每个句子的首字母大写。
|
||||
* @property {Number} INITIAL_CAPS_SENTENCE
|
||||
*/
|
||||
INITIAL_CAPS_SENTENCE: 3,
|
||||
INITIAL_CAPS_SENTENCE = 3,
|
||||
/**
|
||||
* !#en Capitalize all characters automatically.
|
||||
* !#zh 自动把输入的所有字符大写。
|
||||
* @property {Number} INITIAL_CAPS_ALL_CHARACTERS
|
||||
*/
|
||||
INITIAL_CAPS_ALL_CHARACTERS: 4,
|
||||
INITIAL_CAPS_ALL_CHARACTERS = 4,
|
||||
/**
|
||||
* Don't do anything with the input text.
|
||||
* @property {Number} DEFAULT
|
||||
*/
|
||||
DEFAULT: 5
|
||||
});
|
||||
DEFAULT = 5
|
||||
};
|
||||
|
||||
export { KeyboardReturnType, InputMode, InputFlag }
|
||||
@@ -35,27 +35,27 @@ import { SpriteComponent } from './sprite-component';
|
||||
* !#zh 进度条模式
|
||||
* @enum ProgressBar.Mode
|
||||
*/
|
||||
var Mode = cc.Enum({
|
||||
enum Mode {
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 水平方向模式
|
||||
* @property {Number} HORIZONTAL
|
||||
*/
|
||||
HORIZONTAL: 0,
|
||||
HORIZONTAL = 0,
|
||||
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 垂直方向模式
|
||||
* @property {Number} VERTICAL
|
||||
*/
|
||||
VERTICAL: 1,
|
||||
VERTICAL = 1,
|
||||
/**
|
||||
* !#en TODO
|
||||
* !#zh 填充模式
|
||||
* @property {Number} FILLED
|
||||
*/
|
||||
FILLED: 2,
|
||||
});
|
||||
FILLED = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en
|
||||
@@ -171,7 +171,11 @@ export class ProgressBarComponent extends Component {
|
||||
* !#zh 当前进度值,该数值的区间是 0-1 之间。
|
||||
* @property {Number} progress
|
||||
*/
|
||||
@property
|
||||
@property({
|
||||
default: 0.1,
|
||||
range: [0, 1, 0.1],
|
||||
slide: true
|
||||
})
|
||||
get progress() {
|
||||
return this._progress;
|
||||
}
|
||||
|
||||
@@ -38,20 +38,20 @@ import { UITransformComponent } from './ui-transfrom-component';
|
||||
* !#zh 滑动器方向
|
||||
* @enum Slider.Direction
|
||||
*/
|
||||
var Direction = cc.Enum({
|
||||
enum Direction {
|
||||
/**
|
||||
* !#en The horizontal direction.
|
||||
* !#zh 水平方向
|
||||
* @property {Number} Horizontal
|
||||
*/
|
||||
Horizontal: 0,
|
||||
Horizontal = 0,
|
||||
/**
|
||||
* !#en The vertical direction.
|
||||
* !#zh 垂直方向
|
||||
* @property {Number} Vertical
|
||||
*/
|
||||
Vertical: 1
|
||||
});
|
||||
Vertical = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en The Slider Control
|
||||
@@ -124,7 +124,11 @@ export class SliderComponent extends Component {
|
||||
* !#zh 当前进度值,该数值的区间是 0-1 之间
|
||||
* @property {Number} progress
|
||||
*/
|
||||
@property
|
||||
@property({
|
||||
default: 0.1,
|
||||
slide: true,
|
||||
range: [0.1, 1, 0.01],
|
||||
})
|
||||
get progress() {
|
||||
return this._progress;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
****************************************************************************/
|
||||
import ComponentEventHandler from '../../../components/CCComponentEventHandler';
|
||||
import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../../core/data/class-decorator';
|
||||
import ButtonComponent from './button-component';
|
||||
import { ButtonComponent} from './button-component';
|
||||
import { SpriteComponent} from './sprite-component';
|
||||
import { ToggleGroupComponent} from './toggle-group-component';
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
import WidgetManager from '../../../2d/base-ui/CCWidgetManager';
|
||||
import { Component} from '../../../components/component';
|
||||
import { ccclass, property, executeInEditMode, menu, executionOrder } from '../../../core/data/class-decorator';
|
||||
import { Node } from '../../../scene-graph/index'
|
||||
import { Node } from '../../../scene-graph/index';
|
||||
/**
|
||||
* !#en Enum for Widget's alignment mode, indicating when the widget should refresh.
|
||||
* !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。
|
||||
@@ -83,7 +83,7 @@ var LEFT_RIGHT = LEFT | RIGHT;
|
||||
@executionOrder(100)
|
||||
@menu('UI/Widget')
|
||||
@executeInEditMode
|
||||
export default class WidgetComponent extends Component {
|
||||
export class WidgetComponent extends Component {
|
||||
/**
|
||||
* !#zh: 对齐开关,由 AlignFlags 组成
|
||||
*
|
||||
@@ -144,7 +144,7 @@ export default class WidgetComponent extends Component {
|
||||
* @default null
|
||||
*/
|
||||
@property({
|
||||
type: cc.NodeUI
|
||||
type: Node
|
||||
})
|
||||
get target() {
|
||||
return this._target;
|
||||
|
||||
+22
-24
@@ -1,30 +1,28 @@
|
||||
|
||||
import { CanvasComponent} from './components/canvas-component';
|
||||
import { UIRenderComponent} from './components/ui-render-component';
|
||||
import { SpriteComponent} from './components/sprite-component';
|
||||
import { UITransformComponent } from './components/ui-transfrom-component';
|
||||
// import LabelComponent from './components/label-component';
|
||||
// import {UITransformComponent} from './components/ui-transfrom-componentent';
|
||||
// import ButtonComponent from './components/button-component';
|
||||
// import ToggleGroupComponent from './components/toggle-group-component';
|
||||
// import ToggleComponent from './components/toggle-component';
|
||||
// import ToggleContainerComponent from './components/toggle-container-component';
|
||||
// import SliderComponent from './components/slider-component';
|
||||
// import ProgressBarComponent from './components/progress-bar-component';
|
||||
// import WidgetComponent from './components/widget-component';
|
||||
// import EditBoxComponent from './components/editbox/edit-box-component';
|
||||
import { CanvasComponent } from './components/canvas-component';
|
||||
import { UIRenderComponent } from './components/ui-render-component';
|
||||
import { SpriteComponent } from './components/sprite-component';
|
||||
import './components/ui-transfrom-component';
|
||||
import { LabelComponent } from './components/label-component';
|
||||
import { ButtonComponent } from './components/button-component';
|
||||
import { ToggleGroupComponent } from './components/toggle-group-component';
|
||||
import { ToggleComponent } from './components/toggle-component';
|
||||
import { ToggleContainerComponent } from './components/toggle-container-component';
|
||||
import { SliderComponent } from './components/slider-component';
|
||||
import { ProgressBarComponent } from './components/progress-bar-component';
|
||||
import { WidgetComponent } from './components/widget-component';
|
||||
import { EditBoxComponent } from './components/editbox/edit-box-component';
|
||||
import './assembler/index';
|
||||
|
||||
cc.CanvasComponent = CanvasComponent;
|
||||
cc.UIRenderComponent = UIRenderComponent;
|
||||
cc.SpriteComponent = SpriteComponent;
|
||||
// cc.LabelComponent = LabelComponent;
|
||||
// cc.UIRectComponent = UIRectComponent;
|
||||
// cc.ButtonComponent = ButtonComponent;
|
||||
// cc.ToggleGroupComponent = ToggleGroupComponent;
|
||||
// cc.ToggleComponent = ToggleComponent;
|
||||
// cc.ToggleContainerComponent = ToggleContainerComponent;
|
||||
// cc.SliderComponent = SliderComponent;
|
||||
// cc.ProgressBarComponent = ProgressBarComponent;
|
||||
// cc.WidgetComponent = WidgetComponent;
|
||||
// cc.EditBoxComponent = EditBoxComponent;
|
||||
cc.LabelComponent = LabelComponent;
|
||||
cc.ButtonComponent = ButtonComponent;
|
||||
cc.ToggleGroupComponent = ToggleGroupComponent;
|
||||
cc.ToggleComponent = ToggleComponent;
|
||||
cc.ToggleContainerComponent = ToggleContainerComponent;
|
||||
cc.SliderComponent = SliderComponent;
|
||||
cc.ProgressBarComponent = ProgressBarComponent;
|
||||
cc.WidgetComponent = WidgetComponent;
|
||||
cc.EditBoxComponent = EditBoxComponent;
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
window.files = {
|
||||
"aa": [
|
||||
"simple"
|
||||
"simple",
|
||||
"ui"
|
||||
],
|
||||
// "animation": [
|
||||
// "spec-skeleton"
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>ui</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
background-color: #333;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fit {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="fit">
|
||||
<canvas id="canvas" tabindex="-1" class="fit">
|
||||
<img name="testImg" src="cubetexture.png" />
|
||||
</canvas>
|
||||
|
||||
<script src="../bin/cocos-3d.dev.js"></script>
|
||||
<script>
|
||||
const $body = document.body;
|
||||
const bcr = $body.getBoundingClientRect();
|
||||
const canv = document.getElementById('canvas');
|
||||
canv.width = bcr.width;
|
||||
canv.height = bcr.height;
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
const bcr = $body.getBoundingClientRect();
|
||||
cc.director.root.resize(bcr.width, bcr.height);
|
||||
});
|
||||
|
||||
function createTexture(imgElms) {
|
||||
const textureAsset = new cc.Texture2D();
|
||||
textureAsset.image = new cc.ImageAsset(imgElms[0]);
|
||||
return textureAsset;
|
||||
}
|
||||
const geomList = ['box', 'sphere', 'cylinder', 'cone', 'torus', 'capsule'];
|
||||
function onStart() {
|
||||
const root = cc.director.root;
|
||||
const scene = new cc.Scene();
|
||||
|
||||
const canvasNode = new cc.Node('Canvas');
|
||||
canvasNode.parent = scene;
|
||||
canvasNode.addComponent(cc.CanvasComponent);
|
||||
|
||||
const spriteNode = new cc.Node('sprite');
|
||||
spriteNode.parent = canvasNode;
|
||||
spriteNode.setPosition(0, 0, 0);
|
||||
const spriteComp = spriteNode.addComponent(cc.SpriteComponent);
|
||||
|
||||
// let elem = cc.game.canvas.getElementsByTagName('img')[0];
|
||||
const spriteFrame = new cc.SpriteFrame();
|
||||
let elem = cc.game.canvas.getElementsByTagName('img')[0];
|
||||
spriteFrame.image = new cc.ImageAsset(elem);
|
||||
// spriteFrame.setOriginalSize(cc.size(elem.width, elem.height));
|
||||
// spriteFrame.setRect(0, 0, elem.width, elem.height);
|
||||
spriteComp.spriteFrame = spriteFrame;
|
||||
|
||||
cc.director.runSceneImmediate(scene);
|
||||
}
|
||||
cc.game.run({ id: 'canvas' }, onStart);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user