/** * Copyright (c) 2019-present Houfeng * @author Houfeng */ import { IAnimation } from "../Stage/IAnimation"; import { ISceneModel } from "./ISceneModel"; import { IShapeModel, ShapeModel } from "../Shape"; import { IStageModel } from "../Stage/IStageModel"; import { ITransition } from "../Transition/ITransition"; import { SceneStates } from "./SceneStates"; import { Selection } from "../Selectable"; import { ShapeUpdateContext } from "../CommandMgr"; /** * Scene 模型类 * 通过 Scene 模型,可对当前 Scene 下的 Shapes 进行 CRUD 操作 */ export declare class SceneModel implements ISceneModel { /** * 对应的 HTML 元素 */ private __element; /** * 对应的 HTML 元素 */ get element(): Element; /** * 设置对应的 HTML 元素 */ setElement: (value: Element) => void; private __stage; get stage(): IStageModel; /** * 是否跳过 */ skip: boolean; /** * 切换是否跳过 */ toggleSkip(): boolean; /** * Scene 的当前状态 */ state: SceneStates; /** * 选中当前 Scene */ select(): void; /** * SceneId (自动生成) */ id: string; /** * 描述信息(一般用于演讲者备注) */ description: string; /** * Scene 背景 */ background: string; /** * 转场动画 */ transition: ITransition; /** * 当前 Scene 中的所有 Shape 动画集合 */ animations: IAnimation[]; /** * 当前 Scene 中的所有 Shapes */ shapes: ShapeModel[]; /** * 当前选区信息 */ selection: Selection; /** * 附加内容 */ attachment: any; /** * 通过初始数据构建一个 SceneModel 实例 * @param stage 所属 stage * @param data SceneModel 数据 */ constructor(stage: IStageModel, data: ISceneModel); /** * 添加一个新的 Shape * @param data 图形模型初始化数据 * @param options 选项 */ addShape: (data: IShapeModel | IShapeModel[], options?: { index?: number | number[]; track?: boolean; active?: boolean; }) => ShapeModel[]; /** * 通过 index 删除一个 Shape * @param index 将要删除的 Shape 的 index */ delShapeByIndex: (index: number) => ShapeModel; /** * 通过 id 删除一个 Shape * @param id SceneId */ delShapeById: (id: string) => ShapeModel; /** * 删除一组图形 */ delShapes: (items: IShapeModel[], options?: { track?: boolean; }) => IShapeModel[]; /** * 删除所有活动中的图形 */ delActiveShapes: () => IShapeModel[]; /** * 删除所有选中的图形 */ delSeletedShapes: () => IShapeModel[]; /** * 当前 tack context ,用于防止多重 track */ private __trackingContext; clean(options?: { track?: boolean; }): void; /** * 跟踪形状变更并放到 undo/redo 栈中 * 默认为当前活动中的图形 * @param handler 包裹函数 * @param keys 追踪的属性 * @param shapes 图形 */ track: (handler: Function, keys?: string[], shapes?: ShapeModel[]) => any; /** * 创建形状变更追踪上下文 * @param keys 追踪的属性 * @param shapes 图形 */ createUpdateContext(keys?: string[], shapes?: ShapeModel[]): ShapeUpdateContext; /** * 移动选中的图形 * @param x 横坐标移动的距离 * @param y 纵坐标移的距离 */ moveSelectedShapes: (x: number, y: number, shapes?: ShapeModel[]) => ShapeModel[]; /** * 选中所有图形 */ selectAll: () => void; unSelectAll: () => void; /** * 通过初始数据创建一个 ShapeModel 实例 * @param data 初始数据 */ createShapeModel: (data: IShapeModel) => ShapeModel; /** * 创建所有 Shape 实例 */ protected createShapeModels(): void; /** * 所有激活中的图形 */ get activeShapes(): ShapeModel[]; /** * 所有选中的图形 */ get selectedShapes(): ShapeModel[]; /** * 所有正在移动的图形 */ get moveingShapes(): ShapeModel[]; /** * 正在编辑的图形 */ get editingShape(): ShapeModel; changeShapeIndex: (shape: ShapeModel, toIndex: number) => void; offsetShapes(shapes: ShapeModel[], offset: number | number[], options?: { track?: boolean; }): void; forward: (shapes?: ShapeModel[], options?: { track?: boolean; }) => void; backward: (shapes?: ShapeModel[], options?: { track?: boolean; }) => void; foremost: (shapes?: ShapeModel[], options?: { track?: boolean; }) => void; last: (shapes?: ShapeModel[], options?: { track?: boolean; }) => void; /** * 左对齐一组图形 */ alignToLeft: (shapes?: ShapeModel[]) => void; /** * 右对齐一组图形 */ alignToRight: (shapes?: ShapeModel[]) => void; /** * 水平居中一组图形 */ alignToCenter: (shapes?: ShapeModel[]) => void; alignToTop: (shapes?: ShapeModel[]) => void; alignToBottom: (shapes?: ShapeModel[]) => void; alignToMiddle: (shapes?: ShapeModel[]) => void; distributeHorizontal: (shapes?: ShapeModel[]) => void; distributeVertical: (shapes?: ShapeModel[]) => void; makeGroup: (shapes?: ShapeModel[]) => void; unmakeGroup: (shapes?: ShapeModel[]) => void; toJSON(): { id: string; background: string; description: string; animations: IAnimation[]; transition: ITransition; shapes: ShapeModel[]; attachment: any; }; }