WINDOWS

Struct WINDOWS 

Source
pub struct WINDOWS;
Expand description

Windows service.

Implementations§

Source§

impl WINDOWS

Source

pub fn exit_on_last_close(&self) -> Var<bool>

Defines if app process exit should be requested when the last window closes. This is true by default.

This setting does not consider headless windows and is fully ignored in headless apps.

Note that if APP.exit is requested directly the windows service will cancel it, request close for all headed and headless windows, and if all windows close request app exit again, independent of this setting.

Source

pub fn default_render_mode(&self) -> Var<RenderMode>

Defines the render mode of windows opened by this service.

Note that this setting only affects windows opened after it is changed, also the view-process may select a different render mode if it cannot support the requested mode.

Source

pub fn parallel(&self) -> Var<ParallelWin>

Defines what window operations can run in parallel, between windows.

Note that this config is for parallel execution between windows, see the parallel property for parallel execution within windows and widgets.

See ParallelWin for the options.

Source

pub fn system_chrome(&self) -> Var<bool>

Variable that tracks the OS window manager configuration for the window chrome.

The chrome (also known as window decorations) defines the title bar, window buttons and window border. Some window managers don’t provide a native chrome, you can use this config with WindowVars::chrome in a register_root_extender to provide a custom fallback chrome, the main crate zng also provides a custom chrome fallback.

Source§

impl WINDOWS

Source

pub fn open<F: Future<Output = WindowRoot> + Send + 'static>( &self, window_id: impl Into<WindowId>, new_window: impl IntoFuture<IntoFuture = F>, ) -> ResponseVar<WindowVars>

Requests a new window.

The new_window future runs inside the new WINDOW context.

Returns a response var that will update once when the window starts building, the WindowVars::instance_state can be use to continue monitoring the window.

An update cycle is processed between the end of new_window and the window init, this means that you can use the context WINDOW to set variables that will be read on init with the new value.

Note that there are no window handles, the window is controlled in the service using the ID or from the inside.

§Panics

If the window_id is already assigned to an open or opening window.

Source

pub fn focus_or_open<F: Future<Output = WindowRoot> + Send + 'static>( &self, window_id: impl Into<WindowId>, new_window: impl IntoFuture<IntoFuture = F>, ) -> ResponseVar<WindowVars>

Focus a window if it is open or loading, otherwise opens it focused.

Returns a variable that updates once the window starts building or is already open. You can track the focused status using WindowVars::is_focused.

Source

pub fn open_headless<F: Future<Output = WindowRoot> + Send + 'static>( &self, window_id: impl Into<WindowId>, new_window: impl IntoFuture<IntoFuture = F>, with_renderer: bool, ) -> ResponseVar<WindowVars>

Requests a new headless window.

This is similar to open, but the window will not show on screen and can optionally not even have a renderer.

§Panics

If the window_id is already assigned to an open or opening window.

Source

pub fn loading_handle( &self, window_id: impl Into<WindowId>, deadline: impl Into<Deadline>, debug_name: impl Into<Txt>, ) -> Option<WindowLoadingHandle>

Gets a handle that stops the window from loading while the handle is alive.

A window is only opened in the view-process after it is loaded, without any loading handles the window is considered loaded after the first layout pass. Nodes in the window can request a loading handle to delay the view opening to after all async resources it requires are loaded.

Note that a window is only loaded after all handles are dropped or expired, you should set a reasonable deadline,
it is best to partially render a window after a short time than not show anything.

Returns None if the window has already loaded or is not found.

Source

pub fn close( &self, window_id: impl Into<WindowId>, ) -> ResponseVar<CloseWindowResult>

Starts closing a window, the operation can be canceled by listeners of WINDOW_CLOSE_REQUESTED_EVENT. If the window has children they are closed together.

Returns a response var that will update once with the result of the operation.

If the window is not found returns Closed.

Source

pub fn close_together( &self, windows: impl IntoIterator<Item = WindowId>, ) -> ResponseVar<CloseWindowResult>

