ferroui_xaml_interactivity/templates/
action_collection_template.rs1use crate::ActionCollection;
4use ferroui_base::styling::ITemplate;
5use ferroui_base::{ferro_markup_type, BoxedValue};
6use ferroui_markup_xaml::templates::TemplateContent;
7use std::cell::RefCell;
8use std::rc::Rc;
9
10#[derive(Default)]
16pub struct ActionCollectionTemplate {
17 content: RefCell<Option<BoxedValue>>,
18}
19
20impl ActionCollectionTemplate {
21 pub fn new() -> Rc<Self> {
23 Rc::new(Self::default())
24 }
25
26 pub fn content(&self) -> Option<BoxedValue> {
29 self.content.borrow().clone()
30 }
31
32 pub fn set_content(&self, value: Option<BoxedValue>) {
33 *self.content.borrow_mut() = value;
34 }
35
36 pub fn build(&self) -> Option<ActionCollection> {
42 TemplateContent::load_as::<ActionCollection>(self.content().as_ref()).map(|result| result.result().clone())
43 }
44}
45
46impl ITemplate for ActionCollectionTemplate {
47 fn build(&self) -> BoxedValue {
50 Rc::new(ActionCollectionTemplate::build(self))
51 }
52}
53
54impl PartialEq for ActionCollectionTemplate {
55 fn eq(&self, other: &Self) -> bool {
56 std::ptr::eq(self, other)
57 }
58}
59
60ferro_markup_type!(class ActionCollectionTemplate {
61 this: Rc<ActionCollectionTemplate>,
62 handles: [ActionCollectionTemplate, Rc<ActionCollectionTemplate>, Option<Rc<ActionCollectionTemplate>>],
63 interfaces: [Rc<dyn ITemplate>],
64 constructors: [() => ActionCollectionTemplate::new],
65 content: Content,
66 properties: [
67 Content: Option<BoxedValue> {
68 get: ActionCollectionTemplate::content,
69 set: ActionCollectionTemplate::set_content
70 } [TemplateContent(TemplateResultType = type(ActionCollection))],
71 ],
72});