@@ -80,8 +80,7 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
80
80
let points = shape_editor. selected_points ( ) ;
81
81
let selected_points: Vec < & ManipulatorPointId > = points. collect ( ) ;
82
82
83
- if selected_points. len ( ) == 1 {
84
- let point = & selected_points[ 0 ] ;
83
+ if let [ point] = selected_points. as_slice ( ) {
85
84
if let ManipulatorPointId :: PrimaryHandle ( _) | ManipulatorPointId :: EndHandle ( _) = point {
86
85
let anchor_position = point. get_anchor_position ( & vector_data) . unwrap ( ) ;
87
86
* selected. pivot = viewspace. transform_point2 ( anchor_position) ;
@@ -114,10 +113,10 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
114
113
responses. add ( NodeGraphMessage :: RunDocumentGraph ) ;
115
114
}
116
115
TransformLayerMessage :: BeginGrab => {
117
- if ! ( using_path_tool || using_select_tool)
116
+ if ( ! using_path_tool && ! using_select_tool)
118
117
|| ( using_path_tool && shape_editor. selected_points ( ) . next ( ) . is_none ( ) )
119
- || matches ! ( self . transform_operation, TransformOperation :: Grabbing ( _) )
120
118
|| selected_layers. is_empty ( )
119
+ || matches ! ( self . transform_operation, TransformOperation :: Grabbing ( _) )
121
120
{
122
121
selected. original_transforms . clear ( ) ;
123
122
@@ -132,7 +131,8 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
132
131
}
133
132
TransformLayerMessage :: BeginRotate => {
134
133
let selected_points: Vec < & ManipulatorPointId > = shape_editor. selected_points ( ) . collect ( ) ;
135
- if !( using_path_tool || using_select_tool)
134
+
135
+ if ( !using_path_tool && !using_select_tool)
136
136
|| ( using_path_tool && selected_points. is_empty ( ) )
137
137
|| selected_layers. is_empty ( )
138
138
|| matches ! ( self . transform_operation, TransformOperation :: Rotating ( _) )
@@ -141,37 +141,31 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
141
141
return ;
142
142
}
143
143
144
- if let Some ( vector_data) = selected_layers. first ( ) . and_then ( |& layer| document. network_interface . compute_modified_vector ( layer) ) {
145
- if selected_points. len ( ) == 1 {
146
- let point = & selected_points[ 0 ] ;
147
-
148
- match point {
149
- ManipulatorPointId :: Anchor ( _) => {
150
- if let Some ( [ handle1, handle2] ) = point. get_handle_pair ( & vector_data) {
151
- if ( handle1. get_handle_length ( & vector_data) == 0. && handle2. get_handle_length ( & vector_data) == 0. )
152
- || ( handle1. get_handle_length ( & vector_data) == f64:: MAX && handle2. get_handle_length ( & vector_data) == f64:: MAX )
153
- {
154
- return ;
155
- }
156
- }
157
- }
158
- _ => {
159
- // TODO: Need to fix handle snap to anchor issue. SEE (https://discord.com/channels/731730685944922173/1217752903209713715).
144
+ let Some ( vector_data) = selected_layers. first ( ) . and_then ( |& layer| document. network_interface . compute_modified_vector ( layer) ) else {
145
+ selected. original_transforms . clear ( ) ;
146
+ return ;
147
+ } ;
160
148
161
- let handle_length = point. as_handle ( ) . and_then ( |handle| Some ( handle. get_handle_length ( & vector_data) ) ) ;
149
+ if let [ point] = selected_points. as_slice ( ) {
150
+ if matches ! ( point, ManipulatorPointId :: Anchor ( _) ) {
151
+ if let Some ( [ handle1, handle2] ) = point. get_handle_pair ( & vector_data) {
152
+ let handle1_length = handle1. length ( & vector_data) ;
153
+ let handle2_length = handle2. length ( & vector_data) ;
162
154
163
- if let Some ( length) = handle_length {
164
- if length == 0. {
165
- selected. original_transforms . clear ( ) ;
166
- return ;
167
- }
168
- }
155
+ if ( handle1_length == 0. && handle2_length == 0. ) || ( handle1_length == f64:: MAX && handle2_length == f64:: MAX ) {
156
+ return ;
169
157
}
170
158
}
159
+ } else {
160
+ // TODO: Fix handle snap to anchor issue, see <https://discord.com/channels/731730685944922173/1217752903209713715>
161
+
162
+ let handle_length = point. as_handle ( ) . map ( |handle| handle. length ( & vector_data) ) ;
163
+
164
+ if handle_length == Some ( 0. ) {
165
+ selected. original_transforms . clear ( ) ;
166
+ return ;
167
+ }
171
168
}
172
- } else {
173
- selected. original_transforms . clear ( ) ;
174
- return ;
175
169
}
176
170
177
171
begin_operation ( self . transform_operation , & mut self . typing , & mut self . mouse_position , & mut self . start_mouse ) ;
@@ -184,45 +178,38 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
184
178
let selected_points: Vec < & ManipulatorPointId > = shape_editor. selected_points ( ) . collect ( ) ;
185
179
186
180
if ( using_path_tool && selected_points. is_empty ( ) )
187
- || !( using_path_tool || using_select_tool)
188
- || matches ! ( self . transform_operation, TransformOperation :: Scaling ( _) )
181
+ || ( !using_path_tool && !using_select_tool)
189
182
|| selected_layers. is_empty ( )
183
+ || matches ! ( self . transform_operation, TransformOperation :: Scaling ( _) )
190
184
{
191
185
selected. original_transforms . clear ( ) ;
192
186
return ;
193
187
}
194
188
195
- if let Some ( vector_data) = selected_layers. first ( ) . and_then ( |& layer| document. network_interface . compute_modified_vector ( layer) ) {
196
- if selected_points. len ( ) == 1 {
197
- let point = & selected_points[ 0 ] ;
198
-
199
- match point {
200
- ManipulatorPointId :: Anchor ( _) => {
201
- if let Some ( [ handle1, handle2] ) = point. get_handle_pair ( & vector_data) {
202
- let handle1_length = handle1. get_handle_length ( & vector_data) ;
203
- let handle2_length = handle2. get_handle_length ( & vector_data) ;
204
-
205
- if ( handle1_length == 0. && handle2_length == 0. ) || ( handle1_length == f64:: MAX && handle2_length == f64:: MAX ) {
206
- selected. original_transforms . clear ( ) ;
207
- return ;
208
- }
209
- }
210
- }
211
- _ => {
212
- let handle_length = point. as_handle ( ) . and_then ( |handle| Some ( handle. get_handle_length ( & vector_data) ) ) ;
213
-
214
- if let Some ( length) = handle_length {
215
- if length == 0. {
216
- selected. original_transforms . clear ( ) ;
217
- return ;
218
- }
219
- }
189
+ let Some ( vector_data) = selected_layers. first ( ) . and_then ( |& layer| document. network_interface . compute_modified_vector ( layer) ) else {
190
+ selected. original_transforms . clear ( ) ;
191
+ return ;
192
+ } ;
193
+
194
+ if let [ point] = selected_points. as_slice ( ) {
195
+ if matches ! ( point, ManipulatorPointId :: Anchor ( _) ) {
196
+ if let Some ( [ handle1, handle2] ) = point. get_handle_pair ( & vector_data) {
197
+ let handle1_length = handle1. length ( & vector_data) ;
198
+ let handle2_length = handle2. length ( & vector_data) ;
199
+
200
+ if ( handle1_length == 0. && handle2_length == 0. ) || ( handle1_length == f64:: MAX && handle2_length == f64:: MAX ) {
201
+ selected. original_transforms . clear ( ) ;
202
+ return ;
220
203
}
221
204
}
205
+ } else {
206
+ let handle_length = point. as_handle ( ) . map ( |handle| handle. length ( & vector_data) ) ;
207
+
208
+ if handle_length == Some ( 0. ) {
209
+ selected. original_transforms . clear ( ) ;
210
+ return ;
211
+ }
222
212
}
223
- } else {
224
- selected. original_transforms . clear ( ) ;
225
- return ;
226
213
}
227
214
228
215
begin_operation ( self . transform_operation , & mut self . typing , & mut self . mouse_position , & mut self . start_mouse ) ;
@@ -295,6 +282,7 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
295
282
}
296
283
} ;
297
284
}
285
+
298
286
self . mouse_position = input. mouse . position ;
299
287
}
300
288
TransformLayerMessage :: SelectionChanged => {
0 commit comments