aboutsummaryrefslogtreecommitdiff
path: root/src/tool/deletion_tool.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool/deletion_tool.rs')
-rw-r--r--src/tool/deletion_tool.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/tool/deletion_tool.rs b/src/tool/deletion_tool.rs
index 5ff3e6a..afd916a 100644
--- a/src/tool/deletion_tool.rs
+++ b/src/tool/deletion_tool.rs
@@ -1,15 +1,26 @@
+//! A meta tool for selecting parts of a map and removing them in a single operation.
+//!
+//! The user can draw a rectangle, which currently must have it's side parallel to the x and y-axes
+//! of the world. With the first node placement, the mode is started, while the second placement would
+//! finish the process and delete all elements that are *completely* contained in the rectangle
+//! (partially contained items are not deleted) or abort it, in which case the selection is removed
+//! and nothing is deleted.
+
use super::Tool;
+use crate::colours::DEFAULT_COLOURS;
use crate::map::Map;
use crate::math::{Rect, Surface, Vec2};
use crate::transform::Transform;
-use crate::colours::DEFAULT_COLOURS;
use raylib::core::drawing::{RaylibDraw, RaylibDrawHandle};
+/// The deletion tool itself.
pub struct DeletionTool {
deletion_rect: Option<(Vec2<f64>, Vec2<f64>)>,
}
impl DeletionTool {
+ /// Create a new deletion tool, there should only be one deletion tool and it should be created
+ /// by the editor.
pub fn new() -> Self {
Self {
deletion_rect: None,
@@ -36,15 +47,8 @@ impl Tool for DeletionTool {
fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) {
if let Some((pos1, pos2)) = self.deletion_rect {
let rect_px = transform.rect_m_to_px(&Rect::bounding_rect(pos1, pos2));
- rld.draw_rectangle_rec(
- rect_px,
- DEFAULT_COLOURS.deletion_rect
- );
- rld.draw_rectangle_lines_ex(
- rect_px,
- 4,
- DEFAULT_COLOURS.deletion_rect_outline
- );
+ rld.draw_rectangle_rec(rect_px, DEFAULT_COLOURS.deletion_rect);
+ rld.draw_rectangle_lines_ex(rect_px, 4, DEFAULT_COLOURS.deletion_rect_outline);
}
}