From 7f8903e9bea67af842945c4651ead91672008206 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Tue, 5 May 2026 17:55:39 +0800 Subject: [PATCH] feat: add Input device setting for canvas navigation --- src/components/common/FormItem.vue | 12 +- .../settings/TabGlobalSettings.vue | 46 ++++++++ src/lib/litegraph/src/CanvasPointer.ts | 7 ++ src/lib/litegraph/src/LGraphCanvas.ts | 18 ++- src/lib/litegraph/src/LiteGraphGlobal.ts | 9 ++ src/locales/en/main.json | 1 + src/locales/en/settings.json | 10 ++ .../settings/components/SettingItem.vue | 15 +-- .../composables/useInputDeviceDetection.ts | 11 ++ .../composables/useLitegraphSettings.ts | 32 +++--- .../settings/constants/coreSettings.ts | 104 +++++++----------- src/platform/settings/types.ts | 4 +- .../core/canvas/useCanvasInteractions.test.ts | 12 +- .../core/canvas/useCanvasInteractions.ts | 2 +- src/schemas/apiSchema.ts | 1 + 15 files changed, 180 insertions(+), 104 deletions(-) create mode 100644 src/platform/settings/composables/useInputDeviceDetection.ts diff --git a/src/components/common/FormItem.vue b/src/components/common/FormItem.vue index c3c76afe84..854dab3db9 100644 --- a/src/components/common/FormItem.vue +++ b/src/components/common/FormItem.vue @@ -68,19 +68,19 @@ function getFormAttrs(item: FormItem) { } switch (item.type) { case 'combo': - case 'radio': - attrs['options'] = + case 'radio': { + const resolvedOptions = typeof item.options === 'function' - ? // @ts-expect-error: Audit and deprecate usage of legacy options type: - // (value) => [string | {text: string, value: string}] - item.options(formValue.value) + ? item.options(formValue.value) : item.options + attrs['options'] = resolvedOptions - if (typeof item.options?.[0] !== 'string') { + if (typeof resolvedOptions?.[0] !== 'string') { attrs['optionLabel'] = 'text' attrs['optionValue'] = 'value' } break + } } return attrs } diff --git a/src/components/rightSidePanel/settings/TabGlobalSettings.vue b/src/components/rightSidePanel/settings/TabGlobalSettings.vue index 49422821c7..1e92bc12ba 100644 --- a/src/components/rightSidePanel/settings/TabGlobalSettings.vue +++ b/src/components/rightSidePanel/settings/TabGlobalSettings.vue @@ -9,6 +9,7 @@ import Slider from '@/components/ui/slider/Slider.vue' import { LiteGraph } from '@/lib/litegraph/src/litegraph' import type { LinkRenderType } from '@/lib/litegraph/src/types/globalEnums' import { LinkMarkerShape } from '@/lib/litegraph/src/types/globalEnums' +import { useInputDeviceDetection } from '@/platform/settings/composables/useInputDeviceDetection' import { useSettingStore } from '@/platform/settings/settingStore' import { WidgetInputBaseClass } from '@/renderer/extensions/vueNodes/widgets/components/layout' import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog' @@ -40,6 +41,33 @@ const nodes2Enabled = computed({ }) // CANVAS settings +const inputDevice = computed({ + get: () => settingStore.get('Comfy.Graph.WheelInputMode'), + set: (value) => settingStore.set('Comfy.Graph.WheelInputMode', value) +}) + +const { detectedInputDevice } = useInputDeviceDetection() + +const inputDeviceOptions = computed(() => [ + { + value: 'auto', + label: + detectedInputDevice.value === 'trackpad' + ? t( + 'settings.Comfy_Graph_WheelInputMode.options.Auto-detect (Trackpad)' + ) + : t('settings.Comfy_Graph_WheelInputMode.options.Auto-detect (Mouse)') + }, + { + value: 'mouse', + label: t('settings.Comfy_Graph_WheelInputMode.options.Mouse') + }, + { + value: 'trackpad', + label: t('settings.Comfy_Graph_WheelInputMode.options.Trackpad') + } +]) + const gridSpacing = computed({ get: () => settingStore.get('Comfy.SnapToGrid.GridSize'), set: (value) => settingStore.set('Comfy.SnapToGrid.GridSize', value) @@ -128,6 +156,24 @@ function openFullSettings() { {{ t('rightSidePanel.globalSettings.canvas') }}
+ +