Browse Source

fix points

Bastien Sevajol 3 years ago
parent
commit
3ee0fcf7f0
1 changed files with 22 additions and 11 deletions
  1. 22 11
      src/scene/main.rs

+ 22 - 11
src/scene/main.rs View File

182
                     self.selected_scene_items
182
                     self.selected_scene_items
183
                         .extend(self.get_scene_items_for_scene_area(&scene_from, &scene_to));
183
                         .extend(self.get_scene_items_for_scene_area(&scene_from, &scene_to));
184
                 }
184
                 }
185
-                UserEvent::RightClick(window_position) => {
186
-                    let scene_point =
187
-                        scene_point_from_window_point(&window_position, &self.display_offset);
185
+                UserEvent::RightClick(window_right_click_point) => {
186
+                    let scene_right_click_point = scene_point_from_window_point(
187
+                        &window_right_click_point,
188
+                        &self.display_offset,
189
+                    );
190
+
191
+                    // TODO: aucune selection et right click sur un item: scene_item_menu sur un item
192
+                    // TODO: selection et right click sur un item de la selection: scene_item_menu sur un TOUS les item de la selection
193
+                    // TODO: selection et right click sur un item PAS dans la selection: scene_item_menu sur un item
194
+
188
                     if let Some(scene_item_usize) =
195
                     if let Some(scene_item_usize) =
189
-                        self.get_first_scene_item_for_scene_point(&scene_point)
196
+                        self.get_first_scene_item_for_scene_point(&scene_right_click_point)
190
                     {
197
                     {
191
                         if self.selected_scene_items.contains(&scene_item_usize) {
198
                         if self.selected_scene_items.contains(&scene_item_usize) {
192
                             let scene_item = self
199
                             let scene_item = self
384
             )?;
391
             )?;
385
         }
392
         }
386
 
393
 
387
-        if let Some(left_click_down) = self.left_click_down {
388
-            if left_click_down != self.current_cursor_position {
394
+        if let Some(window_left_click_down_point) = self.left_click_down {
395
+            let scene_left_click_down_point =
396
+                scene_point_from_window_point(&window_left_click_down_point, &self.display_offset);
397
+            let scene_current_cursor_position =
398
+                scene_point_from_window_point(&self.current_cursor_position, &self.display_offset);
399
+            if scene_left_click_down_point != scene_current_cursor_position {
389
                 scene_mesh_builder.rectangle(
400
                 scene_mesh_builder.rectangle(
390
                     DrawMode::fill(),
401
                     DrawMode::fill(),
391
                     graphics::Rect::new(
402
                     graphics::Rect::new(
392
-                        left_click_down.x - self.display_offset.x,
393
-                        left_click_down.y - self.display_offset.y,
394
-                        self.current_cursor_position.x - left_click_down.x,
395
-                        self.current_cursor_position.y - left_click_down.y,
403
+                        scene_left_click_down_point.x,
404
+                        scene_left_click_down_point.y,
405
+                        scene_current_cursor_position.x - scene_left_click_down_point.x,
406
+                        scene_current_cursor_position.y - scene_left_click_down_point.y,
396
                     ),
407
                     ),
397
                     graphics::GREEN,
408
                     graphics::GREEN,
398
                 )?;
409
                 )?;
400
 
411
 
401
             scene_mesh_builder.circle(
412
             scene_mesh_builder.circle(
402
                 DrawMode::fill(),
413
                 DrawMode::fill(),
403
-                window_point_from_scene_point(&left_click_down, &self.display_offset),
414
+                scene_left_click_down_point,
404
                 2.0,
415
                 2.0,
405
                 2.0,
416
                 2.0,
406
                 graphics::YELLOW,
417
                 graphics::YELLOW,