MCPcopy Create free account
hub / github.com/angular-rust/ux-components / new

Method new

src/elements/fitted_box.rs:71–127  ·  view source on GitHub ↗
(widget: &FittedBox)

Source from the content-addressed store, hash-verified

69
70impl FittedBoxElement {
71 pub fn new(widget: &FittedBox) -> Self {
72 let node = LayoutSystem::new_node(
73 style::Style {
74 size: geometry::Size {
75 width: style::Dimension::Percent(1.0),
76 height: style::Dimension::Percent(1.0),
77 },
78 ..default()
79 },
80 vec![],
81 )
82 .unwrap();
83
84 // assert!(options.rendering.is_some(), "No Rendering given to Canvas, cannot create a canvas without one.");
85
86 let component = WidgetComponent::get(widget.key.id());
87
88 // component.onrender.listen(box |_| {
89 // log::warn!("Got signal to render FittedBox");
90 // });
91
92 // canvas = self;
93 // let scale = widget.scale;
94
95 let child = widget.child.create_element();
96 if let Some(child) = child.node() {
97 let child_style = LayoutSystem::style(child).unwrap();
98 LayoutSystem::set_style(
99 child,
100 style::Style {
101 size: geometry::Size {
102 width: style::Dimension::Percent(1.0),
103 height: style::Dimension::Percent(1.0),
104 },
105 ..child_style
106 },
107 )
108 .unwrap();
109 LayoutSystem::set_children(node, vec![child]).unwrap()
110 }
111
112 Self {
113 captured: None,
114 child,
115 component,
116 state: Default::default(),
117 focus_invalid: true,
118 focused: None,
119 marked: None,
120 oncapturedchange: Signal::new(),
121 onfocusedchange: Signal::new(),
122 onmarkedchange: Signal::new(),
123 onscalechange: Signal::new(),
124 scale: 1.0,
125 node,
126 }
127 }
128

Callers

nothing calls this directly

Calls 3

idMethod · 0.45
create_elementMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected