@@ -36,7 +36,7 @@ pub enum Drag {
3636 } ,
3737 PinToWire {
3838 source_pin : Pin ,
39- wire_id : InstanceId ,
39+ start_pos : Pos2 ,
4040 } ,
4141 BranchWire {
4242 original_wire_id : InstanceId ,
@@ -86,12 +86,10 @@ impl App {
8686 return ;
8787 }
8888 let pin_pos = self . db . pin_position ( pin) ;
89- let wire_id = self . db . new_wire ( Wire :: new ( pin_pos, mouse) ) ;
9089 self . drag = Some ( Drag :: PinToWire {
9190 source_pin : pin,
92- wire_id ,
91+ start_pos : pin_pos ,
9392 } ) ;
94- self . current_dirty = true ;
9593 }
9694 Hover :: Instance ( instance) => match self . db . ty ( instance) {
9795 InstanceKind :: Gate ( _) => {
@@ -250,16 +248,30 @@ impl App {
250248 }
251249 Some ( Drag :: PinToWire {
252250 source_pin : _,
253- wire_id ,
251+ start_pos ,
254252 } ) => {
255- let wire = self . db . get_wire_mut ( wire_id) ;
256- if wire. end != mouse {
257- wire. end = mouse;
258- self . drag_had_movement = true ;
259- }
253+ let drag_distance = ( mouse - start_pos) . length ( ) ;
254+
255+ if drag_distance >= MIN_WIRE_SIZE {
256+ let wire = Wire :: new ( start_pos, mouse) ;
257+ let wire_id = self . db . new_wire ( wire) ;
258+
259+ self . drag = Some ( Drag :: Resize {
260+ id : wire_id,
261+ start : false ,
262+ } ) ;
260263
261- if wire . end != mouse {
264+ self . drag_had_movement = true ;
262265 self . connection_manager . mark_instance_dirty ( wire_id) ;
266+ self . current_dirty = true ;
267+ } else if drag_distance > 2.0 {
268+ ui. painter ( ) . line_segment (
269+ [
270+ start_pos - self . viewport_offset ,
271+ mouse - self . viewport_offset ,
272+ ] ,
273+ Stroke :: new ( 2.0 , COLOR_HOVER_PIN_TO_WIRE ) ,
274+ ) ;
263275 }
264276 }
265277 Some ( Drag :: BranchWire {
@@ -375,10 +387,10 @@ impl App {
375387 }
376388 Drag :: PinToWire {
377389 source_pin : _,
378- wire_id ,
390+ start_pos : _ ,
379391 } => {
380- self . connection_manager . mark_instance_dirty ( wire_id ) ;
381- self . connection_manager . rebuild_spatial_index ( & self . db ) ;
392+ // Wire was never created if drag distance was too short
393+ // Nothing to clean up
382394 }
383395 Drag :: BranchWire {
384396 original_wire_id,
0 commit comments