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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//! Commit signal — "this adjustment has settled".
//!
//! [`egui::Response::changed`] fires on every intermediate value a drag sweeps
//! through, which is what a live preview wants. It is the wrong signal for work
//! you would not want to repeat dozens of times for one gesture: a network
//! write, a disk persist, a device reprogram.
//!
//! [`ResponseCommitExt::committed`] reports the frame an adjustment settles
//! instead. See the trait for what counts as settled.
//!
//! # Usage
//!
//! ```no_run
//! # use elegance::{MetricSlider, ResponseCommitExt};
//! # fn push_to_backend(_: f32) {}
//! # fn preview(_: f32) {}
//! # egui::__run_test_ui(|ui| {
//! let mut buffer = 16.0_f32;
//! let resp = ui.add(
//! MetricSlider::new(&mut buffer, 0.0..=32.0)
//! .suffix("GiB")
//! .stops([4.0, 8.0, 16.0, 32.0]),
//! );
//! if resp.changed() {
//! preview(buffer); // live, every intermediate stop
//! }
//! if resp.committed() {
//! push_to_backend(buffer); // once per settled adjustment
//! }
//! # });
//! ```
use ;
/// Every pointer button egui can report.
///
/// The length is tied to [`NUM_POINTER_BUTTONS`], so if egui ever gains a
/// button this array stops compiling instead of silently leaving that button
/// uncommitted — the failure mode this list exists to prevent.
const ALL_POINTER_BUTTONS: = ;
/// Memory key for a widget-reported commit. Stores the pass number the commit
/// was reported on, so reading it is idempotent within a pass and an entry
/// cannot fire on a later one.
/// Report that an adjustment on `id` settled this pass.
///
/// A [`Response`] records *that* a widget changed, never *what drove it*, so
/// non-pointer input cannot be classified from the outside: a keyboard nudge
/// and a smoothed scroll frame look identical there. Rather than guess, each
/// elegance value widget reports its own non-pointer settle through this
/// channel, at the point where it already knows which input it just handled.
///
/// `id` must be the id of the [`Response`] the widget *returns*. For a widget
/// that unions several responses that is the first one, since
/// [`Response::union`] keeps the left id.
pub
/// Whether a widget reported a commit for the pass now being laid out.
/// Was this widget clicked by *any* pointer button?
///
/// [`Response::clicked`] is primary-only, but every elegance value widget
/// gates its pointer write on a button-agnostic predicate, so a click with any
/// button moves the value and therefore has to commit.
/// Extension trait for reading the *commit* signal off a value widget's
/// [`Response`]. Import this trait (or `use elegance::*`) to bring the method
/// into scope.