Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event-prop-type): adds event prop type #909

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 2 additions & 8 deletions src/application/worker/store/modules/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -520,8 +516,6 @@ const actions = {
type: propData.type,
path
},
group,
groupName,

writeToSwap
});
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