diff options
| author | Arne Dußin | 2021-01-17 14:19:59 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-01-17 14:19:59 +0100 |
| commit | b019d10df4080fdb0ab57445040d24f9b14abdac (patch) | |
| tree | 268305b1024f8a15a88eb72f593fcfab0f0e8d61 /src/client.rs | |
| parent | b58e965327deef14d6414a912bb6698c6f745ce9 (diff) | |
| parent | 51b7747e62c189d430318c67368a5c84e50ece61 (diff) | |
| download | graf_karto-b019d10df4080fdb0ab57445040d24f9b14abdac.tar.gz graf_karto-b019d10df4080fdb0ab57445040d24f9b14abdac.zip | |
Merge branch 'master' into net
Diffstat (limited to 'src/client.rs')
| -rw-r--r-- | src/client.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/client.rs b/src/client.rs index e100340..4ed5581 100644 --- a/src/client.rs +++ b/src/client.rs @@ -21,17 +21,18 @@ #[macro_use] extern crate log; -pub mod button; pub mod cli; pub mod colours; pub mod config; pub mod editor; pub mod grid; pub mod gui; +pub mod input; pub mod map; pub mod math; pub mod server; pub mod snapping; +pub mod stable_vec; pub mod svg; pub mod tool; pub mod transform; @@ -42,6 +43,7 @@ use config::Config; use editor::Editor; use float_cmp::F64Margin; use gui::{DimensionIndicator, ToolSidebar}; +use input::Input; use raylib::prelude::*; use snapping::Snapper; use std::ffi::CString; @@ -97,11 +99,13 @@ fn main() { &CString::new(GUI_STYLE).expect("Could not create C string from style file name"), )); + let mut input = Input::new(&rl); + config::register_bindings(&config, &mut input); let mut editor = Editor::new(&mut rl, &thread, config); let mut dimension_indicator = DimensionIndicator::new(); - let tool_sidebar = ToolSidebar::new(&mut rl, &thread); + let mut tool_sidebar = ToolSidebar::new(&mut rl, &thread, &mut input); let mut snapper = Snapper::default(); - let mut cli = CLI::new(); + let mut cli = CLI::new(&mut input); let mut transform = Transform::new(); let mut last_mouse_pos = rl.get_mouse_position(); @@ -109,6 +113,8 @@ fn main() { let screen_width = rl.get_screen_width(); let screen_height = rl.get_screen_height(); + input.update(&mut rl); + // Move the canvas together with the mouse if rl.is_mouse_button_down(MouseButton::MOUSE_MIDDLE_BUTTON) { transform.move_by_px(&(rl.get_mouse_position() - last_mouse_pos).into()); @@ -126,16 +132,11 @@ fn main() { ); } - cli.update(&mut rl, &mut editor); + cli.update(&mut editor, &mut input); dimension_indicator.update(editor.map_mut(), &mut rl); snapper.update(&mut rl, cli.active()); - editor.update( - &mut rl, - &transform, - &snapper, - ToolSidebar::mouse_captured(screen_height as u16, last_mouse_pos.into()), - cli.active(), - ); + editor.update(&mut rl, &transform, &snapper, &mut input); + tool_sidebar.update(screen_height as u16, &mut input); // Drawing section { @@ -145,7 +146,7 @@ fn main() { editor.map().draw(&mut d, &transform); editor.draw_tools(&mut d, &transform); - tool_sidebar.draw(screen_height as u16, &mut d, &mut editor); + tool_sidebar.draw(&mut d, &mut editor); snapper.draw(&mut d); gui::position_indicator_draw(&mut d, last_mouse_pos.into(), &transform, &snapper); dimension_indicator.draw(&mut d, &transform); |
