#[repr(C)]pub struct CssMockEnvironment {
pub os: OptionOsCondition,
pub os_version: OptionOsVersion,
pub desktop_env: OptionLinuxDesktopEnv,
pub theme: OptionThemeCondition,
pub language: OptionString,
pub prefers_reduced_motion: OptionBool,
pub prefers_high_contrast: OptionBool,
pub viewport_width: OptionF32,
pub viewport_height: OptionF32,
}Expand description
Mock environment for CSS evaluation.
Allows overriding auto-detected system properties for testing and development.
Any field set to None will use the auto-detected value.
Any field set to Some(...) will override the auto-detected value.
§Example
use azul_css::dynamic_selector::{OsCondition, ThemeCondition, OsVersion};
// Mock a Linux dark theme environment on any platform
let mock = CssMockEnvironment {
os: Some(OsCondition::Linux),
theme: Some(ThemeCondition::Dark),
..Default::default()
};
// Mock Windows XP for retro testing
let mock = CssMockEnvironment {
os: Some(OsCondition::Windows),
os_version: Some(OsVersion::WIN_XP),
..Default::default()
};Fields§
§os: OptionOsConditionOverride the detected operating system
os_version: OptionOsVersionOverride the detected OS version
desktop_env: OptionLinuxDesktopEnvOverride the Linux desktop environment (only applies when os = Linux)
theme: OptionThemeConditionOverride the current theme (light/dark)
language: OptionStringOverride the current language (BCP 47 tag, e.g., “de-DE”, “en-US”)
prefers_reduced_motion: OptionBoolOverride the reduced motion preference
prefers_high_contrast: OptionBoolOverride the high contrast preference
viewport_width: OptionF32Override viewport dimensions (for @media queries) Only use for testing - normally set by window size
viewport_height: OptionF32Implementations§
Source§impl CssMockEnvironment
impl CssMockEnvironment
Sourcepub fn dark_theme() -> Self
pub fn dark_theme() -> Self
Create a mock for dark theme
Sourcepub fn light_theme() -> Self
pub fn light_theme() -> Self
Create a mock for light theme
Sourcepub fn apply_to(&self, ctx: &mut DynamicSelectorContext)
pub fn apply_to(&self, ctx: &mut DynamicSelectorContext)
Apply this mock to a DynamicSelectorContext
Trait Implementations§
Source§impl Clone for CssMockEnvironment
impl Clone for CssMockEnvironment
Source§fn clone(&self) -> CssMockEnvironment
fn clone(&self) -> CssMockEnvironment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CssMockEnvironment
impl Debug for CssMockEnvironment
Source§impl Default for CssMockEnvironment
impl Default for CssMockEnvironment
Source§fn default() -> CssMockEnvironment
fn default() -> CssMockEnvironment
Auto Trait Implementations§
impl Freeze for CssMockEnvironment
impl RefUnwindSafe for CssMockEnvironment
impl Send for CssMockEnvironment
impl Sync for CssMockEnvironment
impl Unpin for CssMockEnvironment
impl UnsafeUnpin for CssMockEnvironment
impl UnwindSafe for CssMockEnvironment
Blanket Implementations§
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§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