aboutsummaryrefslogtreecommitdiff
path: root/src/components/Settings.vue
blob: 30ff0c3b3a897fd12f887e837f8369a11ee2fa11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<script lang="ts">
import {defineComponent, PropType} from 'vue';
import type {LayoutOptions} from '../lib';

export default defineComponent({
	props: {
		layoutOptions: {type: Object as PropType<LayoutOptions>, required: true},
		componentOptions: {type: Object, required: true},
	},
	methods: {
		closeClicked(evt: Event){
			if (evt.target == this.$el || (this.$refs.closeIcon as HTMLElement).contains(evt.target as HTMLElement)){
				this.$emit('settings-close');
			}
		},
		onLayoutOptChg(){
			this.$emit('layout-option-change');
		},
		onMinTileSzChg(){
			let minInput = this.$refs.minTileSzInput as HTMLInputElement;
			let maxInput = this.$refs.maxTileSzInput as HTMLInputElement;
			if (Number(minInput.value) > Number(maxInput.value)){
				this.layoutOptions.maxTileSz = this.layoutOptions.minTileSz;
			}
			this.onLayoutOptChg();
		},
		onMaxTileSzChg(){
			let minInput = this.$refs.minTileSzInput as HTMLInputElement;
			let maxInput = this.$refs.maxTileSzInput as HTMLInputElement;
			if (Number(maxInput.value) < Number(minInput.value)){
				this.layoutOptions.minTileSz = this.layoutOptions.maxTileSz;
			}
			this.onLayoutOptChg();
		},
	},
	emits: ['settings-close', 'layout-option-change', ],
});
</script>

<template>
<div class="absolute bottom-4 right-4 min-w-[5cm] p-3 bg-stone-50 visible rounded-md shadow shadow-black">
	<svg class="block absolute top-2 right-2 w-6 h-6 hover:cursor-pointer" @click="closeClicked" ref="closeIcon">
		<use href="#svg-close"/>
	</svg>
	<h1 class="text-xl font-bold mb-2">Settings</h1>
	<hr class="border-stone-400"/>
	<div>
		<label>Tile Spacing <input type="range" min="0" max="20" class="mx-2 w-[3cm]"
			v-model.number="layoutOptions.tileSpacing" @input="onLayoutOptChg"/></label>
	</div>
	<hr class="border-stone-400"/>
	<div>
		<label>
			<span class="inline-block w-[3cm]">Min Tile Size</span>
			<input type="range" min="0" max="400" v-model.number="layoutOptions.minTileSz" class="w-[3cm]"
				@input="onMinTileSzChg" ref="minTileSzInput"/>
		</label>
	</div>
	<div>
		<label>
			<span class="inline-block w-[3cm]">Max Tile Size</span>
			<input type="range" min="0" max="400" v-model.number="layoutOptions.maxTileSz" class="w-[3cm]"
				@input="onMaxTileSzChg" ref="maxTileSzInput"/>
		</label>
	</div>
	<hr class="border-stone-400"/>
	<div>
		Layout Method
		<ul>
			<li>
				<label> <input type="radio" v-model="layoutOptions.layoutType" value="sqr"
					@change="onLayoutOptChg"/> Squares </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.layoutType" value="rect"
					@change="onLayoutOptChg"/> Rectangles </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.layoutType" value="sweep"
					@change="onLayoutOptChg"/> Sweep to side </label>
			</li>
		</ul>
	</div>
	<hr class="border-stone-400"/>
	<div>
		Rect leaf separation
		<ul>
			<li>
				<label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="none"
					@change="onLayoutOptChg"/> None </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="start"
					@change="onLayoutOptChg"/> To start </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.rectSepLeaves" value="end"
					@change="onLayoutOptChg"/> To end </label>
			</li>
		</ul>
	</div>
	<hr class="border-stone-400"/>
	<div>
		<label> <input type="checkbox" v-model="layoutOptions.sweepingToParent"
			@change="onLayoutOptChg"/> Sweep to parent</label>
	</div>
	<hr class="border-stone-400"/>
	<div>
		Sweep Mode
		<ul>
			<li>
				<label> <input type="radio" v-model="layoutOptions.sweepMode" value="left"
					@change="onLayoutOptChg"/> To left </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.sweepMode" value="top"
					@change="onLayoutOptChg"/> To top </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.sweepMode" value="shorter"
					@change="onLayoutOptChg"/> To shorter </label>
			</li>
			<li>
				<label> <input type="radio" v-model="layoutOptions.sweepMode" value="auto"
					@change="onLayoutOptChg"/> Auto </label>
			</li>
		</ul>
	</div>
	<hr class="border-stone-400"/>
	<div>
		<label>Animation Speed <input type="range" min="0" max="1000" class="mx-2 w-[3cm]"
			v-model.number="componentOptions.transitionDuration"/></label>
	</div>
</div>
</template>