mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 17:10:06 +00:00
fix: add GLSLShader to canvas image preview node types (#9198)
## Summary Add `GLSLShader` to `CANVAS_IMAGE_PREVIEW_NODE_TYPES` so GLSL shader previews are promoted through subgraph nodes. ## Changes - Add `'GLSLShader'` to the `CANVAS_IMAGE_PREVIEW_NODE_TYPES` set in `src/composables/node/useNodeCanvasImagePreview.ts` ## Context GLSLShader node previews were not showing on parent subgraph nodes because `CANVAS_IMAGE_PREVIEW_NODE_TYPES` only included `PreviewImage` and `SaveImage`. The `$$canvas-image-preview` pseudo-widget was never created for GLSLShader nodes, so the promotion system had nothing to promote. This degraded the UX of all 12 shipped GLSL blueprint subgraphs — users couldn't see shader output previews without expanding the subgraph. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9198-fix-add-GLSLShader-to-canvas-image-preview-node-types-3126d73d3650817dbe9beab4bdeaa414) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -4,6 +4,7 @@ import type {
|
||||
IBaseWidget,
|
||||
IWidgetOptions
|
||||
} from '@/lib/litegraph/src/types/widgets'
|
||||
import type { DrawWidgetOptions } from '@/lib/litegraph/src/widgets/BaseWidget'
|
||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
@@ -77,7 +78,9 @@ const renderPreview = (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
node: LGraphNode,
|
||||
shiftY: number,
|
||||
computedHeight: number | undefined
|
||||
computedHeight: number | undefined,
|
||||
imgs: HTMLImageElement[],
|
||||
width: number
|
||||
) => {
|
||||
if (!node.size) return
|
||||
|
||||
@@ -99,7 +102,6 @@ const renderPreview = (
|
||||
node.pointerDown = null
|
||||
}
|
||||
|
||||
const imgs = node.imgs ?? []
|
||||
if (imgs.length === 0) return
|
||||
|
||||
let { imageIndex } = node
|
||||
@@ -112,7 +114,7 @@ const renderPreview = (
|
||||
const settingStore = useSettingStore()
|
||||
const allowImageSizeDraw = settingStore.get('Comfy.Node.AllowImageSizeDraw')
|
||||
const IMAGE_TEXT_SIZE_TEXT_HEIGHT = allowImageSizeDraw ? 15 : 0
|
||||
const dw = node.size[0]
|
||||
const dw = width
|
||||
const dh = computedHeight ? computedHeight - IMAGE_TEXT_SIZE_TEXT_HEIGHT : 0
|
||||
|
||||
if (imageIndex == null) {
|
||||
@@ -358,8 +360,29 @@ class ImagePreviewWidget extends BaseWidget {
|
||||
this.serialize = false
|
||||
}
|
||||
|
||||
override drawWidget(ctx: CanvasRenderingContext2D): void {
|
||||
renderPreview(ctx, this.node, this.y, this.computedHeight)
|
||||
override drawWidget(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
options: DrawWidgetOptions
|
||||
): void {
|
||||
const imgs = options.previewImages ?? this.node.imgs ?? []
|
||||
renderPreview(
|
||||
ctx,
|
||||
this.node,
|
||||
this.y,
|
||||
this.computedHeight,
|
||||
imgs,
|
||||
options.width
|
||||
)
|
||||
}
|
||||
|
||||
override createCopyForNode(node: LGraphNode): this {
|
||||
const copy = new ImagePreviewWidget(
|
||||
node,
|
||||
this.name,
|
||||
this.options as IWidgetOptions<string | object>
|
||||
) as this
|
||||
copy.value = this.value
|
||||
return copy
|
||||
}
|
||||
|
||||
override onPointerDown(pointer: CanvasPointer, node: LGraphNode): boolean {
|
||||
|
||||
Reference in New Issue
Block a user