@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.
@@ -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
+ }
@@ -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::*;
@@ -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();