pub struct WindowDesc<T> {
    pub id: WindowId,
    /* private fields */
}
Expand description

A description of a window to be instantiated.

This struct has builder methods to specify some window properties. Each of these methods usually corresponds to a platform API call when constructing the function. Except for title(), they have no default values and the APIS won’t be called if the method is not used.

Fields§

§id: WindowId

The WindowId that will be assigned to this window.

This can be used to track a window from when it is launched and when it actually connects.

Implementations§

§

impl<T> WindowDesc<T>where T: Data,

pub fn new<W>(root: W) -> WindowDesc<T>where W: Widget<T> + 'static,

Create a new WindowDesc, taking the root Widget for this window.

pub fn title(self, title: impl Into<LabelText<T>>) -> WindowDesc<T>

Set the title for this window. This is a LabelText; it can be either a String, a LocalizedString, or a closure that computes a string; it will be kept up to date as the application’s state changes.

If this method isn’t called, the default title will be LocalizedString::new("app-name").

pub fn menu( self, menu: impl FnMut(Option<WindowId>, &T, &Env) -> Menu<T> + 'static ) -> WindowDesc<T>

Set the menu for this window.

menu is a callback for creating the menu. Its first argument is the id of the window that will have the menu, or None if it’s creating the root application menu for an app with no menus (which can happen, for example, on macOS).

pub fn window_size_policy(self, size_policy: WindowSizePolicy) -> WindowDesc<T>

Set the window size policy

pub fn window_size(self, size: impl Into<Size>) -> WindowDesc<T>

Set the window’s initial drawing area size in display points.

You can pass in a tuple (width, height) or a Size, e.g. to create a window with a drawing area 1000dp wide and 500dp high:

window.window_size((1000.0, 500.0));

The actual window size in pixels will depend on the platform DPI settings.

This should be considered a request to the platform to set the size of the window. The platform might increase the size a tiny bit due to DPI.

pub fn with_min_size(self, size: impl Into<Size>) -> WindowDesc<T>

Set the window’s minimum drawing area size in display points.

The actual minimum window size in pixels will depend on the platform DPI settings.

This should be considered a request to the platform to set the minimum size of the window. The platform might increase the size a tiny bit due to DPI.

To set the window’s initial drawing area size use window_size.

pub fn resizable(self, resizable: bool) -> WindowDesc<T>

Builder-style method to set whether this window can be resized.

pub fn show_titlebar(self, show_titlebar: bool) -> WindowDesc<T>

Builder-style method to set whether this window’s titlebar is visible.

pub fn transparent(self, transparent: bool) -> WindowDesc<T>

Builder-style method to set whether this window’s background should be transparent.

pub fn set_position(self, position: impl Into<Point>) -> WindowDesc<T>

Sets the initial window position in display points, relative to the origin of the virtual screen.

pub fn set_level(self, level: WindowLevel) -> WindowDesc<T>

Sets the WindowLevel of the window

pub fn set_always_on_top(self, always_on_top: bool) -> WindowDesc<T>

Sets whether the window is always on top.

An always on top window stays on top, even after clicking off of it.

pub fn set_window_state(self, state: WindowState) -> WindowDesc<T>

Set initial state for the window.

pub fn with_config(self, config: WindowConfig) -> WindowDesc<T>

Set the WindowConfig of window.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for WindowDesc<T>

§

impl<T> !Send for WindowDesc<T>

§

impl<T> !Sync for WindowDesc<T>

§

impl<T> Unpin for WindowDesc<T>where T: Unpin,

§

impl<T> !UnwindSafe for WindowDesc<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> RoundFrom<T> for T

§

fn round_from(x: T) -> T

Performs the conversion.
§

impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,

§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more