trust + fix redraw bug

This commit is contained in:
2025-12-17 01:16:28 -05:00
parent 70ac0fbcb2
commit 7e6369029f
7 changed files with 38 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
use crate::{
ActiveData, Axis, Painter, SizeCtx, Ui, UiRegion, UiVec2, WidgetId, render::MaskIdx,
util::HashSet,
ActiveData, Axis, Painter, SizeCtx, Ui, UiRegion, UiVec2, WidgetId,
render::MaskIdx,
util::{HashSet, forget_ref},
};
use std::ops::{Deref, DerefMut};
@@ -30,9 +31,7 @@ impl<'a, State: 'static> DrawState<'a, State> {
/// will just return if so
pub fn redraw(&mut self, id: WidgetId) {
self.widgets.needs_redraw.remove(&id);
if self.draw_started.contains(&id) {
return;
}
self.draw_started.remove(&id);
// check if parent depends on the desired size of this, if so then redraw it first
for axis in [Axis::X, Axis::Y] {
if let Some(&(outer, old)) = self.cache.size.axis_dyn(axis).get(&id)
@@ -202,11 +201,10 @@ impl<'a, State: 'static> DrawState<'a, State> {
*region = region.outside(&from).within(&to);
}
active.region = active.region.outside(&from).within(&to);
// children will not be changed, so this technically should not be needed
// probably need unsafe
let children = active.children.clone();
// SAFETY: children cannot be recursive
let children = unsafe { forget_ref(&active.children) };
for child in children {
self.mov(child, from, to);
self.mov(*child, from, to);
}
}