@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
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
use super::internal::text_input_core::TextInputCore;
|
|
2
|
+
use super::internal::text_input_presenter::TextInputTemplate;
|
|
3
|
+
use super::TextInputColors;
|
|
4
|
+
use crate::event::{FocusChangedEventArgs, SelectionChangedEventArgs, TextChangedEventArgs};
|
|
5
|
+
use crate::node::{FlexBox, HasFlexBoxRoot, Node, NodeRef, ScrollBarVisibility};
|
|
6
|
+
use crate::FontFamily;
|
|
7
|
+
use std::any::Any;
|
|
8
|
+
use std::rc::Rc;
|
|
9
|
+
|
|
10
|
+
#[derive(Clone)]
|
|
11
|
+
pub struct TextArea {
|
|
12
|
+
core: Rc<TextInputCore>,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl Default for TextArea {
|
|
16
|
+
fn default() -> Self {
|
|
17
|
+
Self::new()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
impl TextArea {
|
|
22
|
+
pub fn new() -> Self {
|
|
23
|
+
let core = Rc::new(TextInputCore::multiline());
|
|
24
|
+
core.finish_init(Rc::downgrade(&core));
|
|
25
|
+
Self { core }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pub fn text(&self, value: impl Into<String>) -> &Self {
|
|
29
|
+
self.core.text(value);
|
|
30
|
+
self
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub fn value(&self) -> String {
|
|
34
|
+
self.core.value()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pub fn selection_start(&self) -> u32 {
|
|
38
|
+
self.core.selection_start()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pub fn selection_end(&self) -> u32 {
|
|
42
|
+
self.core.selection_end()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
pub fn selection_start_byte_offset(&self) -> u32 {
|
|
46
|
+
self.core.selection_start_byte_offset()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pub fn selection_end_byte_offset(&self) -> u32 {
|
|
50
|
+
self.core.selection_end_byte_offset()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pub fn placeholder(&self, value: impl Into<String>) -> &Self {
|
|
54
|
+
self.core.placeholder(value);
|
|
55
|
+
self
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pub fn max_chars(&self, limit: i32) -> &Self {
|
|
59
|
+
self.core.max_chars(limit);
|
|
60
|
+
self
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
pub fn read_only(&self, flag: bool) -> &Self {
|
|
64
|
+
self.core.read_only(flag);
|
|
65
|
+
self
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
pub fn accepts_tab(&self, flag: bool) -> &Self {
|
|
69
|
+
self.core.accepts_tab(flag);
|
|
70
|
+
self
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
pub fn selection_range(&self, start: u32, end: u32) -> &Self {
|
|
74
|
+
self.core.selection_range(start, end);
|
|
75
|
+
self
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
pub fn caret(&self, position: u32) -> &Self {
|
|
79
|
+
self.core.caret(position);
|
|
80
|
+
self
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
pub fn caret_to_end(&self) -> &Self {
|
|
84
|
+
self.core.caret_to_end();
|
|
85
|
+
self
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pub fn colors(&self, colors: Option<TextInputColors>) -> &Self {
|
|
89
|
+
self.core.colors(colors);
|
|
90
|
+
self
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
pub fn template(&self, template: Option<Rc<dyn TextInputTemplate>>) -> &Self {
|
|
94
|
+
self.core.template(template);
|
|
95
|
+
self
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
pub fn enabled(&self, enabled: bool) -> &Self {
|
|
99
|
+
self.core.enabled(enabled);
|
|
100
|
+
self
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
pub fn focusable(&self, enabled: bool, tab_index: i32) -> &Self {
|
|
104
|
+
self.core.focusable(enabled, tab_index);
|
|
105
|
+
self
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
pub fn node_id(&self, id: impl Into<String>) -> &Self {
|
|
109
|
+
self.core.node_id(id);
|
|
110
|
+
self
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
pub fn line_height(&self, value: f32) -> &Self {
|
|
114
|
+
self.core.line_height(value);
|
|
115
|
+
self
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
pub fn font_family(&self, family: FontFamily) -> &Self {
|
|
119
|
+
self.core.font_family(family);
|
|
120
|
+
self
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
pub fn font_size(&self, size: f32) -> &Self {
|
|
124
|
+
self.core.font_size(size);
|
|
125
|
+
self
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
pub fn wrapping(&self, flag: bool) -> &Self {
|
|
129
|
+
self.core.wrapping(flag);
|
|
130
|
+
self
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
pub fn vertical_scrollbar_visibility(&self, mode: ScrollBarVisibility) -> &Self {
|
|
134
|
+
self.core.vertical_scrollbar_visibility(mode);
|
|
135
|
+
self
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
pub fn horizontal_scrollbar_visibility(&self, mode: ScrollBarVisibility) -> &Self {
|
|
139
|
+
self.core.horizontal_scrollbar_visibility(mode);
|
|
140
|
+
self
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pub fn on_changed(&self, handler: impl Fn(TextChangedEventArgs) + 'static) -> &Self {
|
|
144
|
+
self.core.on_changed(handler);
|
|
145
|
+
self
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
pub fn on_text_changed(&self, handler: impl Fn(TextChangedEventArgs) + 'static) -> &Self {
|
|
149
|
+
self.core.on_text_changed(handler);
|
|
150
|
+
self
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
pub fn on_selection_changed(
|
|
154
|
+
&self,
|
|
155
|
+
handler: impl Fn(SelectionChangedEventArgs) + 'static,
|
|
156
|
+
) -> &Self {
|
|
157
|
+
self.core.on_selection_changed(handler);
|
|
158
|
+
self
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
pub fn on_focus_changed(&self, handler: impl Fn(FocusChangedEventArgs) + 'static) -> &Self {
|
|
162
|
+
self.core.on_focus_changed(handler);
|
|
163
|
+
self
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
pub fn focus_now(&self) -> &Self {
|
|
167
|
+
self.core.focus_now();
|
|
168
|
+
self
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pub fn scroll_offset_x(&self) -> f32 {
|
|
172
|
+
self.core.scroll_offset_x()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
pub fn scroll_offset_y(&self) -> f32 {
|
|
176
|
+
self.core.scroll_offset_y()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
pub fn scroll_to(&self, x: f32, y: f32) -> &Self {
|
|
180
|
+
self.core.scroll_to(x, y);
|
|
181
|
+
self
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
impl HasFlexBoxRoot for TextArea {
|
|
186
|
+
fn flex_box_root(&self) -> &FlexBox {
|
|
187
|
+
self.core.flex_box_root()
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
impl Node for TextArea {
|
|
192
|
+
fn retained_node_ref(&self) -> NodeRef {
|
|
193
|
+
let core = self.core.clone();
|
|
194
|
+
self.core
|
|
195
|
+
.flex_box_root()
|
|
196
|
+
.retained_node_ref()
|
|
197
|
+
.with_build_callback(move || core.build_control())
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
fn retained_owner_attachment(&self) -> Option<Rc<dyn Any>> {
|
|
201
|
+
Some(self.core.clone())
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
fn build_self(&self) {
|
|
205
|
+
self.core.build_control();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
use super::internal::text_input_core::TextInputCore;
|
|
2
|
+
use super::internal::text_input_presenter::TextInputTemplate;
|
|
3
|
+
use super::TextInputColors;
|
|
4
|
+
use crate::event::{FocusChangedEventArgs, SelectionChangedEventArgs, TextChangedEventArgs};
|
|
5
|
+
use crate::node::{FlexBox, HasFlexBoxRoot, Node, NodeRef, TextCore};
|
|
6
|
+
use crate::FontFamily;
|
|
7
|
+
use std::any::Any;
|
|
8
|
+
use std::rc::Rc;
|
|
9
|
+
|
|
10
|
+
#[derive(Clone, Default)]
|
|
11
|
+
pub struct TextInput {
|
|
12
|
+
core: Rc<TextInputCore>,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl TextInput {
|
|
16
|
+
pub fn new() -> Self {
|
|
17
|
+
let core = Rc::new(TextInputCore::new());
|
|
18
|
+
core.finish_init(Rc::downgrade(&core));
|
|
19
|
+
Self { core }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
pub fn text(&self, value: impl Into<String>) -> &Self {
|
|
23
|
+
self.core.text(value);
|
|
24
|
+
self
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
pub fn value(&self) -> String {
|
|
28
|
+
self.core.value()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pub fn selection_start(&self) -> u32 {
|
|
32
|
+
self.core.selection_start()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
pub fn selection_end(&self) -> u32 {
|
|
36
|
+
self.core.selection_end()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn selection_start_byte_offset(&self) -> u32 {
|
|
40
|
+
self.core.selection_start_byte_offset()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn selection_end_byte_offset(&self) -> u32 {
|
|
44
|
+
self.core.selection_end_byte_offset()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn placeholder(&self, value: impl Into<String>) -> &Self {
|
|
48
|
+
self.core.placeholder(value);
|
|
49
|
+
self
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pub fn max_chars(&self, limit: i32) -> &Self {
|
|
53
|
+
self.core.max_chars(limit);
|
|
54
|
+
self
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pub fn read_only(&self, flag: bool) -> &Self {
|
|
58
|
+
self.core.read_only(flag);
|
|
59
|
+
self
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
pub fn accepts_tab(&self, flag: bool) -> &Self {
|
|
63
|
+
self.core.accepts_tab(flag);
|
|
64
|
+
self
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
pub fn password(&self, flag: bool) -> &Self {
|
|
68
|
+
self.core.password(flag);
|
|
69
|
+
self
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pub fn host_autofill(&self, hint: impl AsRef<str>) -> &Self {
|
|
73
|
+
self.core.host_autofill(Some(hint.as_ref()));
|
|
74
|
+
self
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
pub fn clear_host_autofill(&self) -> &Self {
|
|
78
|
+
self.core.host_autofill(None);
|
|
79
|
+
self
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
pub fn selection_range(&self, start: u32, end: u32) -> &Self {
|
|
83
|
+
self.core.selection_range(start, end);
|
|
84
|
+
self
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
pub fn caret(&self, position: u32) -> &Self {
|
|
88
|
+
self.core.caret(position);
|
|
89
|
+
self
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
pub fn caret_to_end(&self) -> &Self {
|
|
93
|
+
self.core.caret_to_end();
|
|
94
|
+
self
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
pub fn colors(&self, colors: Option<TextInputColors>) -> &Self {
|
|
98
|
+
self.core.colors(colors);
|
|
99
|
+
self
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
pub fn template(&self, template: Option<Rc<dyn TextInputTemplate>>) -> &Self {
|
|
103
|
+
self.core.template(template);
|
|
104
|
+
self
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
pub fn enabled(&self, enabled: bool) -> &Self {
|
|
108
|
+
self.core.enabled(enabled);
|
|
109
|
+
self
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
pub fn focusable(&self, enabled: bool, tab_index: i32) -> &Self {
|
|
113
|
+
self.core.focusable(enabled, tab_index);
|
|
114
|
+
self
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
pub fn node_id(&self, id: impl Into<String>) -> &Self {
|
|
118
|
+
self.core.node_id(id);
|
|
119
|
+
self
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
pub fn line_height(&self, value: f32) -> &Self {
|
|
123
|
+
self.core.line_height(value);
|
|
124
|
+
self
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
pub fn font_family(&self, family: FontFamily) -> &Self {
|
|
128
|
+
self.core.font_family(family);
|
|
129
|
+
self
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pub fn font_size(&self, size: f32) -> &Self {
|
|
133
|
+
self.core.font_size(size);
|
|
134
|
+
self
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
pub fn on_changed(&self, handler: impl Fn(TextChangedEventArgs) + 'static) -> &Self {
|
|
138
|
+
self.core.on_changed(handler);
|
|
139
|
+
self
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pub fn on_text_changed(&self, handler: impl Fn(TextChangedEventArgs) + 'static) -> &Self {
|
|
143
|
+
self.core.on_text_changed(handler);
|
|
144
|
+
self
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
pub fn on_selection_changed(
|
|
148
|
+
&self,
|
|
149
|
+
handler: impl Fn(SelectionChangedEventArgs) + 'static,
|
|
150
|
+
) -> &Self {
|
|
151
|
+
self.core.on_selection_changed(handler);
|
|
152
|
+
self
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
pub fn on_focus_changed(&self, handler: impl Fn(FocusChangedEventArgs) + 'static) -> &Self {
|
|
156
|
+
self.core.on_focus_changed(handler);
|
|
157
|
+
self
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
pub fn focus_now(&self) -> &Self {
|
|
161
|
+
self.core.focus_now();
|
|
162
|
+
self
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
pub(crate) fn editor_node(&self) -> TextCore {
|
|
166
|
+
self.core.editor_node()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
impl HasFlexBoxRoot for TextInput {
|
|
171
|
+
fn flex_box_root(&self) -> &FlexBox {
|
|
172
|
+
self.core.flex_box_root()
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
impl Node for TextInput {
|
|
177
|
+
fn retained_node_ref(&self) -> NodeRef {
|
|
178
|
+
let core = self.core.clone();
|
|
179
|
+
self.core
|
|
180
|
+
.flex_box_root()
|
|
181
|
+
.retained_node_ref()
|
|
182
|
+
.with_build_callback(move || core.build_control())
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fn retained_owner_attachment(&self) -> Option<Rc<dyn Any>> {
|
|
186
|
+
Some(self.core.clone())
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
fn build_self(&self) {
|
|
190
|
+
self.core.build_control();
|
|
191
|
+
}
|
|
192
|
+
}
|
package/src/debug.rs
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
use crate::event::{self, PointerType};
|
|
2
|
+
use crate::ffi::{self, KeyEventType, PointerEventType};
|
|
3
|
+
use crate::node::NodeHandle;
|
|
4
|
+
|
|
5
|
+
pub fn pointer_event(
|
|
6
|
+
event_type: PointerEventType,
|
|
7
|
+
handle: NodeHandle,
|
|
8
|
+
x: f32,
|
|
9
|
+
y: f32,
|
|
10
|
+
modifiers: u32,
|
|
11
|
+
pointer_id: i32,
|
|
12
|
+
pointer_type: PointerType,
|
|
13
|
+
button: i32,
|
|
14
|
+
buttons: u32,
|
|
15
|
+
pressure: f32,
|
|
16
|
+
width: f32,
|
|
17
|
+
height: f32,
|
|
18
|
+
click_count: i32,
|
|
19
|
+
) -> bool {
|
|
20
|
+
event::dispatch_pointer_event(
|
|
21
|
+
handle,
|
|
22
|
+
event_type,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
modifiers,
|
|
26
|
+
pointer_id,
|
|
27
|
+
pointer_type,
|
|
28
|
+
button,
|
|
29
|
+
buttons,
|
|
30
|
+
pressure,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
click_count,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pub fn focus_changed(handle: NodeHandle, focused: bool) {
|
|
38
|
+
event::dispatch_focus_changed(handle, focused);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pub fn key_event(event_type: KeyEventType, key: &str, modifiers: u32) -> bool {
|
|
42
|
+
event::dispatch_key_event(event_type, key.to_string(), modifiers)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[no_mangle]
|
|
46
|
+
pub extern "C" fn __fui_debug_pointer_event(
|
|
47
|
+
event_type: u32,
|
|
48
|
+
handle: u64,
|
|
49
|
+
x: f32,
|
|
50
|
+
y: f32,
|
|
51
|
+
modifiers: u32,
|
|
52
|
+
) {
|
|
53
|
+
event::dispatch_pointer_event(
|
|
54
|
+
NodeHandle::from_raw(handle),
|
|
55
|
+
match event_type {
|
|
56
|
+
1 => PointerEventType::Down,
|
|
57
|
+
2 => PointerEventType::Up,
|
|
58
|
+
3 => PointerEventType::Move,
|
|
59
|
+
4 => PointerEventType::Enter,
|
|
60
|
+
5 => PointerEventType::Leave,
|
|
61
|
+
_ => PointerEventType::Cancel,
|
|
62
|
+
},
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
modifiers,
|
|
66
|
+
-1,
|
|
67
|
+
PointerType::Mouse,
|
|
68
|
+
0,
|
|
69
|
+
0,
|
|
70
|
+
0.0,
|
|
71
|
+
0.0,
|
|
72
|
+
0.0,
|
|
73
|
+
0,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#[no_mangle]
|
|
78
|
+
pub extern "C" fn __fui_debug_key_event(
|
|
79
|
+
event_type: u32,
|
|
80
|
+
key_ptr: *const u8,
|
|
81
|
+
key_len: u32,
|
|
82
|
+
modifiers: u32,
|
|
83
|
+
) {
|
|
84
|
+
let key = if key_ptr.is_null() || key_len == 0 {
|
|
85
|
+
String::new()
|
|
86
|
+
} else {
|
|
87
|
+
let bytes = unsafe { std::slice::from_raw_parts(key_ptr, key_len as usize) };
|
|
88
|
+
String::from_utf8_lossy(bytes).into_owned()
|
|
89
|
+
};
|
|
90
|
+
event::dispatch_key_event(
|
|
91
|
+
match event_type {
|
|
92
|
+
2 => KeyEventType::Up,
|
|
93
|
+
_ => KeyEventType::Down,
|
|
94
|
+
},
|
|
95
|
+
key,
|
|
96
|
+
modifiers,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[no_mangle]
|
|
101
|
+
pub extern "C" fn __fui_debug_focus_changed(handle: u64, focused: bool) {
|
|
102
|
+
event::dispatch_focus_changed(NodeHandle::from_raw(handle), focused);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#[no_mangle]
|
|
106
|
+
pub extern "C" fn __fui_debug_scroll(
|
|
107
|
+
handle: u64,
|
|
108
|
+
offset_x: f32,
|
|
109
|
+
offset_y: f32,
|
|
110
|
+
content_width: f32,
|
|
111
|
+
content_height: f32,
|
|
112
|
+
viewport_width: f32,
|
|
113
|
+
viewport_height: f32,
|
|
114
|
+
) {
|
|
115
|
+
event::dispatch_scroll(
|
|
116
|
+
NodeHandle::from_raw(handle),
|
|
117
|
+
offset_x,
|
|
118
|
+
offset_y,
|
|
119
|
+
content_width,
|
|
120
|
+
content_height,
|
|
121
|
+
viewport_width,
|
|
122
|
+
viewport_height,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pub fn debug_tree_words() -> Vec<u32> {
|
|
127
|
+
let mut len = 0u32;
|
|
128
|
+
let ptr = unsafe { ffi::ui_get_debug_tree_buffer(&mut len as *mut u32) };
|
|
129
|
+
if ptr.is_null() || len == 0 {
|
|
130
|
+
return Vec::new();
|
|
131
|
+
}
|
|
132
|
+
unsafe { std::slice::from_raw_parts(ptr, len as usize) }.to_vec()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#[cfg(test)]
|
|
136
|
+
mod tests {
|
|
137
|
+
use super::debug_tree_words;
|
|
138
|
+
use crate::ffi;
|
|
139
|
+
|
|
140
|
+
#[test]
|
|
141
|
+
fn reads_debug_tree_words_from_host() {
|
|
142
|
+
ffi::test::reset();
|
|
143
|
+
ffi::test::set_debug_tree_words(&[1, 2, 3, 4]);
|
|
144
|
+
assert_eq!(debug_tree_words(), vec![1, 2, 3, 4]);
|
|
145
|
+
}
|
|
146
|
+
}
|