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