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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Thin wrappers around the top-level `Noesis::GUI::*` helpers that don't
//! fit into the provider / view / render-device modules.
use CString;
use ;
use crate;
/// Load a [`ResourceDictionary`] XAML via the installed XAML provider and
/// install it as the process-global application resources. Every
/// [`crate::view::View`] created afterwards inherits these styles and
/// brushes. Replaces any previously-installed dictionary.
///
/// Returns `true` when the URI resolved to a valid
/// `ResourceDictionary`; `false` when the provider didn't serve bytes or
/// when the XAML parsed to a different root element.
///
/// [`ResourceDictionary`]: https://docs.noesisengine.com/gui/ResourceDictionary.html
///
/// # Panics
///
/// Panics if `uri` contains an interior NUL byte.
/// Install application resources by building the merged-dictionary
/// chain manually, leaf by leaf. `uris` are the leaf
/// `ResourceDictionary` URIs in dependency order; earlier entries
/// must be loadable without referencing later entries.
///
/// Sidesteps a Noesis behaviour where a top-level `LoadXaml` of a
/// parent dictionary parses its `MergedDictionaries` children in
/// isolation, leaving cross-sibling `{StaticResource SiblingKey}`
/// references inside child bodies null-resolved at parse time.
///
/// Each leaf is created empty, added to the parent's
/// `MergedDictionaries` collection (so the parent scope is wired in
/// before parsing starts), then loaded by assigning its `Source`
/// property, at which point the parent already contains every
/// previously-loaded sibling.
///
/// # Relative URIs in installed leaves
///
/// Each leaf is loaded via `ResourceDictionary::SetSource(Uri)`,
/// which means relative URIs *inside* a leaf (most notably
/// `<FontFamily>Folder/#Family</FontFamily>` resources) resolve
/// against the leaf's own location. A `Theme/Fonts.xaml` leaf
/// declaring `<FontFamily>Fonts/#X</FontFamily>` will look for
/// family `X` in folder `Theme/Fonts/`, not the project-root
/// `Fonts/`. If your font provider's `register_font` calls register
/// under `Fonts/`, the corresponding leaf needs to use a relative-up
/// URI (`../Fonts/#X`), or the leaf needs to live at the same
/// directory level as the assets it references. Absolute URIs
/// (`/Assets/Fonts/#X`) sidestep leaf-relative resolution entirely;
/// the relative-up form is the alternative when assets live above the
/// leaf.
///
/// # Panics
///
/// Panics if any URI contains an interior NUL byte.
/// Load the XAML at `uri` into an existing component instance: the
/// code-behind / `x:Class` pattern, where the root object already exists and
/// `GUI::LoadComponent` populates its children and named fields in place
/// (instead of constructing a fresh tree the way [`crate::view::FrameworkElement::load`]
/// does).
///
/// Returns `false` when `component` is null or `uri` is empty/unresolvable.
/// A `true` return means the call linked and ran; it does **not** by itself
/// guarantee the tree was populated.
///
/// # Reflection requirement / limitation
///
/// For `LoadComponent` to actually graft the parsed tree onto `component`, the
/// instance's reflected type must match the XAML root's `x:Class`. Noesis maps
/// the root element back onto the supplied instance by type identity; a
/// mismatch leaves the instance untouched (and Noesis logs a type error).
/// The custom-class registration surface ([`crate::classes`]) supplies exactly
/// such a type: register a class as `"Nz.LoadTarget"`, instantiate it, and load
/// XAML whose root carries `x:Class="Nz.LoadTarget"`; the parsed children and
/// named fields are grafted onto that instance (verified by `tests/parse_xaml`,
/// which asserts a named child becomes resolvable through the instance only
/// after this call). The caller is responsible for ensuring the registered type
/// name and the XAML `x:Class` agree; this entry point does not synthesize that
/// pairing on its own.
///
/// # Safety
///
/// `component` must be a live `Noesis::BaseComponent*` (for example a
/// [`crate::classes::ClassInstance::raw`] value) that outlives the call, or
/// null. The pointer is borrowed; ownership is not taken and the caller's
/// reference is unaffected. Runs on the view-driving thread; no `VerifyAccess`
/// is performed.
///
/// # Panics
///
/// Panics if `uri` contains an interior NUL byte.
pub unsafe