|
@@ -15,22 +15,45 @@
|
|
|
import { SGraphyItem, SGraphyScene, SGraphyView } from "@saga-web/graphy";
|
|
|
import { SGraphyCommand } from "@saga-web/graphy/lib";
|
|
|
import { SUndoCommand } from "@saga-web/base/lib";
|
|
|
- import {SPoint} from "@saga-web/draw/lib";
|
|
|
+ import { SPoint } from "@saga-web/draw/lib";
|
|
|
|
|
|
- class TextItem extends SGraphyItem {
|
|
|
+ class TextItem extends SObjectItem {
|
|
|
/** 宽度 */
|
|
|
width = 100;
|
|
|
/** 高度 */
|
|
|
height = 100;
|
|
|
/** 文本内容 */
|
|
|
- _text: string = "";
|
|
|
+ private _text: string = "";
|
|
|
get text(): string {
|
|
|
return this._text;
|
|
|
}
|
|
|
- set text(v: string): void {
|
|
|
+ set text(v: string) {
|
|
|
this._text = v;
|
|
|
this.update();
|
|
|
}
|
|
|
+
|
|
|
+ /** 文本颜色 */
|
|
|
+ private _color: string ="#333333";
|
|
|
+ get color():string {
|
|
|
+ return this._color;
|
|
|
+ }
|
|
|
+ set color(v: string) {
|
|
|
+ this._color = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 字体 */
|
|
|
+ private _font: SFont;
|
|
|
+ get font():SFont {
|
|
|
+ return this._font;
|
|
|
+ }
|
|
|
+ set font(v: SFont) {
|
|
|
+ this._font = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 文本绘制最大宽 */
|
|
|
+ maxWidth: number | undefined = undefined;
|
|
|
|
|
|
/**
|
|
|
* 构造函数
|
|
@@ -77,7 +100,7 @@
|
|
|
canvas.drawRect(0, 0, this.width, this.height);
|
|
|
canvas.brush.color = SColor.Yellow;
|
|
|
canvas.font.textBaseLine = STextBaseLine.Top;
|
|
|
- canvas.drawText(this.text, 0, 0);
|
|
|
+ canvas.drawText(this.text, 0, 0 , this.maxWidth);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -87,6 +110,7 @@
|
|
|
|
|
|
constructor() {
|
|
|
super();
|
|
|
+ this.textItem.maxWidth = 100;
|
|
|
this.addItem(this.textItem);
|
|
|
this.textItem.connect("onMove", this, this.onItemMove.bind(this));
|
|
|
}
|
|
@@ -111,16 +135,16 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- class SGraphyPropertyCommand extends SGraphyCommand {
|
|
|
+ class SGraphyPropertyCommand<T> extends SGraphyCommand {
|
|
|
item: SGraphyItem;
|
|
|
/** 属性名称 */
|
|
|
propName: string;
|
|
|
/** 属性旧值 */
|
|
|
- oldProp: <T>;
|
|
|
+ oldProp: T;
|
|
|
/** 属性新值 */
|
|
|
- newProp: <T>;
|
|
|
+ newProp: T;
|
|
|
|
|
|
- constructor(scene: SGraphyScene, item: SGraphyItem, propName: string, oldProp: <T>, newProp: <T>) {
|
|
|
+ constructor(scene: SGraphyScene, item: SGraphyItem, propName: string, oldProp: T, newProp: T) {
|
|
|
super(scene);
|
|
|
this.item = item;
|
|
|
this.propName = propName;
|