move widgets on draw if region size is same

This commit is contained in:
2025-09-27 16:11:30 -04:00
parent 5f2dffc189
commit 95f049acb4
13 changed files with 204 additions and 176 deletions

View File

@@ -1,9 +1,4 @@
/// intentionally does not implement copy or clone
/// which should make it harder to misuse;
/// the idea is to generally try to guarantee all IDs
/// point to something valid, although duplicate
/// gets around this if needed
#[derive(Eq, Hash, PartialEq, Debug)]
#[derive(Eq, Hash, PartialEq, Debug, Clone, Copy)]
pub struct Id(u64);
#[derive(Default)]
@@ -28,39 +23,3 @@ impl IdTracker {
self.free.push(id);
}
}
impl Id {
/// this must be used carefully to make sure
/// all IDs are still valid references;
/// named weirdly to indicate this.
/// generally should not be used in "user" code
pub fn duplicate(&self) -> Self {
Self(self.0)
}
/// this must be used carefully to make sure
/// all IDs are still valid references.
/// generally should not be used in "user" code
pub fn copyable(&self) -> CopyId {
CopyId(self.0)
}
}
#[derive(Eq, Hash, PartialEq, Debug, Clone, Copy)]
pub struct CopyId(u64);
impl CopyId {
pub fn id(&self) -> Id {
Id(self.0)
}
}
pub trait IdUtil {
fn duplicate(&self) -> Self;
}
impl IdUtil for Option<Id> {
fn duplicate(&self) -> Self {
self.as_ref().map(|i| i.duplicate())
}
}