@effindomv2/fui-rs 0.1.11 → 0.1.13
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/Cargo.toml +1 -1
- package/package.json +1 -1
- package/scripts/hostgen/rust-host-events.ts +1 -1
- package/scripts/hostgen/rust-host-services.ts +16 -16
- package/src/controls/anti_selection_area.rs +15 -0
- package/src/controls/button.rs +39 -0
- package/src/controls/checkbox.rs +36 -1
- package/src/controls/combobox.rs +18 -1
- package/src/controls/dropdown.rs +18 -0
- package/src/controls/internal/pressable_labeled_control.rs +70 -0
- package/src/controls/mod.rs +2 -1
- package/src/controls/nav_link.rs +11 -13
- package/src/controls/progress_bar.rs +120 -6
- package/src/controls/radio_button.rs +39 -1
- package/src/controls/selection_area.rs +17 -0
- package/src/controls/slider.rs +37 -0
- package/src/controls/switch.rs +35 -1
- package/src/controls/tests.rs +237 -0
- package/src/controls/text_area.rs +15 -0
- package/src/controls/text_input.rs +15 -0
- package/src/generated/framework_host_services.rs +40 -40
- package/src/lib.rs +2 -2
- package/src/node/mod.rs +29 -11
- package/src/node/scroll_box.rs +15 -0
- package/src/node/text_node.rs +21 -13
- package/src/node/virtual_list.rs +15 -0
- package/src/text.rs +15 -0
package/src/node/scroll_box.rs
CHANGED
|
@@ -512,3 +512,18 @@ impl HasFlexBoxRoot for ScrollBox {
|
|
|
512
512
|
&self.inner.root
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
+
|
|
516
|
+
impl ThemeBindable for ScrollBox {
|
|
517
|
+
fn theme_binding_node(&self) -> NodeRef {
|
|
518
|
+
self.inner.root.retained_node_ref()
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
fn weak_theme_target(&self) -> Box<dyn Fn() -> Option<Self>> {
|
|
522
|
+
let weak = Rc::downgrade(&self.inner);
|
|
523
|
+
Box::new(move || {
|
|
524
|
+
Some(ScrollBox {
|
|
525
|
+
inner: weak.upgrade()?,
|
|
526
|
+
})
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
}
|
package/src/node/text_node.rs
CHANGED
|
@@ -81,19 +81,6 @@ impl TextNode {
|
|
|
81
81
|
self
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
pub fn bind_theme(&self, handler: impl Fn(&TextNode, crate::theme::Theme) + 'static) -> &Self {
|
|
85
|
-
let weak_core = Rc::downgrade(&self.core);
|
|
86
|
-
let weak_props = Rc::downgrade(&self.props);
|
|
87
|
-
let guard = crate::theme::subscribe(move |theme| {
|
|
88
|
-
let (Some(core), Some(props)) = (weak_core.upgrade(), weak_props.upgrade()) else {
|
|
89
|
-
return;
|
|
90
|
-
};
|
|
91
|
-
handler(&TextNode { core, props }, theme);
|
|
92
|
-
});
|
|
93
|
-
self.retained_node_ref().retain_attachment(Rc::new(guard));
|
|
94
|
-
self
|
|
95
|
-
}
|
|
96
|
-
|
|
97
84
|
pub fn width(&self, width: f32, unit: Unit) -> &Self {
|
|
98
85
|
self.props.borrow_mut().width = Some((width, unit));
|
|
99
86
|
{
|
|
@@ -279,6 +266,10 @@ impl TextNode {
|
|
|
279
266
|
self
|
|
280
267
|
}
|
|
281
268
|
|
|
269
|
+
pub fn max_lines(&self, max_lines: i32) -> &Self {
|
|
270
|
+
self.text_limits(i32::MAX, max_lines)
|
|
271
|
+
}
|
|
272
|
+
|
|
282
273
|
pub fn wrapping(&self, wrap: bool) -> &Self {
|
|
283
274
|
self.props.borrow_mut().wrapping = Some(wrap);
|
|
284
275
|
if self.has_built_handle() {
|
|
@@ -666,6 +657,23 @@ impl Node for TextNode {
|
|
|
666
657
|
}
|
|
667
658
|
}
|
|
668
659
|
|
|
660
|
+
impl super::ThemeBindable for TextNode {
|
|
661
|
+
fn theme_binding_node(&self) -> NodeRef {
|
|
662
|
+
self.retained_node_ref()
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
fn weak_theme_target(&self) -> Box<dyn Fn() -> Option<Self>> {
|
|
666
|
+
let weak_core = Rc::downgrade(&self.core);
|
|
667
|
+
let weak_props = Rc::downgrade(&self.props);
|
|
668
|
+
Box::new(move || {
|
|
669
|
+
Some(TextNode {
|
|
670
|
+
core: weak_core.upgrade()?,
|
|
671
|
+
props: weak_props.upgrade()?,
|
|
672
|
+
})
|
|
673
|
+
})
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
669
677
|
#[cfg(test)]
|
|
670
678
|
mod tests {
|
|
671
679
|
use super::*;
|
package/src/node/virtual_list.rs
CHANGED
|
@@ -513,6 +513,21 @@ impl HasFlexBoxRoot for VirtualList {
|
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
impl ThemeBindable for VirtualList {
|
|
517
|
+
fn theme_binding_node(&self) -> NodeRef {
|
|
518
|
+
self.inner.root.retained_node_ref()
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
fn weak_theme_target(&self) -> Box<dyn Fn() -> Option<Self>> {
|
|
522
|
+
let weak = Rc::downgrade(&self.inner);
|
|
523
|
+
Box::new(move || {
|
|
524
|
+
Some(VirtualList {
|
|
525
|
+
inner: weak.upgrade()?,
|
|
526
|
+
})
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
516
531
|
#[cfg(test)]
|
|
517
532
|
mod tests {
|
|
518
533
|
use super::*;
|
package/src/text.rs
CHANGED
|
@@ -962,6 +962,21 @@ mod tests {
|
|
|
962
962
|
.any(|call| matches!(call, Call::SetTextStyleRuns { run_count: 2, .. })));
|
|
963
963
|
}
|
|
964
964
|
|
|
965
|
+
#[test]
|
|
966
|
+
fn rich_text_inherits_fui_as_max_lines_surface() {
|
|
967
|
+
ffi::test::reset();
|
|
968
|
+
let node = RichText::from_text("One line");
|
|
969
|
+
node.max_lines(1).build();
|
|
970
|
+
assert!(ffi::test::take_calls().iter().any(|call| matches!(
|
|
971
|
+
call,
|
|
972
|
+
Call::SetTextLimits {
|
|
973
|
+
max_chars,
|
|
974
|
+
max_lines,
|
|
975
|
+
..
|
|
976
|
+
} if *max_chars == i32::MAX && *max_lines == 1
|
|
977
|
+
)));
|
|
978
|
+
}
|
|
979
|
+
|
|
965
980
|
#[test]
|
|
966
981
|
fn text_layout_waits_for_loaded_and_fonts_before_reporting_ready() {
|
|
967
982
|
ffi::test::reset();
|