@@ -422,7 +422,10 @@ impl CircuitViewTemplate {
422
422
match selection {
423
423
Some ( Selection :: MoveBlock ( block) ) => {
424
424
let app = self . application . borrow ( ) ;
425
- app. new_action ( Action :: NewBlock ( self . plot_provider . borrow ( ) . clone ( ) , * block) ) ;
425
+ app. new_action ( Action :: NewBlock (
426
+ self . plot_provider . borrow ( ) . clone ( ) ,
427
+ * block,
428
+ ) ) ;
426
429
let window = app. imp ( ) . window ( ) . borrow ( ) ;
427
430
window. as_ref ( ) . unwrap ( ) . module_list ( ) . unselect_items ( ) ;
428
431
}
@@ -593,21 +596,26 @@ impl CircuitViewTemplate {
593
596
}
594
597
}
595
598
Selection :: Connection ( ConnectionSource :: Block ( origin_id, output) , _, position) => {
596
- let connection = plot_provider. with_mut ( |plot| {
597
- plot. set_selection ( Selection :: None ) ;
598
-
599
- if let Some ( block_id) = plot. get_block_at ( position) &&
600
- let Some ( block) = plot. get_block ( block_id) &&
601
- let Some ( i) = block. position_on_connection ( position, true ) {
602
-
603
- block. connection ( Connector :: Input ( i) ) . is_none ( ) . then ( ||
604
- Connection :: new_basic ( origin_id, output, block_id, i )
605
- )
606
- }
607
- else {
608
- Some ( Connection :: new ( Port :: Output ( origin_id, output) , vec ! [ Segment :: Waypoint ( HashMap :: new( ) , position, false ) ] ) )
609
- }
610
- } ) . flatten ( ) ;
599
+ let connection = plot_provider
600
+ . with_mut ( |plot| {
601
+ plot. set_selection ( Selection :: None ) ;
602
+
603
+ if let Some ( block_id) = plot. get_block_at ( position)
604
+ && let Some ( block) = plot. get_block ( block_id)
605
+ && let Some ( i) = block. position_on_connection ( position, true )
606
+ {
607
+ block
608
+ . connection ( Connector :: Input ( i) )
609
+ . is_none ( )
610
+ . then ( || Connection :: new_basic ( origin_id, output, block_id, i) )
611
+ } else {
612
+ Some ( Connection :: new (
613
+ Port :: Output ( origin_id, output) ,
614
+ vec ! [ Segment :: Waypoint ( HashMap :: new( ) , position, false ) ] ,
615
+ ) )
616
+ }
617
+ } )
618
+ . flatten ( ) ;
611
619
612
620
if let Some ( connection) = connection {
613
621
self . application
@@ -618,17 +626,22 @@ impl CircuitViewTemplate {
618
626
self . drawing_area . queue_draw ( )
619
627
}
620
628
Selection :: Connection ( ConnectionSource :: Waypoint ( segment_id) , _, position) => {
621
- let segment = plot_provider. with_mut ( |plot| {
622
- plot. set_selection ( Selection :: None ) ;
623
- if let Some ( block_id) = plot. get_block_at ( position) &&
624
- let Some ( block) = plot. get_block ( block_id) &&
625
- let Some ( i) = block. position_on_connection ( position, true ) {
626
- block. connection ( Connector :: Input ( i) ) . is_none ( ) . then_some ( Segment :: Block ( block_id, i) )
627
- }
628
- else {
629
- Some ( Segment :: Waypoint ( HashMap :: new ( ) , position, false ) )
630
- }
631
- } ) . flatten ( ) ;
629
+ let segment = plot_provider
630
+ . with_mut ( |plot| {
631
+ plot. set_selection ( Selection :: None ) ;
632
+ if let Some ( block_id) = plot. get_block_at ( position)
633
+ && let Some ( block) = plot. get_block ( block_id)
634
+ && let Some ( i) = block. position_on_connection ( position, true )
635
+ {
636
+ block
637
+ . connection ( Connector :: Input ( i) )
638
+ . is_none ( )
639
+ . then_some ( Segment :: Block ( block_id, i) )
640
+ } else {
641
+ Some ( Segment :: Waypoint ( HashMap :: new ( ) , position, false ) )
642
+ }
643
+ } )
644
+ . flatten ( ) ;
632
645
633
646
if let Some ( segment) = segment {
634
647
self . application . borrow ( ) . new_action ( Action :: AddSegment (
0 commit comments