@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,705 @@
1
+ use crate::ffi;
2
+ use crate::ffi::{GridUnit, ImageSamplingKind};
3
+
4
+ #[cfg(feature = "native-runtime")]
5
+ unsafe extern "C" {
6
+ fn fui_native_commit_ready();
7
+ }
8
+
9
+ #[derive(Clone, Copy, Debug, PartialEq)]
10
+ pub struct TextRangeRect {
11
+ pub x: f32,
12
+ pub y: f32,
13
+ pub width: f32,
14
+ pub height: f32,
15
+ }
16
+
17
+ #[derive(Clone, Copy, Debug, PartialEq)]
18
+ pub struct TextSelectionEndpointRects {
19
+ pub start: TextRangeRect,
20
+ pub end: TextRangeRect,
21
+ }
22
+
23
+ fn with_utf8(text: &str, callback: impl FnOnce(*const u8, u32)) {
24
+ let bytes = text.as_bytes();
25
+ callback(
26
+ if bytes.is_empty() {
27
+ std::ptr::null()
28
+ } else {
29
+ bytes.as_ptr()
30
+ },
31
+ bytes.len() as u32,
32
+ );
33
+ }
34
+
35
+ pub fn reset() {
36
+ unsafe { ffi::ui_reset() }
37
+ }
38
+
39
+ pub fn create_node(node_type: u32) -> u64 {
40
+ unsafe { ffi::ui_create_node(node_type) }
41
+ }
42
+
43
+ pub fn delete_node(handle: u64) {
44
+ unsafe { ffi::ui_delete_node(handle) }
45
+ }
46
+
47
+ pub fn add_child(parent: u64, child: u64) {
48
+ unsafe { ffi::ui_node_add_child(parent, child) }
49
+ }
50
+
51
+ #[allow(dead_code)]
52
+ pub fn remove_child(parent: u64, child: u64) {
53
+ unsafe { ffi::ui_node_remove_child(parent, child) }
54
+ }
55
+
56
+ pub fn set_root(handle: u64) {
57
+ unsafe { ffi::ui_set_root(handle) }
58
+ }
59
+
60
+ pub fn set_node_id(handle: u64, node_id: &str) {
61
+ with_utf8(node_id, |ptr, len| unsafe {
62
+ ffi::ui_set_node_id(handle, ptr, len)
63
+ })
64
+ }
65
+
66
+ pub fn set_semantic_role(handle: u64, role: u32) {
67
+ unsafe { ffi::ui_set_semantic_role(handle, role) }
68
+ }
69
+
70
+ pub fn set_semantic_label(handle: u64, label: &str) {
71
+ with_utf8(label, |ptr, len| unsafe {
72
+ ffi::ui_set_semantic_label(handle, ptr, len)
73
+ })
74
+ }
75
+
76
+ pub fn set_semantic_checked(handle: u64, state: u32) {
77
+ unsafe { ffi::ui_set_semantic_checked(handle, state) }
78
+ }
79
+
80
+ pub fn set_semantic_selected(handle: u64, has_selected: bool, selected: bool) {
81
+ unsafe { ffi::ui_set_semantic_selected(handle, has_selected, selected) }
82
+ }
83
+
84
+ pub fn set_semantic_disabled(handle: u64, has_disabled: bool, disabled: bool) {
85
+ unsafe { ffi::ui_set_semantic_disabled(handle, has_disabled, disabled) }
86
+ }
87
+
88
+ pub fn set_semantic_value_range(
89
+ handle: u64,
90
+ has_value_range: bool,
91
+ value_now: f32,
92
+ value_min: f32,
93
+ value_max: f32,
94
+ ) {
95
+ unsafe {
96
+ ffi::ui_set_semantic_value_range(handle, has_value_range, value_now, value_min, value_max)
97
+ }
98
+ }
99
+
100
+ pub fn set_semantic_orientation(handle: u64, orientation: u32) {
101
+ unsafe { ffi::ui_set_semantic_orientation(handle, orientation) }
102
+ }
103
+
104
+ pub fn set_semantic_expanded(handle: u64, has_expanded: bool, is_expanded: bool) {
105
+ unsafe { ffi::ui_set_semantic_expanded(handle, has_expanded, is_expanded) }
106
+ }
107
+
108
+ pub fn request_semantic_announcement(handle: u64) {
109
+ unsafe { ffi::ui_request_semantic_announcement(handle) }
110
+ }
111
+
112
+ pub fn request_focus(handle: u64) {
113
+ unsafe { ffi::ui_request_focus(handle) }
114
+ }
115
+
116
+ pub fn push_semantic_scope(handle: u64) -> u32 {
117
+ unsafe { ffi::ui_push_semantic_scope(handle) }
118
+ }
119
+
120
+ pub fn remove_semantic_scope(token: u32) {
121
+ unsafe { ffi::ui_remove_semantic_scope(token) }
122
+ }
123
+
124
+ pub fn set_is_portal(handle: u64, is_portal: bool) {
125
+ unsafe { ffi::ui_set_is_portal(handle, is_portal) }
126
+ }
127
+
128
+ pub fn set_visibility(handle: u64, visibility: u32) {
129
+ unsafe { ffi::ui_set_visibility(handle, visibility) }
130
+ }
131
+
132
+ pub fn set_width(handle: u64, value: f32, unit: u32) {
133
+ unsafe { ffi::ui_set_width(handle, value, unit) }
134
+ }
135
+
136
+ pub fn set_height(handle: u64, value: f32, unit: u32) {
137
+ unsafe { ffi::ui_set_height(handle, value, unit) }
138
+ }
139
+
140
+ pub fn set_fill_width(handle: u64, fill: bool) {
141
+ unsafe { ffi::ui_set_fill_width(handle, fill) }
142
+ }
143
+
144
+ pub fn set_fill_height(handle: u64, fill: bool) {
145
+ unsafe { ffi::ui_set_fill_height(handle, fill) }
146
+ }
147
+
148
+ pub fn set_fill_width_percent(handle: u64, percent: f32) {
149
+ unsafe { ffi::ui_set_fill_width_percent(handle, percent) }
150
+ }
151
+
152
+ pub fn set_fill_height_percent(handle: u64, percent: f32) {
153
+ unsafe { ffi::ui_set_fill_height_percent(handle, percent) }
154
+ }
155
+
156
+ pub fn set_min_width(handle: u64, value: f32, unit: u32) {
157
+ unsafe { ffi::ui_set_min_width(handle, value, unit) }
158
+ }
159
+
160
+ pub fn set_max_width(handle: u64, value: f32, unit: u32) {
161
+ unsafe { ffi::ui_set_max_width(handle, value, unit) }
162
+ }
163
+
164
+ pub fn set_min_height(handle: u64, value: f32, unit: u32) {
165
+ unsafe { ffi::ui_set_min_height(handle, value, unit) }
166
+ }
167
+
168
+ pub fn set_max_height(handle: u64, value: f32, unit: u32) {
169
+ unsafe { ffi::ui_set_max_height(handle, value, unit) }
170
+ }
171
+
172
+ pub fn set_bg_color(handle: u64, color: u32) {
173
+ unsafe { ffi::ui_set_bg_color(handle, color) }
174
+ }
175
+
176
+ pub fn set_box_style(
177
+ handle: u64,
178
+ bg_color: u32,
179
+ radius_tl: f32,
180
+ radius_tr: f32,
181
+ radius_br: f32,
182
+ radius_bl: f32,
183
+ border_width: f32,
184
+ border_color: u32,
185
+ border_style_enum: u32,
186
+ border_dash_on: f32,
187
+ border_dash_off: f32,
188
+ ) {
189
+ unsafe {
190
+ ffi::ui_set_box_style(
191
+ handle,
192
+ bg_color,
193
+ radius_tl,
194
+ radius_tr,
195
+ radius_br,
196
+ radius_bl,
197
+ border_width,
198
+ border_color,
199
+ border_style_enum,
200
+ border_dash_on,
201
+ border_dash_off,
202
+ )
203
+ }
204
+ }
205
+
206
+ pub fn set_linear_gradient(
207
+ handle: u64,
208
+ sx: f32,
209
+ sy: f32,
210
+ ex: f32,
211
+ ey: f32,
212
+ offsets: &[f32],
213
+ colors: &[u32],
214
+ ) {
215
+ let count = offsets.len().min(colors.len());
216
+ unsafe {
217
+ ffi::ui_set_linear_gradient(
218
+ handle,
219
+ sx,
220
+ sy,
221
+ ex,
222
+ ey,
223
+ count as u32,
224
+ if count == 0 {
225
+ std::ptr::null()
226
+ } else {
227
+ offsets.as_ptr()
228
+ },
229
+ if count == 0 {
230
+ std::ptr::null()
231
+ } else {
232
+ colors.as_ptr()
233
+ },
234
+ )
235
+ }
236
+ }
237
+
238
+ pub fn set_drop_shadow(
239
+ handle: u64,
240
+ color: u32,
241
+ offset_x: f32,
242
+ offset_y: f32,
243
+ blur_sigma: f32,
244
+ spread: f32,
245
+ ) {
246
+ unsafe { ffi::ui_set_drop_shadow(handle, color, offset_x, offset_y, blur_sigma, spread) }
247
+ }
248
+
249
+ pub fn set_layer_effect(handle: u64, opacity: f32, blur_sigma: f32, blend_mode_enum: u32) {
250
+ unsafe { ffi::ui_set_layer_effect(handle, opacity, blur_sigma, blend_mode_enum) }
251
+ }
252
+
253
+ pub fn set_background_blur(handle: u64, blur_sigma: f32) {
254
+ unsafe { ffi::ui_set_background_blur(handle, blur_sigma) }
255
+ }
256
+
257
+ pub fn set_text(handle: u64, text: &str) {
258
+ let bytes = text.as_bytes();
259
+ unsafe {
260
+ ffi::ui_set_text(
261
+ handle,
262
+ if bytes.is_empty() {
263
+ std::ptr::null()
264
+ } else {
265
+ bytes.as_ptr()
266
+ },
267
+ bytes.len() as u32,
268
+ )
269
+ }
270
+ }
271
+
272
+ pub fn set_font(handle: u64, font_id: u32, size: f32) {
273
+ unsafe { ffi::ui_set_font(handle, font_id, size) }
274
+ }
275
+
276
+ pub fn register_font_fallback(font_id: u32, fallback_font_id: u32) {
277
+ unsafe { ffi::ui_register_font_fallback(font_id, fallback_font_id) }
278
+ }
279
+
280
+ pub fn set_line_height(handle: u64, line_height: f32) {
281
+ unsafe { ffi::ui_set_line_height(handle, line_height) }
282
+ }
283
+
284
+ pub fn set_text_style_runs(handle: u64, words: &[u32]) {
285
+ unsafe {
286
+ ffi::ui_set_text_style_runs(
287
+ handle,
288
+ (words.len() / 7) as u32,
289
+ if words.is_empty() {
290
+ std::ptr::null()
291
+ } else {
292
+ words.as_ptr()
293
+ },
294
+ )
295
+ }
296
+ }
297
+
298
+ pub fn prepare_node(handle: u64) -> u64 {
299
+ unsafe { ffi::ui_prepare_node(handle).into() }
300
+ }
301
+
302
+ pub fn set_dynamic_text_charset(handle: u64, charset: &str) {
303
+ with_utf8(charset, |ptr, len| unsafe {
304
+ ffi::ui_set_dynamic_text_charset(handle, ptr, len)
305
+ })
306
+ }
307
+
308
+ pub fn replace_text_range(handle: u64, start: u32, end: u32, text: &str, caret: u32) {
309
+ with_utf8(text, |ptr, len| unsafe {
310
+ ffi::ui_replace_text_range(handle, start, end, ptr, len, caret)
311
+ })
312
+ }
313
+
314
+ pub fn get_text_metrics(handle: u64) -> Option<[f32; 5]> {
315
+ let mut width = 0.0;
316
+ let mut height = 0.0;
317
+ let mut baseline = 0.0;
318
+ let mut line_count = 0u32;
319
+ let mut max_line_width = 0.0;
320
+ let ok = unsafe {
321
+ ffi::ui_get_text_metrics(
322
+ handle,
323
+ &mut width,
324
+ &mut height,
325
+ &mut baseline,
326
+ &mut line_count,
327
+ &mut max_line_width,
328
+ )
329
+ };
330
+ if ok {
331
+ Some([width, height, baseline, line_count as f32, max_line_width])
332
+ } else {
333
+ None
334
+ }
335
+ }
336
+
337
+ pub fn set_text_color(handle: u64, color: u32) {
338
+ unsafe { ffi::ui_set_text_color(handle, color) }
339
+ }
340
+
341
+ pub fn set_text_align(handle: u64, align_enum: u32) {
342
+ unsafe { ffi::ui_set_text_align(handle, align_enum) }
343
+ }
344
+
345
+ pub fn set_text_vertical_align(handle: u64, align_enum: u32) {
346
+ unsafe { ffi::ui_set_text_vertical_align(handle, align_enum) }
347
+ }
348
+
349
+ pub fn set_text_limits(handle: u64, max_chars: i32, max_lines: i32) {
350
+ unsafe { ffi::ui_set_text_limits(handle, max_chars, max_lines) }
351
+ }
352
+
353
+ pub fn set_text_wrapping(handle: u64, wrap: bool) {
354
+ unsafe { ffi::ui_set_text_wrapping(handle, wrap) }
355
+ }
356
+
357
+ pub fn set_text_obscured(handle: u64, obscured: bool) {
358
+ unsafe { ffi::ui_set_text_obscured(handle, obscured) }
359
+ }
360
+
361
+ pub fn set_text_overflow(handle: u64, overflow_enum: u32) {
362
+ unsafe { ffi::ui_set_text_overflow(handle, overflow_enum) }
363
+ }
364
+
365
+ pub fn set_text_overflow_fade(handle: u64, horizontal: bool, vertical: bool) {
366
+ unsafe { ffi::ui_set_text_overflow_fade(handle, horizontal, vertical) }
367
+ }
368
+
369
+ pub fn set_selectable(handle: u64, selectable: bool, selection_color: u32) {
370
+ unsafe { ffi::ui_set_selectable(handle, selectable, selection_color) }
371
+ }
372
+
373
+ pub fn set_editable(handle: u64, editable: bool) {
374
+ unsafe { ffi::ui_set_editable(handle, editable) }
375
+ }
376
+
377
+ pub fn set_editor_command_keys(handle: u64, enabled: bool) {
378
+ unsafe { ffi::ui_set_editor_command_keys(handle, enabled) }
379
+ }
380
+
381
+ pub fn set_editor_accepts_tab(handle: u64, enabled: bool) {
382
+ unsafe { ffi::ui_set_editor_accepts_tab(handle, enabled) }
383
+ }
384
+
385
+ pub fn set_caret_color(handle: u64, color: u32) {
386
+ unsafe { ffi::ui_set_caret_color(handle, color) }
387
+ }
388
+
389
+ pub fn set_text_selection_range(handle: u64, start: u32, end: u32) {
390
+ unsafe { ffi::ui_set_text_selection_range(handle, start, end) }
391
+ }
392
+
393
+ pub fn register_text_input_metadata(handle: u64, is_password: bool, hint: Option<&str>) {
394
+ with_utf8(hint.unwrap_or(""), |ptr, len| unsafe {
395
+ ffi::fui_register_text_input_metadata(handle, is_password, ptr as usize, len)
396
+ });
397
+ }
398
+
399
+ pub fn set_preserve_selection_on_pointer_down(handle: u64, preserve: bool) {
400
+ unsafe { ffi::ui_set_preserve_selection_on_pointer_down(handle, preserve) }
401
+ }
402
+
403
+ pub fn select_word_at(handle: u64, logical_x: f32, logical_y: f32) -> bool {
404
+ unsafe { ffi::ui_select_word_at(handle, logical_x, logical_y) }
405
+ }
406
+
407
+ pub fn begin_selection_endpoint_drag(handle: u64, endpoint: u32) -> bool {
408
+ unsafe { ffi::ui_begin_selection_endpoint_drag(handle, endpoint) }
409
+ }
410
+
411
+ pub fn get_text_range_rects(handle: u64, start: u32, end: u32) -> Vec<TextRangeRect> {
412
+ let rect_count = unsafe { ffi::ui_get_text_range_rect_count(handle, start, end) as usize };
413
+ if rect_count == 0 {
414
+ return Vec::new();
415
+ }
416
+ let mut rect_words = vec![0.0f32; rect_count * 4];
417
+ let copied_count = unsafe {
418
+ ffi::ui_copy_text_range_rects(
419
+ handle,
420
+ start,
421
+ end,
422
+ rect_words.as_mut_ptr(),
423
+ rect_count as u32,
424
+ ) as usize
425
+ };
426
+ if copied_count == 0 {
427
+ return Vec::new();
428
+ }
429
+ rect_words
430
+ .chunks_exact(4)
431
+ .take(copied_count)
432
+ .map(|words| TextRangeRect {
433
+ x: words[0],
434
+ y: words[1],
435
+ width: words[2],
436
+ height: words[3],
437
+ })
438
+ .collect()
439
+ }
440
+
441
+ pub fn get_cross_selection_endpoint_rects(area_handle: u64) -> Option<TextSelectionEndpointRects> {
442
+ let mut rect_words = [0.0f32; 8];
443
+ let ok = unsafe {
444
+ ffi::ui_copy_cross_selection_endpoint_rects(area_handle, rect_words.as_mut_ptr())
445
+ };
446
+ if !ok {
447
+ return None;
448
+ }
449
+ Some(TextSelectionEndpointRects {
450
+ start: TextRangeRect {
451
+ x: rect_words[0],
452
+ y: rect_words[1],
453
+ width: rect_words[2],
454
+ height: rect_words[3],
455
+ },
456
+ end: TextRangeRect {
457
+ x: rect_words[4],
458
+ y: rect_words[5],
459
+ width: rect_words[6],
460
+ height: rect_words[7],
461
+ },
462
+ })
463
+ }
464
+
465
+ pub fn clear_current_selection() {
466
+ unsafe { ffi::ui_clear_current_selection() }
467
+ }
468
+
469
+ pub fn is_point_in_selection(logical_x: f32, logical_y: f32) -> bool {
470
+ unsafe { ffi::ui_is_point_in_selection(logical_x, logical_y) }
471
+ }
472
+
473
+ pub fn set_interactive(handle: u64, interactive: bool) {
474
+ unsafe { ffi::ui_set_interactive(handle, interactive) }
475
+ }
476
+
477
+ pub fn set_scroll_proxy_target(handle: u64, scroll_handle: u64) {
478
+ unsafe { ffi::ui_set_scroll_proxy_target(handle, scroll_handle) }
479
+ }
480
+
481
+ pub fn set_focusable(handle: u64, focusable: bool, tab_index: i32) {
482
+ unsafe { ffi::ui_set_focusable(handle, focusable, tab_index) }
483
+ }
484
+
485
+ pub fn set_padding(handle: u64, left: f32, top: f32, right: f32, bottom: f32) {
486
+ unsafe { ffi::ui_set_padding(handle, left, top, right, bottom) }
487
+ }
488
+
489
+ pub fn set_flex_direction(handle: u64, direction: u32) {
490
+ unsafe { ffi::ui_set_flex_direction(handle, direction) }
491
+ }
492
+
493
+ pub fn set_flex_basis(handle: u64, basis: f32) {
494
+ unsafe { ffi::ui_set_flex_basis(handle, basis) }
495
+ }
496
+
497
+ pub fn set_justify_content(handle: u64, justify: u32) {
498
+ unsafe { ffi::ui_set_justify_content(handle, justify) }
499
+ }
500
+
501
+ pub fn set_align_items(handle: u64, align: u32) {
502
+ unsafe { ffi::ui_set_align_items(handle, align) }
503
+ }
504
+
505
+ pub fn set_align_self(handle: u64, align: u32) {
506
+ unsafe { ffi::ui_set_align_self(handle, align) }
507
+ }
508
+
509
+ pub fn set_margin(handle: u64, left: f32, top: f32, right: f32, bottom: f32) {
510
+ unsafe { ffi::ui_set_margin(handle, left, top, right, bottom) }
511
+ }
512
+
513
+ pub fn set_position_type(handle: u64, position_type: u32) {
514
+ unsafe { ffi::ui_set_position_type(handle, position_type) }
515
+ }
516
+
517
+ pub fn set_position(handle: u64, left: f32, top: f32, right: f32, bottom: f32) {
518
+ unsafe { ffi::ui_set_position(handle, left, top, right, bottom) }
519
+ }
520
+
521
+ pub fn set_is_shared_size_scope(handle: u64, is_scope: bool) {
522
+ unsafe { ffi::ui_set_is_shared_size_scope(handle, is_scope) }
523
+ }
524
+
525
+ pub fn set_custom_drawable(handle: u64, is_custom_drawable: bool) {
526
+ unsafe { ffi::ui_set_custom_drawable(handle, is_custom_drawable) }
527
+ }
528
+
529
+ pub fn set_flex_wrap(handle: u64, wrap: u32) {
530
+ unsafe { ffi::ui_set_flex_wrap(handle, wrap) }
531
+ }
532
+
533
+ pub fn set_clip_to_bounds(handle: u64, clip: bool) {
534
+ unsafe { ffi::ui_set_clip_to_bounds(handle, clip) }
535
+ }
536
+
537
+ pub fn set_selection_area(handle: u64, is_area: bool) {
538
+ unsafe { ffi::ui_set_selection_area(handle, is_area) }
539
+ }
540
+
541
+ pub fn set_selection_area_barrier(handle: u64, is_barrier: bool) {
542
+ unsafe { ffi::ui_set_selection_area_barrier(handle, is_barrier) }
543
+ }
544
+
545
+ pub fn clear_selection(text_node_handle: u64) {
546
+ unsafe { ffi::ui_clear_selection(text_node_handle) }
547
+ }
548
+
549
+ pub fn retarget_selection(from_text_node_handle: u64, to_text_node_handle: u64) {
550
+ unsafe { ffi::ui_retarget_selection(from_text_node_handle, to_text_node_handle) }
551
+ }
552
+
553
+ pub fn grid_set_columns(handle: u64, values: &[f32], types: &[GridUnit]) {
554
+ let count = values.len().min(types.len());
555
+ let type_words: Vec<u8> = types[..count].iter().map(|value| *value as u8).collect();
556
+ unsafe { ffi::ui_grid_set_columns(handle, count as u32, values.as_ptr(), type_words.as_ptr()) }
557
+ }
558
+
559
+ pub fn grid_set_rows(handle: u64, values: &[f32], types: &[GridUnit]) {
560
+ let count = values.len().min(types.len());
561
+ let type_words: Vec<u8> = types[..count].iter().map(|value| *value as u8).collect();
562
+ unsafe { ffi::ui_grid_set_rows(handle, count as u32, values.as_ptr(), type_words.as_ptr()) }
563
+ }
564
+
565
+ pub fn grid_set_column_shared_size_group(handle: u64, index: u32, group: &str) {
566
+ with_utf8(group, |ptr, len| unsafe {
567
+ ffi::ui_grid_set_column_shared_size_group(handle, index, ptr, len)
568
+ });
569
+ }
570
+
571
+ pub fn grid_set_row_shared_size_group(handle: u64, index: u32, group: &str) {
572
+ with_utf8(group, |ptr, len| unsafe {
573
+ ffi::ui_grid_set_row_shared_size_group(handle, index, ptr, len)
574
+ });
575
+ }
576
+
577
+ pub fn set_grid_placement(handle: u64, row: u32, col: u32, row_span: u32, col_span: u32) {
578
+ unsafe { ffi::ui_node_set_grid_placement(handle, row, col, row_span, col_span) }
579
+ }
580
+
581
+ pub fn set_image(
582
+ handle: u64,
583
+ texture_id: u32,
584
+ object_fit: u32,
585
+ sampling_kind: ImageSamplingKind,
586
+ max_aniso: u32,
587
+ ) {
588
+ unsafe {
589
+ ffi::ui_set_image(
590
+ handle,
591
+ texture_id,
592
+ object_fit,
593
+ sampling_kind as u32,
594
+ max_aniso,
595
+ )
596
+ }
597
+ }
598
+
599
+ pub fn set_image_nine(
600
+ handle: u64,
601
+ texture_id: u32,
602
+ inset_left: f32,
603
+ inset_top: f32,
604
+ inset_right: f32,
605
+ inset_bottom: f32,
606
+ sampling_kind: ImageSamplingKind,
607
+ max_aniso: u32,
608
+ ) {
609
+ unsafe {
610
+ ffi::ui_set_image_nine(
611
+ handle,
612
+ texture_id,
613
+ inset_left,
614
+ inset_top,
615
+ inset_right,
616
+ inset_bottom,
617
+ sampling_kind as u32,
618
+ max_aniso,
619
+ )
620
+ }
621
+ }
622
+
623
+ pub fn set_svg(
624
+ handle: u64,
625
+ svg_id: u32,
626
+ tint_color: u32,
627
+ sampling_kind: ImageSamplingKind,
628
+ max_aniso: u32,
629
+ ) {
630
+ unsafe { ffi::ui_set_svg(handle, svg_id, tint_color, sampling_kind as u32, max_aniso) }
631
+ }
632
+
633
+ pub fn set_scroll_enabled(handle: u64, enabled_x: bool, enabled_y: bool) {
634
+ unsafe { ffi::ui_set_scroll_enabled(handle, enabled_x, enabled_y) }
635
+ }
636
+
637
+ pub fn set_scroll_friction(handle: u64, friction: f32) {
638
+ unsafe { ffi::ui_set_scroll_friction(handle, friction) }
639
+ }
640
+
641
+ pub fn set_smooth_scrolling(handle: u64, smooth_scrolling: bool) {
642
+ unsafe { ffi::ui_set_smooth_scrolling(handle, smooth_scrolling) }
643
+ }
644
+
645
+ pub fn set_scroll_offset(handle: u64, offset_x: f32, offset_y: f32) {
646
+ unsafe { ffi::ui_set_scroll_offset(handle, offset_x, offset_y) }
647
+ }
648
+
649
+ pub fn set_scroll_content_size(handle: u64, content_width: f32, content_height: f32) {
650
+ unsafe { ffi::ui_set_scroll_content_size(handle, content_width, content_height) }
651
+ }
652
+
653
+ pub fn clear_momentum_scroll() {
654
+ unsafe { ffi::ui_clear_momentum_scroll() }
655
+ }
656
+
657
+ pub fn commit_frame() {
658
+ unsafe {
659
+ ffi::ui_commit_frame();
660
+ #[cfg(feature = "native-runtime")]
661
+ fui_native_commit_ready();
662
+ }
663
+ }
664
+
665
+ pub fn resize_window(width: f32, height: f32) {
666
+ unsafe { ffi::ui_resize_window(width, height) }
667
+ }
668
+
669
+ pub fn request_render() {
670
+ unsafe { ffi::request_render() }
671
+ }
672
+
673
+ pub fn get_viewport_width() -> f32 {
674
+ unsafe { ffi::get_viewport_width() }
675
+ }
676
+
677
+ pub fn get_viewport_height() -> f32 {
678
+ unsafe { ffi::get_viewport_height() }
679
+ }
680
+
681
+ pub fn get_bounds(handle: u64) -> Option<[f32; 4]> {
682
+ let mut x = 0.0;
683
+ let mut y = 0.0;
684
+ let mut width = 0.0;
685
+ let mut height = 0.0;
686
+ let ok = unsafe { ffi::ui_get_bounds(handle, &mut x, &mut y, &mut width, &mut height) };
687
+ if ok {
688
+ Some([x, y, width, height])
689
+ } else {
690
+ None
691
+ }
692
+ }
693
+
694
+ pub fn get_visible_bounds(handle: u64) -> Option<[f32; 4]> {
695
+ let mut x = 0.0;
696
+ let mut y = 0.0;
697
+ let mut width = 0.0;
698
+ let mut height = 0.0;
699
+ let ok = unsafe { ffi::ui_get_visible_bounds(handle, &mut x, &mut y, &mut width, &mut height) };
700
+ if ok {
701
+ Some([x, y, width, height])
702
+ } else {
703
+ None
704
+ }
705
+ }