@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.
Files changed (115) hide show
  1. package/COMMERCIAL.md +7 -0
  2. package/Cargo.toml +34 -0
  3. package/LICENSE.md +9 -0
  4. package/README.md +88 -0
  5. package/package.json +54 -0
  6. package/scripts/build.sh +227 -0
  7. package/scripts/check-runtime-dependency.sh +41 -0
  8. package/scripts/framework-host-services.ts +40 -0
  9. package/scripts/generate-host-events.ts +17 -0
  10. package/scripts/generate-host-services.ts +28 -0
  11. package/scripts/hostgen/common.ts +73 -0
  12. package/scripts/hostgen/registry.ts +159 -0
  13. package/scripts/hostgen/rust-host-events.ts +171 -0
  14. package/scripts/hostgen/rust-host-services.ts +257 -0
  15. package/src/animation.rs +625 -0
  16. package/src/app.rs +324 -0
  17. package/src/assets.rs +572 -0
  18. package/src/bindings/mod.rs +1 -0
  19. package/src/bindings/ui.rs +705 -0
  20. package/src/bitmap.rs +317 -0
  21. package/src/bridge_callbacks.rs +242 -0
  22. package/src/context_menu_manager.rs +332 -0
  23. package/src/controls/anti_selection_area.rs +54 -0
  24. package/src/controls/button.rs +542 -0
  25. package/src/controls/checkbox.rs +372 -0
  26. package/src/controls/combobox.rs +1574 -0
  27. package/src/controls/context_menu.rs +1367 -0
  28. package/src/controls/control_template_set.rs +46 -0
  29. package/src/controls/control_tokens.rs +596 -0
  30. package/src/controls/dialog.rs +590 -0
  31. package/src/controls/dropdown.rs +1010 -0
  32. package/src/controls/form.rs +229 -0
  33. package/src/controls/internal/button_presenter.rs +142 -0
  34. package/src/controls/internal/checkbox_indicator_presenter.rs +210 -0
  35. package/src/controls/internal/dropdown_chevron_presenter.rs +134 -0
  36. package/src/controls/internal/dropdown_field_presenter.rs +269 -0
  37. package/src/controls/internal/dropdown_option_row_presenter.rs +184 -0
  38. package/src/controls/internal/mod.rs +13 -0
  39. package/src/controls/internal/pressable_indicator_presenter.rs +26 -0
  40. package/src/controls/internal/pressable_labeled_control.rs +492 -0
  41. package/src/controls/internal/radio_indicator_presenter.rs +208 -0
  42. package/src/controls/internal/selectable_popup_list.rs +597 -0
  43. package/src/controls/internal/slider_presenter.rs +282 -0
  44. package/src/controls/internal/switch_indicator_presenter.rs +235 -0
  45. package/src/controls/internal/text_input_core.rs +1074 -0
  46. package/src/controls/internal/text_input_presenter.rs +108 -0
  47. package/src/controls/mod.rs +235 -0
  48. package/src/controls/nav_link.rs +395 -0
  49. package/src/controls/popup.rs +191 -0
  50. package/src/controls/progress_bar.rs +287 -0
  51. package/src/controls/radio_button.rs +348 -0
  52. package/src/controls/radio_group.rs +283 -0
  53. package/src/controls/selection_area.rs +82 -0
  54. package/src/controls/shared.rs +68 -0
  55. package/src/controls/slider.rs +701 -0
  56. package/src/controls/switch.rs +293 -0
  57. package/src/controls/templating.rs +49 -0
  58. package/src/controls/tests.rs +3905 -0
  59. package/src/controls/text_area.rs +207 -0
  60. package/src/controls/text_input.rs +192 -0
  61. package/src/debug.rs +146 -0
  62. package/src/drag_drop.rs +424 -0
  63. package/src/drag_gesture.rs +258 -0
  64. package/src/drawing.rs +385 -0
  65. package/src/event.rs +1603 -0
  66. package/src/external_drop.rs +467 -0
  67. package/src/fetch.rs +500 -0
  68. package/src/ffi.rs +3542 -0
  69. package/src/file.rs +1677 -0
  70. package/src/focus_adorner.rs +307 -0
  71. package/src/focus_visibility.rs +121 -0
  72. package/src/frame_scheduler.rs +159 -0
  73. package/src/frame_signal.rs +64 -0
  74. package/src/generated/ffi.rs +798 -0
  75. package/src/generated/framework_host_services.rs +74 -0
  76. package/src/generated/mod.rs +2 -0
  77. package/src/host_services.rs +162 -0
  78. package/src/image_sampling.rs +78 -0
  79. package/src/keyboard_scroll.rs +137 -0
  80. package/src/keyboard_scroll_tracker.rs +385 -0
  81. package/src/lib.rs +547 -0
  82. package/src/logger.rs +56 -0
  83. package/src/mobile_text_selection_toolbar.rs +1034 -0
  84. package/src/navigation.rs +48 -0
  85. package/src/node/core.rs +2210 -0
  86. package/src/node/custom_drawable.rs +149 -0
  87. package/src/node/flex_box.rs +874 -0
  88. package/src/node/grid.rs +304 -0
  89. package/src/node/helpers.rs +442 -0
  90. package/src/node/image.rs +506 -0
  91. package/src/node/mod.rs +315 -0
  92. package/src/node/scroll_bar.rs +845 -0
  93. package/src/node/scroll_box.rs +514 -0
  94. package/src/node/scroll_state.rs +121 -0
  95. package/src/node/scroll_view.rs +557 -0
  96. package/src/node/svg_node.rs +474 -0
  97. package/src/node/text_node.rs +633 -0
  98. package/src/node/virtual_list.rs +678 -0
  99. package/src/panic_hook.rs +36 -0
  100. package/src/persisted.rs +274 -0
  101. package/src/platform.rs +556 -0
  102. package/src/popup_presenter.rs +344 -0
  103. package/src/selection_handle_adorner.rs +838 -0
  104. package/src/signal.rs +134 -0
  105. package/src/text.rs +1065 -0
  106. package/src/theme.rs +571 -0
  107. package/src/timers.rs +106 -0
  108. package/src/tool_tip.rs +167 -0
  109. package/src/tool_tip_manager.rs +691 -0
  110. package/src/transitions.rs +41 -0
  111. package/src/typography.rs +520 -0
  112. package/src/viewport.rs +108 -0
  113. package/src/worker.rs +308 -0
  114. package/src/worker_job.rs +82 -0
  115. package/src/worker_runtime.rs +172 -0
