mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 08:30:06 +00:00
handle opacity setting
This commit is contained in:
@@ -28,18 +28,6 @@ test.describe('Vue Node Custom Colors', () => {
|
|||||||
await expect(comfyPage.canvas).toHaveScreenshot(
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
||||||
'vue-node-custom-color-blue.png'
|
'vue-node-custom-color-blue.png'
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify actual DOM properties for header and body colors
|
|
||||||
const nodeHeader = loadCheckpointNode.locator(
|
|
||||||
'[data-testid^="node-header-"]'
|
|
||||||
)
|
|
||||||
const nodeBody = loadCheckpointNode
|
|
||||||
|
|
||||||
// Header should have blue header color (#223)
|
|
||||||
await expect(nodeHeader).toHaveCSS('background-color', 'rgb(34, 34, 51)')
|
|
||||||
|
|
||||||
// Node body should have blue body color (#335)
|
|
||||||
await expect(nodeBody).toHaveCSS('background-color', 'rgb(51, 51, 85)')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: implement loading node colors from workflow in Vue system
|
// TODO: implement loading node colors from workflow in Vue system
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
{
|
{
|
||||||
transform: `translate(${position.x ?? 0}px, ${(position.y ?? 0) - LiteGraph.NODE_TITLE_HEIGHT}px)`,
|
transform: `translate(${position.x ?? 0}px, ${(position.y ?? 0) - LiteGraph.NODE_TITLE_HEIGHT}px)`,
|
||||||
zIndex: zIndex,
|
zIndex: zIndex,
|
||||||
backgroundColor: nodeBodyBackgroundColor
|
backgroundColor: nodeBodyBackgroundColor,
|
||||||
|
opacity: nodeOpacity
|
||||||
},
|
},
|
||||||
dragStyle
|
dragStyle
|
||||||
]"
|
]"
|
||||||
@@ -233,34 +234,29 @@ const muted = computed((): boolean => nodeData.mode === 2) // NEVER mode
|
|||||||
// Node body background color that exactly replicates LiteGraph's drawNode logic
|
// Node body background color that exactly replicates LiteGraph's drawNode logic
|
||||||
const nodeBodyBackgroundColor = computed(() => {
|
const nodeBodyBackgroundColor = computed(() => {
|
||||||
const colorPaletteStore = useColorPaletteStore()
|
const colorPaletteStore = useColorPaletteStore()
|
||||||
const settingStore = useSettingStore()
|
|
||||||
|
|
||||||
// This replicates the drawNode logic for bgColor
|
// This replicates the drawNode logic for bgColor
|
||||||
let bgColor = nodeData.bgcolor || '' // matches: old_bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR
|
let bgColor = nodeData.bgcolor || '' // matches: old_bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR
|
||||||
|
|
||||||
if (!bgColor) return '' // No color to adjust
|
// Apply light theme background lightening (same as drawNode)
|
||||||
|
if (
|
||||||
// Apply the exact same adjustments as the drawNode monkey patch
|
colorPaletteStore.completedActivePalette.light_theme &&
|
||||||
const adjustments: { lightness?: number; opacity?: number } = {}
|
nodeData.bgcolor
|
||||||
|
) {
|
||||||
// 1. Apply opacity setting (same as drawNode)
|
|
||||||
const opacity = settingStore.get('Comfy.Node.Opacity')
|
|
||||||
if (opacity) adjustments.opacity = opacity
|
|
||||||
|
|
||||||
// 2. Apply light theme background lightening (same as drawNode)
|
|
||||||
if (colorPaletteStore.completedActivePalette.light_theme) {
|
|
||||||
// This matches: "if (old_bgcolor) adjustments.lightness = 0.5"
|
// This matches: "if (old_bgcolor) adjustments.lightness = 0.5"
|
||||||
adjustments.lightness = 0.5
|
bgColor = adjustColor(bgColor, { lightness: 0.5 })
|
||||||
}
|
|
||||||
|
|
||||||
// Apply all adjustments at once: node.bgcolor = adjustColor(bgColor, adjustments)
|
|
||||||
if (Object.keys(adjustments).length > 0) {
|
|
||||||
bgColor = adjustColor(bgColor, adjustments)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bgColor
|
return bgColor
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Node opacity applied to ALL nodes (colored and non-colored) to match LiteGraph
|
||||||
|
const nodeOpacity = computed(() => {
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
const opacity = settingStore.get('Comfy.Node.Opacity')
|
||||||
|
return opacity || 1 // Default to fully opaque if no setting
|
||||||
|
})
|
||||||
|
|
||||||
// Use canvas interactions for proper wheel event handling and pointer event capture control
|
// Use canvas interactions for proper wheel event handling and pointer event capture control
|
||||||
const { handleWheel, shouldHandleNodePointerEvents } = useCanvasInteractions()
|
const { handleWheel, shouldHandleNodePointerEvents } = useCanvasInteractions()
|
||||||
|
|
||||||
|
|||||||
@@ -129,35 +129,27 @@ const tooltipConfig = computed(() => {
|
|||||||
|
|
||||||
// Header style that exactly replicates LiteGraph's drawNode monkey patch logic
|
// Header style that exactly replicates LiteGraph's drawNode monkey patch logic
|
||||||
const headerStyle = computed(() => {
|
const headerStyle = computed(() => {
|
||||||
if (!nodeData?.color) {
|
|
||||||
return { backgroundColor: '' } // Explicitly clear background color
|
|
||||||
}
|
|
||||||
|
|
||||||
const colorPaletteStore = useColorPaletteStore()
|
const colorPaletteStore = useColorPaletteStore()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
|
// Get opacity setting - applies to ALL nodes (colored and non-colored)
|
||||||
|
const opacity = settingStore.get('Comfy.Node.Opacity') || 1
|
||||||
|
|
||||||
|
if (!nodeData?.color) {
|
||||||
|
// Non-colored nodes: only apply opacity
|
||||||
|
return { backgroundColor: '', opacity }
|
||||||
|
}
|
||||||
|
|
||||||
// Start with the original color (same as old_color in drawNode)
|
// Start with the original color (same as old_color in drawNode)
|
||||||
let headerColor = nodeData.color
|
let headerColor = nodeData.color
|
||||||
|
|
||||||
// Apply the exact same adjustments as the drawNode monkey patch
|
// Apply light theme adjustments for colored nodes
|
||||||
const adjustments: { lightness?: number; opacity?: number } = {}
|
|
||||||
|
|
||||||
// 1. Apply opacity setting (same as drawNode)
|
|
||||||
const opacity = settingStore.get('Comfy.Node.Opacity')
|
|
||||||
if (opacity) adjustments.opacity = opacity
|
|
||||||
|
|
||||||
// 2. Apply light theme adjustments (same as drawNode)
|
|
||||||
if (colorPaletteStore.completedActivePalette.light_theme) {
|
if (colorPaletteStore.completedActivePalette.light_theme) {
|
||||||
// This matches: "if (old_color) { node.color = adjustColor(old_color, { lightness: 0.5 }) }"
|
// This matches: "if (old_color) { node.color = adjustColor(old_color, { lightness: 0.5 }) }"
|
||||||
adjustments.lightness = 0.5
|
headerColor = adjustColor(headerColor, { lightness: 0.5 })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply all adjustments at once (matching drawNode's approach)
|
return { backgroundColor: headerColor, opacity }
|
||||||
if (Object.keys(adjustments).length > 0) {
|
|
||||||
headerColor = adjustColor(headerColor, adjustments)
|
|
||||||
}
|
|
||||||
|
|
||||||
return { backgroundColor: headerColor }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const resolveTitle = (info: VueNodeData | undefined) => {
|
const resolveTitle = (info: VueNodeData | undefined) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user