1#![allow(clippy::uninlined_format_args)]
2
3pub mod application;
4mod convert;
5pub mod window;
6pub mod window_modifiers;
7
8pub trait ModifyWindow {
9 fn modify_window<T>(&mut self, f: impl FnOnce(&winit::window::Window) -> T) -> Option<T>;
11 fn window(&self) -> Option<Arc<winit::window::Window>>;
13}
14
15use std::sync::Arc;
16
17use vizia_core::{context::TreeProps, prelude::EventContext};
18use window::Window;
19
20impl ModifyWindow for EventContext<'_> {
21 fn modify_window<T>(&mut self, f: impl FnOnce(&winit::window::Window) -> T) -> Option<T> {
22 self.with_current(self.parent_window(), move |cx| {
23 cx.get_view::<Window>()
24 .and_then(|window| window.window.clone())
25 .map(|window| (f)(window.as_ref()))
26 })
27 }
28
29 fn window(&self) -> Option<Arc<winit::window::Window>> {
30 self.get_view_with::<Window>(self.parent_window()).and_then(|window| window.window.clone())
31 }
32}