Commit 94674e57 authored by rockyl's avatar rockyl

合并主分支

parent 0eb76352
...@@ -9,7 +9,7 @@ import {applyAutoAdjust} from "../../zeroing/decorators/auto-adjust"; ...@@ -9,7 +9,7 @@ import {applyAutoAdjust} from "../../zeroing/decorators/auto-adjust";
import {applyScript} from "../../zeroing/decorators/scripts"; import {applyScript} from "../../zeroing/decorators/scripts";
import {applyEvents} from "../../zeroing/decorators/events"; import {applyEvents} from "../../zeroing/decorators/events";
import {afterConstructor} from "../../zeroing/decorators/after-constructor"; import {afterConstructor} from "../../zeroing/decorators/after-constructor";
import {injectProperties, instantiateScript} from "../../zeroing/utils/index"; import {injectProperties, instantiateScript, toBoolean} from "../../zeroing/utils/index";
import {isUI} from "../../zeroing/game-warpper/nodes/IUIComponent"; import {isUI} from "../../zeroing/game-warpper/nodes/IUIComponent";
import Transform from "../math/Transform"; import Transform from "../math/Transform";
......
...@@ -349,6 +349,7 @@ export class Stage extends Container { ...@@ -349,6 +349,7 @@ export class Stage extends Container {
* @param {number} renderType 渲染类型2canvas * @param {number} renderType 渲染类型2canvas
* @param {boolean} transparent 透明否,默认透明true,此时bgColor无效 * @param {boolean} transparent 透明否,默认透明true,此时bgColor无效
* @param {number} bgColor 背景颜色十六进制 * @param {number} bgColor 背景颜色十六进制
* @param autoResize 是否自动重置尺寸
* @public * @public
* @since 1.0.0 * @since 1.0.0
*/ */
...@@ -360,7 +361,8 @@ export class Stage extends Container { ...@@ -360,7 +361,8 @@ export class Stage extends Container {
scaleMode: string = StageScaleMode.FIXED_WIDTH, scaleMode: string = StageScaleMode.FIXED_WIDTH,
renderType: RENDERER_TYPE = RENDERER_TYPE.WEBGL, renderType: RENDERER_TYPE = RENDERER_TYPE.WEBGL,
transparent: boolean = true, transparent: boolean = true,
bgColor: number = 0x000000 bgColor: number = 0x000000,
autoResize: boolean = false,
) { ) {
super(); super();
let s: Stage = this; let s: Stage = this;
...@@ -376,6 +378,7 @@ export class Stage extends Container { ...@@ -376,6 +378,7 @@ export class Stage extends Container {
s.rootDiv = div; s.rootDiv = div;
s.setFrameRate(frameRate); s.setFrameRate(frameRate);
s._scaleMode = scaleMode; s._scaleMode = scaleMode;
s.autoResize = autoResize;
//s.anchorX = desW >> 1; //s.anchorX = desW >> 1;
//s.anchorY = desH >> 1; //s.anchorY = desH >> 1;
......
...@@ -500,6 +500,86 @@ export class TextField extends Sprite { ...@@ -500,6 +500,86 @@ export class TextField extends Sprite {
private _border: boolean = false; private _border: boolean = false;
/**
* 设置或获取阴影颜色
* @property property
* @public
* @since 1.0.6
* @param value
*/
public set shadowColor(value: string) {
if (this._shadowColor != value) {
this._shadowColor = value;
this.dirty = true;
}
}
public get shadowColor(): string {
return this._shadowColor;
}
private _shadowColor: string = '#000';
/**
* 设置或获取阴影模糊度
* @property property
* @public
* @since 1.0.6
* @param value
*/
public set shadowBlur(value: number) {
if (this._shadowBlur != value) {
this._shadowBlur = value;
this.dirty = true;
}
}
public get shadowBlur(): number {
return this._shadowBlur;
}
private _shadowBlur: number = 0;
/**
* 设置或获取阴影偏移
* @property property
* @public
* @since 1.0.6
* @param value
*/
public set shadowOffset(value: ObservablePoint) {
if (this._shadowOffset != value) {
this._shadowOffset = value;
this.dirty = true;
}
}
public get shadowOffset(): ObservablePoint {
return this._shadowOffset;
}
get shadowOffsetX(): number {
return this.position.x;
}
set shadowOffsetX(value: number) {
this._shadowOffset.x = value;
}
get shadowOffsetY(): number {
return this.position.y;
}
set shadowOffsetY(value: number) {
this._shadowOffset.y = value;
}
private _shadowOffset: ObservablePoint = new ObservablePoint(this.onShadowOffsetChange, this);
private onShadowOffsetChange() {
this.dirty = true;
}
private _setupFont(font, size, bold, italic) { private _setupFont(font, size, bold, italic) {
let fontStyle: any = size; let fontStyle: any = size;
fontStyle += "px "; fontStyle += "px ";
...@@ -602,7 +682,7 @@ export class TextField extends Sprite { ...@@ -602,7 +682,7 @@ export class TextField extends Sprite {
if (!text) { if (!text) {
s.canvas.width = 0; s.canvas.width = 0;
s.canvas.height = 0; s.canvas.height = 0;
if(!this._width && !this._height){ if (!this._width && !this._height) {
s._localBoundsSelf.clear(); s._localBoundsSelf.clear();
} }
this.anchorTexture = {x: 0, y: 0}; this.anchorTexture = {x: 0, y: 0};
...@@ -653,7 +733,7 @@ export class TextField extends Sprite { ...@@ -653,7 +733,7 @@ export class TextField extends Sprite {
} }
} else { } else {
//textWidth取每行最大值,如果没设置过textWidth //textWidth取每行最大值,如果没设置过textWidth
const shouldMeasureTextWidth = !s._width && s._width != 0 ? true : false; const shouldMeasureTextWidth = !s._width && s._width != 0;
let index = 0; let index = 0;
for (let i = 0, l = hardLines.length; i < l; i++) { for (let i = 0, l = hardLines.length; i < l; i++) {
let str = hardLines[i]; let str = hardLines[i];
...@@ -665,7 +745,7 @@ export class TextField extends Sprite { ...@@ -665,7 +745,7 @@ export class TextField extends Sprite {
index++; index++;
} }
if (shouldMeasureTextWidth) { if (shouldMeasureTextWidth) {
textWidth = Math.max(lineWidth, textWidth); textWidth = lineWidth;
} }
} }
index = 0; index = 0;
...@@ -742,6 +822,12 @@ export class TextField extends Sprite { ...@@ -742,6 +822,12 @@ export class TextField extends Sprite {
} }
} }
ctx.setTransform(1, 0, 0, 1, tx + padding, padding); ctx.setTransform(1, 0, 0, 1, tx + padding, padding);
if (this._shadowBlur > 0) {
ctx.shadowBlur = this._shadowBlur;
ctx.shadowColor = this._shadowColor;
ctx.shadowOffsetX = this._shadowOffset.x;
ctx.shadowOffsetY = this._shadowOffset.y;
}
s._prepContext(ctx); s._prepContext(ctx);
let lineH = s._lineSpacing + s.size; let lineH = s._lineSpacing + s.size;
//如果有_textHeight,就需要应用竖直对齐 //如果有_textHeight,就需要应用竖直对齐
......
...@@ -8,6 +8,7 @@ import {instantiate} from "./view-interpreter"; ...@@ -8,6 +8,7 @@ import {instantiate} from "./view-interpreter";
import {injectProperties, objClone} from "../utils/utils"; import {injectProperties, objClone} from "../utils/utils";
import {devicePixelRatio} from "../../2d/const"; import {devicePixelRatio} from "../../2d/const";
import {Point} from "../../2d/math/Point"; import {Point} from "../../2d/math/Point";
import {alignMgr} from "../decorators/AlignManager";
const propPrefixFilter = ['_', '__', '$']; const propPrefixFilter = ['_', '__', '$'];
const includeProps = ['_width', '_height', 'worldMatrix']; const includeProps = ['_width', '_height', 'worldMatrix'];
...@@ -39,11 +40,15 @@ export class EditorStage extends Node { ...@@ -39,11 +40,15 @@ export class EditorStage extends Node {
this.name = 'editor-stage'; this.name = 'editor-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
this.percentWidth = 100; this.percentWidth = 100;
this.percentHeight = 100; this.percentHeight = 100;
} }
launch(onStart) { launch(onStart) {
Stage.addUpdateObj(alignMgr);
onStart(); onStart();
} }
...@@ -124,7 +129,7 @@ export class EditorStage extends Node { ...@@ -124,7 +129,7 @@ export class EditorStage extends Node {
//console.log('modifyProps:', key, offsetV, node[key]); //console.log('modifyProps:', key, offsetV, node[key]);
} }
} }
node.adjustProxy.adjustLayout(); //node.adjustProxy.adjustLayout();
return true; return true;
} else { } else {
console.warn('node not found:', nodePath); console.warn('node not found:', nodePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment