pub struct Bitmap<'a> { /* private fields */ }Implementations§
Source§impl<'a> Bitmap<'a>
impl<'a> Bitmap<'a>
Sourcepub fn new(data: &'a [u32], width: usize, height: usize) -> Bitmap<'a>
pub fn new(data: &'a [u32], width: usize, height: usize) -> Bitmap<'a>
Examples found in repository?
examples/child_window.rs (line 26)
16 fn handle_event(&mut self, event: Event) -> Response {
17 match event {
18 Event::Frame => {
19 let window = &self.window.as_ref().unwrap();
20
21 let scale = window.scale();
22 let size = window.size();
23 let width = (scale * size.width) as usize;
24 let height = (scale * size.height) as usize;
25 self.framebuffer.resize(width * height, 0xFF00FFFF);
26 window.present(Bitmap::new(&self.framebuffer, width, height));
27 }
28 Event::Close => {
29 self.event_loop.exit();
30 }
31 _ => {}
32 }
33
34 Response::Ignore
35 }
36}
37
38struct ChildState {
39 framebuffer: Vec<u32>,
40 window: Option<Window>,
41}
42
43impl ChildState {
44 fn handle_event(&mut self, event: Event) -> Response {
45 match event {
46 Event::Frame => {
47 let window = &self.window.as_ref().unwrap();
48
49 let scale = window.scale();
50 let size = window.size();
51 let width = (scale * size.width) as usize;
52 let height = (scale * size.height) as usize;
53 self.framebuffer.resize(width * height, 0xFFFF00FF);
54 window.present(Bitmap::new(&self.framebuffer, width, height));
55 }
56 _ => {}
57 }
58
59 Response::Ignore
60 }More examples
examples/basic.rs (line 41)
26 fn handle_event(&mut self, event: Event) -> Response {
27 match event {
28 Event::Expose(rects) => {
29 println!("expose: {:?}", rects);
30 }
31 Event::Frame => {
32 println!("frame");
33
34 let window = self.window.as_ref().unwrap();
35
36 let scale = window.scale();
37 self.width = (WIDTH as f64 * scale) as usize;
38 self.height = (HEIGHT as f64 * scale) as usize;
39 self.framebuffer.resize(self.width * self.height, 0xFFFF00FF);
40
41 window.present(Bitmap::new(&self.framebuffer, self.width, self.height));
42 }
43 Event::GainFocus => {
44 println!("gain focus");
45 }
46 Event::LoseFocus => {
47 println!("lose focus");
48 }
49 Event::MouseEnter => {
50 println!("mouse enter");
51 }
52 Event::MouseExit => {
53 println!("mouse exit");
54 }
55 Event::MouseMove(pos) => {
56 println!("mouse move: {:?}", pos);
57 }
58 Event::MouseDown(btn) => {
59 println!("mouse down: {:?}", btn);
60 return Response::Capture;
61 }
62 Event::MouseUp(btn) => {
63 println!("mouse up: {:?}", btn);
64 return Response::Capture;
65 }
66 Event::Scroll(delta) => {
67 println!("scroll: {:?}", delta);
68 return Response::Capture;
69 }
70 Event::Close => {
71 self.event_loop.exit();
72 }
73 }
74
75 Response::Ignore
76 }pub fn data(&self) -> &'a [u32]
pub fn width(&self) -> usize
pub fn height(&self) -> usize
Auto Trait Implementations§
impl<'a> Freeze for Bitmap<'a>
impl<'a> RefUnwindSafe for Bitmap<'a>
impl<'a> Send for Bitmap<'a>
impl<'a> Sync for Bitmap<'a>
impl<'a> Unpin for Bitmap<'a>
impl<'a> UnsafeUnpin for Bitmap<'a>
impl<'a> UnwindSafe for Bitmap<'a>
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