diff options
| author | Arne Dußin | 2020-11-15 19:47:39 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-15 19:47:39 +0100 |
| commit | aff7416b65281458ba478ec24b77d94b183e3b82 (patch) | |
| tree | 5c7777b318a6fa8b85d76521a6781c8eae60ce63 /src/tool/room_tool.rs | |
| parent | 6aabd0123961d90095df3cefefeb0718f94aa6fc (diff) | |
| download | graf_karto-aff7416b65281458ba478ec24b77d94b183e3b82.tar.gz graf_karto-aff7416b65281458ba478ec24b77d94b183e3b82.zip | |
Fix the dimension indicators persisting after add
The dimension indicators were drawn very for the blink of an eye when
starting a rect that comes after the first. This commit should fix that.
Diffstat (limited to 'src/tool/room_tool.rs')
| -rw-r--r-- | src/tool/room_tool.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs index 0ac74b5..3416596 100644 --- a/src/tool/room_tool.rs +++ b/src/tool/room_tool.rs @@ -30,6 +30,11 @@ impl RoomTool { } impl Tool for RoomTool { + fn deactivate(&mut self) { + self.unfinished_rect = None; + self.dimension_indicator.clear_dimensions(); + } + fn active_update(&mut self, map_data: &mut MapData, rl: &RaylibHandle, transform: &Transform) { let mouse_pos_m = transform.point_px_to_m(rl.get_mouse_position().into()); // Update the currently drawn rectangle, if it exists, and also its dimension indicator. @@ -42,6 +47,7 @@ impl Tool for RoomTool { // Start or finish drawing the currently unfinished rectangle if self.keybindings.finish_draw.is_pressed(rl) && self.unfinished_rect.is_some() { let (pos1, pos2) = self.unfinished_rect.take().unwrap(); + self.dimension_indicator.clear_dimensions(); map_data.rooms_mut().push(Rect::bounding_rect(pos1, pos2)); } else if self.keybindings.start_draw.is_pressed(rl) { let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE); |
