on_custom_attribs Box → Rc

This commit is contained in:
galister
2026-01-06 20:47:05 +09:00
parent e535c5fe94
commit 1257be6cc4
3 changed files with 5 additions and 5 deletions

View File

@@ -8,9 +8,9 @@ use glam::Vec2;
use wgui::{ use wgui::{
assets::AssetPath, assets::AssetPath,
components::{ components::{
Component,
button::{ButtonClickCallback, ComponentButton}, button::{ButtonClickCallback, ComponentButton},
checkbox::ComponentCheckbox, checkbox::ComponentCheckbox,
Component,
}, },
drawing::Color, drawing::Color,
event::StyleSetRequest, event::StyleSetRequest,
@@ -90,7 +90,7 @@ impl TestbedGeneric {
)?; )?;
let extra = ParseDocumentExtra { let extra = ParseDocumentExtra {
on_custom_attribs: Some(Box::new(move |par| { on_custom_attribs: Some(Rc::new(move |par| {
let Some(my_custom_value) = par.get_value("_my_custom") else { let Some(my_custom_value) = par.get_value("_my_custom") else {
return; return;
}; };

View File

@@ -1069,9 +1069,9 @@ impl CustomAttribsInfoOwned {
} }
} }
pub type OnCustomAttribsFunc = Box<dyn Fn(CustomAttribsInfo)>; pub type OnCustomAttribsFunc = Rc<dyn Fn(CustomAttribsInfo)>;
#[derive(Default)] #[derive(Default, Clone)]
pub struct ParseDocumentExtra { pub struct ParseDocumentExtra {
pub on_custom_attribs: Option<OnCustomAttribsFunc>, // all attributes with '_' character prepended pub on_custom_attribs: Option<OnCustomAttribsFunc>, // all attributes with '_' character prepended
pub dev_mode: bool, pub dev_mode: bool,

View File

@@ -113,7 +113,7 @@ impl<S: 'static> GuiPanel<S> {
AssetPath::FileOrBuiltIn(path) AssetPath::FileOrBuiltIn(path)
}, },
extra: wgui::parser::ParseDocumentExtra { extra: wgui::parser::ParseDocumentExtra {
on_custom_attribs: Some(Box::new({ on_custom_attribs: Some(Rc::new({
let custom_elems = custom_elems.clone(); let custom_elems = custom_elems.clone();
move |attribs| { move |attribs| {
custom_elems.borrow_mut().push(attribs.to_owned()); custom_elems.borrow_mut().push(attribs.to_owned());