补齐快速编辑重绘契约
恢复快速编辑面板的模式与重绘产物状态字段 补回快速编辑结果图层工厂
This commit is contained in:
@@ -265,6 +265,7 @@ export type GenerateDialogState = {
|
|||||||
assetLabel?: string;
|
assetLabel?: string;
|
||||||
status: 'idle' | 'generating' | 'pending-confirmation' | 'failed';
|
status: 'idle' | 'generating' | 'pending-confirmation' | 'failed';
|
||||||
composerOpen?: boolean;
|
composerOpen?: boolean;
|
||||||
|
isRedrawAsNewArtifact?: boolean;
|
||||||
sourceLayerId?: string;
|
sourceLayerId?: string;
|
||||||
generatedLayerId?: string;
|
generatedLayerId?: string;
|
||||||
specType?: SpecGenerationType;
|
specType?: SpecGenerationType;
|
||||||
@@ -444,6 +445,7 @@ export type CanvasContextMenuState =
|
|||||||
|
|
||||||
export type QuickEditPanelState = {
|
export type QuickEditPanelState = {
|
||||||
referenceUploadContextId?: string;
|
referenceUploadContextId?: string;
|
||||||
|
mode?: 'quick-edit' | 'redraw';
|
||||||
sourceLayerId: string;
|
sourceLayerId: string;
|
||||||
prompt: string;
|
prompt: string;
|
||||||
assetLabel?: string;
|
assetLabel?: string;
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ type GeneratedResultLayerOptions = {
|
|||||||
generationInputs?: CanvasGenerationInputs;
|
generationInputs?: CanvasGenerationInputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type QuickEditResultLayerOptions = {
|
||||||
|
generated: EditorImageGenerationResult;
|
||||||
|
generatedIndex: number;
|
||||||
|
sourceLayer: CanvasLayer;
|
||||||
|
generationInputs: CanvasGenerationInputs;
|
||||||
|
mode?: 'quick-edit' | 'redraw';
|
||||||
|
frame?: GenerateDialogState['placeholder'];
|
||||||
|
title?: string;
|
||||||
|
};
|
||||||
|
|
||||||
type IconSpritesheetResultLayerOptions = {
|
type IconSpritesheetResultLayerOptions = {
|
||||||
generated: EditorIconSpritesheetGenerationResult;
|
generated: EditorIconSpritesheetGenerationResult;
|
||||||
iconResults?: EditorIconSpritesheetIconResult[] | null;
|
iconResults?: EditorIconSpritesheetIconResult[] | null;
|
||||||
@@ -173,6 +183,67 @@ export function createGeneratedResultLayer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createQuickEditResultLayer({
|
||||||
|
generated,
|
||||||
|
generatedIndex,
|
||||||
|
sourceLayer,
|
||||||
|
generationInputs,
|
||||||
|
mode = 'quick-edit',
|
||||||
|
frame,
|
||||||
|
title,
|
||||||
|
}: QuickEditResultLayerOptions): CanvasLayer {
|
||||||
|
const originalWidth =
|
||||||
|
frame?.originalWidth ||
|
||||||
|
generated.width ||
|
||||||
|
sourceLayer.originalWidth ||
|
||||||
|
1024;
|
||||||
|
const originalHeight =
|
||||||
|
frame?.originalHeight ||
|
||||||
|
generated.height ||
|
||||||
|
sourceLayer.originalHeight ||
|
||||||
|
1024;
|
||||||
|
const { width, height } = resolveLayerResolutionSize(
|
||||||
|
originalWidth,
|
||||||
|
originalHeight,
|
||||||
|
{
|
||||||
|
width: sourceLayer.width,
|
||||||
|
height: sourceLayer.height,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const frameX =
|
||||||
|
frame && frame.width > 0
|
||||||
|
? frame.x + frame.width / 2 - width / 2
|
||||||
|
: undefined;
|
||||||
|
const frameY =
|
||||||
|
frame && frame.height > 0
|
||||||
|
? frame.y + frame.height / 2 - height / 2
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
return applyGeneratedMetadata(
|
||||||
|
{
|
||||||
|
id: `layer-quick-edit-${generatedIndex}`,
|
||||||
|
resourceId: `local-resource-quick-edit-${generatedIndex}`,
|
||||||
|
title:
|
||||||
|
title ??
|
||||||
|
`${sourceLayer.title} ${mode === 'redraw' ? '重绘' : '快速编辑'}`,
|
||||||
|
src: generated.imageSrc,
|
||||||
|
x: frameX ?? sourceLayer.x + sourceLayer.width + 32,
|
||||||
|
y: frameY ?? sourceLayer.y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
originalWidth,
|
||||||
|
originalHeight,
|
||||||
|
zIndex: generatedIndex + 10,
|
||||||
|
sourceType: generated.sourceType,
|
||||||
|
sourceResourceId: sourceLayer.resourceId,
|
||||||
|
groupId: sourceLayer.groupId,
|
||||||
|
assetKind: sourceLayer.assetKind,
|
||||||
|
},
|
||||||
|
generated,
|
||||||
|
generationInputs,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function applyImageEditResultToSourceLayer({
|
export function applyImageEditResultToSourceLayer({
|
||||||
generated,
|
generated,
|
||||||
sourceLayer,
|
sourceLayer,
|
||||||
|
|||||||
Reference in New Issue
Block a user