Skip to content

Commit 6eb478d

Browse files
committed
Merge pysssss/app-builder-preview
2 parents 05f8663 + f312016 commit 6eb478d

File tree

6 files changed

+174
-28
lines changed

6 files changed

+174
-28
lines changed

src/components/LiteGraphCanvasSplitterOverlay.vue

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<Splitter
1919
:key="splitterRefreshKey"
2020
class="bg-transparent pointer-events-none border-none flex-1 overflow-hidden"
21-
:state-key="sidebarStateKey"
21+
:state-key="isSelectMode ? 'builder-splitter' : sidebarStateKey"
2222
state-storage="local"
2323
@resizestart="onResizestart"
2424
>
@@ -35,8 +35,10 @@
3535
)
3636
: 'bg-comfy-menu-bg pointer-events-auto'
3737
"
38-
:min-size="sidebarLocation === 'left' ? 10 : 15"
39-
:size="20"
38+
:min-size="
39+
sidebarLocation === 'left' ? SIDEBAR_MIN_SIZE : BUILDER_MIN_SIZE
40+
"
41+
:size="SIDE_PANEL_SIZE"
4042
:style="firstPanelStyle"
4143
:role="sidebarLocation === 'left' ? 'complementary' : undefined"
4244
:aria-label="
@@ -54,7 +56,7 @@
5456
</SplitterPanel>
5557

5658
<!-- Main panel (always present) -->
57-
<SplitterPanel :size="80" class="flex flex-col">
59+
<SplitterPanel :size="CENTER_PANEL_SIZE" class="flex flex-col">
5860
<slot name="topmenu" :sidebar-panel-visible />
5961

