@@ -7,6 +7,8 @@ use egui::{
77
88use crate :: { assets, config:: CanvasConfig } ;
99
10+ const EDGE_THRESHOLD : f32 = 15.0 ;
11+
1012// TODO Direction is not used anymore. I can calculate it from current positions?
1113#[ derive( serde:: Deserialize , serde:: Serialize , Debug , Clone , Copy , Default , Eq , PartialEq ) ]
1214pub enum Direction {
@@ -547,7 +549,6 @@ impl TemplateApp {
547549 fn draw_canvas ( & mut self , ui : & mut Ui ) {
548550 let ( resp, _painter) = ui. allocate_painter ( ui. available_size ( ) , Sense :: hover ( ) ) ;
549551 let canvas_rect = resp. rect ;
550- let threshold = 10.0 ;
551552
552553 if let Some ( pd) = & mut self . panel_drag {
553554 if let Some ( mouse) = ui. ctx ( ) . pointer_interact_pos ( ) {
@@ -641,12 +642,12 @@ impl TemplateApp {
641642 ) ) ;
642643 }
643644 InstanceType :: Wire ( wire) => {
644- if mouse_pos. distance ( wire. end ) < 10.0 {
645+ if mouse_pos. distance ( wire. end ) < EDGE_THRESHOLD {
645646 self . resize = Some ( Resize {
646647 id : instance. id ,
647648 start : false ,
648649 } ) ;
649- } else if mouse_pos. distance ( wire. start ) < 10.0 {
650+ } else if mouse_pos. distance ( wire. start ) < EDGE_THRESHOLD {
650651 self . resize = Some ( Resize {
651652 id : instance. id ,
652653 start : true ,
@@ -711,7 +712,7 @@ impl TemplateApp {
711712 continue ;
712713 }
713714 for other_pin in other_ins. pins ( ) {
714- if self_pin. pos . distance ( other_pin. pos ) > threshold {
715+ if self_pin. pos . distance ( other_pin. pos ) > EDGE_THRESHOLD {
715716 continue ;
716717 }
717718
@@ -729,9 +730,9 @@ impl TemplateApp {
729730 // TODO: inefficient but okay for now. We want to highlight connections for moving
730731 // object.
731732 for conn in & possible_connections {
732- if let Some ( ( pin , _ ) ) = conn. get_pin ( moving_instance_id) {
733+ if let Some ( ( _ , other ) ) = conn. get_pin ( moving_instance_id) {
733734 ui. painter ( )
734- . circle_filled ( pin . pos , 10.0 , Color32 :: LIGHT_YELLOW ) ;
735+ . circle_filled ( other . pos , EDGE_THRESHOLD , Color32 :: LIGHT_YELLOW ) ;
735736 }
736737 }
737738 if mouse_up {
0 commit comments