From 9799d3c6a8f0c242668203a1c70d7b6cfed3e855 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 15 Dec 2020 00:46:54 +0100 Subject: Refactor to make interaction between tools easier --- src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 7e04456..de42ab7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,9 @@ pub mod dimension_indicator; pub mod editor; pub mod grid; pub mod gui; -pub mod map_data; +pub mod map; pub mod math; +pub mod scaleable; pub mod svg; pub mod tool; pub mod transform; @@ -75,6 +76,8 @@ fn main() { if rl.is_mouse_button_down(MouseButton::MOUSE_MIDDLE_BUTTON) { transform.move_by_px(&(rl.get_mouse_position() - last_mouse_pos).into()); } + // Update the last mouse position + last_mouse_pos = rl.get_mouse_position(); let mouse_wheel_move = rl.get_mouse_wheel_move(); if mouse_wheel_move != 0 { @@ -87,19 +90,17 @@ fn main() { } editor.update( - &rl, + &mut rl, &transform, - ToolSidebar::mouse_captured(screen_height as u16, rl.get_mouse_position().into()), + ToolSidebar::mouse_captured(screen_height as u16, last_mouse_pos.into()), ); - // Update the last mouse position - last_mouse_pos = rl.get_mouse_position(); - // Drawing section { let mut d = rl.begin_drawing(&thread); d.clear_background(Color::BLACK); grid::draw_grid(&mut d, screen_width, screen_height, &transform); + editor.map().draw(&mut d, &transform); editor.draw_tools(&mut d, &transform); tool_sidebar.draw(screen_height as u16, &mut d, &mut editor); -- cgit v1.2.3-70-g09d2