Mercurial > tablet-emu
diff src/state.rs @ 17:0bce7fe96937
Add a client, copy of the GTK interface.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 26 Aug 2021 22:00:55 +0200 |
parents | 478cf2a7d577 |
children |
line wrap: on
line diff
--- a/src/state.rs +++ b/src/state.rs @@ -109,3 +109,48 @@ impl State { Ok(()) } } + +pub struct FakeState { + width: f64, + height: f64, + selected_tool: Key, + pressed: bool, +} + +impl FakeState { + pub fn new() -> FakeState { + FakeState { + width: DEFAULT_WIDTH as f64, + height: DEFAULT_HEIGHT as f64, + selected_tool: Key::ButtonToolPen, + pressed: false, + } + } + + pub fn is_pressed(&self) -> bool { + self.pressed + } + + pub fn set_size(&mut self, width: i32, height: i32) { + self.width = width as f64; + self.height = height as f64; + } + + pub fn select_tool(&mut self, tool: Key) { + self.selected_tool = tool; + } + + pub fn press(&mut self, _x: f64, _y: f64) -> std::io::Result<()> { + self.pressed = true; + Ok(()) + } + + pub fn release(&mut self, _x: f64, _y: f64) -> std::io::Result<()> { + self.pressed = false; + Ok(()) + } + + pub fn motion(&mut self, _x: f64, _y: f64) -> std::io::Result<()> { + Ok(()) + } +}