16
16
<div class =" layer-visibility" >
17
17
<IconButton :icon =" layer.visible ? 'EyeVisible' : 'EyeHidden'" @click =" toggleLayerVisibility(layer.path)" :size =" 24" :title =" layer.visible ? 'Visible' : 'Hidden'" />
18
18
</div >
19
- <div class =" layer" :class =" layer.selected ? 'selected' : ''" @click.shift.exact =" handleShiftClick(layer.path)" @click.alt.exact =" handleControlClick(layer.path)" @click.exact =" handleClick(layer.path)" >
19
+ <div
20
+ class =" layer"
21
+ :class =" layer.selected ? 'selected' : ''"
22
+ @click.shift.exact =" handleShiftClick(layer.path)"
23
+ @click.alt.exact =" handleControlClick(layer.path)"
24
+ @click.exact =" handleClick(layer.path)"
25
+ >
20
26
<div class =" layer-thumbnail" ></div >
21
27
<div class =" layer-type-icon" >
22
28
<Icon :icon =" 'NodeTypePath'" title =" Path" />
59
65
margin-left : 4px ;
60
66
padding-left : 16px ;
61
67
}
62
-
63
68
.selected {
64
69
background : #ff0000 ;
65
70
}
@@ -113,89 +118,73 @@ export default defineComponent({
113
118
},
114
119
async handleControlClick(path : BigUint64Array ) {
115
120
let i = 0 ;
116
- this .endPath = new BigUint64Array ([]);
117
- for (const layer of this .layers ) {
118
- if (layer .path === path ) {
119
- layer .selected = ! layer .selected ;
120
- if (layer .selected ) {
121
- this .startPath = path ;
122
- } else {
123
- let j = i + 1 ;
124
- while (j < this .layers .length ) {
125
- // Look for a selected layer below to assign to startPath
121
+ this .endPath = - 1n ;
122
+ this .layers .forEach ((layer , idx , layers ) => {
123
+ if (layer .path === path ) {
124
+ layers [idx ].selected = ! layer .selected ;
125
+ if (layer .selected ) {
126
+ [this .startPath ] = path ;
127
+ } else {
128
+ let j = i + 1 ;
129
+ while (j < this .layers .length ) {
130
+ // Look for a selected layer below to assign to startPath
131
+ if (this .layers [j ].selected ) {
132
+ [this .startPath ] = this .layers [j ].path ;
133
+ break ;
134
+ }
135
+ j += 1 ;
136
+ }
137
+ if (j >= this .layers .length ) {
138
+ // Look above
139
+ j = i - 1 ;
140
+ while (j >= 0 ) {
126
141
if (this .layers [j ].selected ) {
127
- this .startPath = this .layers [j ].path ;
142
+ console .log (" ABOVE" );
143
+ [this .startPath ] = this .layers [j ].path ;
128
144
break ;
129
145
}
130
- j += 1 ;
131
- }
132
- if (j >= this .layers .length ) {
133
- // Look above
134
- j = i - 1 ;
135
- while (j >= 0 ) {
136
- if (this .layers [j ].selected ) {
137
- console .log (" ABOVE" );
138
- this .startPath = this .layers [j ].path ;
139
- break ;
140
- }
141
- j -= 1 ;
142
- }
143
- }
144
- if (j < 0 ) {
145
- // RESET
146
- this .startPath = new BigUint64Array ([]);
146
+ j -= 1 ;
147
147
}
148
148
}
149
+ if (j < 0 ) {
150
+ // RESET
151
+ this .startPath = - 1n ;
152
+ }
149
153
}
150
- i += 1 ;
151
- }
154
+ }
155
+ i += 1 ;
156
+ });
152
157
},
153
158
async handleShiftClick(path : BigUint64Array ) {
154
159
// The two paths of the range are stored in startPath and endPath
155
- // So for a new Shift+Click, unselect all paths between startPath and endPath(stored in prev Sft+C)
160
+ // So for a new Shift+Click, unselect all paths between startPath and endPath(stored in prev Sft+C)
156
161
// Then select all paths between startPath and path(new endPath) and assign path to endPath
157
-
158
- if (this .startPath .length === 0 ) {
162
+ if (this .startPath === - 1n ) {
159
163
// If nothing was selected before, usually at the start of the app
160
164
// Also if the user manually deselects all the layers
161
- for (const layer of this .layers ) {
162
- if (layer .path [0 ] < path [0 ]) {
163
- layer .selected = ! layer .selected ;
164
- } else if (layer .path [0 ] === path [0 ]) {
165
- layer .selected = true
165
+ this .layers .forEach ((layer ) => {
166
+ if (layer .path [0 ] <= path [0 ]) {
167
+ layer .selected = true ;
166
168
}
167
- }
168
- this .startPath = path ;
169
- this .endPath = this .layers [0 ].path ;
169
+ });
170
170
} else {
171
-
172
- if (this .endPath .length !== 0 ) {
173
- for (const layer of this .layers ) {
174
- if ((layer .path [0 ] >= this .endPath [0 ] && layer .path [0 ] < this .startPath [0 ]) || (layer .path [0 ] <= this .endPath [0 ] && layer .path [0 ] > this .startPath [0 ])) {
175
- layer .selected = false ;
176
- }
177
- }
178
- }
179
-
180
- this .endPath = path ;
181
- for (const layer of this .layers ) {
182
- if ((layer .path [0 ] >= path [0 ] && layer .path [0 ] <= this .startPath [0 ]) || (layer .path [0 ] <= path [0 ] && layer .path [0 ] >= this .startPath [0 ])) {
171
+ [this .endPath ] = path ;
172
+ this .layers .forEach ((layer ) => {
173
+ if ((layer .path [0 ] >= path [0 ] && layer .path [0 ] <= this .startPath ) || (layer .path [0 ] <= path [0 ] && layer .path [0 ] >= this .startPath )) {
183
174
layer .selected = true ;
184
175
}
185
- }
176
+ });
186
177
}
187
178
},
188
-
189
179
190
180
async handleClick(path : BigUint64Array ) {
191
- this .startPath = path ;
192
- this .endPath = new BigUint64Array ([]);
193
-
194
- for (const layer of this .layers ) {
195
- // Can we directly index into `layers`? Is the path `i` at the `i`th index in layers?
196
- // Delete layer op may affect the order of layers and the paths.
197
- layer .selected = layer .path === path ;
198
- }
181
+ [this .startPath ] = path ;
182
+ [this .endPath ] = path ;
183
+ this .layers .forEach ((layer ) => {
184
+ // Can we directly index into `layers`? Is the path `i` at the `i`th index in layers?
185
+ // Delete layer op may affect the order of layers and the paths.
186
+ layer .selected = layer .path === path ;
187
+ });
199
188
},
200
189
},
201
190
mounted() {
@@ -218,8 +207,8 @@ export default defineComponent({
218
207
PopoverDirection ,
219
208
SeparatorType ,
220
209
layers: [] as Array <LayerPanelEntry >,
221
- startPath: new BigUint64Array ([]) ,
222
- endPath: new BigUint64Array ([]) ,
210
+ startPath: - 1 n ,
211
+ endPath: - 1 n ,
223
212
};
224
213
},
225
214
});
0 commit comments