Skip to main content

WindowOptions

Struct WindowOptions 

Source
pub struct WindowOptions {
Show 19 fields pub title: String, pub size: Size, pub min_size: Option<Size>, pub start_hidden: bool, pub size_to_fit: bool, pub app_name: Option<String>, pub locales: Option<AppLocales>, pub title_fn: Option<fn() -> String>, pub version: Option<String>, pub tabbing: WindowTabbing, pub chrome: WindowChrome, pub background: WindowBackground, pub shadow: bool, pub resizable: bool, pub placement: WindowPlacement, pub max_size: Option<Size>, pub remember_frame: Option<String>, pub key: Option<String>, pub kind: WindowKind,
}

Fields§

§title: String§size: Size§min_size: Option<Size>§start_hidden: bool

Create and mount the window without showing it or activating the app. Supported on AppKit; other backends currently ignore this option. Defaults to false.

Menu-bar apps can keep their initial host hidden and open Preferences on demand. The window still exists and can be shown with WindowHandle::set_visible(true); this does not change the app’s keep-running policy.

§size_to_fit: bool

Ask the backend to size this window to its content once it has been built and laid out, rather than keeping Self::size (docs/windows.md). size still decides the width and acts as the height ceiling, so a panel with more content than fits the screen scrolls instead of growing past it.

What a preferences panel wants on every desktop. Ignored by backends that cannot resize a live window, and by the ones with no windows at all.

§app_name: Option<String>

The app’s display name for the standard application menu / About (macOS). None falls back to title; set it when title carries extra decoration you don’t want in About <name> (e.g. the showcase’s window title is “Day Showcase (AppKit)” but its app name is “Showcase”).

§locales: Option<AppLocales>

The app’s locale catalog, installed by day::launch (docs/localization.md).

The order is why this is the framework’s job: the OS’s languages reach day-l10n from the live backend, and the catalog has to be registered after that hint and before the first localized string is read. An app that installs it itself (before launch, where there is no backend yet) registers against an empty hint list and resolves to DEFAULT, so a French device opens an English window.

§title_fn: Option<fn() -> String>

The title, computed once the catalog above is installed: how a window title comes from the catalog rather than a literal. Takes precedence over Self::title, which stays the fallback for the moment before (and for apps with nothing to translate).

A plain fn rather than a closure: this struct is Clone, and the callers are a non-capturing || res::str::app_title().format(), which coerces.

§version: Option<String>

The app’s version, for Day’s exit line (Clean exit for <app> v<version> …, docs/lifecycle.md): env!("CARGO_PKG_VERSION") in the app crate, which the scaffold’s window() sets. None falls back to the DAY_APP_VERSION the day CLI sets on a launch.

§tabbing: WindowTabbing

macOS window tabbing for this window (Cap::WindowTabbing); ignored elsewhere.

§chrome: WindowChrome

The window’s frame: standard, a title bar the content runs under, or none (docs/window-chrome.md). Desktop only; phones and the web ignore it.

§background: WindowBackground

What shows behind the content: the window background, nothing, or a system material.

§shadow: bool

Whether the window casts the platform’s drop shadow. A transparent, shaped window often wants none.

§resizable: bool

Whether the user can resize the window by its edges.

§placement: WindowPlacement

Where the window opens.

§max_size: Option<Size>

The largest content size the user can resize the window to (Cap::WindowGeometry).

§remember_frame: Option<String>

Remember this window’s size, position and maximized state under this key, and reopen it that way next launch (docs/windows.md “Remembered frames”). A position that no attached display shows any more is dropped, so a window never reopens off-screen.

§key: Option<String>

The logical window this opens (docs/windows.md): open_window focuses an already-open window with the same key instead of opening a second (the preferences pattern). None always opens a new one.

§kind: WindowKind

The kind of window: a regular one, a preferences panel, an About panel.

Implementations§

Source§

impl WindowOptions

Source

pub fn title(self, title: impl Into<String>) -> Self

The window title. Replaces a title_fn set earlier (the generated res::window_options() sets one), so the last title named wins.

Source

pub fn size(self, width: f64, height: f64) -> Self

The content size the window opens at (desktop; phones fill the screen).

Source

pub fn min_size(self, width: f64, height: f64) -> Self

The smallest content size the user can resize to.

Source

pub fn max_size(self, width: f64, height: f64) -> Self

The largest content size the user can resize to (Cap::WindowGeometry).

Source

pub fn start_hidden(self) -> Self

Create and mount the window without showing it; see Self::start_hidden.

Source

pub fn size_to_fit(self) -> Self

Size the window to its content once built; see Self::size_to_fit.

Source

pub fn app_name(self, name: impl Into<String>) -> Self

The app’s display name for the application menu and About; see Self::app_name.

Source

pub fn locales( self, default: &'static str, catalog: &'static [(&'static str, &'static str)], ) -> Self

The app’s locale catalog, as res::locales::{DEFAULT, CATALOG}; see Self::locales.

Source

pub fn title_fn(self, f: fn() -> String) -> Self

The title, computed once the catalog is installed; see Self::title_fn.

Source

pub fn version(self, version: impl Into<String>) -> Self

The app’s version, for Day’s exit line; see Self::version.

Source

pub fn tabbing(self, tabbing: WindowTabbing) -> Self

macOS window tabbing for this window; see Self::tabbing.

Source

pub fn chrome(self, chrome: WindowChrome) -> Self

The window’s frame; see Self::chrome.

Source

pub fn background(self, background: WindowBackground) -> Self

What shows behind the content; see Self::background.

Source

pub fn no_shadow(self) -> Self

No drop shadow, for a transparent or shaped window; see Self::shadow.

Source

pub fn fixed_size(self) -> Self

A window the user cannot resize; see Self::resizable.

Source

pub fn placement(self, placement: WindowPlacement) -> Self

Where the window opens; see Self::placement.

Source

pub fn remember_frame(self, key: impl Into<String>) -> Self

Remember and restore this window’s frame under key; see Self::remember_frame.

Source

pub fn key(self, key: impl Into<String>) -> Self

The logical window this opens; see Self::key.

Source

pub fn kind(self, kind: WindowKind) -> Self

The kind of window; see Self::kind.

Trait Implementations§

Source§

impl Clone for WindowOptions

Source§

fn clone(&self) -> WindowOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Day API ↩ Guides· daybrite.dev