6062
<Splitter
@@ -95,8 +97,10 @@
9597
)
9698
: 'bg-comfy-menu-bg pointer-events-auto'
9799
"
98-
:min-size="sidebarLocation === 'right' ? 10 : 15"
99-
:size="20"
100+
:min-size="
101+
sidebarLocation === 'right' ? SIDEBAR_MIN_SIZE : BUILDER_MIN_SIZE
102+
"
103+
:size="SIDE_PANEL_SIZE"
100104
:style="lastPanelStyle"
101105
:role="sidebarLocation === 'right' ? 'complementary' : undefined"
102106
:aria-label="
@@ -123,8 +127,14 @@ import SplitterPanel from 'primevue/splitterpanel'
123127
import { computed } from 'vue'
124128
import { useI18n } from 'vue-i18n'
125129
126-
import { useSettingStore } from '@/platform/settings/settingStore'
127130
import { useAppMode } from '@/composables/useAppMode'
131+
import {
132+
BUILDER_MIN_SIZE,
133+
CENTER_PANEL_SIZE,
134+
SIDEBAR_MIN_SIZE,
135+
SIDE_PANEL_SIZE
136+
} from '@/constants/splitterConstants'
137+
import { useSettingStore } from '@/platform/settings/settingStore'
128138
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
129139
import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore'
130140
import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
@@ -145,12 +155,12 @@ const unifiedWidth = computed(() =>
145155
146156
const { focusMode } = storeToRefs(workspaceStore)
147157
148-
const { mode, isBuilderMode } = useAppMode()
158+
const { isSelectMode, isBuilderMode } = useAppMode()
149159
const { activeSidebarTabId, activeSidebarTab } = storeToRefs(sidebarTabStore)
150160
const { bottomPanelVisible } = storeToRefs(useBottomPanelStore())
151161
const { isOpen: rightSidePanelVisible } = storeToRefs(rightSidePanelStore)
152162
const showOffsideSplitter = computed(
153-
() => rightSidePanelVisible.value || mode.value === 'builder:select'
163+
() => rightSidePanelVisible.value || isSelectMode.value
154164
)
155165
156166
const sidebarPanelVisible = computed(
@@ -176,7 +186,7 @@ function onResizestart({ originalEvent: event }: SplitterResizeStartEvent) {
176186
* to recalculate the width and panel order
177187
*/
178188
const splitterRefreshKey = computed(() => {
179-
return `main-splitter${rightSidePanelVisible.value ? '-with-right-panel' : ''}-${sidebarLocation.value}`
189+
return `main-splitter${rightSidePanelVisible.value ? '-with-right-panel' : ''}${isSelectMode.value ? '-builder' : ''}-${sidebarLocation.value}`
180190
})
181191
182192
const firstPanelStyle = computed(() => {

src/components/builder/AppBuilder.vue

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup lang="ts">
22
import { remove } from 'es-toolkit'
3-
import { computed, ref, toValue } from 'vue'
3+
import { computed, provide, ref, toValue } from 'vue'
44
import type { MaybeRef } from 'vue'
55
import { useI18n } from 'vue-i18n'
66
77
import DraggableList from '@/components/common/DraggableList.vue'
88
import IoItem from '@/components/builder/IoItem.vue'
99
import PropertiesAccordionItem from '@/components/rightSidePanel/layout/PropertiesAccordionItem.vue'
10+
import WidgetItem from '@/components/rightSidePanel/parameters/WidgetItem.vue'
1011
import Button from '@/components/ui/button/Button.vue'
1112
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
1213
import type { LGraphNode, NodeId } from '@/lib/litegraph/src/LGraphNode'
@@ -23,9 +24,11 @@ import TransformPane from '@/renderer/core/layout/transform/TransformPane.vue'
2324
import { app } from '@/scripts/app'
2425
import { DOMWidgetImpl } from '@/scripts/domWidget'
2526
import { useDialogService } from '@/services/dialogService'
27+
import { useAppMode } from '@/composables/useAppMode'
2628
import { useAppModeStore } from '@/stores/appModeStore'
2729
import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
2830
import { cn } from '@/utils/tailwindUtil'
31+
import { HideLayoutFieldKey } from '@/types/widgetTypes'
2932
3033
type BoundStyle = { top: string; left: string; width: string; height: string }
3134
@@ -37,10 +40,24 @@ const workflowStore = useWorkflowStore()
3740
const { t } = useI18n()
3841
const canvas: LGraphCanvas = canvasStore.getCanvas()
3942
43+
const { isSelectMode, isArrangeMode } = useAppMode()
4044
const hoveringSelectable = ref(false)
4145
46+
provide(HideLayoutFieldKey, true)
47+
4248
workflowStore.activeWorkflow?.changeTracker?.reset()
4349
50+
const arrangeInputs = computed(() =>
51+
appModeStore.selectedInputs
52+
.map(([nodeId, widgetName]) => {
53+
const node = app.rootGraph.getNodeById(nodeId)
54+
const widget = node?.widgets?.find((w) => w.name === widgetName)
55+
if (!node || !widget) return null
56+
return { nodeId, widgetName, node, widget }
57+
})
58+
.filter((item): item is NonNullable<typeof item> => item !== null)
59+
)
60+
4461
const inputsWithState = computed(() =>
4562
appModeStore.selectedInputs.map(([nodeId, widgetName]) => {
4663
const node = getNodeByLocatorId(app.rootGraph, String(nodeId))
@@ -180,12 +197,36 @@ const renderedInputs = computed<[string, MaybeRef<BoundStyle> | undefined][]>(
180197
</script>
181198
<template>
182199
<div class="flex font-bold p-2 border-border-subtle border-b items-center">
183-
{{ t('linearMode.builder.title') }}
200+
{{
201+
isArrangeMode ? t('nodeHelpPage.inputs') : t('linearMode.builder.title')
202+
}}
184203
<Button class="ml-auto" @click="appModeStore.exitBuilder">
185204
{{ t('linearMode.builder.exit') }}
186205
</Button>
187206
</div>
207+
<DraggableList
208+
v-if="isArrangeMode"
209+
v-slot="{ dragClass }"
210+
v-model="appModeStore.selectedInputs"
211+
>
212+
<div
213+
v-for="{ nodeId, widgetName, node, widget } in arrangeInputs"
214+
:key="`${nodeId}: ${widgetName}`"
215+
:class="cn(dragClass, 'p-2 my-2 pointer-events-auto')"
216+
:aria-label="`${widget.label ?? widgetName} — ${node.title}`"
217+
>
218+
<div class="pointer-events-none" inert>
219+
<WidgetItem
220+
:widget="widget"
221+
:node="node"
222+
show-node-name
223+
hidden-widget-actions
224+
/>
225+
</div>
226+
</div>
227+
</DraggableList>
188228
<PropertiesAccordionItem
229+
v-else
189230
:label="t('nodeHelpPage.inputs')"
190231
enable-empty-state
191232
:disabled="!appModeStore.selectedInputs.length"
@@ -234,6 +275,7 @@ const renderedInputs = computed<[string, MaybeRef<BoundStyle> | undefined][]>(
234275
</DraggableList>
235276
</PropertiesAccordionItem>
236277
<PropertiesAccordionItem
278+
v-if="!isArrangeMode"
237279
:label="t('nodeHelpPage.outputs')"
238280
enable-empty-state
239281
:disabled="!appModeStore.selectedOutputs.length"
@@ -277,7 +319,10 @@ const renderedInputs = computed<[string, MaybeRef<BoundStyle> | undefined][]>(
277319
</DraggableList>
278320
</PropertiesAccordionItem>
279321

280-
<Teleport v-if="!settingStore.get('Comfy.VueNodes.Enabled')" to="body">
322+
<Teleport
323+
v-if="isSelectMode && !settingStore.get('Comfy.VueNodes.Enabled')"
324+
to="body"
325+
>
281326
<div
282327
:class="
283328
cn(

src/components/rightSidePanel/parameters/WidgetItem.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {
3131
node,
3232
isDraggable = false,
3333
hiddenFavoriteIndicator = false,
34+
hiddenWidgetActions = false,
3435
showNodeName = false,
3536
parents = [],
3637
isShownOnParents = false
@@ -39,6 +40,7 @@ const {
3940
node: LGraphNode
4041
isDraggable?: boolean
4142
hiddenFavoriteIndicator?: boolean
43+
hiddenWidgetActions?: boolean
4244
showNodeName?: boolean
4345
parents?: SubgraphNode[]
4446
isShownOnParents?: boolean
@@ -167,7 +169,10 @@ const displayLabel = customRef((track, trigger) => {
167169
>
168170
{{ sourceNodeName }}
169171
</span>
170-
<div class="flex items-center gap-1 shrink-0 pointer-events-auto">
172+
<div
173+
v-if="!hiddenWidgetActions"
174+
class="flex items-center gap-1 shrink-0 pointer-events-auto"
175+
>
171176
<WidgetActions
172177
v-model:label="displayLabel"
173178
:widget="widget"

src/composables/useAppMode.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export function useAppMode() {
1616
)
1717

1818
const isBuilderMode = computed(
19-
() => mode.value === 'builder:select' || mode.value === 'builder:arrange'
19+
() => isSelectMode.value || isArrangeMode.value
2020
)
21+
const isSelectMode = computed(() => mode.value === 'builder:select')
22+
const isArrangeMode = computed(() => mode.value === 'builder:arrange')
2123
const isAppMode = computed(
2224
() => mode.value === 'app' || mode.value === 'builder:arrange'
2325
)
@@ -36,6 +38,8 @@ export function useAppMode() {
3638
mode,
3739
enableAppBuilder,
3840
isBuilderMode,
41+
isSelectMode,
42+
isArrangeMode,
3943
isAppMode,
4044
isGraphMode,
4145
setMode

src/constants/splitterConstants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** Default panel size (%) for sidebar and builder panels */
2+
export const SIDE_PANEL_SIZE = 20
3+
4+
/** Default panel size (%) for the center/main panel */
5+
export const CENTER_PANEL_SIZE = 80
6+
7+
/** Minimum panel size (%) for the sidebar */
8+
export const SIDEBAR_MIN_SIZE = 10
9+
10+
/** Minimum panel size (%) for the builder panel */
11+
export const BUILDER_MIN_SIZE = 15

0 commit comments

Comments
 (0)