From 46848f75b71cb6a4169441c9dfe7980831afa906 Mon Sep 17 00:00:00 2001 From: Sam Wray Date: Sat, 4 May 2024 14:01:52 +0100 Subject: [PATCH] feat(event-prop-type): adds event prop type --- src/application/renderers/isf.js | 9 ++++++++ .../worker/store/modules/dataTypes.js | 3 +++ .../worker/store/modules/modules.js | 10 ++------- src/components/Control.vue | 21 ++++++++++++++++++- src/components/inputs/Button.vue | 2 ++ 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/application/renderers/isf.js b/src/application/renderers/isf.js index 100a8e5b6..1d9bb0d2c 100644 --- a/src/application/renderers/isf.js +++ b/src/application/renderers/isf.js @@ -56,6 +56,8 @@ function render({ module, canvas, context, pipeline, props }) { } else { renderer.setValue(input.NAME, canvas); } + } else if (input.TYPE === "event") { + renderer.setValue(input.NAME, !!props[input.NAME]); } else { renderer.setValue(input.NAME, props[input.NAME]); } @@ -197,6 +199,13 @@ async function setupModule(moduleDefinition) { }); break; + + case "event": + addProp(input.NAME, { + type: "event", + label: input.LABEL || input.NAME + }); + break; } } diff --git a/src/application/worker/store/modules/dataTypes.js b/src/application/worker/store/modules/dataTypes.js index 7938e5360..8dab2f645 100644 --- a/src/application/worker/store/modules/dataTypes.js +++ b/src/application/worker/store/modules/dataTypes.js @@ -11,6 +11,9 @@ const state = { bool: { get: value => value }, + event: { + get: value => value + }, vec2: { get: value => value, inputs: () => ({ 0: 0, 1: 0 }) diff --git a/src/application/worker/store/modules/modules.js b/src/application/worker/store/modules/modules.js index 143627d56..1001b53f4 100644 --- a/src/application/worker/store/modules/modules.js +++ b/src/application/worker/store/modules/modules.js @@ -480,22 +480,18 @@ const actions = { ); const { type } = propData; - // if (group || groupName) { - // propData = state.active[name].props[groupName].props[prop]; - // } - if (data === currentValue) { return; } let dataOut = data; - dataOut = applyExpression({ inputId, value: dataOut }); - if (store.state.dataTypes[type] && store.state.dataTypes[type].create) { dataOut = await store.state.dataTypes[type].create(dataOut); } + dataOut = applyExpression({ inputId, value: dataOut }); + if (!Array.isArray(dataOut)) { const { strict, min, max, abs } = propData; @@ -520,8 +516,6 @@ const actions = { type: propData.type, path }, - group, - groupName, writeToSwap }); diff --git a/src/components/Control.vue b/src/components/Control.vue index 84adc12d6..0026081a5 100644 --- a/src/components/Control.vue +++ b/src/components/Control.vue @@ -78,6 +78,15 @@ > +
+ +
@@ -95,6 +104,7 @@ import Vec4Control from "./Controls/Vec4Control"; import hasLink from "./mixins/has-input-link"; import inputIsFocused from "./mixins/input-is-focused"; import Select from "./inputs/Select.vue"; +import Button from "./inputs/Button.vue"; export default { mixins: [hasLink, inputIsFocused], @@ -140,7 +150,8 @@ export default { ColorControl, Vec3Control, Vec4Control, - Select + Select, + Button }, data() { @@ -168,6 +179,14 @@ export default { id: this.inputId, title: this.inputTitle }); + }, + + buttonDown() { + this.internalValue = 1; + }, + + buttonUp() { + this.internalValue = 0; } }, diff --git a/src/components/inputs/Button.vue b/src/components/inputs/Button.vue index 182b2469c..0d1a1d140 100644 --- a/src/components/inputs/Button.vue +++ b/src/components/inputs/Button.vue @@ -26,10 +26,12 @@ button.light { background: #363636; } +button.active, button:active { background: #363636; } +button.light.active, button.light:active { background: #9a9a9a; }