Line data Source code
1 : <script setup lang="ts">
2 : import { computed } from 'vue'
3 : import { useI18n } from 'vue-i18n'
4 :
5 : import Button from '@comfyorg/design-system/button/Button'
6 : import Slider from '@comfyorg/design-system/slider/Slider'
7 : import AppSingleSelect from '@/components/common/AppSingleSelect.vue'
8 : import NumberField from '@comfyorg/design-system/number-field/NumberField'
9 : import NumberFieldInput from '@comfyorg/design-system/number-field/NumberFieldInput'
10 : import { LiteGraph } from '@/lib/litegraph/src/litegraph'
11 : import type { LinkRenderType } from '@comfyorg/graph-model/globalEnums'
12 : import { LinkMarkerShape } from '@comfyorg/graph-model/globalEnums'
13 : import { useSettingStore } from '@/platform/settings/settingStore'
14 : import { WidgetInputBaseClass } from '@/renderer/extensions/vueNodes/widgets/components/layout'
15 : import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog'
16 : import { cn } from '@comfyorg/tailwind-utils'
17 :
18 : import PropertiesAccordionItem from '@comfyorg/design-system/accordion/PropertiesAccordionItem'
19 : import FieldSwitch from '@comfyorg/design-system/field/FieldSwitch'
20 : import LayoutField from '@comfyorg/design-system/field/LayoutField'
21 :
22 5 : const { t } = useI18n()
23 5 : const settingStore = useSettingStore()
24 5 : const settingsDialog = useSettingsDialog()
25 :
26 : // NODES settings
27 5 : const showAdvancedParameters = computed({
28 : get: () => settingStore.get('Comfy.Node.AlwaysShowAdvancedWidgets'),
29 : set: (value) =>
30 : settingStore.set('Comfy.Node.AlwaysShowAdvancedWidgets', value)
31 : })
32 :
33 5 : const showToolbox = computed({
34 : get: () => settingStore.get('Comfy.Canvas.SelectionToolbox'),
35 : set: (value) => settingStore.set('Comfy.Canvas.SelectionToolbox', value)
36 : })
37 :
38 5 : const nodes2Enabled = computed({
39 : get: () => settingStore.get('Comfy.VueNodes.Enabled'),
40 : set: (value) => settingStore.set('Comfy.VueNodes.Enabled', value)
41 : })
42 :
43 : // CANVAS settings
44 5 : const gridSpacing = computed({
45 : get: () => settingStore.get('Comfy.SnapToGrid.GridSize'),
46 : set: (value) => settingStore.set('Comfy.SnapToGrid.GridSize', value)
47 : })
48 :
49 5 : const snapToGrid = computed({
50 : get: () => settingStore.get('pysssss.SnapToGrid'),
51 : set: (value) => settingStore.set('pysssss.SnapToGrid', value)
52 : })
53 :
54 : // CONNECTION LINKS settings
55 5 : const linkShape = computed({
56 : get: () => settingStore.get('Comfy.Graph.LinkMarkers'),
57 : set: (value) => settingStore.set('Comfy.Graph.LinkMarkers', value)
58 : })
59 :
60 5 : const linkShapeOptions = computed(() => [
61 : { value: LinkMarkerShape.None, name: t('g.none') },
62 : { value: LinkMarkerShape.Circle, name: t('shape.circle') },
63 : { value: LinkMarkerShape.Arrow, name: t('shape.arrow') }
64 : ])
65 :
66 5 : let theOldLinkRenderMode: LinkRenderType = LiteGraph.SPLINE_LINK
67 5 : const showConnectedLinks = computed({
68 : get: () => settingStore.get('Comfy.LinkRenderMode') !== LiteGraph.HIDDEN_LINK,
69 : set: (value) => {
70 0 : let oldLinkRenderMode = settingStore.get('Comfy.LinkRenderMode')
71 0 : if (oldLinkRenderMode !== LiteGraph.HIDDEN_LINK) {
72 0 : theOldLinkRenderMode = oldLinkRenderMode
73 : }
74 0 : const newMode = value ? theOldLinkRenderMode : LiteGraph.HIDDEN_LINK
75 0 : settingStore.set('Comfy.LinkRenderMode', newMode)
76 : }
77 : })
78 :
79 2355 : const GRID_SIZE_MIN = 1
80 2355 : const GRID_SIZE_MAX = 100
81 2355 : const GRID_SIZE_STEP = 1
82 :
83 0 : function updateGridSpacingFromSlider(values?: number[]) {
84 0 : if (!values?.length) return
85 0 : gridSpacing.value = values[0]
86 : }
87 :
88 0 : function openFullSettings() {
89 0 : settingsDialog.show()
90 : }
91 5 : </script>
92 :
93 : <template>
94 5 : <div class="flex flex-col border-t">
95 : <!-- NODES Section -->
96 : <PropertiesAccordionItem class="border-b">
97 : <template #label>
98 : {{ t('rightSidePanel.globalSettings.nodes') }}
99 : </template>
100 : <div class="space-y-4 px-4 py-3">
101 : <FieldSwitch
102 : v-model="showAdvancedParameters"
103 : :label="t('rightSidePanel.globalSettings.showAdvanced')"
104 : :tooltip="t('settings.Comfy_Node_AlwaysShowAdvancedWidgets.tooltip')"
105 : />
106 : <FieldSwitch
107 : v-model="showToolbox"
108 : :label="t('rightSidePanel.globalSettings.showToolbox')"
109 : :tooltip="t('settings.Comfy_Canvas_SelectionToolbox.tooltip')"
110 : />
111 : <FieldSwitch
112 : v-model="nodes2Enabled"
113 : :label="t('rightSidePanel.globalSettings.nodes2')"
114 : :tooltip="t('settings.Comfy_VueNodes_Enabled.tooltip')"
115 : />
116 : </div>
117 : </PropertiesAccordionItem>
118 :
119 : <!-- CANVAS Section -->
120 : <PropertiesAccordionItem class="border-b">
121 : <template #label>
122 : {{ t('rightSidePanel.globalSettings.canvas') }}
123 : </template>
124 : <div class="space-y-4 px-4 py-3">
125 : <LayoutField :label="t('rightSidePanel.globalSettings.gridSpacing')">
126 : <div
127 : :class="
128 : cn(WidgetInputBaseClass, 'flex h-7 items-center gap-2 pr-2 pl-3')
129 : "
130 : >
131 : <Slider
132 : :model-value="[gridSpacing]"
133 : class="grow text-xs"
134 : :min="GRID_SIZE_MIN"
135 : :max="GRID_SIZE_MAX"
136 : :step="GRID_SIZE_STEP"
137 : @update:model-value="updateGridSpacingFromSlider"
138 : />
139 : <NumberField
140 : v-model="gridSpacing"
141 : class="h-auto w-16 shrink-0 bg-transparent hover:bg-transparent"
142 : :min="GRID_SIZE_MIN"
143 : :max="GRID_SIZE_MAX"
144 : :step="GRID_SIZE_STEP"
145 : :format-options="{ maximumFractionDigits: 0 }"
146 : >
147 : <NumberFieldInput
148 : :aria-label="t('rightSidePanel.globalSettings.gridSpacing')"
149 : class="text-xs"
150 : />
151 : </NumberField>
152 : </div>
153 : </LayoutField>
154 : <FieldSwitch
155 : v-model="snapToGrid"
156 : :label="t('rightSidePanel.globalSettings.snapNodesToGrid')"
157 : :tooltip="t('settings.pysssss_SnapToGrid.tooltip')"
158 : />
159 : </div>
160 : </PropertiesAccordionItem>
161 :
162 : <!-- CONNECTION LINKS Section -->
163 : <PropertiesAccordionItem class="border-b">
164 : <template #label>
165 : {{ t('rightSidePanel.globalSettings.connectionLinks') }}
166 : </template>
167 : <div class="space-y-4 px-4 py-3">
168 : <LayoutField :label="t('rightSidePanel.globalSettings.linkShape')">
169 : <AppSingleSelect
170 : v-model="linkShape"
171 : :options="linkShapeOptions"
172 : :label="t('rightSidePanel.globalSettings.linkShape')"
173 : :class="cn(WidgetInputBaseClass, 'w-full text-xs')"
174 : size="md"
175 : data-capture-wheel="true"
176 : />
177 : </LayoutField>
178 : <FieldSwitch
179 : v-model="showConnectedLinks"
180 : :label="t('rightSidePanel.globalSettings.showConnectedLinks')"
181 : :tooltip="t('settings.Comfy_LinkRenderMode.tooltip')"
182 : />
183 : </div>
184 : </PropertiesAccordionItem>
185 :
186 : <!-- View all settings button -->
187 : <div class="flex items-center justify-center border-b p-4">
188 : <Button
189 : variant="muted-textonly"
190 : size="sm"
191 : class="text-sm"
192 : @click="openFullSettings"
193 : >
194 : {{ t('rightSidePanel.globalSettings.viewAllSettings') }}
195 : <i class="icon-[lucide--settings]" />
196 : </Button>
197 : </div>
198 : </div>
199 : </template>
|