Skip to content

Instantly share code, notes, and snippets.

@sfackler
Forked from Skrylar/traiting.rs
Created January 3, 2014 07:45
Show Gist options
  • Save sfackler/8234365 to your computer and use it in GitHub Desktop.
Save sfackler/8234365 to your computer and use it in GitHub Desktop.
pub trait ApplicationDelegate {
fn application_did_quit(&mut self, _timestamp: u32) {}
}
pub struct MouseMotionEventInfo;
pub struct MouseButtonEventInfo;
pub struct MouseWheelEventInfo;
pub trait MouseDelegate {
fn mouse_did_move(&mut self, _info: &MouseMotionEventInfo) {}
fn mouse_did_click(&mut self, _info: &MouseButtonEventInfo) {}
fn mouse_did_scroll(&mut self, _info: &MouseWheelEventInfo) {}
}
pub struct NullDelegate;
impl ApplicationDelegate for NullDelegate {}
impl MouseDelegate for NullDelegate {}
impl NullDelegate {
pub fn as_app<'a>(&'a mut self) -> &'a mut ApplicationDelegate {
self as &mut ApplicationDelegate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment