1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! The accessibility display settings a translucent surface has to answer to.
//!
//! # What this crate does and does not do
//!
//! **This crate reads these settings. It does not act on them for you.**
//!
//! *Reduce Transparency* asks for a surface that is not see-through. There is
//! no way to satisfy it from inside `GlassSurface`: `NSGlassEffectView` has
//! no opacity control, and its whole function is to sample and blur what is
//! behind the window. Honouring the setting means **not using the material at
//! all** for the duration — substituting an opaque view, with the colours,
//! contrast and layout that go with it. That substitute is the caller's
//! content, not something a wrapper around one AppKit view can synthesise.
//!
//! This module makes the check one call; building the opaque alternative is
//! the caller's job.
//!
//! # The shape a caller wants
//!
//! Decide at construction, and re-decide when it changes:
//!
//! ```no_run
//! # #[cfg(target_os = "macos")] {
//! if macos_liquid_glass::accessibility::reduce_transparency() {
//! // Build the opaque variant — no GlassSurface.
//! } else {
//! // Build the glass one.
//! }
//! # }
//! ```
//!
//! These settings change while the app runs, and unlike the Icon & widget style
//! there IS a notification for them:
//! `NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification`, posted on
//! `NSWorkspace.sharedWorkspace().notificationCenter()`. Observe it the same way
//! you would any other. (Note that is the *workspace's* centre, not
//! `NSNotificationCenter.default` — a common way to register an observer that
//! never fires.)
//!
//! # Also worth honouring
//!
//! [`increase_contrast`] asks for stronger borders and less subtle colour
//! separation, which matters for a material whose edges are defined by a faint
//! rim. [`differentiate_without_color`] asks that colour never be the only
//! carrier of meaning — relevant if you drive anything off
//! `WidgetStyle::tint`.
use NSWorkspace;
/// Whether the user asked for **Reduce Transparency**.
///
/// System Settings ▸ Accessibility ▸ Display ▸ Reduce transparency.
///
/// When this is `true`, a Liquid Glass surface is the wrong choice and the
/// caller should build an opaque variant instead — see the module docs for why
/// this crate reports the setting rather than acting on it.
/// Whether the user asked for **Increase Contrast**.
///
/// System Settings ▸ Accessibility ▸ Display ▸ Increase contrast. Implies
/// stronger borders and less reliance on subtle tonal separation, which a
/// glass surface leans on heavily.
/// Whether the user asked that colour not be the sole carrier of meaning.
///
/// System Settings ▸ Accessibility ▸ Display ▸ Differentiate without color.
/// Whether the user asked for **Reduce Motion**.
///
/// System Settings ▸ Accessibility ▸ Display ▸ Reduce motion. This crate
/// animates nothing, so it is here for callers that do.