From 311ee192b2e997429c82b0f0ba10168e17bf8103 Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Sat, 29 Apr 2023 13:47:22 -0700 Subject: [PATCH] Selection thing --- src/lib/components/ComfyApp.svelte | 4 ++ src/lib/components/WidgetContainer.svelte | 48 +++++++++++++++++------ src/lib/stores/layoutState.ts | 4 +- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/lib/components/ComfyApp.svelte b/src/lib/components/ComfyApp.svelte index 8f711da..30896d3 100644 --- a/src/lib/components/ComfyApp.svelte +++ b/src/lib/components/ComfyApp.svelte @@ -8,6 +8,7 @@ import { Checkbox } from "@gradio/form" import nodeState from "$lib/stores/nodeState"; import uiState from "$lib/stores/uiState"; + import layoutState from "$lib/stores/layoutState"; import { ImageViewer } from "$lib/ImageViewer"; import { download } from "$lib/utils" @@ -39,6 +40,9 @@ $: if (app) app.lCanvas.allow_dragnodes = !$uiState.nodesLocked; $: if (app) app.lCanvas.allow_interaction = !$uiState.graphLocked; + $: if ($uiState.uiEditMode) + $layoutState.currentSelection = [] + let graphSize = null; function toggleGraph() { diff --git a/src/lib/components/WidgetContainer.svelte b/src/lib/components/WidgetContainer.svelte index 65b51ea..37df5e9 100644 --- a/src/lib/components/WidgetContainer.svelte +++ b/src/lib/components/WidgetContainer.svelte @@ -48,11 +48,23 @@ // Ensure dragging is stopped on drag finish }; - const startDrag = () => { - return + const startDrag = (evt: MouseEvent) => { + const dragItemId: string = evt.target.dataset["dragItemId"]; + const item = $layoutState.allItems[dragItemId].dragItem + if (evt.ctrlKey) { + const index = $layoutState.currentSelection.indexOf(item.id) + if (index === -1) + $layoutState.currentSelection.push(item.id); + else + $layoutState.currentSelection.splice(index, 1); + $layoutState.currentSelection = $layoutState.currentSelection; + } + else { + $layoutState.currentSelection = [item.id] + } }; - const stopDrag = () => { - return + + const stopDrag = (evt: MouseEvent) => { }; $: if ($queueState && widget) { @@ -65,6 +77,7 @@ {#if container && children} {@const id = container.id}