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
|
<template>
<div class="fixed left-0 top-0 w-full h-full bg-black/40" @click="onClose">
<div class="absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2
min-w-[8cm] max-h-[80%] overflow-auto p-3" :style="styles">
<close-icon @click.stop="onClose" 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>
<div class="border rounded p-1">
<h2 class="text-center">Layout</h2>
<div class="flex gap-2">
<div class="grow">
Sweep leaves to side
<ul>
<li> <label> <input type="radio" v-model="sweepLeaves" :value="true"
@change="onSettingChg('layoutType')"/> Yes </label> </li>
<li> <label> <input type="radio" v-model="sweepLeaves" :value="false"
@change="onSettingChg('layoutType')"/> No </label> </li>
</ul>
</div>
<div class="grow">
Sweep into parent
<ul>
<li> <label> <input type="radio" :disabled="!sweepLeaves" v-model="lytOpts.sweepToParent"
value="none" @change="onSettingChg('sweepToParent')"/> Never </label> </li>
<li> <label> <input type="radio" :disabled="!sweepLeaves" v-model="lytOpts.sweepToParent"
value="prefer" @change="onSettingChg('sweepToParent')"/> Always </label> </li>
<li> <label> <input type="radio" :disabled="!sweepLeaves" v-model="lytOpts.sweepToParent"
value="fallback" @change="onSettingChg('sweepToParent')"/> If needed </label> </li>
</ul>
</div>
</div>
<div class="grid grid-cols-[minmax(0,3fr)_minmax(0,4fr)_minmax(0,2fr)] gap-1">
<!-- Row 1 -->
<label for="minTileSizeInput">Min Tile Size</label>
<input type="range" min="0" max="400" v-model.number="lytOpts.minTileSz"
@input="onSettingChg('minTileSz')" name="minTileSizeInput" ref="minTileSzInput"/>
<div class="my-auto text-right">{{pxToDisplayStr(lytOpts.minTileSz)}}</div>
<!-- Row 2 -->
<label for="maxTileSizeInput">Max Tile Size</label>
<input type="range" min="0" max="400" v-model.number="lytOpts.maxTileSz"
@input="onSettingChg('maxTileSz')" name="maxTileSizeInput" ref="maxTileSzInput"/>
<div class="my-auto text-right">{{pxToDisplayStr(lytOpts.maxTileSz)}}</div>
<!-- Row 3 -->
<label for="tileSpacingInput">Tile Spacing</label>
<input type="range" min="0" max="20" v-model.number="lytOpts.tileSpacing"
@input="onSettingChg('tileSpacing')" name="tileSpacingInput"/>
<div class="my-auto text-right">{{pxToDisplayStr(lytOpts.tileSpacing)}}</div>
</div>
</div>
<div class="border rounded p-1">
<h2 class="text-center">Timing</h2>
<div class="grid grid-cols-[minmax(0,3fr)_minmax(0,4fr)_minmax(0,2fr)] gap-1">
<!-- Row 1 -->
<label for="animationTimeInput">Animation Time</label>
<input type="range" min="0" max="3000" v-model.number="uiOpts.transitionDuration"
@change="onSettingChg('transitionDuration')" class="my-auto" name="animationTimeInput"/>
<div class="my-auto text-right">{{uiOpts.transitionDuration}} ms</div>
<!-- Row 2 -->
<label for="autoModeDelayInput">Auo-mode Delay</label>
<input type="range" min="0" max="3000" v-model.number="uiOpts.autoActionDelay"
@change="onSettingChg('autoActionDelay')" class="my-auto" name="autoModeDelayInput"/>
<div class="my-auto text-right">{{uiOpts.autoActionDelay}} ms</div>
</div>
</div>
<div class="border rounded p-1">
<h2 class="text-center">Other</h2>
<div>
<label> <input type="checkbox" v-model="uiOpts.useReducedTree"
@change="onSettingChg('useReducedTree')"/> Use simplified tree </label>
</div>
<div>
<label> <input type="checkbox" v-model="uiOpts.searchJumpMode"
@change="onSettingChg('searchJumpMode')"/> Skip search animation </label>
</div>
</div>
<s-button class="mx-auto mt-2" :style="{color: uiOpts.textColor, backgroundColor: uiOpts.bgColor}"
@click="$emit('reset')">
Reset
</s-button>
</div>
</div>
</template>
<script lang="ts">
import {defineComponent, PropType} from 'vue';
import SButton from './SButton.vue';
import CloseIcon from './icon/CloseIcon.vue';
import {UiOptions} from '../lib';
import {LayoutOptions} from '../layout';
export default defineComponent({
props: {
lytOpts: {type: Object as PropType<LayoutOptions>, required: true},
uiOpts: {type: Object as PropType<UiOptions>, required: true},
},
data(){
return {
sweepLeaves: this.lytOpts.layoutType == 'sweep',
// For making only two of 'layoutType's values available for user selection
};
},
computed: {
styles(): Record<string,string> {
return {
backgroundColor: this.uiOpts.bgColorAlt,
borderRadius: this.uiOpts.borderRadius + 'px',
boxShadow: this.uiOpts.shadowNormal,
};
},
},
watch: {
sweepLeaves(newVal: boolean, oldVal: boolean){
this.lytOpts.layoutType = newVal ? 'sweep' : 'rect';
},
},
methods: {
onClose(evt: Event){
if (evt.target == this.$el || (this.$refs.closeIcon as typeof CloseIcon).$el.contains(evt.target)){
this.$emit('close');
}
},
onSettingChg(setting: string){
// Maintain min/max-tile-size consistency
if (setting == 'minTileSz' || setting == 'maxTileSz'){
let minInput = this.$refs.minTileSzInput as HTMLInputElement;
let maxInput = this.$refs.maxTileSzInput as HTMLInputElement;
if (setting == 'minTileSz' && Number(minInput.value) > Number(maxInput.value)){
this.lytOpts.maxTileSz = this.lytOpts.minTileSz;
} else if (setting == 'maxTileSz' && Number(maxInput.value) < Number(minInput.value)){
this.lytOpts.minTileSz = this.lytOpts.maxTileSz;
}
}
//
this.$emit('setting-chg', setting);
},
pxToDisplayStr(px: number): string {
return (px / 3.78).toFixed() + ' mm';
}
},
components: {SButton, CloseIcon, },
emits: ['close', 'setting-chg', 'reset', ],
});
</script>
|