@@ -80,8 +80,7 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
8080 let points = shape_editor. selected_points ( ) ;
8181 let selected_points: Vec < & ManipulatorPointId > = points. collect ( ) ;
8282
83- if selected_points. len ( ) == 1 {
84- let point = & selected_points[ 0 ] ;
83+ if let [ point] = selected_points. as_slice ( ) {
8584 if let ManipulatorPointId :: PrimaryHandle ( _) | ManipulatorPointId :: EndHandle ( _) = point {
8685 let anchor_position = point. get_anchor_position ( & vector_data) . unwrap ( ) ;
8786 * selected. pivot = viewspace. transform_point2 ( anchor_position) ;
@@ -114,10 +113,10 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
114113 responses. add ( NodeGraphMessage :: RunDocumentGraph ) ;
115114 }
116115 TransformLayerMessage :: BeginGrab => {
117- if ! ( using_path_tool || using_select_tool)
116+ if ( ! using_path_tool && ! using_select_tool)
118117 || ( using_path_tool && shape_editor. selected_points ( ) . next ( ) . is_none ( ) )
119- || matches ! ( self . transform_operation, TransformOperation :: Grabbing ( _) )
120118 || selected_layers. is_empty ( )
119+ || matches ! ( self . transform_operation, TransformOperation :: Grabbing ( _) )
121120 {
122121 selected. original_transforms . clear ( ) ;
123122
@@ -132,7 +131,8 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
132131 }
133132 TransformLayerMessage :: BeginRotate => {
134133 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)
136136 || ( using_path_tool && selected_points. is_empty ( ) )
137137 || selected_layers. is_empty ( )
138138 || matches ! ( self . transform_operation, TransformOperation :: Rotating ( _) )
@@ -141,37 +141,31 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
141141 return ;
142142 }
143143
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+ } ;
160148
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) ;
162154
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 ;
169157 }
170158 }
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+ }
171168 }
172- } else {
173- selected. original_transforms . clear ( ) ;
174- return ;
175169 }
176170
177171 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
184178 let selected_points: Vec < & ManipulatorPointId > = shape_editor. selected_points ( ) . collect ( ) ;
185179
186180 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)
189182 || selected_layers. is_empty ( )
183+ || matches ! ( self . transform_operation, TransformOperation :: Scaling ( _) )
190184 {
191185 selected. original_transforms . clear ( ) ;
192186 return ;
193187 }
194188
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 ;
220203 }
221204 }
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+ }
222212 }
223- } else {
224- selected. original_transforms . clear ( ) ;
225- return ;
226213 }
227214
228215 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
295282 }
296283 } ;
297284 }
285+
298286 self . mouse_position = input. mouse . position ;
299287 }
300288 TransformLayerMessage :: SelectionChanged => {
0 commit comments