• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * This module provides functionality for component coordinates and sizes.
23 * @namespace componentUtils
24 * @syscap SystemCapability.ArkUI.ArkUI.Full
25 * @since 10
26 */
27/**
28 * This module provides functionality for component coordinates and sizes.
29 * @namespace componentUtils
30 * @syscap SystemCapability.ArkUI.ArkUI.Full
31 * @atomicservice
32 * @since 11
33 */
34/**
35 * This module provides functionality for component coordinates and sizes.
36 * @namespace componentUtils
37 * @syscap SystemCapability.ArkUI.ArkUI.Full
38 * @crossplatform
39 * @atomicservice
40 * @since 12
41 */
42declare namespace componentUtils {
43
44  /**
45  * Component information.
46  * @typedef ComponentInfo
47  * @syscap SystemCapability.ArkUI.ArkUI.Full
48  * @since 10
49  */
50  /**
51  * Component information.
52  * @typedef ComponentInfo
53  * @syscap SystemCapability.ArkUI.ArkUI.Full
54  * @atomicservice
55  * @since 11
56  */
57  /**
58  * Component information.
59  * @typedef ComponentInfo
60  * @syscap SystemCapability.ArkUI.ArkUI.Full
61  * @crossplatform
62  * @atomicservice
63  * @since 12
64  */
65  interface ComponentInfo {
66
67    /**
68    * component size.
69    * @type {Size}
70    * @syscap SystemCapability.ArkUI.ArkUI.Full
71    * @since 10
72    */
73    /**
74    * component size.
75    * @type {Size}
76    * @syscap SystemCapability.ArkUI.ArkUI.Full
77    * @atomicservice
78    * @since 11
79    */
80    /**
81    * component size.
82    * @type {Size}
83    * @syscap SystemCapability.ArkUI.ArkUI.Full
84    * @crossplatform
85    * @atomicservice
86    * @since 12
87    */
88    size: Size
89
90    /**
91    * Obtain attribute information relative to the local.
92    * @type {Offset}
93    * @syscap SystemCapability.ArkUI.ArkUI.Full
94    * @since 10
95    */
96    /**
97    * Obtain attribute information relative to the local.
98    * @type {Offset}
99    * @syscap SystemCapability.ArkUI.ArkUI.Full
100    * @atomicservice
101    * @since 11
102    */
103    /**
104    * Obtain attribute information relative to the local.
105    * @type {Offset}
106    * @syscap SystemCapability.ArkUI.ArkUI.Full
107    * @crossplatform
108    * @atomicservice
109    * @since 12
110    */
111    localOffset: Offset
112
113    /**
114    * Obtain attribute information relative to the window.
115    * @type {Offset}
116    * @syscap SystemCapability.ArkUI.ArkUI.Full
117    * @since 10
118    */
119    /**
120    * Obtain attribute information relative to the window.
121    * @type {Offset}
122    * @syscap SystemCapability.ArkUI.ArkUI.Full
123    * @atomicservice
124    * @since 11
125    */
126    /**
127    * Obtain attribute information relative to the window.
128    * @type {Offset}
129    * @syscap SystemCapability.ArkUI.ArkUI.Full
130    * @crossplatform
131    * @atomicservice
132    * @since 12
133    */
134    windowOffset: Offset
135
136    /**
137    * Obtain attribute information relative to the screen.
138    * @type {Offset}
139    * @syscap SystemCapability.ArkUI.ArkUI.Full
140    * @since 10
141    */
142    /**
143    * Obtain attribute information relative to the screen.
144    * @type {Offset}
145    * @syscap SystemCapability.ArkUI.ArkUI.Full
146    * @atomicservice
147    * @since 11
148    */
149    /**
150    * Obtain attribute information relative to the screen.
151    * @type {Offset}
152    * @syscap SystemCapability.ArkUI.ArkUI.Full
153    * @crossplatform
154    * @atomicservice
155    * @since 12
156    */
157    screenOffset: Offset
158
159    /**
160    * Obtain attribute information for translation.
161    * @type {TranslateResult}
162    * @syscap SystemCapability.ArkUI.ArkUI.Full
163    * @since 10
164    */
165    /**
166    * Obtain attribute information for translation.
167    * @type {TranslateResult}
168    * @syscap SystemCapability.ArkUI.ArkUI.Full
169    * @atomicservice
170    * @since 11
171    */
172    /**
173    * Obtain attribute information for translation.
174    * @type {TranslateResult}
175    * @syscap SystemCapability.ArkUI.ArkUI.Full
176    * @crossplatform
177    * @atomicservice
178    * @since 12
179    */
180    translate: TranslateResult
181
182    /**
183    * Obtain attribute information for scale.
184    * @type {ScaleResult}
185    * @syscap SystemCapability.ArkUI.ArkUI.Full
186    * @since 10
187    */
188    /**
189    * Obtain attribute information for scale.
190    * @type {ScaleResult}
191    * @syscap SystemCapability.ArkUI.ArkUI.Full
192    * @atomicservice
193    * @since 11
194    */
195    /**
196    * Obtain attribute information for scale.
197    * @type {ScaleResult}
198    * @syscap SystemCapability.ArkUI.ArkUI.Full
199    * @crossplatform
200    * @atomicservice
201    * @since 12
202    */
203    scale: ScaleResult
204
205    /**
206    * Obtain attribute information for rotate.
207    * @type {RotateResult}
208    * @syscap SystemCapability.ArkUI.ArkUI.Full
209    * @since 10
210    */
211    /**
212    * Obtain attribute information for rotate.
213    * @type {RotateResult}
214    * @syscap SystemCapability.ArkUI.ArkUI.Full
215    * @atomicservice
216    * @since 11
217    */
218    /**
219    * Obtain attribute information for rotate.
220    * @type {RotateResult}
221    * @syscap SystemCapability.ArkUI.ArkUI.Full
222    * @crossplatform
223    * @atomicservice
224    * @since 12
225    */
226    rotate: RotateResult
227
228    /**
229    * Obtain attribute information of the transformation matrix.
230    * @type {Matrix4Result}
231    * @syscap SystemCapability.ArkUI.ArkUI.Full
232    * @since 10
233    */
234    /**
235    * Obtain attribute information of the transformation matrix.
236    * @type {Matrix4Result}
237    * @syscap SystemCapability.ArkUI.ArkUI.Full
238    * @atomicservice
239    * @since 11
240    */
241    /**
242    * Obtain attribute information of the transformation matrix.
243    * @type {Matrix4Result}
244    * @syscap SystemCapability.ArkUI.ArkUI.Full
245    * @crossplatform
246    * @atomicservice
247    * @since 12
248    */
249    transform: Matrix4Result
250  }
251
252  /**
253  * Defines the size property.
254  * @typedef Size
255  * @syscap SystemCapability.ArkUI.ArkUI.Full
256  * @since 10
257  */
258  /**
259  * Defines the size property.
260  * @typedef Size
261  * @syscap SystemCapability.ArkUI.ArkUI.Full
262  * @atomicservice
263  * @since 11
264  */
265  /**
266  * Defines the size property.
267  * @typedef Size
268  * @syscap SystemCapability.ArkUI.ArkUI.Full
269  * @crossplatform
270  * @atomicservice
271  * @since 12
272  */
273  interface Size {
274
275    /**
276    * Defines the width property.
277    * @type {number}
278    * @syscap SystemCapability.ArkUI.ArkUI.Full
279    * @since 10
280    */
281    /**
282    * Defines the width property.
283    * @type {number}
284    * @syscap SystemCapability.ArkUI.ArkUI.Full
285    * @atomicservice
286    * @since 11
287    */
288    /**
289    * Defines the width property.
290    * @type {number}
291    * @syscap SystemCapability.ArkUI.ArkUI.Full
292    * @crossplatform
293    * @atomicservice
294    * @since 12
295    */
296    width: number
297
298    /**
299    * Defines the height property.
300    * @type {number}
301    * @syscap SystemCapability.ArkUI.ArkUI.Full
302    * @since 10
303    */
304    /**
305    * Defines the height property.
306    * @type {number}
307    * @syscap SystemCapability.ArkUI.ArkUI.Full
308    * @atomicservice
309    * @since 11
310    */
311    /**
312    * Defines the height property.
313    * @type {number}
314    * @syscap SystemCapability.ArkUI.ArkUI.Full
315    * @crossplatform
316    * @atomicservice
317    * @since 12
318    */
319    height: number
320  }
321
322  /**
323  * Defines the offset property.
324  * @typedef Offset
325  * @syscap SystemCapability.ArkUI.ArkUI.Full
326  * @since 10
327  */
328  /**
329  * Defines the offset property.
330  * @typedef Offset
331  * @syscap SystemCapability.ArkUI.ArkUI.Full
332  * @atomicservice
333  * @since 11
334  */
335  /**
336  * Defines the offset property.
337  * @typedef Offset
338  * @syscap SystemCapability.ArkUI.ArkUI.Full
339  * @crossplatform
340  * @atomicservice
341  * @since 12
342  */
343  interface Offset {
344
345    /**
346    * Coordinate x of the Position.
347    * @type {number}
348    * @syscap SystemCapability.ArkUI.ArkUI.Full
349    * @since 10
350    */
351    /**
352    * Coordinate x of the Position.
353    * @type {number}
354    * @syscap SystemCapability.ArkUI.ArkUI.Full
355    * @atomicservice
356    * @since 11
357    */
358    /**
359    * Coordinate x of the Position.
360    * @type {number}
361    * @syscap SystemCapability.ArkUI.ArkUI.Full
362    * @crossplatform
363    * @atomicservice
364    * @since 12
365    */
366    x: number
367
368    /**
369    * Coordinate y of the Position.
370    * @type {number}
371    * @syscap SystemCapability.ArkUI.ArkUI.Full
372    * @since 10
373    */
374    /**
375    * Coordinate y of the Position.
376    * @type {number}
377    * @syscap SystemCapability.ArkUI.ArkUI.Full
378    * @atomicservice
379    * @since 11
380    */
381    /**
382    * Coordinate y of the Position.
383    * @type {number}
384    * @syscap SystemCapability.ArkUI.ArkUI.Full
385    * @crossplatform
386    * @atomicservice
387    * @since 12
388    */
389    y: number
390  }
391
392  /**
393  * Translation Result
394  * @typedef TranslateResult
395  * @syscap SystemCapability.ArkUI.ArkUI.Full
396  * @since 10
397  */
398  /**
399  * Translation Result
400  * @typedef TranslateResult
401  * @syscap SystemCapability.ArkUI.ArkUI.Full
402  * @atomicservice
403  * @since 11
404  */
405  /**
406  * Translation Result
407  * @typedef TranslateResult
408  * @syscap SystemCapability.ArkUI.ArkUI.Full
409  * @crossplatform
410  * @atomicservice
411  * @since 12
412  */
413  interface TranslateResult {
414
415    /**
416    * Indicates the translation distance of the x-axis, in vp.
417    * @type {number}
418    * @syscap SystemCapability.ArkUI.ArkUI.Full
419    * @since 10
420    */
421    /**
422    * Indicates the translation distance of the x-axis, in vp.
423    * @type {number}
424    * @syscap SystemCapability.ArkUI.ArkUI.Full
425    * @atomicservice
426    * @since 11
427    */
428    /**
429    * Indicates the translation distance of the x-axis, in vp.
430    * @type {number}
431    * @syscap SystemCapability.ArkUI.ArkUI.Full
432    * @crossplatform
433    * @atomicservice
434    * @since 12
435    */
436    x: number
437
438    /**
439    * Indicates the translation distance of the y-axis, in vp.
440    * @type {number}
441    * @syscap SystemCapability.ArkUI.ArkUI.Full
442    * @since 10
443    */
444    /**
445    * Indicates the translation distance of the y-axis, in vp.
446    * @type {number}
447    * @syscap SystemCapability.ArkUI.ArkUI.Full
448    * @atomicservice
449    * @since 11
450    */
451    /**
452    * Indicates the translation distance of the y-axis, in vp.
453    * @type {number}
454    * @syscap SystemCapability.ArkUI.ArkUI.Full
455    * @crossplatform
456    * @atomicservice
457    * @since 12
458    */
459    y: number
460
461    /**
462    * Indicates the translation distance of the z-axis, in vp.
463    * @type {number}
464    * @syscap SystemCapability.ArkUI.ArkUI.Full
465    * @since 10
466    */
467    /**
468    * Indicates the translation distance of the z-axis, in vp.
469    * @type {number}
470    * @syscap SystemCapability.ArkUI.ArkUI.Full
471    * @atomicservice
472    * @since 11
473    */
474    /**
475    * Indicates the translation distance of the z-axis, in vp.
476    * @type {number}
477    * @syscap SystemCapability.ArkUI.ArkUI.Full
478    * @crossplatform
479    * @atomicservice
480    * @since 12
481    */
482    z: number
483  }
484
485  /**
486  * Scale Result
487  * @typedef ScaleResult
488  * @syscap SystemCapability.ArkUI.ArkUI.Full
489  * @since 10
490  */
491  /**
492  * Scale Result
493  * @typedef ScaleResult
494  * @syscap SystemCapability.ArkUI.ArkUI.Full
495  * @atomicservice
496  * @since 11
497  */
498  /**
499  * Scale Result
500  * @typedef ScaleResult
501  * @syscap SystemCapability.ArkUI.ArkUI.Full
502  * @crossplatform
503  * @atomicservice
504  * @since 12
505  */
506  interface ScaleResult {
507
508    /**
509    * Zoom factor of the x-axis.
510    * @type {number}
511    * @syscap SystemCapability.ArkUI.ArkUI.Full
512    * @since 10
513    */
514    /**
515    * Zoom factor of the x-axis.
516    * @type {number}
517    * @syscap SystemCapability.ArkUI.ArkUI.Full
518    * @atomicservice
519    * @since 11
520    */
521    /**
522    * Zoom factor of the x-axis.
523    * @type {number}
524    * @syscap SystemCapability.ArkUI.ArkUI.Full
525    * @crossplatform
526    * @atomicservice
527    * @since 12
528    */
529    x: number
530
531    /**
532    * Zoom factor of the y-axis.
533    * @type {number}
534    * @syscap SystemCapability.ArkUI.ArkUI.Full
535    * @since 10
536    */
537    /**
538    * Zoom factor of the y-axis.
539    * @type {number}
540    * @syscap SystemCapability.ArkUI.ArkUI.Full
541    * @atomicservice
542    * @since 11
543    */
544    /**
545    * Zoom factor of the y-axis.
546    * @type {number}
547    * @syscap SystemCapability.ArkUI.ArkUI.Full
548    * @crossplatform
549    * @atomicservice
550    * @since 12
551    */
552    y: number
553
554    /**
555    * Zoom factor of the z-axis.
556    * @type {number}
557    * @syscap SystemCapability.ArkUI.ArkUI.Full
558    * @since 10
559    */
560    /**
561    * Zoom factor of the z-axis.
562    * @type {number}
563    * @syscap SystemCapability.ArkUI.ArkUI.Full
564    * @atomicservice
565    * @since 11
566    */
567    /**
568    * Zoom factor of the z-axis.
569    * @type {number}
570    * @syscap SystemCapability.ArkUI.ArkUI.Full
571    * @crossplatform
572    * @atomicservice
573    * @since 12
574    */
575    z: number
576
577    /**
578    * Transform the x-axis coordinate of the center point.
579    * @type {number}
580    * @syscap SystemCapability.ArkUI.ArkUI.Full
581    * @since 10
582    */
583    /**
584    * Transform the x-axis coordinate of the center point.
585    * @type {number}
586    * @syscap SystemCapability.ArkUI.ArkUI.Full
587    * @atomicservice
588    * @since 11
589    */
590    /**
591    * Transform the x-axis coordinate of the center point.
592    * @type {number}
593    * @syscap SystemCapability.ArkUI.ArkUI.Full
594    * @crossplatform
595    * @atomicservice
596    * @since 12
597    */
598    centerX: number
599
600    /**
601    * Transform the y-axis coordinate of the center point.
602    * @type {number}
603    * @syscap SystemCapability.ArkUI.ArkUI.Full
604    * @since 10
605    */
606    /**
607    * Transform the y-axis coordinate of the center point.
608    * @type {number}
609    * @syscap SystemCapability.ArkUI.ArkUI.Full
610    * @atomicservice
611    * @since 11
612    */
613    /**
614    * Transform the y-axis coordinate of the center point.
615    * @type {number}
616    * @syscap SystemCapability.ArkUI.ArkUI.Full
617    * @crossplatform
618    * @atomicservice
619    * @since 12
620    */
621    centerY: number
622  }
623
624  /**
625  * Rotation Result.
626  * @typedef RotateResult
627  * @syscap SystemCapability.ArkUI.ArkUI.Full
628  * @since 10
629  */
630  /**
631  * Rotation Result.
632  * @typedef RotateResult
633  * @syscap SystemCapability.ArkUI.ArkUI.Full
634  * @atomicservice
635  * @since 11
636  */
637  /**
638  * Rotation Result.
639  * @typedef RotateResult
640  * @syscap SystemCapability.ArkUI.ArkUI.Full
641  * @crossplatform
642  * @atomicservice
643  * @since 12
644  */
645  interface RotateResult {
646
647    /**
648    * Axis of rotation vector x coordinate.
649    * @type {number}
650    * @syscap SystemCapability.ArkUI.ArkUI.Full
651    * @since 10
652    */
653    /**
654    * Axis of rotation vector x coordinate.
655    * @type {number}
656    * @syscap SystemCapability.ArkUI.ArkUI.Full
657    * @atomicservice
658    * @since 11
659    */
660    /**
661    * Axis of rotation vector x coordinate.
662    * @type {number}
663    * @syscap SystemCapability.ArkUI.ArkUI.Full
664    * @crossplatform
665    * @atomicservice
666    * @since 12
667    */
668    x: number
669
670    /**
671    * Axis of rotation vector y coordinate.
672    * @type {number}
673    * @syscap SystemCapability.ArkUI.ArkUI.Full
674    * @since 10
675    */
676    /**
677    * Axis of rotation vector y coordinate.
678    * @type {number}
679    * @syscap SystemCapability.ArkUI.ArkUI.Full
680    * @atomicservice
681    * @since 11
682    */
683    /**
684    * Axis of rotation vector y coordinate.
685    * @type {number}
686    * @syscap SystemCapability.ArkUI.ArkUI.Full
687    * @crossplatform
688    * @atomicservice
689    * @since 12
690    */
691    y: number
692
693    /**
694    * Axis of rotation vector z coordinate.
695    * @type {number}
696    * @syscap SystemCapability.ArkUI.ArkUI.Full
697    * @since 10
698    */
699    /**
700    * Axis of rotation vector z coordinate.
701    * @type {number}
702    * @syscap SystemCapability.ArkUI.ArkUI.Full
703    * @atomicservice
704    * @since 11
705    */
706    /**
707    * Axis of rotation vector z coordinate.
708    * @type {number}
709    * @syscap SystemCapability.ArkUI.ArkUI.Full
710    * @crossplatform
711    * @atomicservice
712    * @since 12
713    */
714    z: number
715
716    /**
717    * Transform the x-axis coordinate of the center point.
718    * @type {number}
719    * @syscap SystemCapability.ArkUI.ArkUI.Full
720    * @since 10
721    */
722    /**
723    * Transform the x-axis coordinate of the center point.
724    * @type {number}
725    * @syscap SystemCapability.ArkUI.ArkUI.Full
726    * @atomicservice
727    * @since 11
728    */
729    /**
730    * Transform the x-axis coordinate of the center point.
731    * @type {number}
732    * @syscap SystemCapability.ArkUI.ArkUI.Full
733    * @crossplatform
734    * @atomicservice
735    * @since 12
736    */
737    centerX: number
738
739    /**
740    * Transform the y-axis coordinate of the center point.
741    * @type {number}
742    * @syscap SystemCapability.ArkUI.ArkUI.Full
743    * @since 10
744    */
745    /**
746    * Transform the y-axis coordinate of the center point.
747    * @type {number}
748    * @syscap SystemCapability.ArkUI.ArkUI.Full
749    * @atomicservice
750    * @since 11
751    */
752    /**
753    * Transform the y-axis coordinate of the center point.
754    * @type {number}
755    * @syscap SystemCapability.ArkUI.ArkUI.Full
756    * @crossplatform
757    * @atomicservice
758    * @since 12
759    */
760    centerY: number
761
762    /**
763    * Rotation angle.
764    * @type {number}
765    * @syscap SystemCapability.ArkUI.ArkUI.Full
766    * @since 10
767    */
768    /**
769    * Rotation angle.
770    * @type {number}
771    * @syscap SystemCapability.ArkUI.ArkUI.Full
772    * @atomicservice
773    * @since 11
774    */
775    /**
776    * Rotation angle.
777    * @type {number}
778    * @syscap SystemCapability.ArkUI.ArkUI.Full
779    * @crossplatform
780    * @atomicservice
781    * @since 12
782    */
783    angle: number
784  }
785
786  /**
787  * The matrix is column-first fourth-order matrix.
788  * @typedef { [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number,] } Matrix4Result
789  * @syscap SystemCapability.ArkUI.ArkUI.Full
790  * @since 10
791  */
792  /**
793  * The matrix is column-first fourth-order matrix.
794  * @typedef { [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number,] } Matrix4Result
795  * @syscap SystemCapability.ArkUI.ArkUI.Full
796  * @atomicservice
797  * @since 11
798  */
799  /**
800  * The matrix is column-first fourth-order matrix.
801  * @typedef { [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number,] } Matrix4Result
802  * @syscap SystemCapability.ArkUI.ArkUI.Full
803  * @crossplatform
804  * @atomicservice
805  * @since 12
806  */
807  type Matrix4Result = [
808    number,
809    number,
810    number,
811    number,
812    number,
813    number,
814    number,
815    number,
816    number,
817    number,
818    number,
819    number,
820    number,
821    number,
822    number,
823    number,
824  ];
825
826  /**
827  * Provide the ability to obtain the coordinates and size of component drawing areas.
828  * @param {string} id - component id.
829  * @returns {ComponentInfo} the object of ComponentInfo.
830  * @throws { BusinessError } 100001 - UI execution context not found.
831  * @syscap SystemCapability.ArkUI.ArkUI.Full
832  * @crossplatform
833  * @since 10
834  */
835  /**
836  * Provide the ability to obtain the coordinates and size of component drawing areas.
837  * @param {string} id - component id.
838  * @returns {ComponentInfo} the object of ComponentInfo.
839  * @throws { BusinessError } 100001 - UI execution context not found.
840  * @syscap SystemCapability.ArkUI.ArkUI.Full
841  * @crossplatform
842  * @atomicservice
843  * @since 11
844  * @deprecated since 18
845  * @useinstead ohos.arkui.UIContext.ComponentUtils#getRectangleById
846  */
847  function getRectangleById(id: string): ComponentInfo;
848}
849
850export default componentUtils;
851