more retained size fixes
This commit is contained in:
@@ -41,7 +41,7 @@ pub struct WidgetInstance {
|
||||
pub textures: Vec<TextureHandle>,
|
||||
pub primitives: Vec<PrimitiveHandle>,
|
||||
pub children: Vec<Id>,
|
||||
pub resize: Option<(Id, Size)>,
|
||||
pub resize: Option<Id>,
|
||||
pub mask: MaskIdx,
|
||||
pub layer: usize,
|
||||
pub desired_size: Size,
|
||||
@@ -84,25 +84,24 @@ impl<'a> PainterCtx<'a> {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Some((rid, size)) = active.resize {
|
||||
// let checked = &mut HashMap::default();
|
||||
// let mut ctx = SizeCtx {
|
||||
// checked,
|
||||
// text: self.text,
|
||||
// textures: self.textures,
|
||||
// widgets: self.widgets,
|
||||
// size: UiVec2::FULL_SIZE,
|
||||
// screen_size: self.screen_size,
|
||||
// px_dependent: self.px_dependent,
|
||||
// id,
|
||||
// };
|
||||
// let desired = ctx.size_inner(id, active.region.size());
|
||||
// if size != desired {
|
||||
self.redraw(rid);
|
||||
if self.draw_started.contains(&id) {
|
||||
return;
|
||||
if let Some(rid) = active.resize {
|
||||
let desired = SizeCtx {
|
||||
checked: &mut Default::default(),
|
||||
text: self.text,
|
||||
textures: self.textures,
|
||||
widgets: self.widgets,
|
||||
size: UiVec2::FULL_SIZE,
|
||||
screen_size: self.screen_size,
|
||||
px_dependent: &mut Default::default(),
|
||||
id,
|
||||
}
|
||||
.size_inner(id, active.region.size());
|
||||
if active.desired_size != desired {
|
||||
self.redraw(rid);
|
||||
if self.draw_started.contains(&id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
let Some(active) = self.remove(id) else {
|
||||
@@ -209,11 +208,11 @@ impl<'a> PainterCtx<'a> {
|
||||
desired_size,
|
||||
layer,
|
||||
};
|
||||
for (cid, size) in sized_children {
|
||||
if let Some(w) = self.active.get_mut(&cid)
|
||||
for cid in sized_children.keys() {
|
||||
if let Some(w) = self.active.get_mut(cid)
|
||||
&& w.resize.is_none()
|
||||
{
|
||||
w.resize = Some((id, size))
|
||||
w.resize = Some(id)
|
||||
}
|
||||
}
|
||||
for c in &old_children {
|
||||
@@ -411,10 +410,9 @@ impl SizeCtx<'_> {
|
||||
size
|
||||
}
|
||||
pub fn size<W>(&mut self, id: &WidgetId<W>) -> Size {
|
||||
// TODO: determine if this is useful
|
||||
// if let Some(&size) = self.checked.get(&id.id) {
|
||||
// return size;
|
||||
// }
|
||||
if let Some(&size) = self.checked.get(&id.id) {
|
||||
return size;
|
||||
}
|
||||
self.size_inner(id.id, self.size)
|
||||
}
|
||||
fn size_raw(&mut self, id: Id) -> Size {
|
||||
|
||||
Reference in New Issue
Block a user