pub struct Point {
pub x: f64,
pub y: f64,
}Fields§
§x: f64§y: f64Implementations§
Source§impl Point
impl Point
Sourcepub fn new(x: f64, y: f64) -> Point
pub fn new(x: f64, y: f64) -> Point
Examples found in repository?
examples/child_window.rs (line 99)
63fn main() {
64 let parent_event_loop = EventLoop::new().unwrap();
65
66 let parent_state = Rc::new(RefCell::new(ParentState {
67 event_loop: parent_event_loop.clone(),
68 framebuffer: Vec::new(),
69 window: None,
70 }));
71
72 let window = WindowOptions::new()
73 .title("parent window")
74 .size(Size::new(512.0, 512.0))
75 .open(&parent_event_loop, {
76 let state = Rc::downgrade(&parent_state);
77 move |event| state.upgrade().unwrap().borrow_mut().handle_event(event)
78 })
79 .unwrap();
80
81 window.show();
82
83 let parent_window_raw = window.as_raw().unwrap();
84 parent_state.borrow_mut().window = Some(window);
85
86 let child_event_loop = EventLoopOptions::new().mode(EventLoopMode::Guest).build().unwrap();
87
88 let child_state = Rc::new(RefCell::new(ChildState {
89 framebuffer: Vec::new(),
90 window: None,
91 }));
92
93 let mut window_opts = WindowOptions::new();
94 unsafe {
95 window_opts.raw_parent(parent_window_raw);
96 }
97
98 let window = window_opts
99 .position(Point::new(128.0, 128.0))
100 .size(Size::new(256.0, 256.0))
101 .open(&child_event_loop, {
102 let state = Rc::downgrade(&child_state);
103 move |event| state.upgrade().unwrap().borrow_mut().handle_event(event)
104 })
105 .unwrap();
106
107 window.show();
108
109 child_state.borrow_mut().window = Some(window);
110
111 parent_event_loop.run().unwrap();
112
113 child_state.borrow_mut().window = None;
114
115 parent_state.borrow_mut().window = None;
116}pub fn scale(self, scale: f64) -> Point
Trait Implementations§
impl Copy for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnsafeUnpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more