aboutsummaryrefslogtreecommitdiff
path: root/src/tool/room_tool.rs
diff options
context:
space:
mode:
authorArne Dußin2020-11-20 20:00:28 +0100
committerArne Dußin2020-11-20 20:00:28 +0100
commitcf0cbe3fd28b2099b580edc1714b4d68bf7183cd (patch)
treeb03561c1ae7860cad247d089cb1ad728efa843ec /src/tool/room_tool.rs
parentf62dabcb390d4808739745c050dfba8e2826b214 (diff)
downloadgraf_karto-cf0cbe3fd28b2099b580edc1714b4d68bf7183cd.tar.gz
graf_karto-cf0cbe3fd28b2099b580edc1714b4d68bf7183cd.zip
Add simple tool sidebar gui
Diffstat (limited to 'src/tool/room_tool.rs')
-rw-r--r--src/tool/room_tool.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs
index 3416596..c4a8b8c 100644
--- a/src/tool/room_tool.rs
+++ b/src/tool/room_tool.rs
@@ -35,7 +35,13 @@ impl Tool for RoomTool {
self.dimension_indicator.clear_dimensions();
}
- fn active_update(&mut self, map_data: &mut MapData, rl: &RaylibHandle, transform: &Transform) {
+ fn active_update(
+ &mut self,
+ map_data: &mut MapData,
+ rl: &RaylibHandle,
+ transform: &Transform,
+ mouse_blocked: bool,
+ ) {
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.
if let Some((ref pos1, ref mut pos2)) = &mut self.unfinished_rect {
@@ -45,16 +51,18 @@ 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() {
+ if self.keybindings.finish_draw.is_pressed(rl, mouse_blocked)
+ && 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) {
+ } else if self.keybindings.start_draw.is_pressed(rl, mouse_blocked) {
let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE);
self.unfinished_rect = Some((snapped_mouse_pos, snapped_mouse_pos))
}
- if self.keybindings.abort_draw.is_pressed(rl) {
+ if self.keybindings.abort_draw.is_pressed(rl, false) {
self.unfinished_rect = None;
}
}