File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -663,10 +663,22 @@ impl App {
663663 . pointer_interact_pos ( )
664664 . map ( |p| self . screen_to_world ( p) ) ;
665665
666- if resp. dragged ( )
666+ if resp. drag_started ( )
667667 && let Some ( pos) = mouse_pos_world
668668 {
669- self . drag = Some ( Drag :: Panel { pos, kind } ) ;
669+ let id = match kind {
670+ InstanceKind :: Gate ( kind) => self . db . new_gate ( Gate { pos, kind } ) ,
671+ InstanceKind :: Power => self . db . new_power ( Power { pos, on : true } ) ,
672+ InstanceKind :: Wire => self . db . new_wire ( Wire :: new_at ( pos) ) ,
673+ InstanceKind :: CustomCircuit ( c) => self . db . new_custom_circuit ( CustomCircuit {
674+ pos,
675+ definition_index : c,
676+ } ) ,
677+ } ;
678+ self . drag = Some ( Drag :: Canvas ( crate :: drag:: CanvasDrag :: Single {
679+ id,
680+ offset : Vec2 :: ZERO ,
681+ } ) ) ;
670682 }
671683 ui. add_space ( 8.0 ) ;
672684
@@ -788,7 +800,7 @@ impl App {
788800 let dragging = self . drag . is_some ( ) ;
789801 let hovered_now = self . get_hovered ( mouse) ;
790802
791- if mouse_clicked {
803+ if mouse_clicked && self . drag . is_none ( ) {
792804 self . hovered = hovered_now;
793805 self . clicked_on = hovered_now. map ( |h| h. instance ( ) ) ;
794806 self . handle_drag_start_canvas ( mouse) ;
You can’t perform that action at this time.
0 commit comments