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
//! Process-global icon registry: id → [`VectorIcon`].
//!
//! Widgets deep inside the tree paint icons that only the *host* knows
//! about (a node editor draws a boolean-operation strip; the artwork
//! belongs to the app, not to agg-gui). Threading an icon table down
//! through every schema type and every paint call would make the schema
//! expensive to clone and every intermediate layer aware of icons, so
//! the lookup goes through a global instead — the same shape as the
//! system font slot and the SVG parse-options cell.
//!
//! It is a `RwLock<HashMap>` rather than a thread-local because the
//! host registers once at startup while tests paint from many threads;
//! a thread-local would silently render icon-less in every thread but
//! the one that registered. A poisoned lock is recovered rather than
//! propagated: a panic elsewhere must not turn every later icon lookup
//! into a panic of its own.
use HashMap;
use ;
use VectorIcon;
type IconMap = ;
static ICONS: = new;
/// Register `icon` under `id`, replacing any previous registration.
///
/// Ids are free-form; hosts should namespace them (`"boolean.combine"`)
/// so two features cannot collide.
/// Look up a registered icon. `None` means "nothing registered under
/// this id" — callers are expected to fall back to something visible
/// (text) rather than painting nothing.
/// Every registered id, unordered. Diagnostics and tests.
// There is deliberately no `clear_icons`. The registry is global and
// widgets read it mid-paint from any thread, so a clear is a foot-gun
// with no legitimate caller: production registers once at startup, and a
// test that wants isolation registers under its own id (re-registering
// an id replaces it, which is all "reset this icon" ever needs).