@@ -0,0 +1,315 @@
1
+ use crate::bindings::ui;
2
+ use crate::drawing::DrawContext;
3
+ use crate::event::{
4
+ FocusChangedEventArgs, GestureEventArgs, KeyEventArgs, LongPressEventArgs, PointerEventArgs,
5
+ PointerType, WheelEventArgs, DEFAULT_LONG_PRESS_MINIMUM_DURATION_MS,
6
+ DEFAULT_LONG_PRESS_MOVEMENT_TOLERANCE,
7
+ };
8
+ use crate::ffi::{
9
+ AlignItems, AlignSelf, BorderStyle, CursorStyle, FlexDirection, FlexWrap, GridUnit,
10
+ HandleValue, ImageSamplingKind, JustifyContent, NodeType, ObjectFit, Orientation, PositionType,
11
+ SemanticCheckedState, SemanticRole, TextAlign, TextOverflow, TextVerticalAlign, Unit,
12
+ Visibility,
13
+ };
14
+ use crate::theme;
15
+ use crate::transitions::NodeTransitions;
16
+ use crate::typography::{FontFamily, FontStyle, FontWeight};
17
+ use std::any::Any;
18
+ use std::cell::RefCell;
19
+ use std::rc::{Rc, Weak};
20
+
21
+ mod core;
22
+ mod custom_drawable;
23
+ mod flex_box;
24
+ mod grid;
25
+ mod helpers;
26
+ mod image;
27
+ mod scroll_bar;
28
+ mod scroll_box;
29
+ mod scroll_state;
30
+ mod scroll_view;
31
+ mod svg_node;
32
+ mod text_node;
33
+ mod virtual_list;
34
+
35
+ pub use core::{ContextMenuEventArgs, Node, NodeHandle};
36
+ pub(crate) use core::{NodeRef, WeakFlexBox, WeakNodeRef};
37
+ pub use custom_drawable::CustomDrawable;
38
+ pub use flex_box::{Border, FlexBox, GradientStop};
39
+ pub use grid::{Grid, GridTrack};
40
+ pub(crate) use helpers::*;
41
+ pub use helpers::{
42
+ auto, column, custom_drawable, fill, flex_box, grid, image, pct, portal, px, row, scroll_box,
43
+ scroll_view, svg, text, viewport_height, viewport_width, virtual_list, Length,
44
+ };
45
+ pub use image::ImageNode;
46
+ pub use scroll_bar::{ScrollBar, ScrollBarVisibility};
47
+ pub use scroll_box::ScrollBox;
48
+ pub use scroll_state::ScrollState;
49
+ pub use scroll_view::ScrollView;
50
+ pub use svg_node::SvgNode;
51
+ pub use text_node::{TextCore, TextNode};
52
+ pub use virtual_list::VirtualList;
53
+
54
+ pub type Image = ImageNode;
55
+ pub type Svg = SvgNode;
56
+ pub type Text = TextNode;
57
+
58
+ pub trait HasFlexBoxRoot {
59
+ fn flex_box_root(&self) -> &FlexBox;
60
+ }
61
+
62
+ pub trait FlexBoxSurface: HasFlexBoxRoot {
63
+ fn width(&self, width: f32, unit: Unit) -> &Self {
64
+ self.flex_box_root().width(width, unit);
65
+ self
66
+ }
67
+
68
+ fn width_len(&self, length: Length) -> &Self {
69
+ self.flex_box_root().width_len(length);
70
+ self
71
+ }
72
+
73
+ fn height(&self, height: f32, unit: Unit) -> &Self {
74
+ self.flex_box_root().height(height, unit);
75
+ self
76
+ }
77
+
78
+ fn height_len(&self, length: Length) -> &Self {
79
+ self.flex_box_root().height_len(length);
80
+ self
81
+ }
82
+
83
+ fn fill_width(&self) -> &Self {
84
+ self.flex_box_root().fill_width();
85
+ self
86
+ }
87
+
88
+ fn fill_height(&self) -> &Self {
89
+ self.flex_box_root().fill_height();
90
+ self
91
+ }
92
+
93
+ fn fill_size(&self) -> &Self {
94
+ self.flex_box_root().fill_size();
95
+ self
96
+ }
97
+
98
+ fn fill_width_percent(&self, percent: f32) -> &Self {
99
+ self.flex_box_root().fill_width_percent(percent);
100
+ self
101
+ }
102
+
103
+ fn fill_height_percent(&self, percent: f32) -> &Self {
104
+ self.flex_box_root().fill_height_percent(percent);
105
+ self
106
+ }
107
+
108
+ fn min_width(&self, value: f32, unit: Unit) -> &Self {
109
+ self.flex_box_root().min_width(value, unit);
110
+ self
111
+ }
112
+
113
+ fn min_width_len(&self, length: Length) -> &Self {
114
+ self.flex_box_root().min_width_len(length);
115
+ self
116
+ }
117
+
118
+ fn max_width(&self, value: f32, unit: Unit) -> &Self {
119
+ self.flex_box_root().max_width(value, unit);
120
+ self
121
+ }
122
+
123
+ fn max_width_len(&self, length: Length) -> &Self {
124
+ self.flex_box_root().max_width_len(length);
125
+ self
126
+ }
127
+
128
+ fn min_height(&self, value: f32, unit: Unit) -> &Self {
129
+ self.flex_box_root().min_height(value, unit);
130
+ self
131
+ }
132
+
133
+ fn min_height_len(&self, length: Length) -> &Self {
134
+ self.flex_box_root().min_height_len(length);
135
+ self
136
+ }
137
+
138
+ fn max_height(&self, value: f32, unit: Unit) -> &Self {
139
+ self.flex_box_root().max_height(value, unit);
140
+ self
141
+ }
142
+
143
+ fn max_height_len(&self, length: Length) -> &Self {
144
+ self.flex_box_root().max_height_len(length);
145
+ self
146
+ }
147
+
148
+ fn padding(&self, left: f32, top: f32, right: f32, bottom: f32) -> &Self {
149
+ self.flex_box_root().padding(left, top, right, bottom);
150
+ self
151
+ }
152
+
153
+ fn margin(&self, left: f32, top: f32, right: f32, bottom: f32) -> &Self {
154
+ self.flex_box_root().margin(left, top, right, bottom);
155
+ self
156
+ }
157
+
158
+ fn corner_radius(&self, radius: f32) -> &Self {
159
+ self.flex_box_root().corner_radius(radius);
160
+ self
161
+ }
162
+
163
+ fn corners(&self, tl: f32, tr: f32, br: f32, bl: f32) -> &Self {
164
+ self.flex_box_root().corners(tl, tr, br, bl);
165
+ self
166
+ }
167
+
168
+ fn border(&self, width: f32, color: u32) -> &Self {
169
+ self.flex_box_root().border(width, color);
170
+ self
171
+ }
172
+
173
+ fn border_config(&self, border: Border) -> &Self {
174
+ self.flex_box_root().border_config(border);
175
+ self
176
+ }
177
+
178
+ fn bg_color(&self, color: u32) -> &Self {
179
+ self.flex_box_root().bg_color(color);
180
+ self
181
+ }
182
+
183
+ fn opacity(&self, value: f32) -> &Self {
184
+ self.flex_box_root().opacity(value);
185
+ self
186
+ }
187
+
188
+ fn blur(&self, sigma: f32) -> &Self {
189
+ self.flex_box_root().blur(sigma);
190
+ self
191
+ }
192
+
193
+ fn drop_shadow(
194
+ &self,
195
+ color: u32,
196
+ offset_x: f32,
197
+ offset_y: f32,
198
+ blur_sigma: f32,
199
+ spread: f32,
200
+ ) -> &Self {
201
+ self.flex_box_root()
202
+ .drop_shadow(color, offset_x, offset_y, blur_sigma, spread);
203
+ self
204
+ }
205
+
206
+ fn background_blur(&self, sigma: f32) -> &Self {
207
+ self.flex_box_root().background_blur(sigma);
208
+ self
209
+ }
210
+
211
+ fn linear_gradient(
212
+ &self,
213
+ start_x: f32,
214
+ start_y: f32,
215
+ end_x: f32,
216
+ end_y: f32,
217
+ offsets: Vec<f32>,
218
+ colors: Vec<u32>,
219
+ ) -> &Self {
220
+ self.flex_box_root()
221
+ .linear_gradient(start_x, start_y, end_x, end_y, offsets, colors);
222
+ self
223
+ }
224
+
225
+ fn linear_gradient_stops(
226
+ &self,
227
+ start_x: f32,
228
+ start_y: f32,
229
+ end_x: f32,
230
+ end_y: f32,
231
+ stops: Vec<GradientStop>,
232
+ ) -> &Self {
233
+ self.flex_box_root()
234
+ .linear_gradient_stops(start_x, start_y, end_x, end_y, stops);
235
+ self
236
+ }
237
+
238
+ fn transitions(&self, transitions: Option<NodeTransitions>) -> &Self {
239
+ self.flex_box_root().transitions(transitions);
240
+ self
241
+ }
242
+
243
+ fn flex_basis(&self, basis: f32) -> &Self {
244
+ self.flex_box_root().flex_basis(basis);
245
+ self
246
+ }
247
+
248
+ fn justify_content(&self, justify: JustifyContent) -> &Self {
249
+ self.flex_box_root().justify_content(justify);
250
+ self
251
+ }
252
+
253
+ fn align_items(&self, align: AlignItems) -> &Self {
254
+ self.flex_box_root().align_items(align);
255
+ self
256
+ }
257
+
258
+ fn align_self(&self, align: AlignSelf) -> &Self {
259
+ self.flex_box_root().align_self(align);
260
+ self
261
+ }
262
+
263
+ fn flex_wrap(&self, wrap: FlexWrap) -> &Self {
264
+ self.flex_box_root().flex_wrap(wrap);
265
+ self
266
+ }
267
+
268
+ fn position_type(&self, position_type: PositionType) -> &Self {
269
+ self.flex_box_root().position_type(position_type);
270
+ self
271
+ }
272
+
273
+ fn position(&self, left: f32, top: f32) -> &Self {
274
+ self.flex_box_root().position(left, top);
275
+ self
276
+ }
277
+
278
+ fn clip_to_bounds(&self, clip: bool) -> &Self {
279
+ self.flex_box_root().clip_to_bounds(clip);
280
+ self
281
+ }
282
+
283
+ fn cursor(&self, style: CursorStyle) -> &Self {
284
+ self.flex_box_root().cursor(style);
285
+ self
286
+ }
287
+
288
+ fn visibility(&self, visibility: Visibility) -> &Self {
289
+ self.flex_box_root().visibility(visibility);
290
+ self
291
+ }
292
+ }
293
+
294
+ impl<T: HasFlexBoxRoot> FlexBoxSurface for T {}
295
+
296
+ #[derive(Clone)]
297
+ pub struct Child {
298
+ pub(crate) node_ref: NodeRef,
299
+ }
300
+
301
+ impl Child {
302
+ pub fn from_node<T: Node>(value: &T) -> Self {
303
+ Self {
304
+ node_ref: value.retained_node_ref(),
305
+ }
306
+ }
307
+ }
308
+
309
+ impl<T: Node> From<T> for Child {
310
+ fn from(value: T) -> Self {
311
+ Self {
312
+ node_ref: value.retained_node_ref(),
313
+ }
314
+ }
315
+ }