Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. use std::sync::{Arc, Weak};
  2.  
  3. #[derive(Debug)]
  4. struct WinitWindow {
  5. id: usize,
  6. }
  7.  
  8. impl WinitWindow {
  9. pub fn size(&self) -> (usize, usize) {
  10. (1270, 720)
  11. }
  12. }
  13.  
  14. impl Drop for WinitWindow {
  15. fn drop(&mut self) {
  16. println!("Dropping {:?}", self);
  17. }
  18. }
  19.  
  20. enum Event {
  21. WindowCloseRequested,
  22. WindowDestroyed,
  23. }
  24.  
  25. #[derive(Debug)]
  26. struct Window {
  27. inner: WinitWindow,
  28. }
  29.  
  30. impl Window {
  31. pub fn size(&self) -> (usize, usize) {
  32. self.inner.size()
  33. }
  34. }
  35.  
  36. #[derive(Debug)]
  37. struct Application {
  38. default_event_handler: bool,
  39. windows: Vec<Arc<Window>>,
  40. }
  41.  
  42. impl Application {
  43. pub fn new() -> Self {
  44. Application {
  45. windows: Vec::new(),
  46. }
  47. }
  48.  
  49. pub fn open_window(&mut self) -> Arc<Window> {
  50. let window = Arc::new(Window {});
  51. self.windows.push(window.clone());
  52. window
  53. }
  54.  
  55. pub fn run(&mut self, f: impl FnMut(Vec<Event>)) {
  56.  
  57. }
  58. }
  59.  
  60. impl !Send for Application {}
  61. impl !Sync for Application {}
  62.  
  63. fn main() {
  64. let mut app = Application::new();
  65. let window = app.open_window();
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement