Replace RenderExpose event with draw method
This commit is contained in:
parent
6cf5966afa
commit
15b0c2e857
|
@ -30,9 +30,10 @@ impl baseview::AppWindow for MyProgram {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw(&mut self) {}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) {
|
fn on_event(&mut self, event: Event) {
|
||||||
match event {
|
match event {
|
||||||
Event::RenderExpose => {}
|
|
||||||
Event::CursorMotion(x, y) => {
|
Event::CursorMotion(x, y) => {
|
||||||
println!("Cursor moved, x: {}, y: {}", x, y);
|
println!("Cursor moved, x: {}, y: {}", x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ pub struct WindowInfo {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
RenderExpose,
|
|
||||||
CursorMotion(i32, i32), // new (x, y) relative to window
|
CursorMotion(i32, i32), // new (x, y) relative to window
|
||||||
MouseDown(MouseButtonID),
|
MouseDown(MouseButtonID),
|
||||||
MouseUp(MouseButtonID),
|
MouseUp(MouseButtonID),
|
||||||
|
|
|
@ -41,6 +41,7 @@ pub trait AppWindow {
|
||||||
window: raw_window_handle::RawWindowHandle,
|
window: raw_window_handle::RawWindowHandle,
|
||||||
window_info: &WindowInfo,
|
window_info: &WindowInfo,
|
||||||
);
|
);
|
||||||
|
fn draw(&mut self);
|
||||||
fn on_event(&mut self, event: Event);
|
fn on_event(&mut self, event: Event);
|
||||||
fn on_app_message(&mut self, message: Self::AppMessage);
|
fn on_app_message(&mut self, message: Self::AppMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ impl<A: AppWindow> Window<A> {
|
||||||
|
|
||||||
match event_type {
|
match event_type {
|
||||||
xcb::EXPOSE => {
|
xcb::EXPOSE => {
|
||||||
self.app_window.on_event(Event::RenderExpose);
|
self.app_window.draw();
|
||||||
}
|
}
|
||||||
xcb::MOTION_NOTIFY => {
|
xcb::MOTION_NOTIFY => {
|
||||||
let event = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&event) };
|
let event = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&event) };
|
||||||
|
|
Loading…
Reference in a new issue