dash-frontend: clock, wgui: refactoring, non-panicking casts

This commit is contained in:
Aleksander
2025-09-16 20:09:13 +02:00
parent 129785daa7
commit 0fdc0e3828
20 changed files with 287 additions and 165 deletions

View File

@@ -2,7 +2,7 @@ use std::rc::Rc;
use crate::{
any::AnyTrait,
event::{self, EventAlterables},
event::{self, CallbackDataCommon, EventAlterables},
layout::LayoutState,
};
@@ -15,6 +15,15 @@ pub struct InitData<'a> {
pub alterables: &'a mut EventAlterables,
}
impl InitData<'_> {
const fn as_common(&mut self) -> CallbackDataCommon {
CallbackDataCommon {
alterables: self.alterables,
state: self.state,
}
}
}
// common component data
#[derive(Default)]
pub struct ComponentBase {
@@ -32,7 +41,6 @@ pub struct Component(pub Rc<dyn ComponentTrait>);
pub type ComponentWeak = std::rc::Weak<dyn ComponentTrait>;
impl Component {
pub fn weak(&self) -> ComponentWeak {
Rc::downgrade(&self.0)
}