1
0
Fork 0

Replace RenderExpose event with draw method

This commit is contained in:
Billy Messenger 2020-09-05 14:41:26 -05:00
parent 6cf5966afa
commit 15b0c2e857
4 changed files with 4 additions and 3 deletions

View file

@ -30,9 +30,10 @@ impl baseview::AppWindow for MyProgram {
) {
}
fn draw(&mut self) {}
fn on_event(&mut self, event: Event) {
match event {
Event::RenderExpose => {}
Event::CursorMotion(x, y) => {
println!("Cursor moved, x: {}, y: {}", x, y);
}

View file

@ -38,7 +38,6 @@ pub struct WindowInfo {
#[derive(Debug)]
pub enum Event {
RenderExpose,
CursorMotion(i32, i32), // new (x, y) relative to window
MouseDown(MouseButtonID),
MouseUp(MouseButtonID),

View file

@ -41,6 +41,7 @@ pub trait AppWindow {
window: raw_window_handle::RawWindowHandle,
window_info: &WindowInfo,
);
fn draw(&mut self);
fn on_event(&mut self, event: Event);
fn on_app_message(&mut self, message: Self::AppMessage);
}

View file

@ -189,7 +189,7 @@ impl<A: AppWindow> Window<A> {
match event_type {
xcb::EXPOSE => {
self.app_window.on_event(Event::RenderExpose);
self.app_window.draw();
}
xcb::MOTION_NOTIFY => {
let event = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&event) };