🐛 Fix wrong text auto width/height layout

This commit is contained in:
Aitor Moreno
2025-10-01 11:54:31 +02:00
parent 40b34da788
commit c097aef152
3 changed files with 21 additions and 0 deletions

View File

@@ -791,6 +791,7 @@
(rx/subs! (fn [_]
(clear-drawing-cache)
(request-render "pending-finished")
(h/call wasm/internal-module "_update_shape_text_layout_for_all")
(.dispatchEvent ^js js/document event))))
(do
(clear-drawing-cache)

View File

@@ -78,4 +78,13 @@ impl ShapesPool {
let idx = *self.shapes_uuid_to_idx.get(id)?;
Some(&self.shapes[idx])
}
#[allow(dead_code)]
pub fn iter(&self) -> std::slice::Iter<'_, Shape> {
self.shapes.iter()
}
pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, Shape> {
self.shapes.iter_mut()
}
}

View File

@@ -384,6 +384,17 @@ pub extern "C" fn update_shape_text_layout_for(a: u32, b: u32, c: u32, d: u32) {
});
}
#[no_mangle]
pub extern "C" fn update_shape_text_layout_for_all() {
with_state_mut!(state, {
for shape in state.shapes.iter_mut() {
if let Type::Text(text_content) = &mut shape.shape_type {
text_content.update_layout(shape.selrect);
}
}
});
}
#[no_mangle]
pub extern "C" fn get_caret_position_at(x: f32, y: f32) -> i32 {
with_current_shape!(state, |shape: &Shape| {