@effindomv2/fui-rs 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMMERCIAL.md +7 -0
- package/Cargo.toml +34 -0
- package/LICENSE.md +9 -0
- package/README.md +88 -0
- package/package.json +54 -0
- package/scripts/build.sh +227 -0
- package/scripts/check-runtime-dependency.sh +41 -0
- package/scripts/framework-host-services.ts +40 -0
- package/scripts/generate-host-events.ts +17 -0
- package/scripts/generate-host-services.ts +28 -0
- package/scripts/hostgen/common.ts +73 -0
- package/scripts/hostgen/registry.ts +159 -0
- package/scripts/hostgen/rust-host-events.ts +171 -0
- package/scripts/hostgen/rust-host-services.ts +257 -0
- package/src/animation.rs +625 -0
- package/src/app.rs +324 -0
- package/src/assets.rs +572 -0
- package/src/bindings/mod.rs +1 -0
- package/src/bindings/ui.rs +705 -0
- package/src/bitmap.rs +317 -0
- package/src/bridge_callbacks.rs +242 -0
- package/src/context_menu_manager.rs +332 -0
- package/src/controls/anti_selection_area.rs +54 -0
- package/src/controls/button.rs +542 -0
- package/src/controls/checkbox.rs +372 -0
- package/src/controls/combobox.rs +1574 -0
- package/src/controls/context_menu.rs +1367 -0
- package/src/controls/control_template_set.rs +46 -0
- package/src/controls/control_tokens.rs +596 -0
- package/src/controls/dialog.rs +590 -0
- package/src/controls/dropdown.rs +1010 -0
- package/src/controls/form.rs +229 -0
- package/src/controls/internal/button_presenter.rs +142 -0
- package/src/controls/internal/checkbox_indicator_presenter.rs +210 -0
- package/src/controls/internal/dropdown_chevron_presenter.rs +134 -0
- package/src/controls/internal/dropdown_field_presenter.rs +269 -0
- package/src/controls/internal/dropdown_option_row_presenter.rs +184 -0
- package/src/controls/internal/mod.rs +13 -0
- package/src/controls/internal/pressable_indicator_presenter.rs +26 -0
- package/src/controls/internal/pressable_labeled_control.rs +492 -0
- package/src/controls/internal/radio_indicator_presenter.rs +208 -0
- package/src/controls/internal/selectable_popup_list.rs +597 -0
- package/src/controls/internal/slider_presenter.rs +282 -0
- package/src/controls/internal/switch_indicator_presenter.rs +235 -0
- package/src/controls/internal/text_input_core.rs +1074 -0
- package/src/controls/internal/text_input_presenter.rs +108 -0
- package/src/controls/mod.rs +235 -0
- package/src/controls/nav_link.rs +395 -0
- package/src/controls/popup.rs +191 -0
- package/src/controls/progress_bar.rs +287 -0
- package/src/controls/radio_button.rs +348 -0
- package/src/controls/radio_group.rs +283 -0
- package/src/controls/selection_area.rs +82 -0
- package/src/controls/shared.rs +68 -0
- package/src/controls/slider.rs +701 -0
- package/src/controls/switch.rs +293 -0
- package/src/controls/templating.rs +49 -0
- package/src/controls/tests.rs +3905 -0
- package/src/controls/text_area.rs +207 -0
- package/src/controls/text_input.rs +192 -0
- package/src/debug.rs +146 -0
- package/src/drag_drop.rs +424 -0
- package/src/drag_gesture.rs +258 -0
- package/src/drawing.rs +385 -0
- package/src/event.rs +1603 -0
- package/src/external_drop.rs +467 -0
- package/src/fetch.rs +500 -0
- package/src/ffi.rs +3542 -0
- package/src/file.rs +1677 -0
- package/src/focus_adorner.rs +307 -0
- package/src/focus_visibility.rs +121 -0
- package/src/frame_scheduler.rs +159 -0
- package/src/frame_signal.rs +64 -0
- package/src/generated/ffi.rs +798 -0
- package/src/generated/framework_host_services.rs +74 -0
- package/src/generated/mod.rs +2 -0
- package/src/host_services.rs +162 -0
- package/src/image_sampling.rs +78 -0
- package/src/keyboard_scroll.rs +137 -0
- package/src/keyboard_scroll_tracker.rs +385 -0
- package/src/lib.rs +547 -0
- package/src/logger.rs +56 -0
- package/src/mobile_text_selection_toolbar.rs +1034 -0
- package/src/navigation.rs +48 -0
- package/src/node/core.rs +2210 -0
- package/src/node/custom_drawable.rs +149 -0
- package/src/node/flex_box.rs +874 -0
- package/src/node/grid.rs +304 -0
- package/src/node/helpers.rs +442 -0
- package/src/node/image.rs +506 -0
- package/src/node/mod.rs +315 -0
- package/src/node/scroll_bar.rs +845 -0
- package/src/node/scroll_box.rs +514 -0
- package/src/node/scroll_state.rs +121 -0
- package/src/node/scroll_view.rs +557 -0
- package/src/node/svg_node.rs +474 -0
- package/src/node/text_node.rs +633 -0
- package/src/node/virtual_list.rs +678 -0
- package/src/panic_hook.rs +36 -0
- package/src/persisted.rs +274 -0
- package/src/platform.rs +556 -0
- package/src/popup_presenter.rs +344 -0
- package/src/selection_handle_adorner.rs +838 -0
- package/src/signal.rs +134 -0
- package/src/text.rs +1065 -0
- package/src/theme.rs +571 -0
- package/src/timers.rs +106 -0
- package/src/tool_tip.rs +167 -0
- package/src/tool_tip_manager.rs +691 -0
- package/src/transitions.rs +41 -0
- package/src/typography.rs +520 -0
- package/src/viewport.rs +108 -0
- package/src/worker.rs +308 -0
- package/src/worker_job.rs +82 -0
- package/src/worker_runtime.rs +172 -0
package/src/node/grid.rs
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
use super::core::*;
|
|
2
|
+
use super::*;
|
|
3
|
+
|
|
4
|
+
#[derive(Clone)]
|
|
5
|
+
pub struct Grid {
|
|
6
|
+
base: FlexBox,
|
|
7
|
+
props: Rc<RefCell<GridProps>>,
|
|
8
|
+
placements: Rc<RefCell<Vec<(NodeRef, GridPlacement)>>>,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
12
|
+
pub struct GridTrack {
|
|
13
|
+
pub value: f32,
|
|
14
|
+
pub unit: GridUnit,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
impl GridTrack {
|
|
18
|
+
pub const fn px(value: f32) -> Self {
|
|
19
|
+
Self {
|
|
20
|
+
value,
|
|
21
|
+
unit: GridUnit::Pixel,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
pub const fn star(value: f32) -> Self {
|
|
26
|
+
Self {
|
|
27
|
+
value,
|
|
28
|
+
unit: GridUnit::Star,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
pub const fn auto() -> Self {
|
|
33
|
+
Self {
|
|
34
|
+
value: 0.0,
|
|
35
|
+
unit: GridUnit::Auto,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
impl Default for Grid {
|
|
41
|
+
fn default() -> Self {
|
|
42
|
+
let base = FlexBox::default();
|
|
43
|
+
base.core.borrow_mut().kind = NodeKind::Grid;
|
|
44
|
+
Self {
|
|
45
|
+
base,
|
|
46
|
+
props: Rc::new(RefCell::new(GridProps::default())),
|
|
47
|
+
placements: Rc::new(RefCell::new(Vec::new())),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
impl Node for Grid {
|
|
53
|
+
fn retained_node_ref(&self) -> NodeRef {
|
|
54
|
+
NodeRef::from_node(self.base.core.clone(), self.clone())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fn build_self(&self) {
|
|
58
|
+
apply_grid_props(
|
|
59
|
+
self.handle(),
|
|
60
|
+
&self.props.borrow(),
|
|
61
|
+
self.base.core.borrow().behavior.clone(),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fn build_children(&self) {
|
|
66
|
+
self.base.build_children();
|
|
67
|
+
self.apply_grid_placements();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
impl Grid {
|
|
72
|
+
pub(crate) fn downgrade(&self) -> WeakFlexBox {
|
|
73
|
+
self.base.downgrade()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fn apply_grid_placements(&self) {
|
|
77
|
+
for (child, placement) in self.placements.borrow().iter() {
|
|
78
|
+
let handle = child.handle();
|
|
79
|
+
if handle != NodeHandle::INVALID {
|
|
80
|
+
ui::set_grid_placement(
|
|
81
|
+
handle.raw(),
|
|
82
|
+
placement.row,
|
|
83
|
+
placement.col,
|
|
84
|
+
placement.row_span,
|
|
85
|
+
placement.col_span,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
pub fn width(&self, width: f32, unit: Unit) -> &Self {
|
|
92
|
+
self.props.borrow_mut().width = Some((width, unit));
|
|
93
|
+
if self.has_built_handle() {
|
|
94
|
+
ui::set_width(self.handle().raw(), width, unit as u32);
|
|
95
|
+
self.notify_retained_layout_mutation();
|
|
96
|
+
}
|
|
97
|
+
self
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub fn width_len(&self, length: Length) -> &Self {
|
|
101
|
+
let (width, unit) = length;
|
|
102
|
+
self.width(width, unit)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
pub fn height(&self, height: f32, unit: Unit) -> &Self {
|
|
106
|
+
self.props.borrow_mut().height = Some((height, unit));
|
|
107
|
+
if self.has_built_handle() {
|
|
108
|
+
ui::set_height(self.handle().raw(), height, unit as u32);
|
|
109
|
+
self.notify_retained_layout_mutation();
|
|
110
|
+
}
|
|
111
|
+
self
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
pub fn height_len(&self, length: Length) -> &Self {
|
|
115
|
+
let (height, unit) = length;
|
|
116
|
+
self.height(height, unit)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
pub fn bg_color(&self, color: u32) -> &Self {
|
|
120
|
+
self.props.borrow_mut().bg_color = Some(color);
|
|
121
|
+
if self.has_built_handle() {
|
|
122
|
+
ui::set_bg_color(self.handle().raw(), color);
|
|
123
|
+
self.notify_retained_mutation();
|
|
124
|
+
}
|
|
125
|
+
self
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
pub fn padding(&self, left: f32, top: f32, right: f32, bottom: f32) -> &Self {
|
|
129
|
+
self.props.borrow_mut().padding = Some((left, top, right, bottom));
|
|
130
|
+
if self.has_built_handle() {
|
|
131
|
+
ui::set_padding(self.handle().raw(), left, top, right, bottom);
|
|
132
|
+
self.notify_retained_layout_mutation();
|
|
133
|
+
}
|
|
134
|
+
self
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
pub fn corner_radius(&self, radius: f32) -> &Self {
|
|
138
|
+
self.base.corner_radius(radius);
|
|
139
|
+
self
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pub fn cursor(&self, style: CursorStyle) -> &Self {
|
|
143
|
+
self.base.cursor(style);
|
|
144
|
+
self
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
pub fn interactive(&self, interactive: bool) -> &Self {
|
|
148
|
+
self.base.interactive(interactive);
|
|
149
|
+
self
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
pub fn semantic_role(&self, role: SemanticRole) -> &Self {
|
|
153
|
+
self.base.semantic_role(role);
|
|
154
|
+
self
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
pub fn semantic_label(&self, label: impl Into<String>) -> &Self {
|
|
158
|
+
self.base.semantic_label(label);
|
|
159
|
+
self
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
pub(crate) fn semantic_disabled(&self, disabled: bool) -> &Self {
|
|
163
|
+
self.base.semantic_disabled(disabled);
|
|
164
|
+
self
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
pub fn on_pointer_down(&self, handler: impl Fn(&mut PointerEventArgs) + 'static) -> &Self {
|
|
168
|
+
self.base.on_pointer_down(handler);
|
|
169
|
+
self
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
pub fn on_pointer_up(&self, handler: impl Fn(&mut PointerEventArgs) + 'static) -> &Self {
|
|
173
|
+
self.base.on_pointer_up(handler);
|
|
174
|
+
self
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
pub fn on_pointer_enter(&self, handler: impl Fn(&mut PointerEventArgs) + 'static) -> &Self {
|
|
178
|
+
self.base.on_pointer_enter(handler);
|
|
179
|
+
self
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
pub fn on_pointer_leave(&self, handler: impl Fn(&mut PointerEventArgs) + 'static) -> &Self {
|
|
183
|
+
self.base.on_pointer_leave(handler);
|
|
184
|
+
self
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
pub fn on_pointer_cancel(&self, handler: impl Fn(&mut PointerEventArgs) + 'static) -> &Self {
|
|
188
|
+
self.base.on_pointer_cancel(handler);
|
|
189
|
+
self
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
pub fn columns<I>(&self, tracks: I) -> &Self
|
|
193
|
+
where
|
|
194
|
+
I: IntoIterator<Item = GridTrack>,
|
|
195
|
+
{
|
|
196
|
+
let tracks: Vec<GridTrack> = tracks.into_iter().collect();
|
|
197
|
+
let mut props = self.props.borrow_mut();
|
|
198
|
+
props.columns = tracks.iter().map(|track| track.value).collect();
|
|
199
|
+
props.column_types = tracks.iter().map(|track| track.unit).collect();
|
|
200
|
+
drop(props);
|
|
201
|
+
if self.has_built_handle() {
|
|
202
|
+
self.build_self();
|
|
203
|
+
self.notify_retained_layout_mutation();
|
|
204
|
+
}
|
|
205
|
+
self
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
pub fn rows<I>(&self, tracks: I) -> &Self
|
|
209
|
+
where
|
|
210
|
+
I: IntoIterator<Item = GridTrack>,
|
|
211
|
+
{
|
|
212
|
+
let tracks: Vec<GridTrack> = tracks.into_iter().collect();
|
|
213
|
+
let mut props = self.props.borrow_mut();
|
|
214
|
+
props.rows = tracks.iter().map(|track| track.value).collect();
|
|
215
|
+
props.row_types = tracks.iter().map(|track| track.unit).collect();
|
|
216
|
+
drop(props);
|
|
217
|
+
if self.has_built_handle() {
|
|
218
|
+
self.build_self();
|
|
219
|
+
self.notify_retained_layout_mutation();
|
|
220
|
+
}
|
|
221
|
+
self
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
pub fn child<T: Node>(&self, child: &T) -> &Self {
|
|
225
|
+
self.append_child(child);
|
|
226
|
+
self
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
pub fn children<I, C>(&self, children: I) -> &Self
|
|
230
|
+
where
|
|
231
|
+
I: IntoIterator<Item = C>,
|
|
232
|
+
C: Into<Child>,
|
|
233
|
+
{
|
|
234
|
+
for child in children {
|
|
235
|
+
self.retained_node_ref()
|
|
236
|
+
.append_child_ref(&child.into().node_ref);
|
|
237
|
+
}
|
|
238
|
+
self
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
pub fn column_shared_size_group(&self, index: u32, group: impl Into<String>) -> &Self {
|
|
242
|
+
let group = group.into();
|
|
243
|
+
let mut props = self.props.borrow_mut();
|
|
244
|
+
if let Some((_, existing)) = props
|
|
245
|
+
.column_shared_size_groups
|
|
246
|
+
.iter_mut()
|
|
247
|
+
.find(|(existing_index, _)| *existing_index == index)
|
|
248
|
+
{
|
|
249
|
+
*existing = group;
|
|
250
|
+
} else {
|
|
251
|
+
props.column_shared_size_groups.push((index, group));
|
|
252
|
+
}
|
|
253
|
+
drop(props);
|
|
254
|
+
if self.has_built_handle() {
|
|
255
|
+
self.build_self();
|
|
256
|
+
self.notify_retained_layout_mutation();
|
|
257
|
+
}
|
|
258
|
+
self
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
pub fn row_shared_size_group(&self, index: u32, group: impl Into<String>) -> &Self {
|
|
262
|
+
let group = group.into();
|
|
263
|
+
let mut props = self.props.borrow_mut();
|
|
264
|
+
if let Some((_, existing)) = props
|
|
265
|
+
.row_shared_size_groups
|
|
266
|
+
.iter_mut()
|
|
267
|
+
.find(|(existing_index, _)| *existing_index == index)
|
|
268
|
+
{
|
|
269
|
+
*existing = group;
|
|
270
|
+
} else {
|
|
271
|
+
props.row_shared_size_groups.push((index, group));
|
|
272
|
+
}
|
|
273
|
+
drop(props);
|
|
274
|
+
if self.has_built_handle() {
|
|
275
|
+
self.build_self();
|
|
276
|
+
self.notify_retained_layout_mutation();
|
|
277
|
+
}
|
|
278
|
+
self
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
pub fn place_child<T: Node>(
|
|
282
|
+
&self,
|
|
283
|
+
child: &T,
|
|
284
|
+
row: u32,
|
|
285
|
+
col: u32,
|
|
286
|
+
row_span: u32,
|
|
287
|
+
col_span: u32,
|
|
288
|
+
) -> &Self {
|
|
289
|
+
self.append_child(child);
|
|
290
|
+
self.placements.borrow_mut().push((
|
|
291
|
+
child.node_ref(),
|
|
292
|
+
GridPlacement {
|
|
293
|
+
row,
|
|
294
|
+
col,
|
|
295
|
+
row_span,
|
|
296
|
+
col_span,
|
|
297
|
+
},
|
|
298
|
+
));
|
|
299
|
+
if self.has_built_handle() {
|
|
300
|
+
self.apply_grid_placements();
|
|
301
|
+
}
|
|
302
|
+
self
|
|
303
|
+
}
|
|
304
|
+
}
|