switch to Rc<RefCell<...>> for widget storage

This commit is contained in:
2025-12-07 14:36:38 -05:00
parent 38266debb6
commit c99d466b75
27 changed files with 685 additions and 784 deletions

View File

@@ -21,11 +21,11 @@ pub struct TextView {
// cache
tex: Option<RenderedText>,
width: Option<f32>,
pub hint: Option<WidgetId>,
pub hint: Option<WidgetRef>,
}
impl TextView {
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<WidgetId>) -> Self {
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<WidgetRef>) -> Self {
Self {
attrs: attrs.into(),
buf: buf.into(),
@@ -67,9 +67,12 @@ impl TextView {
return tex.clone();
}
self.width = width;
let font_system = &mut ctx.text.font_system;
self.attrs.apply(font_system, &mut self.buf, width);
self.buf.shape_until_scroll(font_system, false);
let mut text_data = ctx.text.borrow_mut();
self.attrs
.apply(&mut text_data.font_system, &mut self.buf, width);
self.buf
.shape_until_scroll(&mut text_data.font_system, false);
drop(text_data);
let tex = ctx.draw_text(&mut self.buf, &self.attrs);
self.tex = Some(tex.clone());
self.attrs.changed = false;
@@ -136,7 +139,7 @@ impl Text {
if self.content.changed {
self.content.changed = false;
self.view.buf.set_text(
&mut ctx.text.font_system,
&mut ctx.text.borrow_mut().font_system,
&self.content,
&Attrs::new().family(self.view.attrs.family),
SHAPING,