Skip to main content

MainWindowOptions

Struct MainWindowOptions 

Source
#[non_exhaustive]
pub struct MainWindowOptions { pub default_size: Option<Size<Points>>, pub default_position: Option<WindowPosition>, pub display: Option<DisplayId>, pub default_mode: Option<WindowMode>, pub default_visible: Option<bool>, pub restore_bounds: bool, pub attributes: WindowAttributes, }
Expand description

Launch-time options for the first app window: nsh.json "window", which the command line writes into the app’s app.json (and the dev server’s app info) and the runners read before any JS runs. The same keys as WindowOptions without id, kind, parent and modal: every attribute, defaultSize, defaultPosition, display, defaultMode and restoreBounds. The app declares the window with <Window> or crate::element::desktop::window() and inherits these; its own options override them. defaultVisible is parsed but has no effect in window model v2: the app host never shows. An unmodified window made before the app was known (a development host’s) follows the attributes the engine sends with the first frame (crate::Core::set_main_window).

Only standalone builds read it (their app.json). Signed packages (.nshpkg) carry none: they run in host apps, which own their windows.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§default_size: Option<Size<Points>>

Its content size when it opens.

§default_position: Option<WindowPosition>

Where it opens.

§display: Option<DisplayId>

The display it opens on (the system’s choice when it is not there).

§default_mode: Option<WindowMode>

The mode it opens in.

§default_visible: Option<bool>

Parsed for compatibility and has no effect in window model v2: the host never shows, and the app declares its windows with <Window> (hide one with hide()). Read at launch only.

§restore_bounds: bool

Opens where the user left it (the runner keeps its placement).

§attributes: WindowAttributes

The attributes the app sets (the platform’s main window keeps its own for the rest: the app’s name as its title, …).

Implementations§

Source§

impl MainWindowOptions

Source

pub fn kept_placement( &self, storage: &dyn StorageBackend, displays: &[Display], ) -> Option<WindowPlacement>

Where to open the main window with restoreBounds: the placement the app’s last run kept in storage (the app’s own, as the engine is given it), fitted on displays, the ones there are now. None without restoreBounds, or with nothing kept: the window opens by defaultSize, defaultPosition, display and defaultMode. For the runners, before they make the window; the engine keeps the placement as the window changes (crate::Core::set_main_window).

Source

pub fn from_json(json: &JsonValue) -> Result<MainWindowOptions, String>

Reads nsh.json’s (or app.json’s) "window": an unknown key or a wrong value is an error, as in the rest of nsh.json.

Trait Implementations§

Source§

impl Clone for MainWindowOptions

Source§

fn clone(&self) -> Self

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 MainWindowOptions

Source§

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

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

impl Default for MainWindowOptions

Source§

fn default() -> Self

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

impl PartialEq for MainWindowOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MainWindowOptions

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.