Bastien Sevajol hace 3 años
padre
commit
3ee0fcf7f0
Se han modificado 1 ficheros con 22 adiciones y 11 borrados
  1. 22 11
      src/scene/main.rs

+ 22 - 11
src/scene/main.rs Ver fichero

@@ -182,11 +182,18 @@ impl MainState {
182 182
                     self.selected_scene_items
183 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 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 198
                         if self.selected_scene_items.contains(&scene_item_usize) {
192 199
                             let scene_item = self
@@ -384,15 +391,19 @@ impl event::EventHandler for MainState {
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 400
                 scene_mesh_builder.rectangle(
390 401
                     DrawMode::fill(),
391 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 408
                     graphics::GREEN,
398 409
                 )?;
@@ -400,7 +411,7 @@ impl event::EventHandler for MainState {
400 411
 
401 412
             scene_mesh_builder.circle(
402 413
                 DrawMode::fill(),
403
-                window_point_from_scene_point(&left_click_down, &self.display_offset),
414
+                scene_left_click_down_point,
404 415
                 2.0,
405 416
                 2.0,
406 417
                 graphics::YELLOW,