Fix input offsets
This commit is contained in:
+5
-6
@@ -432,12 +432,11 @@ fn main() {
|
|||||||
app.flush_display();
|
app.flush_display();
|
||||||
}
|
}
|
||||||
Cmd::Input { pos, input } => {
|
Cmd::Input { pos, input } => {
|
||||||
if pos.0 >= 20 || pos.1 >= 20 {
|
if let Some(m) = app.get_module(pos) {
|
||||||
// We need to deal with our margin.
|
let bounds = m.get_bounds();
|
||||||
if let Some(m) = app.get_module(pos) {
|
let input = input.offset((bounds.0, bounds.1));
|
||||||
m.input(input);
|
m.input(input);
|
||||||
q.lock().unwrap().push_back(Cmd::Draw);
|
q.lock().unwrap().push_back(Cmd::Draw);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::Exit => {
|
Cmd::Exit => {
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ pub enum Input {
|
|||||||
Scroll { pos: (u32, u32), x: f64, y: f64 },
|
Scroll { pos: (u32, u32), x: f64, y: f64 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Input {
|
||||||
|
pub fn offset(&self, offset: (u32, u32)) -> Input{
|
||||||
|
match self {
|
||||||
|
Input::Click{pos, button} => Input::Click{pos: (pos.0 - offset.0, pos.1 - offset.1), button: *button},
|
||||||
|
Input::Scroll{pos, x, y} => Input::Scroll{pos: (pos.0 - offset.0, pos.1 - offset.1), x: *x, y: *y},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait ModuleImpl {
|
pub trait ModuleImpl {
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
Reference in New Issue
Block a user