Skip to content

Commit

Permalink
feat(event-prop-type): adds event prop type (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA committed May 4, 2024
1 parent 4555bb1 commit 2aa6b42
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/application/renderers/isf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -197,6 +199,13 @@ async function setupModule(moduleDefinition) {
});

break;

case "event":
addProp(input.NAME, {
type: "event",
label: input.LABEL || input.NAME
});
break;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/application/worker/store/modules/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const state = {
bool: {
get: value => value
},
event: {
get: value => value
},
vec2: {
get: value => value,
inputs: () => ({ 0: 0, 1: 0 })
Expand Down
4 changes: 2 additions & 2 deletions src/application/worker/store/modules/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ const actions = {

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;

Expand Down
21 changes: 20 additions & 1 deletion src/components/Control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@
>
</Select>
</div>
<div class="input" v-else-if="type === 'event'">
<Button
:class="{ light: !inputIsFocused, active: !!internalValue }"
@pointerdown="buttonDown"
@pointerup="buttonUp"
>
{{ title }}
</Button>
</div>
</c>
</grid>
</template>
Expand All @@ -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],
Expand Down Expand Up @@ -140,7 +150,8 @@ export default {
ColorControl,
Vec3Control,
Vec4Control,
Select
Select,
Button
},
data() {
Expand Down Expand Up @@ -168,6 +179,14 @@ export default {
id: this.inputId,
title: this.inputTitle
});
},
buttonDown() {
this.internalValue = 1;
},
buttonUp() {
this.internalValue = 0;
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/inputs/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ button.light {
background: #363636;
}
button.active,
button:active {
background: #363636;
}
button.light.active,
button.light:active {
background: #9a9a9a;
}
Expand Down

0 comments on commit 2aa6b42

Please sign in to comment.