beginning actual app

This commit is contained in:
2025-11-11 01:35:59 -05:00
parent 379eec771a
commit 92db1264a6
3 changed files with 32 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
use crate::{
layout::{StaticWidgetId, Widget, WidgetId},
layout::{IdLike, Widget},
util::{DynBorrower, HashMap, Id, IdTracker},
};
@@ -47,20 +47,12 @@ impl Widgets {
WidgetWrapper::new(data.widget.as_mut(), &mut data.borrowed)
}
pub fn get_static<W: Widget>(&self, id: &StaticWidgetId<W>) -> Option<&W> {
self.get_dyn(id.id)?.as_any().downcast_ref()
pub fn get<W: Widget>(&self, id: &impl IdLike<W>) -> Option<&W> {
self.get_dyn(id.id())?.as_any().downcast_ref()
}
pub fn get_static_mut<W: Widget>(&mut self, id: &StaticWidgetId<W>) -> Option<&mut W> {
self.get_dyn_mut(id.id)?.as_any_mut().downcast_mut()
}
pub fn get<W: Widget>(&self, id: &WidgetId<W>) -> Option<&W> {
self.get_dyn(id.id)?.as_any().downcast_ref()
}
pub fn get_mut<W: Widget>(&mut self, id: &WidgetId<W>) -> Option<&mut W> {
self.get_dyn_mut(id.id)?.as_any_mut().downcast_mut()
pub fn get_mut<W: Widget>(&mut self, id: &impl IdLike<W>) -> Option<&mut W> {
self.get_dyn_mut(id.id())?.as_any_mut().downcast_mut()
}
pub fn insert<W: Widget>(&mut self, id: Id, widget: W) {