Starts closing multiple windows together, the operation can be canceled by listeners of WINDOW_CLOSE_REQUESTED_EVENT. If canceled none of the windows are closed. Children of each window are also selected the close together.

Returns a response var that will update once with the result of the operation. Returns Cancel if windows is empty.

Source

pub fn close_all(&self) -> ResponseVar<CloseWindowResult>

Starts closing all open windows together, the operation can be canceled by listeners of WINDOW_CLOSE_REQUESTED_EVENT. If canceled none of the windows are closed.

Returns a response var that will update once with the result of the operation. Returns Cancel if no window is open.

Source§

impl WINDOWS

Source

pub fn mode(&self, window_id: impl Into<WindowId>) -> Option<WindowMode>

Gets if the window is headed or headless.

Returns None if the window is not found.

Source

pub fn vars(&self, window_id: impl Into<WindowId>) -> Option<WindowVars>

Returns a shared reference the variables that control the window, if the window exists.

Source

pub fn widget_tree(&self, id: impl Into<WindowId>) -> Option<WidgetInfoTree>

Get the latest info tree for the window.

Source

pub fn widget_info(&self, id: impl Into<WidgetId>) -> Option<WidgetInfo>

Search for the widget in the latest info tree of each open window.

Source

pub fn widget_trees(&self) -> Vec<WidgetInfoTree>

Returns shared references to the widget trees of each open window.

Source§

impl WINDOWS

Source

pub fn frame_image( &self, window_id: impl Into<WindowId>, mask: Option<ImageMaskMode>, ) -> ImageVar

Generate an image from the current rendered frame of the window or the first frame of the window.

The image is not loaded at the moment of return, it will update when the frame pixels are copied.

If the window is not found or an error is reported in the image error.

Source

pub fn frame_image_rect( &self, window_id: impl Into<WindowId>, rect: PxRect, mask: Option<ImageMaskMode>, ) -> ImageVar

Generate an image from a rectangular selection of the current rendered frame of the window, or of the first frame of the window.

If the window is not found the error is reported in the image error.

Source§

impl WINDOWS

Source

pub fn bring_to_top(&self, window_id: impl Into<WindowId>)

Move the window to the front of the operating system Z stack.

Note that the window is not focused, the FOCUS.focus_window operation brings to top and sets focus.

Trait Implementations§

Source§

impl ImageRenderWindowsService for WINDOWS

Available on crate feature image only.
Source§

fn clone_boxed(&self) -> Box<dyn ImageRenderWindowsService>

Clone the service reference.
Source§

fn new_window_root( &self, node: UiNode, render_mode: RenderMode, ) -> Box<dyn ImageRenderWindowRoot>

Create a window root that presents the node. Read more
Source§

fn set_parent_in_window_context(&self, parent_id: WindowId)

Set parent window for the headless render window. Read more
Source§

fn enable_frame_capture_in_window_context(&self, mask: Option<ImageMaskMode>)

Enable frame capture for the window. Read more
Source§

fn open_headless_window( &self, new_window_root: Box<dyn FnOnce() -> Box<dyn ImageRenderWindowRoot> + Send>, )

Open the window. Read more
Source§

fn close_window(&self, window_id: WindowId)

Close the window, does nothing if the window is not found.
Source§

impl WindowsService for WINDOWS

Source§

fn widget_tree(&self, id: WindowId) -> Option<WidgetInfoTree>

Get the latest info tree for the window.
Source§

fn widget_info(&self, id: WidgetId) -> Option<WidgetInfo>

Search for the widget in the latest info tree of each open window.
Source§

fn update_info(&self, updates: &mut InfoUpdates)

Rebuild info trees.
Source§

fn update_widgets(&self, updates: &mut WidgetUpdates)

Update window and widgets.
Source§

fn update_layout(&self, updates: &mut LayoutUpdates)

Layout windows and widgets.
Source§

fn update_render( &self, render_widgets: &mut RenderUpdates, render_update_widgets: &mut RenderUpdates, )

Update frames.

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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
Source§

impl<T> StateValue for T
where T: Any + Send + Sync,