We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
util
1 parent 72f7a5a commit 7df2c86Copy full SHA for 7df2c86
9 files changed
README.md
@@ -74,14 +74,14 @@ use winit::event::{Event, WindowEvent};
74
use winit::event_loop::{ControlFlow, EventLoop};
75
use winit::window::Window;
76
77
-#[path = "../examples/utils/winit_app.rs"]
78
-mod winit_app;
+#[path = "../examples/util/mod.rs"]
+mod util;
79
80
fn main() {
81
let event_loop = EventLoop::new().unwrap();
82
let context = softbuffer::Context::new(event_loop.owned_display_handle()).unwrap();
83
84
- let mut app = winit_app::WinitAppBuilder::with_init(
+ let mut app = util::WinitAppBuilder::with_init(
85
|elwt| {
86
let window = elwt.create_window(Window::default_attributes());
87
Rc::new(window.unwrap())
examples/animation.rs
@@ -7,18 +7,17 @@ use winit::event::{KeyEvent, WindowEvent};
7
8
use winit::keyboard::{Key, NamedKey};
9
10
-#[path = "utils/winit_app.rs"]
11
12
13
14
15
let start = Instant::now();
16
17
18
19
- let app = winit_app::WinitAppBuilder::with_init(
+ let app = util::WinitAppBuilder::with_init(
20
|event_loop| {
21
- let window = winit_app::make_window(event_loop, |w| w);
+ let window = util::make_window(event_loop, |w| w);
22
23
let old_size = (0, 0);
24
let frames = pre_render_frames(0, 0);
@@ -91,7 +90,7 @@ fn main() {
91
90
window.request_redraw();
92
});
93
94
- winit_app::run_app(event_loop, app);
+ util::run_app(event_loop, app);
95
}
96
97
fn pre_render_frames(width: u32, height: u32) -> Vec<Vec<u32>> {
examples/fruit.rs
@@ -4,8 +4,7 @@ use winit::event::{KeyEvent, WindowEvent};
4
5
6
//see fruit.jpg.license for the license of fruit.jpg
@@ -15,9 +14,9 @@ fn main() {
move |elwt| {
- winit_app::make_window(elwt, |w| {
+ util::make_window(elwt, |w| {
w.with_inner_size(winit::dpi::PhysicalSize::new(width, height))
})
},
@@ -77,5 +76,5 @@ fn main() {
examples/rectangle.rs
@@ -5,8 +5,7 @@ use winit::event::{ElementState, KeyEvent, WindowEvent};
fn redraw(buffer: &mut Buffer<'_, impl HasDisplayHandle, impl HasWindowHandle>, flag: bool) {
let width = buffer.width().get();
@@ -30,9 +29,9 @@ fn main() {
30
29
31
32
33
34
35
- let window = winit_app::make_window(elwt, |w| {
+ let window = util::make_window(elwt, |w| {
36
w.with_title("Press space to show/hide a rectangle")
37
38
@@ -106,5 +105,5 @@ fn main() {
106
105
107
108
109
110
examples/util/mod.rs
@@ -0,0 +1,4 @@
1
+mod winit_app;
2
+
3
+#[allow(unused_imports)]
+pub use self::winit_app::*;
examples/utils/winit_app.rs examples/util/winit_app.rsexamples/utils/winit_app.rs renamed to examples/util/winit_app.rs
examples/winit.rs
@@ -3,8 +3,7 @@ use winit::event::{KeyEvent, WindowEvent};
#[cfg(not(target_os = "android"))]
@@ -14,8 +13,8 @@ fn main() {
pub(crate) fn entry(event_loop: EventLoop<()>) {
- |elwt| winit_app::make_window(elwt, |w| w),
+ |elwt| util::make_window(elwt, |w| w),
move |_elwt, window| softbuffer::Surface::new(&context, window.clone()).unwrap(),
)
.with_event_handler(|window, surface, window_id, event, elwt| {
@@ -72,5 +71,5 @@ pub(crate) fn entry(event_loop: EventLoop<()>) {
72
71
73
examples/winit_multithread.rs
@@ -1,8 +1,7 @@
//! `Surface` implements `Send`. This makes sure that multithreading can work here.
#[cfg(not(target_family = "wasm"))]
pub mod ex {
@@ -13,7 +12,7 @@ pub mod ex {
- use super::winit_app;
+ use super::util;
type Surface = softbuffer::Surface<OwnedDisplayHandle, Arc<Window>>;
@@ -55,7 +54,7 @@ pub mod ex {
55
54
pub fn entry(event_loop: EventLoop<()>) {
56
57
58
59
60
let attributes = Window::default_attributes();
61
#[cfg(target_family = "wasm")]
@@ -121,7 +120,7 @@ pub mod ex {
121
120
122
123
124
125
126
127
examples/winit_wrong_sized_buffer.rs
@@ -3,15 +3,14 @@ use winit::event::{KeyEvent, WindowEvent};
move |_elwt, window| {
let mut surface = softbuffer::Surface::new(&context, window.clone()).unwrap();
// Intentionally set the size of the surface to something different than the size of the window.
@@ -64,5 +63,5 @@ fn main() {
64
63
65
66
67
68
0 commit comments