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
use crateComponent;
use crateTheme;
use crateView;
/// Hints to the runtime about what kind of native control this widget maps to.
/// The platform layer uses this to decide whether to render via AppKit/UIKit or
/// fall back to the GPU renderer.
/// Extension of `Component` that carries platform metadata.
///
/// Implement `Widget` to opt in to native platform controls when available.
/// The default implementations delegate everything to `Component::render`,
/// so you only need to override what you care about.
///
/// # Implementing a custom widget
///
/// ```rust
/// use core_glyph::{Component, Signal, Theme, View, NativeHint, Widget, column, text};
///
/// struct MyToggle { on: Signal<bool> }
///
/// impl Component for MyToggle {
/// fn render(&self, theme: &Theme) -> View {
/// // GPU fallback rendering
/// column(vec![text(if self.on.get() { "ON" } else { "OFF" }, 16.0).into()]).into()
/// }
/// }
///
/// impl Widget for MyToggle {
/// fn native_hint(&self) -> NativeHint { NativeHint::Toggle }
/// }
/// ```