1
0
Fork 0

Merge pull request #42 from RustAudio/rename-draw-to-on_frame

Rename WindowHandler.draw to WindowHandler.on_frame (merge after #41)
This commit is contained in:
william light 2020-09-11 17:48:50 +02:00 committed by GitHub
commit ce48ae111a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -16,13 +16,13 @@ struct MyProgram {}
impl WindowHandler for MyProgram {
type Message = ();
fn build(window: &mut Window) -> Self {
fn build(_window: &mut Window) -> Self {
Self {}
}
fn draw(&mut self, _window: &mut Window) {}
fn on_frame(&mut self) {}
fn on_event(&mut self, window: &mut Window, event: Event) {
fn on_event(&mut self, _window: &mut Window, event: Event) {
match event {
Event::CursorMotion(x, y) => {
println!("Cursor moved, x: {}, y: {}", x, y);
@ -63,5 +63,5 @@ impl WindowHandler for MyProgram {
}
}
fn on_message(&mut self, window: &mut Window, _message: Self::Message) {}
fn on_message(&mut self, _window: &mut Window, _message: Self::Message) {}
}

View file

@ -38,7 +38,7 @@ pub trait WindowHandler {
fn build(window: &mut Window) -> Self;
fn draw(&mut self, window: &mut Window);
fn on_frame(&mut self);
fn on_event(&mut self, window: &mut Window, event: Event);
fn on_message(&mut self, window: &mut Window, message: Self::Message);
}

View file

@ -135,7 +135,7 @@ impl Window {
let now = Instant::now();
let until_next_frame =
if now > next_frame {
handler.draw(self);
handler.on_frame();
next_frame = now + self.frame_interval;
self.frame_interval
@ -188,7 +188,7 @@ impl Window {
match event_type {
xcb::EXPOSE => {
handler.draw(self);
handler.on_frame();
}
xcb::MOTION_NOTIFY => {
let event = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&event) };