fix: show psd render base overlays
This commit is contained in:
parent
2226ab34c7
commit
5776c852ba
@ -286,6 +286,8 @@ const PREVIEW_STAGE_TARGET_WIDTH = 760;
|
|||||||
const PREVIEW_STAGE_TARGET_HEIGHT = 760;
|
const PREVIEW_STAGE_TARGET_HEIGHT = 760;
|
||||||
const MIN_IMAGE_SCALE = 0.4;
|
const MIN_IMAGE_SCALE = 0.4;
|
||||||
const MAX_IMAGE_SCALE = 3;
|
const MAX_IMAGE_SCALE = 3;
|
||||||
|
const PSD_LAYER_Z_INDEX_STEP = 10;
|
||||||
|
const PSD_RENDER_BASE_Z_INDEX_OFFSET = 5;
|
||||||
const SELECTED_LAYER_INTERACTION_Z_BOOST = 1;
|
const SELECTED_LAYER_INTERACTION_Z_BOOST = 1;
|
||||||
const SELECTED_LAYER_CONTROLS_Z_BOOST = 1000;
|
const SELECTED_LAYER_CONTROLS_Z_BOOST = 1000;
|
||||||
const MIN_TEXT_POSITION_OFFSET = -5000;
|
const MIN_TEXT_POSITION_OFFSET = -5000;
|
||||||
@ -443,10 +445,12 @@ function TemplatePreviewImage({
|
|||||||
decoding = "async",
|
decoding = "async",
|
||||||
fetchPriority,
|
fetchPriority,
|
||||||
loading = "lazy",
|
loading = "lazy",
|
||||||
|
style,
|
||||||
}: {
|
}: {
|
||||||
template: Pick<AgentPsdTemplate, "name" | "previewUrl" | "renderBaseUrl">;
|
template: Pick<AgentPsdTemplate, "name" | "previewUrl" | "renderBaseUrl">;
|
||||||
alt?: string;
|
alt?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
style?: CSSProperties;
|
||||||
width?: number;
|
width?: number;
|
||||||
quality?: number;
|
quality?: number;
|
||||||
preferRenderBase?: boolean;
|
preferRenderBase?: boolean;
|
||||||
@ -479,7 +483,12 @@ function TemplatePreviewImage({
|
|||||||
const src = fallbackUrls[activeUrlIndex] || "";
|
const src = fallbackUrls[activeUrlIndex] || "";
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return (
|
return (
|
||||||
<div aria-label={alt || template.name} className={className} role="img" />
|
<div
|
||||||
|
aria-label={alt || template.name}
|
||||||
|
className={className}
|
||||||
|
role="img"
|
||||||
|
style={style}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const intrinsicSize = Math.max(1, Math.round(width || 1));
|
const intrinsicSize = Math.max(1, Math.round(width || 1));
|
||||||
@ -500,6 +509,7 @@ function TemplatePreviewImage({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
src={src}
|
src={src}
|
||||||
|
style={style}
|
||||||
width={intrinsicSize}
|
width={intrinsicSize}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -2034,9 +2044,21 @@ export function AgentPsdTemplateEditorDialog({
|
|||||||
);
|
);
|
||||||
const layerStackZIndexById = useMemo(() => {
|
const layerStackZIndexById = useMemo(() => {
|
||||||
return new Map(
|
return new Map(
|
||||||
orderedPreviewLayers.map((layer, index) => [layer.id, index + 1])
|
orderedPreviewLayers.map((layer, index) => [
|
||||||
|
layer.id,
|
||||||
|
(index + 1) * PSD_LAYER_Z_INDEX_STEP,
|
||||||
|
])
|
||||||
);
|
);
|
||||||
}, [orderedPreviewLayers]);
|
}, [orderedPreviewLayers]);
|
||||||
|
const renderBaseZIndex = useMemo(() => {
|
||||||
|
const defaultSourceImageLayer = getDefaultSourceImageLayer(
|
||||||
|
selectedTemplateLayers
|
||||||
|
);
|
||||||
|
const defaultSourceImageZIndex = defaultSourceImageLayer
|
||||||
|
? layerStackZIndexById.get(defaultSourceImageLayer.id) || 0
|
||||||
|
: 0;
|
||||||
|
return defaultSourceImageZIndex + PSD_RENDER_BASE_Z_INDEX_OFFSET;
|
||||||
|
}, [layerStackZIndexById, selectedTemplateLayers]);
|
||||||
const shouldShowCompositeFallback = useMemo(
|
const shouldShowCompositeFallback = useMemo(
|
||||||
() =>
|
() =>
|
||||||
orderedVisiblePreviewLayers.length === 0 ||
|
orderedVisiblePreviewLayers.length === 0 ||
|
||||||
@ -4086,6 +4108,7 @@ export function AgentPsdTemplateEditorDialog({
|
|||||||
loading="eager"
|
loading="eager"
|
||||||
preferRenderBase
|
preferRenderBase
|
||||||
quality={68}
|
quality={68}
|
||||||
|
style={{ zIndex: renderBaseZIndex }}
|
||||||
template={selectedTemplate}
|
template={selectedTemplate}
|
||||||
width={960}
|
width={960}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user