pub struct Environment {Show 22 fields
pub window: Size<Points>,
pub safe_area: Edges<Points>,
pub title_bar: Edges<Points>,
pub keyboard_height: Points,
pub keyboard_duration: f32,
pub color_scheme: ColorScheme,
pub font_scale: f32,
pub rtl: bool,
pub reduce_motion: bool,
pub pixel_ratio: f32,
pub screen_reader: bool,
pub os: Os,
pub os_version: (u16, u16),
pub idiom: Idiom,
pub apple_keyboard: bool,
pub locale: Locale,
pub host: bool,
pub lifecycle: Lifecycle,
pub screen_color: bool,
pub file_requests: bool,
pub speech: bool,
pub web_input: bool,
}Expand description
What the platform knows about the surface.
Fields§
§window: Size<Points>Size of the surface in points.
safe_area: Edges<Points>Insets not covered by system UI (notch, home indicator, title bar).
title_bar: Edges<Points>The title bar’s area while the app hides it (desktops,
crate::desktop::TitleBarStyle::Hidden): top is its height,
left and right the widths the system’s window controls take at
its ends (bottom is 0); all 0 while the system shows its title
bar.
keyboard_height: PointsHeight of the software keyboard over the surface; 0 when hidden.
keyboard_duration: f32Duration of the keyboard’s show / hide animation in milliseconds.
color_scheme: ColorSchemeLight or dark appearance.
font_scale: f32Preferred text size relative to the default (1.0).
rtl: boolThe user’s language is written right to left.
reduce_motion: boolThe user asked for less motion (iOS Reduce Motion, Android’s animator duration scale at 0).
pixel_ratio: f32Device pixels per point.
screen_reader: boolA screen reader runs (VoiceOver, TalkBack).
os: OsThe operating system.
os_version: (u16, u16)The OS version: major and minor (iOS, desktops), Android’s API level and 0.
idiom: IdiomThe kind of device.
apple_keyboard: boolA browser on an Apple platform (macOS, iOS): its keyboard shortcuts
follow Apple’s conventions (crate::keymap::apple_keys: mod is
Command, labels use ⌘). Only read for Os::Web; the other OSes
imply theirs.
locale: LocaleThe user’s locale (number and date formats: Intl’s default).
host: boolThe app embedding NSH answers nsh/host’s calls
(crate::Command::HostCall); without it, they reject at once.
lifecycle: LifecycleWhether the app is in use: in the foreground, visible without the focus, or in the background. For an embedded surface, the embedding app’s.
screen_color: boolThe platform picks a color from the screen
(crate::Command::PickScreenColor); without it, a pick answers
no color at once.
file_requests: boolThe platform shows the system’s open and save dialogs and opens,
reveals and trashes local paths (crate::Command::FileRequest,
the desktops); without it, those requests answer at once with an
error.
speech: boolThe platform recognizes speech (crate::Command::Speech,
crate::speech); without it, a session ends at once
(unavailable) unless the core has a crate::speech::SpeechBackend.
web_input: boolThe platform gives web views trusted input
(crate::Command::SendInput, macOS); without it, the command
does nothing.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn desktop(&self) -> bool
pub fn desktop(&self) -> bool
Desktop behavior applies: a desktop OS, or a browser in the desktop
idiom (Idiom::desktop_on: desktop={{…}} props,
platform.select({ desktop }), platform.desktop, platform.idiom
"desktop").
Sourcepub fn reported_idiom(&self) -> Idiom
pub fn reported_idiom(&self) -> Idiom
The idiom apps see (TS: platform.idiom, Idiom::reported_on).
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more