loop and next button for manual control

This commit is contained in:
Ali Gator 2022-12-19 21:49:57 +01:00
parent cc4a7b08b3
commit a402739b97
2 changed files with 47 additions and 3 deletions

View File

@ -1,5 +1,23 @@
<template> <template>
<div class="form-field"> <div class="form-field">
<div class="form-field">
<label>
Loop
<input
:value="loop"
type="checkbox"
:checked="loop"
@input="toggleLoop()"
/>
</label>
</div>
<input
type="button"
name="next"
class="next"
value="Next"
@click="toggleNext()"
/>
<input <input
type="button" type="button"
name="stop" name="stop"
@ -17,13 +35,21 @@
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from "pinia"; import { mapState, mapActions } from "pinia";
import { globalStore } from "../stores/index.js"; import { globalStore } from "../stores/index.js";
export default { export default {
name: "MenuReset", name: "MenuReset",
computed: {
...mapState(globalStore, ["loop"]),
},
methods: { methods: {
...mapActions(globalStore, ["toggleReset", "toggleStop"]), ...mapActions(globalStore, [
"toggleReset",
"toggleStop",
"toggleLoop",
"toggleNext",
]),
}, },
}; };
</script> </script>

View File

@ -43,7 +43,8 @@ export const globalStore = defineStore("globalStore", {
picture: null, picture: null,
mainMenu: false, mainMenu: false,
activeSubMenu: "", activeSubMenu: "",
loop: true, loop: false,
lastAction: "drawfromlast",
}; };
}, },
actions: { actions: {
@ -62,6 +63,7 @@ export const globalStore = defineStore("globalStore", {
}, },
toggleDraw2d() { toggleDraw2d() {
this.setActiveSubMenu(""); this.setActiveSubMenu("");
this.lastAction = "draw2d";
this.setMainMenu(false); this.setMainMenu(false);
this.toggleStop(); this.toggleStop();
this.canDraw = true; this.canDraw = true;
@ -69,6 +71,7 @@ export const globalStore = defineStore("globalStore", {
}, },
toggleDraw2dLast() { toggleDraw2dLast() {
this.setActiveSubMenu(""); this.setActiveSubMenu("");
this.lastAction = "drawfromlast";
this.setMainMenu(false); this.setMainMenu(false);
this.toggleStop(); this.toggleStop();
this.canDraw = true; this.canDraw = true;
@ -90,6 +93,21 @@ export const globalStore = defineStore("globalStore", {
this.draw2dpicture = false; this.draw2dpicture = false;
this.canDraw = false; this.canDraw = false;
}, },
toggleLoop() {
this.loop = !this.loop;
},
toggleNext() {
switch (this.lastAction) {
case "drawfromlast":
this.toggleDraw2dLast();
break;
case "draw2d":
this.toggleDraw2d();
break;
default:
return;
}
},
setActiveSubMenu(data) { setActiveSubMenu(data) {
if (this.activeSubMenu == data) this.activeSubMenu = ""; if (this.activeSubMenu == data) this.activeSubMenu = "";
else this.activeSubMenu = data; else this.activeSubMenu = data;