Struct zng::window::WindowVars
source · pub struct WindowVars(/* private fields */);
Expand description
Variables that configure the opening or open window.
You can get the vars for any window using WINDOWS.vars
.
You can get the vars for the current context window using WINDOW.vars
.
Implementations§
source§impl WindowVars
impl WindowVars
sourcepub fn chrome(&self) -> ArcVar<bool>
pub fn chrome(&self) -> ArcVar<bool>
Defines if the window chrome is visible.
The window chrome is the non-client area of the window, usually a border with resize handles and a title bar.
The default value is true
.
Note that if the WINDOWS.system_chrome
reports the windowing system prefers a custom chrome and does not
provide one the system chrome is not requested, even if this is true
. Window widget implementers can use this to
detect when a fallback chrome must be provided.
sourcepub fn icon(&self) -> ArcVar<WindowIcon>
pub fn icon(&self) -> ArcVar<WindowIcon>
Window icon.
See WindowIcon
for details.
The default value is WindowIcon::Default
.
You can retrieve the custom icon image using actual_icon
.
sourcepub fn actual_icon(&self) -> ReadOnlyVar<Option<Img>, ArcVar<Option<Img>>>
pub fn actual_icon(&self) -> ReadOnlyVar<Option<Img>, ArcVar<Option<Img>>>
Window icon image.
This is None
if icon
is WindowIcon::Default
, otherwise it is an Img
reference clone.
sourcepub fn cursor(&self) -> ArcVar<CursorSource>
pub fn cursor(&self) -> ArcVar<CursorSource>
Window cursor icon and visibility.
See CursorSource
for details.
The default is CursorIcon::Default
.
sourcepub fn actual_cursor_img(
&self,
) -> ReadOnlyVar<Option<(Img, Point2D<Px, Px>)>, ArcVar<Option<(Img, Point2D<Px, Px>)>>>
pub fn actual_cursor_img( &self, ) -> ReadOnlyVar<Option<(Img, Point2D<Px, Px>)>, ArcVar<Option<(Img, Point2D<Px, Px>)>>>
sourcepub fn state(&self) -> ArcVar<WindowState>
pub fn state(&self) -> ArcVar<WindowState>
Window screen state.
Minimized, maximized or fullscreen. See WindowState
for details.
The default value is WindowState::Normal
.
sourcepub fn monitor(&self) -> ArcVar<MonitorQuery>
pub fn monitor(&self) -> ArcVar<MonitorQuery>
Window monitor.
The query selects the monitor to which the position
and size
is relative to.
It evaluate once when the window opens and then once every time the variable updates. You can track
what the current monitor is by using actual_monitor
.
§Behavior After Open
If this variable is changed after the window has opened, and the new query produces a different
monitor from the actual_monitor
and the window is visible; then the window is moved to
the new monitor:
- Maximized: The window is maximized in the new monitor.
- Normal: The window is centered in the new monitor, keeping the same size, unless the
position
andsize
where set in the same update, in that case these values are used. - Minimized/Hidden: The window restore position and size are defined like Normal.
sourcepub fn video_mode(&self) -> ArcVar<VideoMode>
pub fn video_mode(&self) -> ArcVar<VideoMode>
Video mode for exclusive fullscreen.
sourcepub fn actual_monitor(
&self,
) -> ReadOnlyVar<Option<MonitorId>, ArcVar<Option<MonitorId>>>
pub fn actual_monitor( &self, ) -> ReadOnlyVar<Option<MonitorId>, ArcVar<Option<MonitorId>>>
Current monitor hosting the window.
This is None
only if the window has not opened yet (before first render) or if
no monitors where found in the operating system or if the window is headless without renderer.
sourcepub fn video_modes(&self) -> Box<dyn VarBoxed<Vec<VideoMode>>>
pub fn video_modes(&self) -> Box<dyn VarBoxed<Vec<VideoMode>>>
Available video modes in the current monitor.
sourcepub fn scale_factor(&self) -> ReadOnlyVar<Factor, ArcVar<Factor>>
pub fn scale_factor(&self) -> ReadOnlyVar<Factor, ArcVar<Factor>>
Current scale factor of the current monitor hosting the window.
sourcepub fn actual_position(
&self,
) -> ReadOnlyVar<Point2D<Dip, Dip>, ArcVar<Point2D<Dip, Dip>>>
pub fn actual_position( &self, ) -> ReadOnlyVar<Point2D<Dip, Dip>, ArcVar<Point2D<Dip, Dip>>>
sourcepub fn global_position(
&self,
) -> ReadOnlyVar<Point2D<Px, Px>, ArcVar<Point2D<Px, Px>>>
pub fn global_position( &self, ) -> ReadOnlyVar<Point2D<Px, Px>, ArcVar<Point2D<Px, Px>>>
Window actual position on the virtual screen that encompasses all monitors.
This is a read-only variable that tracks the computed position of the window, it updates every time the window moves.
The initial value is (0, 0)
, it starts updating once the window opens.
sourcepub fn restore_state(&self) -> ReadOnlyVar<WindowState, ArcVar<WindowState>>
pub fn restore_state(&self) -> ReadOnlyVar<WindowState, ArcVar<WindowState>>
Window restore state.
The restore state that the window must be set to be restored, if the current state is Maximized
, Fullscreen
or Exclusive
the restore state is Normal
, if the current state is Minimized
the restore state is the previous state.
When the restore state is Normal
the restore_rect
defines the window position and size.
sourcepub fn restore_rect(
&self,
) -> ReadOnlyVar<Rect<Dip, Dip>, ArcVar<Rect<Dip, Dip>>>
pub fn restore_rect( &self, ) -> ReadOnlyVar<Rect<Dip, Dip>, ArcVar<Rect<Dip, Dip>>>
Window restore position and size when restoring to Normal
.
The restore rectangle is the window position and size when its state is Normal
, when the state is not Normal
this variable tracks the last normal position and size, it will be the window actual_position
and actual_size
again
when the state is set back to Normal
.
This is a read-only variable, to programmatically set it assign the position
and size
variables. The initial
value is (30, 30).at(800, 600)
, it starts updating when the window opens.
Note that to restore the window you only need to set state
to restore_state
, if the restore state is Normal
this position and size will be applied automatically.
sourcepub fn position(&self) -> ArcVar<Point>
pub fn position(&self) -> ArcVar<Point>
Window top-left offset on the monitor
when the window is Normal
.
Relative values are computed in relation to the monitor
size, updating every time the
position or monitor variable updates.
When the user moves the window this value is considered stale, when it updates it overwrites the window position again,
note that the window is only moved if it is in the Normal
state, otherwise only the restore_rect
updates.
When the window is moved by the user this variable does not update back, to track the current position of the window
use actual_position
, to track the restore position use restore_rect
.
The Length::Default
value causes the OS to select a value.
sourcepub fn actual_size(
&self,
) -> ReadOnlyVar<Size2D<Dip, Dip>, ArcVar<Size2D<Dip, Dip>>>
pub fn actual_size( &self, ) -> ReadOnlyVar<Size2D<Dip, Dip>, ArcVar<Size2D<Dip, Dip>>>
Window actual size on the screen.
This is a read-only variable that tracks the computed size of the window, it updates every time the window resizes.
The initial value is (0, 0)
, it starts updating when the window opens.
sourcepub fn actual_size_px(&self) -> Box<dyn VarBoxed<Size2D<Px, Px>>>
pub fn actual_size_px(&self) -> Box<dyn VarBoxed<Size2D<Px, Px>>>
Window actual_size
, converted to pixels given the scale_factor
.
sourcepub fn safe_padding(
&self,
) -> ReadOnlyVar<SideOffsets2D<Dip, Dip>, ArcVar<SideOffsets2D<Dip, Dip>>>
pub fn safe_padding( &self, ) -> ReadOnlyVar<SideOffsets2D<Dip, Dip>, ArcVar<SideOffsets2D<Dip, Dip>>>
Padding that must be applied to the window content so that it stays clear of screen obstructions such as a camera notch cutout.
Note that the unsafe area must still be rendered as it may be partially visible, just don’t place nay interactive or important content outside of this padding.
sourcepub fn size(&self) -> ArcVar<Size>
pub fn size(&self) -> ArcVar<Size>
Window width and height on the screen when the window is Normal
.
Relative values are computed in relation to the monitor
size, updating every time the
size or monitor variable updates.
When the user resizes the window this value is considered stale, when it updates it overwrites the window size again,
note that the window is only resized if it is in the Normal
state, otherwise only the restore_rect
updates.
When the window is resized this variable is not updated back, to track the current window size use actual_size
,
to track the restore size use restore_rect
.
The default value is (800, 600)
.
sourcepub fn auto_size(&self) -> ArcVar<AutoSize>
pub fn auto_size(&self) -> ArcVar<AutoSize>
Defines if and how the window size is controlled by the content layout.
When enabled overwrites size
, but is still coerced by min_size
and max_size
. Auto-size is disabled if the user manually resizes.
The default value is AutoSize::DISABLED
.
sourcepub fn auto_size_origin(&self) -> ArcVar<Point>
pub fn auto_size_origin(&self) -> ArcVar<Point>
The point in the window content that does not move when the window is resized by auto_size
.
When the window size increases it grows to the right-bottom, the top-left corner does not move because
the origin of windows it at the top-left and the position did not change, this variables overwrites this origin
for auto_size
size changes, the window position is adjusted so that it is the center of the resize.
Note this only applies to resizes, the initial auto-size when the window opens is positioned according to the StartPosition
value.
The default value is Point::top_left
.
sourcepub fn font_size(&self) -> ArcVar<Length>
pub fn font_size(&self) -> ArcVar<Length>
Root font size.
This is the font size in all widget branches that do not override the font size. The rem
unit is relative to this value.
sourcepub fn resizable(&self) -> ArcVar<bool>
pub fn resizable(&self) -> ArcVar<bool>
Defines if the user can resize the window using the window frame.
Note that even if disabled the window can still be resized from other sources.
The default value is true
.
sourcepub fn movable(&self) -> ArcVar<bool>
pub fn movable(&self) -> ArcVar<bool>
Defines if the user can move the window using the window frame.
Note that even if disabled the window can still be moved from other sources.
The default value is true
.
Defines the enabled state of the window chrome buttons.
sourcepub fn always_on_top(&self) -> ArcVar<bool>
pub fn always_on_top(&self) -> ArcVar<bool>
Defines if the window should always stay on top of other windows.
Note this only applies to other windows that are not also “always-on-top”.
The default value is false
.
sourcepub fn visible(&self) -> ArcVar<bool>
pub fn visible(&self) -> ArcVar<bool>
Defines if the window is visible on the screen and in the task-bar.
This variable is observed only after the first frame render, before that the window is always not visible.
The default value is true
.
sourcepub fn taskbar_visible(&self) -> ArcVar<bool>
pub fn taskbar_visible(&self) -> ArcVar<bool>
Defines if the window is visible in the task-bar.
The default value is true
.
sourcepub fn parent(&self) -> ArcVar<Option<WindowId>>
pub fn parent(&self) -> ArcVar<Option<WindowId>>
Defines the parent window.
If a parent is set this behavior applies:
- If the parent is minimized, this window is also minimized.
- If the parent window is maximized, this window is restored.
- This window is always on-top of the parent window.
- If the parent window is closed, this window is also closed.
- If
modal
is set, the parent window cannot be focused while this window is open. - If a
color_scheme
is not set, the fallback is the parent’s actual scheme. - If an
accent_color
is not set, the fallback is the parent’s actual accent.
The default value is None
.
§Validation
The parent window cannot have a parent, if it has, that parent ID is used instead. The parent window must exist. This window (child) cannot have children, it also can’t set itself as the parent.
If any of these conditions are not met, an error is logged and the parent var is restored to the previous value.
sourcepub fn nest_parent(
&self,
) -> ReadOnlyVar<Option<WidgetId>, ArcVar<Option<WidgetId>>>
pub fn nest_parent( &self, ) -> ReadOnlyVar<Option<WidgetId>, ArcVar<Option<WidgetId>>>
Gets the widget in parent
that hosts the window, if it is nesting.
Nesting windows are presented as an widget, similar to an “iframe”.
sourcepub fn modal(&self) -> ArcVar<bool>
pub fn modal(&self) -> ArcVar<bool>
Defines the parent
connection.
Value is ignored if parent
is not set. When this is true
the parent window cannot be focused while this window is open.
The default value is false
.
sourcepub fn children(&self) -> ReadOnlyVar<IdSet<WindowId>, ArcVar<IdSet<WindowId>>>
pub fn children(&self) -> ReadOnlyVar<IdSet<WindowId>, ArcVar<IdSet<WindowId>>>
Window children.
This is a set of other windows that have this window as a parent
.
sourcepub fn color_scheme(&self) -> ArcVar<Option<ColorScheme>>
pub fn color_scheme(&self) -> ArcVar<Option<ColorScheme>>
Override the preferred color scheme.
If set to None
the system preference is used, see actual_color_scheme
.
sourcepub fn actual_color_scheme(
&self,
) -> ReadOnlyVar<ColorScheme, ArcVar<ColorScheme>>
pub fn actual_color_scheme( &self, ) -> ReadOnlyVar<ColorScheme, ArcVar<ColorScheme>>
Actual color scheme to use.
This is the system preference, or color_scheme
if it is set.
sourcepub fn accent_color(&self) -> ArcVar<Option<LightDark>>
pub fn accent_color(&self) -> ArcVar<Option<LightDark>>
Override the preferred accent color.
If set to None
the system preference is used, see actual_accent_color
.
sourcepub fn actual_accent_color(&self) -> ReadOnlyVar<LightDark, ArcVar<LightDark>>
pub fn actual_accent_color(&self) -> ReadOnlyVar<LightDark, ArcVar<LightDark>>
Actual accent color to use.
This is the system preference, or color_scheme
if it is set.
The window widget also sets ACCENT_COLOR_VAR
to this variable.
sourcepub fn is_open(&self) -> ReadOnlyVar<bool, ArcVar<bool>>
pub fn is_open(&self) -> ReadOnlyVar<bool, ArcVar<bool>>
If the window is open.
This is a read-only variable, it starts set to true
and will update only once,
when the window finishes opening.
Note that a window is only actually opened in the view-process after it is_loaded
.
sourcepub fn is_loaded(&self) -> ReadOnlyVar<bool, ArcVar<bool>>
pub fn is_loaded(&self) -> ReadOnlyVar<bool, ArcVar<bool>>
If the window has finished loading.
This is a read-only variable, it starts set to false
and will update only once, after
the first window layout and when all loading handles to the window are released.
A window is only opened in the view-process once it is loaded, see WINDOWS.loading_handle
for more details.
sourcepub fn focus_indicator(&self) -> ArcVar<Option<FocusIndicator>>
pub fn focus_indicator(&self) -> ArcVar<Option<FocusIndicator>>
Defines the active user attention required indicator.
This is usually a visual indication on the taskbar icon that prompts the user to focus on the window, it is automatically
changed to None
once the window receives focus or you can set it to None
to cancel the indicator.
Prefer using the FOCUS
service and advanced FocusRequest
configs instead of setting this variable directly.
sourcepub fn frame_capture_mode(&self) -> ArcVar<FrameCaptureMode>
pub fn frame_capture_mode(&self) -> ArcVar<FrameCaptureMode>
Defines if and how the frame pixels are captured for the next rendered frames.
If set to Next
the value will change to Sporadic
after the next frame is rendered.
Note that setting this to Next
does not cause a frame request. Use WIDGET.render_update
for that.
sourcepub fn render_mode(&self) -> ReadOnlyVar<RenderMode, ArcVar<RenderMode>>
pub fn render_mode(&self) -> ReadOnlyVar<RenderMode, ArcVar<RenderMode>>
Window actual render mode.
The initial value is the default_render_mode
, it can update after the window is created, when the view-process
actually creates the backend window and after a view-process respawn.
sourcepub fn access_enabled(
&self,
) -> ReadOnlyVar<AccessEnabled, ArcVar<AccessEnabled>>
pub fn access_enabled( &self, ) -> ReadOnlyVar<AccessEnabled, ArcVar<AccessEnabled>>
If an accessibility service has requested info from this window.
You can enable this in the app-process using enable_access
, the
view-process can also enable it on the first request for accessibility info by an external tool.
This variable does not update to fully disabled after first enable, but the VIEW bit can disable and re-enable.
sourcepub fn system_shutdown_warn(&self) -> ArcVar<Txt>
pub fn system_shutdown_warn(&self) -> ArcVar<Txt>
Attempt to set a system wide shutdown warning associated with the window.
Operating systems that support this show the text in a warning for the user, it must be a short text that identifies the critical operation that cannot be cancelled.
Set to an empty text to remove the warning.
Note that this does not stop the window from closing or the app from exiting normally, you must handle window close requests and show some feedback to the user, the view-process will send a window close request when a system shutdown attempt is detected.
Note that there is no guarantee that the view-process or operating system will actually set a block, there is no error result because operating systems can silently ignore block requests at any moment, even after an initial successful block.
§Current Limitations
The current zng::view_process
or zng-view
only implements this feature on Windows and it will only work properly
under these conditions:
- It must be running in
run_same_process
mode. Windows kills all other processes, so in a run withinit
the app-process will be lost. Note that this also mean that the crash handler and worker processes are also killed. - Must be built with
#![windows_subsystem = "windows"]
and must be running from the Windows Explorer (desktop).
Trait Implementations§
source§impl Clone for WindowVars
impl Clone for WindowVars
source§fn clone(&self) -> WindowVars
fn clone(&self) -> WindowVars
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl PartialEq for WindowVars
impl PartialEq for WindowVars
impl Eq for WindowVars
Auto Trait Implementations§
impl Freeze for WindowVars
impl !RefUnwindSafe for WindowVars
impl Send for WindowVars
impl Sync for WindowVars
impl Unpin for WindowVars
impl !UnwindSafe for WindowVars
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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