I love control flow

This commit is contained in:
2025-11-20 22:48:08 -05:00
parent f6f9ebbe51
commit dff72d2c43
19 changed files with 126 additions and 63 deletions

View File

@@ -4,7 +4,7 @@ use crate::{
core::{TextEdit, TextEditCtx},
layout::{
IdLike, PainterCtx, PainterData, PixelRegion, StaticWidgetId, TextureHandle, Vec2, Widget,
WidgetId, WidgetLike,
WidgetId, WidgetInstance, WidgetLike,
},
util::{HashSet, Id},
};
@@ -184,20 +184,11 @@ impl Ui {
Some(region.to_px(self.data.output_size))
}
pub fn debug(&self, label: &str) {
for (id, inst) in &self.data.active {
let l = &self.data.widgets.data(id).unwrap().label;
if l != label {
continue;
}
println!("\"{label}\" {{");
println!(" region: {}", inst.region);
println!(
" pixel region: {}",
inst.region.to_px(self.data.output_size)
);
println!("}}");
}
pub fn debug(&self, label: &str) -> impl Iterator<Item = &WidgetInstance> {
self.data.active.iter().filter_map(move |(id, inst)| {
let l = &self.data.widgets.label(id);
if *l == label { Some(inst) } else { None }
})
}
}