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