Canary egui harness cursor input
This commit is contained in:
parent
77465dab6e
commit
495fb40c9f
|
@ -1,4 +1,4 @@
|
||||||
use canary::ScriptInstance;
|
use canary::{CursorEventKind, ScriptInstance};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
@ -56,27 +56,30 @@ impl eframe::App for App {
|
||||||
let sense = egui::Sense {
|
let sense = egui::Sense {
|
||||||
click: true,
|
click: true,
|
||||||
drag: true,
|
drag: true,
|
||||||
focusable: false,
|
focusable: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (rect, response) = ui.allocate_at_least(size, sense);
|
let (rect, response) = ui.allocate_at_least(size, sense);
|
||||||
|
|
||||||
// TODO input events
|
if let Some(hover_pos) = response.hover_pos() {
|
||||||
/*let input = ui.input();
|
let local = (hover_pos - rect.left_top()) / rect.size();
|
||||||
for event in input.events.iter() {
|
let norm = local * 2.0 - egui::vec2(1.0, 1.0);
|
||||||
let event = match event {
|
let x = norm.x;
|
||||||
egui::Event::PointerMoved(pos) => {
|
let y = -norm.y;
|
||||||
if input.pointer.primary_down() {
|
let pos = canary::Vec2 { x, y };
|
||||||
Some(())
|
|
||||||
}
|
let kind = if response.drag_started() {
|
||||||
}
|
CursorEventKind::Select
|
||||||
_ => None,
|
} else if response.drag_released() {
|
||||||
|
CursorEventKind::Deselect
|
||||||
|
} else if response.dragged() {
|
||||||
|
CursorEventKind::Drag
|
||||||
|
} else {
|
||||||
|
CursorEventKind::Hover
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((kind, x, y)) = event {
|
self.script.on_cursor_event(kind, pos);
|
||||||
self.script.on_cursor_event(kind, canary::Vec2 { x, y });
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
let texture = egui::TextureId::Managed(0);
|
let texture = egui::TextureId::Managed(0);
|
||||||
let uv = egui::pos2(0.0, 0.0);
|
let uv = egui::pos2(0.0, 0.0);
|
||||||
|
|
Loading…
Reference in New Issue