mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 07:00:23 +00:00
* feat: use a physical min font size as the LOD threshold instead of an abritrary zoom level that is different on different screens * feat: min 1px font size, max 24ox font size * refactor: settings text * refactor: settings text * refactor: version * fix: default font size from 10 to 8 * feat: cache the threshold and move it's calculation out of the render loop * refactor: comments * refactor: removed package-lock * refactor: improve how we manage deprecated settings, and removed any types * refactor: how the migration settings formula works so we get prev settings closer to the new font size setting * test: add in zoom and settings test for LOD * refactor: tests to use best practices * Update test expectations [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
145 lines
3.7 KiB
TypeScript
145 lines
3.7 KiB
TypeScript
import { watchEffect } from 'vue'
|
|
|
|
import {
|
|
CanvasPointer,
|
|
LGraphNode,
|
|
LiteGraph
|
|
} from '@/lib/litegraph/src/litegraph'
|
|
import { useCanvasStore } from '@/stores/graphStore'
|
|
import { useSettingStore } from '@/stores/settingStore'
|
|
|
|
/**
|
|
* Watch for changes in the setting store and update the LiteGraph settings accordingly.
|
|
*/
|
|
export const useLitegraphSettings = () => {
|
|
const settingStore = useSettingStore()
|
|
const canvasStore = useCanvasStore()
|
|
|
|
watchEffect(() => {
|
|
const canvasInfoEnabled = settingStore.get('Comfy.Graph.CanvasInfo')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.show_info = canvasInfoEnabled
|
|
canvasStore.canvas.draw(false, true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const zoomSpeed = settingStore.get('Comfy.Graph.ZoomSpeed')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.zoom_speed = zoomSpeed
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.snaps_for_comfy = settingStore.get(
|
|
'Comfy.Node.AutoSnapLinkToSlot'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.snap_highlights_node = settingStore.get(
|
|
'Comfy.Node.SnapHighlightsNode'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LGraphNode.keepAllLinksOnBypass = settingStore.get(
|
|
'Comfy.Node.BypassAllLinksOnDelete'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.middle_click_slot_add_default_node = settingStore.get(
|
|
'Comfy.Node.MiddleClickRerouteNode'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const linkRenderMode = settingStore.get('Comfy.LinkRenderMode')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.links_render_mode = linkRenderMode
|
|
canvasStore.canvas.setDirty(/* fg */ false, /* bg */ true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const minFontSizeForLOD = settingStore.get(
|
|
'LiteGraph.Canvas.MinFontSizeForLOD'
|
|
)
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.min_font_size_for_lod = minFontSizeForLOD
|
|
canvasStore.canvas.setDirty(/* fg */ true, /* bg */ true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const linkMarkerShape = settingStore.get('Comfy.Graph.LinkMarkers')
|
|
const { canvas } = canvasStore
|
|
if (canvas) {
|
|
canvas.linkMarkerShape = linkMarkerShape
|
|
canvas.setDirty(false, true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const maximumFps = settingStore.get('LiteGraph.Canvas.MaximumFps')
|
|
const { canvas } = canvasStore
|
|
if (canvas) canvas.maximumFps = maximumFps
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const dragZoomEnabled = settingStore.get('Comfy.Graph.CtrlShiftZoom')
|
|
const { canvas } = canvasStore
|
|
if (canvas) canvas.dragZoomEnabled = dragZoomEnabled
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.doubleClickTime = settingStore.get(
|
|
'Comfy.Pointer.DoubleClickTime'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.bufferTime = settingStore.get('Comfy.Pointer.ClickBufferTime')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.maxClickDrift = settingStore.get('Comfy.Pointer.ClickDrift')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.CANVAS_GRID_SIZE = settingStore.get('Comfy.SnapToGrid.GridSize')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.alwaysSnapToGrid = settingStore.get('pysssss.SnapToGrid')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.context_menu_scaling = settingStore.get(
|
|
'LiteGraph.ContextMenu.Scaling'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.Reroute.maxSplineOffset = settingStore.get(
|
|
'LiteGraph.Reroute.SplineOffset'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const navigationMode = settingStore.get('Comfy.Canvas.NavigationMode') as
|
|
| 'standard'
|
|
| 'legacy'
|
|
|
|
LiteGraph.canvasNavigationMode = navigationMode
|
|
LiteGraph.macTrackpadGestures = navigationMode === 'standard'
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.saveViewportWithGraph = settingStore.get(
|
|
'Comfy.EnableWorkflowViewRestore'
|
|
)
|
|
})
|
|
}
|