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 textures: Vec<TextureHandle>,
pub primitives: Vec<PrimitiveHandle>, pub primitives: Vec<PrimitiveHandle>,
pub children: Vec<Id>, pub children: Vec<Id>,
pub resize: Option<(Id, Size)>, pub resize: Option<Id>,
pub mask: MaskIdx, pub mask: MaskIdx,
pub layer: usize, pub layer: usize,
pub desired_size: Size, pub desired_size: Size,
@@ -84,20 +84,19 @@ impl<'a> PainterCtx<'a> {
return; return;
}; };
if let Some((rid, size)) = active.resize { if let Some(rid) = active.resize {
let checked = &mut HashMap::default(); let desired = SizeCtx {
let mut ctx = SizeCtx { checked: &mut Default::default(),
checked,
text: self.text, text: self.text,
textures: self.textures, textures: self.textures,
widgets: self.widgets, widgets: self.widgets,
size: UiVec2::FULL_SIZE, size: UiVec2::FULL_SIZE,
screen_size: self.screen_size, screen_size: self.screen_size,
px_dependent: self.px_dependent, px_dependent: &mut Default::default(),
id, id,
}; }
let desired = ctx.size_inner(id, active.region.size()); .size_inner(id, active.region.size());
if size != desired { if active.desired_size != desired {
self.redraw(rid); self.redraw(rid);
if self.draw_started.contains(&id) { if self.draw_started.contains(&id) {
return; return;
@@ -209,9 +208,11 @@ impl<'a> PainterCtx<'a> {
desired_size, desired_size,
layer, layer,
}; };
for (cid, size) in sized_children { for cid in sized_children.keys() {
if let Some(w) = self.active.get_mut(&cid) { if let Some(w) = self.active.get_mut(cid)
w.resize = Some((id, size)) && w.resize.is_none()
{
w.resize = Some(id)
} }
} }
for c in &old_children { for c in &old_children {
@@ -409,10 +410,9 @@ impl SizeCtx<'_> {
size size
} }
pub fn size<W>(&mut self, id: &WidgetId<W>) -> 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) {
// if let Some(&size) = self.checked.get(&id.id) { return size;
// return size; }
// }
self.size_inner(id.id, self.size) self.size_inner(id.id, self.size)
} }
fn size_raw(&mut self, id: Id) -> Size { fn size_raw(&mut self, id: Id) -> Size {

View File

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

View File

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