git.lucas.co / cce-designer
graphic design tool
git clone https://git.lucas.co/cce-designer.git

commita141f69904eddddc44a6b4eda631d61010598c31
parent005d9297ed
authorLucas Galante <[email protected]>
date2026-05-28 15:43
Update system configuration and interface modules

 src/main.rs | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 914ec31..57707cc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2595,6 +2595,8 @@ fn geometry_to_spreadsheet_data(geom: &Geometry) -> (Vec<String>, Vec<Vec<String
 }
 
     fn on_path_changed(&mut self) {
+        self.drag_widget = None;
+        self.focused_widget = None;
         self.pan_x = 0.0;
         self.pan_y = 0.0;
         self.pan_velocity_x = 0.0;
@@ -4350,14 +4352,16 @@ fn geometry_to_spreadsheet_data(geom: &Geometry) -> (Vec<String>, Vec<Vec<String
                             let idx = self.drag_widget.unwrap();
                             if self.node_slots.contains(&idx) {
                                 if let Some(slot_idx) = self.node_slots.iter().position(|&x| x == idx) {
-                                    let pos = self.current_dir().children[slot_idx].position;
-                                    let (nx, ny) = self.find_empty_cell(pos.0, pos.1, Some(slot_idx));
-                                    self.current_dir_mut().children[slot_idx].position = (nx, ny);
-                                    self.left_offsets[slot_idx] = (nx, ny);
-                                    self.rebuild_positions();
-                                    self.apply_layout();
-                                    self.update_panel_bounds();
-                                    self.upload_vertices();
+                                    if slot_idx < self.current_dir().children.len() {
+                                        let pos = self.current_dir().children[slot_idx].position;
+                                        let (nx, ny) = self.find_empty_cell(pos.0, pos.1, Some(slot_idx));
+                                        self.current_dir_mut().children[slot_idx].position = (nx, ny);
+                                        self.left_offsets[slot_idx] = (nx, ny);
+                                        self.rebuild_positions();
+                                        self.apply_layout();
+                                        self.update_panel_bounds();
+                                        self.upload_vertices();
+                                    }
                                 }
                             }
                             self.widgets[idx].drag_end();