Merge pull request #88 from glowcoil/on_frame_window
add window argument to WindowHandler::on_frame()
This commit is contained in:
commit
663f9d5d4c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue