pub struct Size {
pub width: f64,
pub height: f64,
}Fields§
§width: f64§height: f64Implementations§
Source§impl Size
impl Size
Sourcepub fn new(width: f64, height: f64) -> Size
pub fn new(width: f64, height: f64) -> Size
Examples found in repository?
examples/basic.rs (line 93)
79fn main() {
80 let event_loop = EventLoop::new().unwrap();
81
82 let state = Rc::new(RefCell::new(State {
83 event_loop: event_loop.clone(),
84 window: None,
85 framebuffer: Vec::new(),
86 width: 0,
87 height: 0,
88 timer: None,
89 }));
90
91 let window = WindowOptions::new()
92 .title("window")
93 .size(Size::new(512.0, 512.0))
94 .open(&event_loop, {
95 let state = Rc::downgrade(&state);
96 move |event| state.upgrade().unwrap().borrow_mut().handle_event(event)
97 })
98 .unwrap();
99
100 window.show();
101
102 state.borrow_mut().window = Some(window);
103
104 state.borrow_mut().timer = Some(
105 Timer::repeat(&event_loop, Duration::from_millis(1000), || {
106 println!("timer")
107 })
108 .unwrap(),
109 );
110
111 event_loop.run().unwrap();
112}More examples
examples/child_window.rs (line 74)
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) -> Size
Trait Implementations§
impl Copy for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnsafeUnpin for Size
impl UnwindSafe for Size
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