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