1
0
Fork 0

add window argument to WindowHandler::on_frame()

This commit is contained in:
micah 2021-01-27 02:09:05 -05:00
parent 36e4474c8a
commit ef27adeda1
5 changed files with 14 additions and 15 deletions

View file

@ -14,7 +14,7 @@ struct OpenWindowExample {
}
impl WindowHandler for OpenWindowExample {
fn on_frame(&mut self) {
fn on_frame(&mut self, _window: &mut Window) {
while let Ok(message) = self.rx.pop() {
println!("Message: {:?}", message);
}

View file

@ -218,14 +218,13 @@ impl WindowState {
}
pub(super) fn trigger_event(&mut self, event: Event) {
self.window_handler.on_event(
&mut crate::Window::new(&mut self.window),
event
);
self.window_handler
.on_event(&mut crate::Window::new(&mut self.window), event);
}
pub(super) fn trigger_frame(&mut self) {
self.window_handler.on_frame()
self.window_handler
.on_frame(&mut crate::Window::new(&mut self.window));
}
pub(super) fn process_native_key_event(

View file

@ -137,7 +137,7 @@ unsafe extern "system" fn wnd_proc(
WM_TIMER => {
match wparam {
WIN_FRAME_TIMER => {
(&*window_state_ptr).borrow_mut().handler.on_frame();
(&*window_state_ptr).borrow_mut().handler.on_frame(&mut window);
}
_ => (),
}

View file

@ -13,7 +13,7 @@ use crate::win as platform;
use crate::x11 as platform;
pub trait WindowHandler {
fn on_frame(&mut self);
fn on_frame(&mut self, window: &mut Window);
fn on_event(&mut self, window: &mut Window, event: Event);
}

View file

@ -273,7 +273,7 @@ impl Window {
while self.event_loop_running {
let now = Instant::now();
let until_next_frame = if now > next_frame {
handler.on_frame();
handler.on_frame(&mut crate::Window::new(self));
next_frame = Instant::now() + self.frame_interval;
self.frame_interval