From 92f7e88420991ef87e54fabe71653cb61738af64 Mon Sep 17 00:00:00 2001 From: guozejun Date: Sun, 9 Oct 2022 11:35:08 +0800 Subject: [PATCH] add measure and layout api Change-Id: Ie98243c97bb53306253c31b8b825e276b1bb7d94 Signed-off-by: guozejun --- api/@internal/component/ets/common.d.ts | 88 +++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/api/@internal/component/ets/common.d.ts b/api/@internal/component/ets/common.d.ts index b41f9f4ba3..d8623f93e0 100644 --- a/api/@internal/component/ets/common.d.ts +++ b/api/@internal/component/ets/common.d.ts @@ -2015,6 +2015,82 @@ declare class CommonShapeMethod extends CommonMethod { strokeDashArray(value: Array): T; } +/** + * Sub component border info. + * @since 9 + */ +declare interface LayoutBorderInfo { + borderWidth: number, + margin: Margin, + padding: Padding, +} + +/** + * Sub component position info. + * @since 9 + */ +declare interface LayoutPosition { + x: number, + y: number, +} + +/** + * Sub component layout info. + * @since 9 + */ +declare interface LayoutInfo { + position: LayoutPosition, + constraint: ConstraintSizeOptions, +} + +/** + * Sub component info passed from framework when layout and measure happens. + * @since 9 + */ +declare interface LayoutChild { + /** + * Sub component name. + * @since 9 + */ + name: string, + + /** + * Sub component id. + * @since 9 + */ + id: string, + + /** + * Sub component constraint. + * @since 9 + */ + constraint: ConstraintSizeOptions, + + /** + * Sub component border info. + * @since 9 + */ + borderInfo: LayoutBorderInfo, + + /** + * Sub component position. + * @since 9 + */ + position: LayoutPosition, + + /** + * Call this measure method in onMeasure callback to supply sub component size. + * @since 9 + */ + measure(childConstraint: ConstraintSizeOptions), + + /** + * Call this layout method in onLayout callback to assign layout info to sub component. + * @since 9 + */ + layout(childLayoutInfo: LayoutInfo) +} + /** * Custom Component * @since 7 @@ -2043,6 +2119,18 @@ declare class CustomComponent extends CommonAttribute { */ aboutToDisappear?(): void; + /** + * Custom component override this method to layout each of its sub components. + * @since 9 + */ + onLayout?(children: Array, constraint: ConstraintSizeOptions): void; + + /** + * Custom component override this method to measure each of its sub components. + * @since 9 + */ + onMeasure?(children: Array, constraint: ConstraintSizeOptions): void; + /** * onPageShow Method * @since 7 -- Gitee