diff --git a/src/App.svelte b/src/App.svelte index e65b5fd..5175345 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,12 +1,17 @@ - + diff --git a/src/Graph.svelte b/src/Graph.svelte index dfe97c9..608da7a 100644 --- a/src/Graph.svelte +++ b/src/Graph.svelte @@ -1,5 +1,5 @@ - - -
- - - - +
+ + +
+
+ + + + +
+
+ + diff --git a/src/app.css b/src/app.css index 3eb3aa5..6e78712 100644 --- a/src/app.css +++ b/src/app.css @@ -2,12 +2,12 @@ box-sizing: border-box; } :root { - /* --b1: #004dff; */ - /* --b2: #f19696b3; */ - --b1: #004dff; - --b2: #ffdadab3; - /* --b1: #ff0000; */ - /* --b2: #b6e3f2b3; */ + /* --b1: #004dff; */ + /* --b2: #f19696b3; */ + --b1: #004dff; + --b2: #ffdadab3; + /* --b1: #ff0000; */ + /* --b2: #b6e3f2b3; */ } a { @@ -15,8 +15,8 @@ a { } a:hover { - background-color: var(--b1); - color: #fff; + background-color: var(--b1); + color: #fff; } body { @@ -24,6 +24,11 @@ body { font: 16px Times, serif; + margin: 0; +} + +input { + outline: none; } textrea, select, @@ -32,26 +37,26 @@ button { font: inherit; } -button, input:not([type="range"]) , select { - border: 1px solid var(--b1); - background-color: white; - box-shadow: 2px 2px 0px var(--b2); +button, +input:not([type="range"]), +select { + border: 1px solid var(--b1); + background-color: white; + box-shadow: 2px 2px 0px var(--b2); } button:active { - position: relative; - top: 2px; - left: 2px; - box-shadow: none; -} -video { - width: 100%; + position: relative; + top: 2px; + left: 2px; + box-shadow: none; } + input[type="range"] { - -webkit-appearance: none; - appearance: none; - background: transparent; - cursor: pointer; + -webkit-appearance: none; + appearance: none; + background: transparent; + cursor: pointer; } /* Removes default focus */ @@ -62,53 +67,53 @@ input[type="range"]:focus { /***** Chrome, Safari, Opera and Edge Chromium styles *****/ /* slider track */ input[type="range"]::-webkit-slider-runnable-track { - background-color: var(--b1); - border-radius: 0; - height: 0.3rem; + background-color: var(--b1); + border-radius: 0; + height: 0.3rem; } /* slider thumb */ input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; /* Override default look */ - appearance: none; - margin-top: -5px; /* Centers thumb on the track */ + appearance: none; + margin-top: -5px; /* Centers thumb on the track */ - /*custom styles*/ - background-color: var(--b1); - height: 15px; - width: 10px; + /*custom styles*/ + background-color: var(--b1); + height: 15px; + width: 10px; } -input[type="range"]:focus::-webkit-slider-thumb { +input[type="range"]:focus::-webkit-slider-thumb { /* border: 1px solid #053a5f; */ } /******** Firefox styles ********/ /* slider track */ input[type="range"]::-moz-range-track { - background-color: var(--b1); - border-radius: 0; - height: 0.3rem; + background-color: var(--b1); + border-radius: 0; + height: 0.3rem; } /* slider thumb */ input[type="range"]::-moz-range-thumb { - border: none; /*Removes extra border that FF applies*/ - border-radius: 0; /*Removes default border-radius that FF applies*/ + border: none; /*Removes extra border that FF applies*/ + border-radius: 0; /*Removes default border-radius that FF applies*/ - /*custom styles*/ - background-color: var(--b1); - height: 15px; - width: 10px; + /*custom styles*/ + background-color: var(--b1); + height: 15px; + width: 10px; } input[type="range"]:focus::-moz-range-thumb { } .svelte-flow__node { - border-radius: 0px !important; - border: 1px solid var(--b1) !important; + border-radius: 0px !important; + border: 1px solid var(--b1) !important; } .svelte-flow__attribution { - display: none !important; + display: none !important; } diff --git a/src/nodes/Node.svelte b/src/nodes/Node.svelte index b4de612..fb25537 100644 --- a/src/nodes/Node.svelte +++ b/src/nodes/Node.svelte @@ -1,28 +1,96 @@ -
- {data.name} +
+
+
{data.nodeType}
+ +
+
+ {#if data.nodeType == "input"} + + {:else} + {data.name} + {/if} +
{#each data.inputs as inp, index} - + {inp} {/each} {#each data.outputs as out, index} - + {out} {/each} - - - - - - - - + diff --git a/src/stores.js b/src/stores.js index 93a20ca..be462dd 100644 --- a/src/stores.js +++ b/src/stores.js @@ -7,6 +7,7 @@ import { writable, derived, get } from "svelte/store"; export const nodes = writable([]); export const edges = writable([]); export const auto = writable(true); +export const selectedFilter = writable(); const PREFIX = ""; @@ -146,19 +147,22 @@ export const previewCommand = derived([edges, nodes], ([$edges, $nodes]) => { const source = $nodes.find((n) => n.id === e.source); const target = $nodes.find((n) => n.id === e.target); - if (source.nodeType === "input") { - if (e.sourceHandle.includes("v")) { - edgeIds[e.id] = inputIds[source.id] + ":v"; - } - if (e.sourceHandle.includes("a")) { - edgeIds[e.id] = inputIds[source.id] + ":a"; - } - } + if (source && target) { - if (target.nodeType === "output") { - const outType = e.targetHandle.includes("a") ? "aud_out" : "vid_out"; - edgeIds[e.id] = outType; - } + if (source.nodeType === "input") { + if (e.sourceHandle.includes("v")) { + edgeIds[e.id] = inputIds[source.id] + ":v"; + } + if (e.sourceHandle.includes("a")) { + edgeIds[e.id] = inputIds[source.id] + ":a"; + } + } + + if (target.nodeType === "output") { + const outType = e.targetHandle.includes("a") ? "aud_out" : "vid_out"; + edgeIds[e.id] = outType; + } + } } for (let n of $nodes.filter((n) => n.nodeType == "filter")) { @@ -330,6 +334,7 @@ export function addNode(data, type) { } } + data.nodeType = type; data.inputs = ins; data.outputs = outs; @@ -347,9 +352,9 @@ export function addNode(data, type) { const isAuto = get(auto); if (isAuto) { - const w = 100; + const w = 120; const h = 50; - const margin = 10; + const margin = 50; let prev = null; for (let n of _nodes) { @@ -362,7 +367,7 @@ export function addNode(data, type) { for (let n of _nodes) { if (n.nodeType === "filter") { let _w = prev && prev.width ? prev.width : w; - n.position = { x: prev ? prev.position.x + _w + margin : 0, y: -30 }; + n.position = { x: prev ? prev.position.x + _w + margin : 0, y: -50 }; prev = n; } } @@ -374,8 +379,13 @@ export function addNode(data, type) { } } } + if (node.nodeType === "filter") { + selectedFilter.set(_nodes.length - 1); + } return _nodes; }); + + } export function removeNode(id) {