1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
use vizia_core::{binding::Res, context::EventContext};
use vizia_window::{WindowButtons, WindowPosition, WindowSize};
/// Modifiers for setting the properties of a window.
pub trait WindowModifiers {
fn on_close(self, callback: impl Fn(&mut EventContext) + 'static) -> Self;
fn on_create(self, callback: impl Fn(&mut EventContext) + 'static) -> Self;
/// Sets the title of the window to the given value. Accepts a type, or lens to a type, which implements `ToString`.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .title("Vizia Application")
/// .run();
/// ```
fn title<T: ToString>(self, title: impl Res<T>) -> Self;
/// Sets the inner size of the window to the given value. Accepts a value, or lens, which can be converted to a [`WindowSize`].
///
/// The inner size is the window area excluding the window borders.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .inner_size((300, 300))
/// .run();
/// ```
fn inner_size<S: Into<WindowSize>>(self, size: impl Res<S>) -> Self;
/// Sets the minimum inner size of the window to the given value. Accepts an optional value, or lens, which can be converted to a [`WindowSize`].
///
/// Setting the minimum inner size to `None` removes the minimum inner size constraint from the window.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .min_inner_size(Some((300, 300)))
/// .run();
/// ```
fn min_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self;
/// Sets the maximum inner size of the window to the given value. Accepts an optional value, or lens, which can be converted to a [`WindowSize`].
///
/// Setting the maximum inner size to `None` removes the maximum inner size constraint from the window.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .max_inner_size(Some((1000, 1000)))
/// .run();
/// ```
fn max_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self;
/// Sets the position of the window to the given value. Accepts a value, or lens, which can be converted to a [`Position`].
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .position((100, 200))
/// .run();
/// ```
fn position<P: Into<WindowPosition>>(self, position: impl Res<P>) -> Self;
/// Sets whether the window can be resized. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .resizable(false)
/// .run();
/// ```
fn resizable(self, flag: impl Res<bool>) -> Self;
/// Sets whether the window is minimized. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .minimized(true)
/// .run();
/// ```
fn minimized(self, flag: impl Res<bool>) -> Self;
/// Sets whether the window is maximized. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .maximized(true)
/// .run();
/// ```
fn maximized(self, flag: impl Res<bool>) -> Self;
/// Sets whether the window is visible. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .visible(false)
/// .run();
/// ```
fn visible(self, flag: bool) -> Self;
/// Sets whether the window is transparent. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .transparent(true)
/// .run();
/// ```
fn transparent(self, flag: bool) -> Self;
/// Sets whether the window has decorations. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .decorations(false)
/// .run();
/// ```
fn decorations(self, flag: bool) -> Self;
/// Sets whether the window should be on top of other windows. Accepts a boolean value, or lens to a boolean value.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .always_on_top(true)
/// .run();
/// ```
fn always_on_top(self, flag: bool) -> Self;
/// Sets whether the window has vsync enabled.
///
/// # Example
/// ```no_run
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
/// Application::new(|cx|{
/// // Content here
/// })
/// .vsync(true)
/// .run();
/// ```
fn vsync(self, flag: bool) -> Self;
/// Sets the icon used for the window.
///
/// # Example
/// ```no_run, ignore
/// # use vizia_core::prelude::*;
/// # use vizia_winit::application::Application;
///
/// let icon = vizia::image::load_from_memory(include_bytes!("../icon.png"))
/// .expect("Failed to load icon");
///
/// Application::new(|cx|{
/// // Content here
/// })
/// .icon(icon.width(), icon.height(), icon.into_bytes())
/// .run();
/// ```
fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Self;
fn enabled_window_buttons(self, window_buttons: WindowButtons) -> Self;
}