| 2515 | } |
| 2516 | |
| 2517 | void doLayout() { |
| 2518 | doLayoutDepth++; |
| 2519 | boolean restoreBounds = false; |
| 2520 | if (safeArea && doLayoutDepth == 1) { |
| 2521 | // If this container is marked as a safe area |
| 2522 | // then we may need to add padding to make it *safe* |
| 2523 | Container parent = getParent(); |
| 2524 | if (parent == null || !parent.isSafeAreaInternal(true)) { |
| 2525 | // For efficiency, we check if the parent is a safe area. |
| 2526 | // If so, we don't need to worry because it has already |
| 2527 | // added appropriate padding. |
| 2528 | if (tmpInsets == null) { |
| 2529 | tmpInsets = new TmpInsets(); |
| 2530 | } |
| 2531 | Style s = getStyle(); |
| 2532 | tmpInsets.set(s); |
| 2533 | restoreBounds = snapToSafeAreaInternal(); |
| 2534 | } |
| 2535 | } |
| 2536 | layout.layoutContainer(this); |
| 2537 | int count = getComponentCount(); |
| 2538 | for (int i = 0; i < count; i++) { |
| 2539 | Component c = getComponentAt(i); |
| 2540 | if (c instanceof Container) { |
| 2541 | ((Container) c).layoutContainer(); |
| 2542 | } else { |
| 2543 | c.laidOut(); |
| 2544 | } |
| 2545 | } |
| 2546 | if (restoreBounds && tmpInsets != null) { |
| 2547 | tmpInsets.restore(getStyle()); |
| 2548 | } |
| 2549 | laidOut(); |
| 2550 | if (Form.activePeerCount > 0) { |
| 2551 | onParentPositionChange(); |
| 2552 | } |
| 2553 | doLayoutDepth--; |
| 2554 | |
| 2555 | } |
| 2556 | |
| 2557 | /// Returns the number of components |
| 2558 | /// |