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

Method new

src/elements/widget_component.rs:297–437  ·  view source on GitHub ↗

Create a WidgetComponent with the given options.

(widget: &W)

Source from the content-addressed store, hash-verified

295impl WidgetComponent {
296 /// Create a WidgetComponent with the given options.
297 pub fn new<W: WidgetProperties>(widget: &W) -> Self {
298 let id = widget.key().id();
299 let canvas = match widget.parent() {
300 Some(parent) => {
301 // options.parent.add(self);
302 // parent.canvas
303 }
304 None => {
305 // //parent.is_some()
306
307 // if !Std.is(self, Canvas) && canvas.is_none() {
308 // panic!("WidgetComponent without a canvas {}", _options_);
309 // }
310 }
311 };
312
313 let depth_offset = widget.depth();
314
315 let h = widget.h();
316 let h_max = widget.h_max();
317 let h_min = widget.h_min();
318
319 let key_input = widget.key_input();
320 let mouse_input = widget.mouse_input();
321
322 let parent = widget.parent();
323 let renderable = widget.renderable();
324 // let rendering = options.rendering(); //.unwrap_or(canvas.rendering);
325
326 // let user = options.user.unwrap_or_default();
327
328 let w_min = widget.w_min();
329
330 let w_max = widget.w_max();
331 let x = widget.x();
332 let y = widget.y();
333 let w = widget.w();
334
335 let x_local = x;
336 let y_local = y;
337
338 let instance = Self {
339 id,
340 canvas: box None,
341 children: Vec::new(),
342 children_bounds: ChildBounds {
343 x: 0.0,
344 y: 0.0,
345 w: 0.0,
346 h: 0.0,
347 x_local: 0.0,
348 y_local: 0.0,
349 },
350 clip: None,
351 closest_to_canvas: None,
352 depth: 1.0,
353 depth_offset,
354 destroyed: false,

Callers

nothing calls this directly

Calls 15

idMethod · 0.45
keyMethod · 0.45
parentMethod · 0.45
depthMethod · 0.45
hMethod · 0.45
h_maxMethod · 0.45
h_minMethod · 0.45
key_inputMethod · 0.45
mouse_inputMethod · 0.45
renderableMethod · 0.45
w_minMethod · 0.45
w_maxMethod · 0.45

Tested by

no test coverage detected