| 442 | } |
| 443 | |
| 444 | fn relayout(&self, origin: Point2<f32>) { |
| 445 | let update_childs = match LayoutSystem::layout(self.node) { |
| 446 | Ok(layout) => { |
| 447 | let mut comp = self.as_ref().borrow_mut(); |
| 448 | comp.x = layout.location.x + origin.x; |
| 449 | comp.y = layout.location.y + origin.y; |
| 450 | comp.w = layout.size.width; |
| 451 | comp.h = layout.size.height; |
| 452 | |
| 453 | true |
| 454 | } |
| 455 | Err(e) => { |
| 456 | log::error!("{}", e); |
| 457 | false |
| 458 | } |
| 459 | }; |
| 460 | |
| 461 | if update_childs { |
| 462 | let comp = self.as_ref().borrow(); |
| 463 | self.child.relayout(Point2 { |
| 464 | x: comp.x, |
| 465 | y: comp.y, |
| 466 | }); |
| 467 | } |
| 468 | } |
| 469 | } |