import type { Gizmo } from './gizmo'; import type { FrameCreateData, ItemCreateType, TextCreateData } from './gizmos/item-create-gizmo'; import type { AutoLayoutChangeInfo } from './selection/assisted-layout'; import type { TransformType } from './gizmos/resize-selection-gizmo/transform-types'; import type { InputEventKey } from '@galacean/effects'; export type GizmoActionPhase = 'actionstart' | 'actionupdate' | 'actioncommit'; export type GizmoFrameItemCreateInfo = { type: ItemCreateType.FRAME; id: string; position: [number, number]; info: FrameCreateData; }; export type GizmoTextItemCreateInfo = { type: ItemCreateType.TEXT; id: string; position: [number, number]; info?: TextCreateData; }; export type GizmoSimpleItemCreateInfo = { type: ItemCreateType.IMAGE_GENERATOR | ItemCreateType.VIDEO_GENERATOR | ItemCreateType.NONE; id: string; position: [number, number]; info?: undefined; }; /** 创建类型本身就是判别字段;调用方按 type 分支后可直接读取对应 info。 */ export type GizmoItemCreateInfo = GizmoFrameItemCreateInfo | GizmoTextItemCreateInfo | GizmoSimpleItemCreateInfo; /** Base event shared by all semantic Gizmo actions. */ export interface GizmoActionEvent { source: Gizmo; } export interface GizmoTransformActionEvent extends GizmoActionEvent { transformType: TransformType; autoLayoutChange?: AutoLayoutChangeInfo; } export interface GizmoSelectionActionEvent extends GizmoActionEvent { selectedIds: string[]; oldSelectedIds?: string[]; } export interface GizmoItemCreateActionEvent extends GizmoActionEvent { createInfo: GizmoItemCreateInfo; /** 拖拽被系统取消时,接收方应撤销已实时创建的元素。 */ canceled?: boolean; } export interface GizmoMoveInEvent extends GizmoActionEvent { type: 'moveIn'; itemIds: string[]; targetFrameId: string; } export interface GizmoMoveOutEvent extends GizmoActionEvent { type: 'moveOut'; itemIds: string[]; originalFrameId: string; } export interface GizmoDetachGroupChildrenEvent extends GizmoActionEvent { type: 'detachGroupChildren'; groupId: string; itemIds: string[]; originalFrameId: string; } export type GizmoPlacementChangeEvent = GizmoMoveInEvent | GizmoMoveOutEvent | GizmoDetachGroupChildrenEvent; export interface GizmoFrameRefreshChildrenEvent extends GizmoActionEvent { frameId: string; } export interface GizmoTextInputEvent extends GizmoActionEvent { itemId: string; text: string; fontFamily: string; } export interface GizmoVideoPlayEvent extends GizmoActionEvent { id: string; time: number; } export interface GizmoSpriteTextClickEvent extends GizmoActionEvent { info?: { id: string; index: number; text: string; }; } export type GizmoActionLifecycleEvent = GizmoActionEvent | GizmoTransformActionEvent | GizmoSelectionActionEvent | GizmoItemCreateActionEvent; export type GizmoOwnerEvents = { keyDown: [InputEventKey]; keyUp: [InputEventKey]; actionstart: [GizmoActionLifecycleEvent]; actionupdate: [GizmoActionLifecycleEvent]; actioncommit: [GizmoActionLifecycleEvent]; placementchange: [GizmoPlacementChangeEvent]; framerefreshchildren: [GizmoFrameRefreshChildrenEvent]; textinput: [GizmoTextInputEvent]; videoplay: [GizmoVideoPlayEvent]; spritetextclick: [GizmoSpriteTextClickEvent]; };