Compare commits

2 Commits

Author SHA1 Message Date
b3d0dc3871 more retained size fixes 2025-11-17 14:11:33 -05:00
b6ece4a5ee back to retained... 2025-11-17 13:55:49 -05:00
3 changed files with 24 additions and 24 deletions

View File

@@ -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,20 +84,19 @@ impl<'a> PainterCtx<'a> {
return;
};
if let Some((rid, size)) = active.resize {
let checked = &mut HashMap::default();
let mut ctx = SizeCtx {
checked,
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: self.px_dependent,
px_dependent: &mut Default::default(),
id,
};
let desired = ctx.size_inner(id, active.region.size());
if size != desired {
}
.size_inner(id, active.region.size());
if active.desired_size != desired {
self.redraw(rid);
if self.draw_started.contains(&id) {
return;
@@ -209,9 +208,11 @@ impl<'a> PainterCtx<'a> {
desired_size,
layer,
};
for (cid, size) in sized_children {
if let Some(w) = self.active.get_mut(&cid) {
w.resize = Some((id, size))
for cid in sized_children.keys() {
if let Some(w) = self.active.get_mut(cid)
&& w.resize.is_none()
{
w.resize = Some(id)
}
}
for c in &old_children {
@@ -409,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 {

View File

@@ -134,14 +134,14 @@ impl Ui {
}
fn redraw_updates(&mut self) {
if self.updates.drain(..).next().is_some() {
self.redraw_all();
}
// let mut ctx = PainterCtx::new(&mut self.data);
// for id in self.updates.drain(..) {
// ctx.redraw(id);
// if self.updates.drain(..).next().is_some() {
// self.redraw_all();
// }
// self.free();
let mut ctx = PainterCtx::new(&mut self.data);
for id in self.updates.drain(..) {
ctx.redraw(id);
}
self.free();
}
/// free any resources that don't have references anymore

View File

@@ -3,8 +3,8 @@ use std::sync::Arc;
use app::App;
use arboard::Clipboard;
use cosmic_text::Family;
use render::Renderer;
use iris::prelude::*;
use render::Renderer;
use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::Window};
use crate::testing::input::Input;