I give up on retained for now lmao

This commit is contained in:
2025-11-14 14:39:08 -05:00
parent 218b3f14ed
commit b4947db850
5 changed files with 34 additions and 9 deletions

View File

@@ -103,13 +103,13 @@ impl Align {
}
}
#[derive(Default, Clone, Copy, PartialEq)]
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct Size {
pub x: Len,
pub y: Len,
}
#[derive(Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Len {
pub abs: f32,
pub rel: f32,

View File

@@ -84,6 +84,14 @@ impl<'a> PainterCtx<'a> {
return;
};
if self.widgets.label(&id) == "debug* area" {
if let Some((id, _)) = &active.resize {
println!("RESIZE: {:?}", self.widgets.label(id));
} else {
println!("RESIZE: NONE");
}
}
if let Some((rid, size)) = active.resize {
let checked = &mut HashMap::default();
let mut ctx = SizeCtx {
@@ -105,10 +113,18 @@ impl<'a> PainterCtx<'a> {
}
}
if self.widgets.label(&id) == "debug* area" {
println!("redraw proceeding");
}
let Some(active) = self.remove(id) else {
return;
};
if self.widgets.label(&id) == "debug* area" {
println!("redraw actually");
}
self.draw_inner(
active.layer,
id,
@@ -188,7 +204,7 @@ impl<'a> PainterCtx<'a> {
widgets: painter.ctx.widgets,
checked: &mut Default::default(),
screen_size: painter.ctx.screen_size,
px_dependent: painter.ctx.px_dependent,
px_dependent: &mut Default::default(),
id: painter.id,
size: UiVec2::FULL_SIZE,
}

View File

@@ -318,7 +318,13 @@ impl UiRegion {
impl Display for UiRegion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} -> {}", self.top_left, self.bot_right)
write!(
f,
"{} -> {} (size: {})",
self.top_left,
self.bot_right,
self.size()
)
}
}

View File

@@ -134,11 +134,14 @@ impl Ui {
}
fn redraw_updates(&mut self) {
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

@@ -1,4 +1,4 @@
use crate::layout::{Painter, SizeCtx, StaticWidgetId, Ui, Size, WidgetId, WidgetIdFn};
use crate::layout::{AnyWidget, Painter, Size, SizeCtx, StaticWidgetId, Ui, WidgetId, WidgetIdFn};
use std::{any::Any, marker::PhantomData};