asciibird/src/components/Toolbar.vue

121 lines
3.0 KiB
Vue
Raw Normal View History

2021-02-06 01:22:16 +00:00
<template>
<div>
2021-03-13 03:30:58 +00:00
<vue-draggable-resizable
@dragstop="onDragStop"
2021-04-24 00:20:11 +00:00
:grid="[currentAscii.blockWidth, currentAscii.blockHeight]"
2021-04-17 00:12:02 +00:00
style="z-index: 5;"
:min-width="8 * 25"
:max-width="8 * 30"
2021-05-01 02:17:49 +00:00
:max-height="13 * 39"
:min-height="13 * 38"
2021-04-24 00:20:11 +00:00
:w="toolbarState.w"
:h="toolbarState.h"
:x="toolbarState.x"
:y="toolbarState.y"
2021-02-06 01:22:16 +00:00
>
2021-04-17 00:12:02 +00:00
<t-card style="height: 100%">
2021-03-29 05:10:31 +00:00
<label class="flex ml-1">
<t-checkbox
name="targetingFg"
2021-04-24 00:20:11 +00:00
v-model="toolbarState.targetingFg"
2021-03-29 05:10:31 +00:00
:disabled="
2021-03-29 08:21:23 +00:00
!$store.getters.getTargetingBg && !$store.getters.getTargetingChar
"
2021-03-29 05:10:31 +00:00
/>
<span class="text-sm">FG</span>
</label>
<label class="flex ml-1">
<t-checkbox
name="targetingBg"
2021-04-24 00:20:11 +00:00
v-model="toolbarState.targetingBg"
2021-03-29 05:10:31 +00:00
:disabled="
2021-03-29 08:21:23 +00:00
!$store.getters.getTargetingFg && !$store.getters.getTargetingChar
2021-03-27 02:07:33 +00:00
"
2021-03-29 05:10:31 +00:00
checked
/>
<span class="text-sm">BG</span>
</label>
<label class="flex ml-1">
<t-checkbox
2021-03-29 08:21:23 +00:00
name="targetingChar"
2021-04-24 00:20:11 +00:00
v-model="toolbarState.targetingChar"
2021-03-29 05:10:31 +00:00
:disabled="
!$store.getters.getTargetingFg && !$store.getters.getTargetingBg
2021-03-27 02:07:33 +00:00
"
2021-03-29 05:10:31 +00:00
/>
<span class="text-sm">Text</span>
</label>
2021-03-27 04:16:15 +00:00
2021-03-29 05:10:31 +00:00
<hr />
2021-03-13 03:30:58 +00:00
2021-03-29 05:10:31 +00:00
<Colours />
2021-03-13 03:30:58 +00:00
2021-03-29 05:10:31 +00:00
<t-button
type="button"
v-for="(value, keyToolbar) in $store.getters.getToolbarIcons"
:key="keyToolbar + 50"
2021-04-02 02:07:49 +00:00
:class="`max-h-7 max-w-5 w-7 ${($store.getters.getCurrentTool == keyToolbar ? 'border-gray-900' : 'border-gray-200')}`"
@click="$store.commit('changeTool', keyToolbar)"
2021-03-29 05:10:31 +00:00
>
<font-awesome-icon :icon="[value.fa, value.icon]" />
</t-button>
2021-04-02 02:07:49 +00:00
2021-04-17 00:12:02 +00:00
<hr />
<BrushPreview />
2021-03-29 05:10:31 +00:00
</t-card>
2021-02-06 01:22:16 +00:00
</vue-draggable-resizable>
</div>
</template>
2021-03-20 03:45:10 +00:00
2021-02-06 01:22:16 +00:00
<script>
2021-03-29 05:10:31 +00:00
import Colours from "./Colours.vue";
2021-04-17 00:12:02 +00:00
import BrushPreview from "./parts/BrushPreview.vue";
2021-03-29 05:10:31 +00:00
2021-02-06 01:22:16 +00:00
export default {
2021-04-24 00:20:11 +00:00
created() {
this.toolbar.x = this.toolbarState.x
this.toolbar.y = this.toolbarState.y
this.toolbar.w = this.toolbarState.w
this.toolbar.h = this.toolbarState.h
},
2021-02-06 01:22:16 +00:00
name: "Toolbar",
2021-04-17 00:12:02 +00:00
components: { Colours, BrushPreview },
2021-03-13 03:30:58 +00:00
2021-02-06 01:22:16 +00:00
data: () => ({
2021-04-24 00:20:11 +00:00
toolbar: {
w: 0,
h: 0,
2021-02-06 01:22:16 +00:00
x: 100,
y: 100,
},
}),
2021-04-24 00:20:11 +00:00
computed: {
toolbarState() {
return this.$store.getters.getToolbarState
},
currentAscii() {
return this.$store.getters.currentAscii;
},
},
watch: {},
2021-02-06 01:22:16 +00:00
methods: {
2021-04-24 00:20:11 +00:00
onResize(x, y, w, h) {
this.toolbar.x = x;
this.toolbar.y = y;
this.toolbar.w = w;
this.toolbar.h = h;
this.$store.commit("changeToolBarState", {x: x, y: y, w: this.toolbar.w, h: this.toolbar.h})
2021-02-06 01:22:16 +00:00
},
onDragStop(x, y) {
2021-04-24 00:20:11 +00:00
this.toolbar.x = x;
this.toolbar.y = y;
2021-04-24 00:20:11 +00:00
this.$store.commit("changeToolBarState", {x: x, y: y, w: this.toolbar.w, h: this.toolbar.h})
2021-02-06 01:22:16 +00:00
},
},
};
</script>