inset_embedder_winit/
lib.rs1#![recursion_limit = "256"]
7
8mod frames;
9mod gpu;
10mod images;
11mod ime;
12mod input;
13mod keys;
14mod os;
15mod pacing;
16mod platform;
17mod pointer;
18mod surface;
19mod text_input;
20mod view;
21mod window;
22mod windows;
23
24use inset_embedder::{EmbedderClient, PlatformRef};
25
26pub use images::{DecodeExecution, create_image_loader};
27pub use platform::WinitPlatform;
28
29#[derive(Clone, Debug, PartialEq)]
31pub struct ImplicitViewConfig {
32 pub title: String,
33 pub logical_size: [f64; 2],
34}
35
36impl Default for ImplicitViewConfig {
37 fn default() -> ImplicitViewConfig {
38 ImplicitViewConfig {
39 title: "Inset".to_owned(),
40 logical_size: [900.0, 600.0],
41 }
42 }
43}
44
45pub struct WinitEmbedder {
47 pub implicit_view: Option<ImplicitViewConfig>,
49}
50
51impl Default for WinitEmbedder {
52 fn default() -> WinitEmbedder {
53 WinitEmbedder {
54 implicit_view: Some(ImplicitViewConfig::default()),
55 }
56 }
57}
58
59impl WinitEmbedder {
60 pub fn run<C: EmbedderClient + 'static>(self, start: impl FnOnce(PlatformRef) -> C + 'static) {
63 window::run(self, start, None);
64 }
65
66 pub fn run_with_image_loader<C: EmbedderClient + 'static>(
72 self,
73 make_loader: impl FnOnce(valo::ImageContext) -> valo_codec::ImageLoader + 'static,
74 start: impl FnOnce(PlatformRef) -> C + 'static,
75 ) {
76 window::run(self, start, Some(Box::new(make_loader)));
77 }
78}