MaterialPolicy
struct · ferroui-base · v0.5.0
struct MaterialPolicy
The material policy (WinUI's MaterialHelper): materials are disabled,
and acrylic draws its fallback colour, while the energy saver is on, the
user turned transparency effects off, the effects are not fast enough,
or a test simulates it.
The settings come from the platform
(IPlatformSettings::transparency_enabled and
IPlatformSettings::energy_saver_enabled), read when the policy is
first asked and whenever the platform reports a change of either
(IPlatformSettings::accessibility_settings_changed,
IPlatformSettings::energy_saver_changed). The policy is
per thread, as the objects it serves.
Members
is_disabled_by_policypolicy_changedupdate_policy_statussimulate_disabled_by_policyset_simulate_disabled_by_policyignore_are_effects_fastset_ignore_are_effects_fastare_effects_fastset_are_effects_fasttransparency_enabledenergy_saver_enabledis_window_activeset_window_activewindow_activation_changednoise_brush
is_disabled_by_policy
fn is_disabled_by_policy() -> bool
Whether materials are disabled by the policy.
policy_changed
fn policy_changed(handler: impl Fn(bool) -> () + 'static) -> Subscription
PolicyChanged: handler is called now with the current state, and
whenever the state changes. Dropping the returned guard removes the
handler; Subscription::detach keeps it for the life of the
thread.
update_policy_status
fn update_policy_status()
Reads the settings of the platform again and tells the listeners when the state changes.
simulate_disabled_by_policy
fn simulate_disabled_by_policy() -> bool
SimulateDisabledByPolicy: whether a test makes the policy disable
materials.
set_simulate_disabled_by_policy
fn set_simulate_disabled_by_policy(value: bool)
ignore_are_effects_fast
fn ignore_are_effects_fast() -> bool
IgnoreAreEffectsFast: whether slow effects are ignored.
set_ignore_are_effects_fast
fn set_ignore_are_effects_fast(value: bool)
are_effects_fast
fn are_effects_fast() -> bool
Whether the effects of the renderer are fast enough for materials
(WinUI's CompositionCapabilities.AreEffectsFast); true unless a
platform or the application says otherwise.
set_are_effects_fast
fn set_are_effects_fast(value: bool)
transparency_enabled
fn transparency_enabled() -> bool
Whether the platform permits transparency effects, as the policy last
read it (IPlatformSettings::transparency_enabled; true without
platform settings).
energy_saver_enabled
fn energy_saver_enabled() -> bool
Whether the energy saver is on, as the policy last read it
(IPlatformSettings::energy_saver_enabled; false without platform
settings).
is_window_active
fn is_window_active() -> bool
Whether a window of the application is active: the acrylic of the
host backdrop falls back to its colour while none is (WinUI's
AcrylicBrush follows the activation of its window). true until a
window says otherwise.
set_window_active
fn set_window_active(active: bool)
Records whether a window of the application is active, and tells the
listeners when it changed (the windows of ferroui-controls call it).
window_activation_changed
fn window_activation_changed(handler: impl Fn(bool) -> () + 'static) -> Subscription
handler is called whenever is_window_active
changes. Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the thread.
noise_brush
fn noise_brush(compositor: &Rc<Compositor>) -> CompositionSurfaceBrush
The noise brush the materials share on compositor (WinUI's
MaterialHelper.GetNoiseBrush): a surface brush of the noise texture
that does not stretch and sits at the top left corner, which a border
effect tiles.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEither
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.