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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
<script lang="ts">
import {defineComponent, PropType} from 'vue';
import CloseIcon from './icon/CloseIcon.vue';
import RButton from './RButton.vue';
import type {LayoutOptions} from '../layout';
// Displays configurable options, and sends option-change requests
export default defineComponent({
props: {
lytOpts: {type: Object as PropType<LayoutOptions>, required: true},
uiOpts: {type: Object, required: true},
},
methods: {
onCloseClick(evt: Event){
if (evt.target == this.$el || (this.$refs.closeIcon as typeof CloseIcon).$el.contains(evt.target)){
this.$emit('settings-close');
}
},
onLytOptChg(){
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.lytOpts.maxTileSz = this.lytOpts.minTileSz;
}
this.onLytOptChg();
},
onMaxTileSzChg(){
let minInput = this.$refs.minTileSzInput as HTMLInputElement;
let maxInput = this.$refs.maxTileSzInput as HTMLInputElement;
if (Number(maxInput.value) < Number(minInput.value)){
this.lytOpts.minTileSz = this.lytOpts.maxTileSz;
}
this.onLytOptChg();
},
onTreeChg(){
this.$emit('tree-change');
},
onSave(){
const savedLytOpts = ['tileSpacing', 'minTileSz', 'maxTileSz', 'layoutType', 'sweepMode', 'sweepToParent', ];
for (let prop of savedLytOpts){
localStorage.setItem('lyt ' + prop, String(this.lytOpts[prop as keyof LayoutOptions]));
}
const savedUiOpts = ['tileChgDuration', 'jumpToSearchedNode', 'useReducedTree', ];
for (let prop of savedUiOpts){
localStorage.setItem('ui ' + prop, String(this.uiOpts[prop]));
}
console.log('Settings saved');
},
onReset(){
localStorage.clear();
this.$emit('reset-settings');
console.log('Settings reset');
},
},
components: {CloseIcon, RButton, },
emits: ['settings-close', 'layout-option-change', 'tree-change', 'reset-settings', ],
});
</script>
<template>
<div class="fixed left-0 top-0 w-full h-full bg-black/40" @click="onCloseClick">
<div class="absolute left-1/2 -translate-x-1/2 w-4/5 top-1/2 -translate-y-1/2 max-h-[80%]
p-3 bg-stone-50 visible rounded-md shadow shadow-black">
<close-icon @click.stop="onCloseClick" ref="closeIcon"
class="block absolute top-2 right-2 w-6 h-6 hover:cursor-pointer" />
<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="lytOpts.tileSpacing" @input="onLytOptChg"/></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="lytOpts.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="lytOpts.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="lytOpts.layoutType" value="sqr"
@change="onLytOptChg"/> Squares </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.layoutType" value="rect"
@change="onLytOptChg"/> Rectangles </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.layoutType" value="sweep"
@change="onLytOptChg"/> Sweep to side </label>
</li>
</ul>
</div>
<hr class="border-stone-400"/>
<div>
Sweep to parent
<ul>
<li>
<label> <input type="radio" v-model="lytOpts.sweepToParent" value="none"
@change="onLytOptChg"/> None </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.sweepToParent" value="prefer"
@change="onLytOptChg"/> Prefer </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.sweepToParent" value="fallback"
@change="onLytOptChg"/> Fallback </label>
</li>
</ul>
</div>
<hr class="border-stone-400"/>
<div>
Sweep Mode
<ul>
<li>
<label> <input type="radio" v-model="lytOpts.sweepMode" value="left"
@change="onLytOptChg"/> To left </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.sweepMode" value="top"
@change="onLytOptChg"/> To top </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.sweepMode" value="shorter"
@change="onLytOptChg"/> To shorter </label>
</li>
<li>
<label> <input type="radio" v-model="lytOpts.sweepMode" value="auto"
@change="onLytOptChg"/> Auto </label>
</li>
</ul>
</div>
<hr class="border-stone-400"/>
<div>
<label>Animation Duration <input type="range" min="0" max="3000" class="mx-2 w-[3cm]"
v-model.number="uiOpts.tileChgDuration"/></label>
</div>
<hr class="border-stone-400"/>
<div>
<label> <input type="checkbox" v-model="uiOpts.jumpToSearchedNode"/> Jump to search result</label>
</div>
<hr class="border-stone-400"/>
<div>
Tree
<ul>
<li>
<label> <input type="radio" v-model="uiOpts.useReducedTree" :value="false"
@change="onTreeChg"/> Default </label>
</li>
<li>
<label> <input type="radio" v-model="uiOpts.useReducedTree" :value="true"
@change="onTreeChg"/> Reduced </label>
</li>
</ul>
</div>
<hr class="border-stone-400"/>
<div class="flex justify-around mt-2">
<r-button class="bg-stone-800 text-white" @click="onSave">
Save
</r-button>
<r-button class="bg-stone-800 text-white" @click="onReset">
Reset
</r-button>
</div>
</div>
</div>
</template>
|