From 9c83d054cfa0621e0a7ed043889d7d589b89f876 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Wed, 6 Dec 2023 01:32:37 -0800 Subject: [PATCH] Redesign the Layers panel --- .../{LayerTree.svelte => Layers.svelte} | 260 ++++++++---------- .../components/window/workspace/Panel.svelte | 4 +- .../window/workspace/Workspace.svelte | 2 +- 3 files changed, 115 insertions(+), 151 deletions(-) rename frontend/src/components/panels/{LayerTree.svelte => Layers.svelte} (74%) diff --git a/frontend/src/components/panels/LayerTree.svelte b/frontend/src/components/panels/Layers.svelte similarity index 74% rename from frontend/src/components/panels/LayerTree.svelte rename to frontend/src/components/panels/Layers.svelte index f9bcebcf..dab698c8 100644 --- a/frontend/src/components/panels/LayerTree.svelte +++ b/frontend/src/components/panels/Layers.svelte @@ -23,8 +23,6 @@ let list: LayoutCol | undefined; const RANGE_TO_INSERT_WITHIN_BOTTOM_FOLDER_NOT_ROOT = 20; - const LAYER_INDENT = 16; - const INSERT_MARK_MARGIN_LEFT = 4 + 32 + LAYER_INDENT; const INSERT_MARK_OFFSET = 2; type DraggingData = { @@ -68,18 +66,6 @@ }); }); - function layerIndent(layer: LayerPanelEntry): string { - return `${layer.path.length * LAYER_INDENT}px`; - } - - function markIndent(path: BigUint64Array): string { - return `${INSERT_MARK_MARGIN_LEFT + path.length * LAYER_INDENT}px`; - } - - function markTopOffset(height: number): string { - return `${height}px`; - } - function toggleLayerVisibility(path: BigUint64Array) { editor.instance.toggleLayerVisibility(path); } @@ -171,15 +157,11 @@ if (treeChildren !== undefined && treeOffset !== undefined) { Array.from(treeChildren).forEach((treeChild, index) => { - const layerComponents = treeChild.getElementsByClassName("layer"); - if (layerComponents.length !== 1) return; - const child = layerComponents[0]; - - const indexAttribute = child.getAttribute("data-index"); + const indexAttribute = treeChild.getAttribute("data-index"); if (!indexAttribute) return; const { folderIndex, entry: layer } = layers[parseInt(indexAttribute, 10)]; - const rect = child.getBoundingClientRect(); + const rect = treeChild.getBoundingClientRect(); const position = rect.top + rect.height / 2; const distance = position - clientY; @@ -312,76 +294,70 @@ } - (dragInPanel = false)}> + (dragInPanel = false)}> - + deselectAllLayers()} on:dragover={(e) => draggable && updateInsertLine(e)} on:dragend={() => draggable && drop()}> {#each layers as listing, index (String(listing.entry.path.slice(-1)))} draggable && dragStart(e, listing)} + on:click={(e) => selectLayerWithModifiers(e, listing)} > - - (toggleLayerVisibility(listing.entry.path), e?.stopPropagation())} - size={24} - icon={listing.entry.visible ? "EyeVisible" : "EyeHidden"} - tooltip={listing.entry.visible ? "Visible" : "Hidden"} - /> - - -
- {#if isGroupOrArtboard(listing.entry.layerType)}