1 /*
2 * Copyright (c) 2021-2023 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_LAYOUT_CONSTANTS_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_LAYOUT_CONSTANTS_H
18
19 #include <cstdint>
20 #include "base/utils/linear_map.h"
21 #include "base/utils/utils.h"
22
23 namespace OHOS::Ace {
24
25 enum class LineCap {
26 BUTT,
27 ROUND,
28 SQUARE,
29 };
30
31 enum class ButtonType {
32 NORMAL,
33 CAPSULE,
34 CIRCLE,
35 TEXT,
36 ARC,
37 DOWNLOAD,
38 ICON,
39 CUSTOM,
40 };
41
42 enum class ButtonStyleMode { NORMAL, EMPHASIZE, TEXT };
43
44 enum class ControlSize { SMALL, NORMAL };
45
46 enum class ButtonRole { NORMAL, ERROR };
47
48 // Flex Styles
49 enum class FlexDirection {
50 ROW = 0,
51 COLUMN,
52 ROW_REVERSE,
53 COLUMN_REVERSE,
54 };
55
56 enum class FlexAlign {
57 AUTO,
58
59 // align to the start of the axis, can be both used in MainAxisAlign and CrossAxisAlign.
60 FLEX_START,
61
62 // align to the center of the axis, can be both used in MainAxisAlign and CrossAxisAlign.
63 CENTER,
64
65 // align to the end of the axis, can be both used in MainAxisAlign and CrossAxisAlign.
66 FLEX_END,
67
68 // stretch the cross size, only used in CrossAxisAlign.
69 STRETCH,
70
71 // adjust the cross position according to the textBaseline, only used in CrossAxisAlign.
72 BASELINE,
73
74 // align the children on both ends, only used in MainAxisAlign.
75 SPACE_BETWEEN,
76
77 // align the child with equivalent space, only used in MainAxisAlign.
78 SPACE_AROUND,
79
80 // align the child with space evenly, only used in MainAxisAlign.
81 SPACE_EVENLY,
82
83 // User-defined space, only used in MainAxisAlign.
84 SPACE_CUSTOMIZATION,
85 };
86
87 enum class MainAxisSize {
88 // default setting, fill the max size of the layout param. Only under MAX, mainAxisAlign and FlexItem are valid
89 MAX,
90
91 // make the size of row/column as large as its children's size.
92 MIN,
93 };
94
95 enum class CrossAxisSize {
96 // fill the max size of the layout param in cross size of row/column.
97 MAX,
98
99 // make the cross size of row/column as large as its children's size.
100 MIN,
101 };
102
103 enum class FlexLayoutMode {
104 // If children do not contains flex weight, use this mode. It is the default mode.
105 FLEX_ITEM_MODE,
106
107 // If all the children contains flex weight, use this mode.
108 FLEX_WEIGHT_MODE,
109 };
110
111 // Box Style
112 enum class BoxFlex {
113 // width and height do not extend to box's parent
114 FLEX_NO,
115
116 // width extends to box's parent, height does not extend to box's parent
117 FLEX_X,
118
119 // height extends to box's parent, width does not extend to box's parent
120 FLEX_Y,
121
122 // width and height extend to box's parent
123 FLEX_XY,
124 };
125
126 enum class BoxSizing {
127 // The width and height properties includes only the content. Border and padding are not included.
128 CONTENT_BOX,
129
130 // The width and height properties includes content, padding and border.
131 BORDER_BOX,
132 };
133
134 // Stack Styles
135 enum class StackFit {
136 // keep the child component's size as it is.
137 KEEP,
138
139 // keep the child component's size as the parent's.
140 STRETCH,
141
142 // use parent's layoutParam to layout the child
143 INHERIT,
144
145 // use first child's size as layoutPram max size.
146 FIRST_CHILD,
147 };
148
149 enum class Overflow {
150 // when the size overflows, clip the exceeding.
151 CLIP,
152
153 // when the size overflows, observe the exceeding.
154 OBSERVABLE,
155
156 // when the size overflows, scroll the exceeding.
157 SCROLL,
158
159 // force clip the exceeding.
160 FORCE_CLIP,
161 };
162
163 enum class MainStackSize { MAX, MIN, NORMAL, LAST_CHILD_HEIGHT, MATCH_CHILDREN, MAX_X, MAX_Y };
164
165 enum class MainSwiperSize { MAX, MAX_X, MAX_Y, MIN, AUTO };
166
167 enum class PositionType {
168 PTRELATIVE = 0,
169 PTFIXED,
170 PTABSOLUTE,
171 PTOFFSET, // percentage layout based on RELATIVE
172 PTSEMI_RELATIVE, // absolute offset based on RELATIVE
173 };
174
175 enum class TextAlign {
176 LEFT = 4,
177 RIGHT = 5,
178 CENTER = 1,
179 /*
180 render the text to fit the size of the text container by adding space
181 */
182 JUSTIFY = 3,
183 /*
184 align the text from the start of the text container
185
186 For Direction.ltr, from left side
187 For Direction.rtl, from right side
188 */
189 START = 0,
190 /*
191 align the text from the end of the text container
192
193 For Direction.ltr, from right side
194 For Direction.rtl, from left side
195 */
196 END = 2,
197 };
198
199 namespace StringUtils {
ToString(const TextAlign & textAlign)200 inline std::string ToString(const TextAlign& textAlign)
201 {
202 static const LinearEnumMapNode<TextAlign, std::string> table[] = {
203 { TextAlign::LEFT, "LEFT" },
204 { TextAlign::RIGHT, "RIGHT" },
205 { TextAlign::CENTER, "CENTER" },
206 { TextAlign::JUSTIFY, "JUSTIFY" },
207 { TextAlign::START, "START" },
208 { TextAlign::END, "END" },
209 };
210 auto iter = BinarySearchFindIndex(table, ArraySize(table), textAlign);
211 return iter != -1 ? table[iter].value : "";
212 }
213 } // namespace StringUtils
214
215 enum class TextDataDetectType {
216 PHONE_NUMBER = 0,
217 URL,
218 EMAIL,
219 ADDRESS,
220 DATE_TIME,
221 };
222
223 enum class LineBreakStrategy {
224 GREEDY = 0,
225 HIGH_QUALITY,
226 BALANCED,
227 };
228
229 enum class WhiteSpace {
230 NORMAL,
231 PRE,
232 PRE_WRAP,
233 NOWRAP,
234 PRE_LINE,
235 INHERIT,
236 };
237
238 enum class TextOverflow {
239 NONE,
240 CLIP,
241 ELLIPSIS,
242 MARQUEE,
243 DEFAULT,
244 };
245
246 enum class TextSelectableMode {
247 SELECTABLE_UNFOCUSABLE = 0,
248 SELECTABLE_FOCUSABLE,
249 UNSELECTABLE,
250 };
251
252 namespace StringUtils {
ToString(const TextOverflow & textOverflow)253 inline std::string ToString(const TextOverflow& textOverflow)
254 {
255 static const LinearEnumMapNode<TextOverflow, std::string> table[] = {
256 { TextOverflow::NONE, "NONE" },
257 { TextOverflow::CLIP, "CLIP" },
258 { TextOverflow::ELLIPSIS, "ELLIPSIS" },
259 { TextOverflow::MARQUEE, "MARQUEE" },
260 };
261 auto iter = BinarySearchFindIndex(table, ArraySize(table), textOverflow);
262 return iter != -1 ? table[iter].value : "";
263 }
264 } // namespace StringUtils
265
266 enum class TextDirection {
267 LTR,
268 RTL,
269 INHERIT,
270 AUTO,
271 };
272
273 enum class TextDecoration {
274 NONE,
275 UNDERLINE,
276 OVERLINE,
277 LINE_THROUGH,
278 INHERIT,
279 };
280
281 enum class TextDecorationStyle {
282 SOLID,
283 DOUBLE,
284 DOTTED,
285 DASHED,
286 WAVY,
287 INITIAL,
288 INHERIT,
289 };
290
291 enum class TextHeightAdaptivePolicy {
292 MAX_LINES_FIRST,
293 MIN_FONT_SIZE_FIRST,
294 LAYOUT_CONSTRAINT_FIRST,
295 };
296
297 enum class MarqueeDirection {
298 LEFT,
299 RIGHT,
300 };
301
302 enum class ImageRepeat {
303 NO_REPEAT = 0,
304 REPEAT_X,
305 REPEAT_Y,
306 REPEAT,
307 };
308
309 enum class ImageFit {
310 FILL,
311 CONTAIN,
312 COVER,
313 FITWIDTH,
314 FITHEIGHT,
315 NONE,
316 SCALE_DOWN,
317 TOP_LEFT,
318 TOP,
319 TOP_END,
320 START,
321 CENTER,
322 END,
323 BOTTOM_START,
324 BOTTOM,
325 BOTTOM_END,
326 COVER_TOP_LEFT,
327 };
328
329 enum class DynamicRangeMode {
330 HIGH = 0,
331 CONSTRAINT,
332 STANDARD,
333 };
334
335 enum class AIImageQuality {
336 NONE = 0,
337 LOW,
338 NORMAL,
339 HIGH,
340 };
341
342 enum class ImageRenderMode {
343 ORIGINAL = 0,
344 TEMPLATE,
345 };
346
347 enum class ImageInterpolation {
348 NONE = 0,
349 LOW,
350 MEDIUM,
351 HIGH,
352 };
353
354 enum class EdgeEffect {
355 SPRING = 0,
356 FADE,
357 NONE,
358 };
359
360 enum class BorderStyle {
361 SOLID,
362 DASHED,
363 DOTTED,
364 NONE,
365 };
366
367 enum class BorderImageRepeat {
368 SPACE,
369 STRETCH,
370 REPEAT,
371 ROUND,
372 };
373
374 enum class BorderImageDirection {
375 LEFT,
376 RIGHT,
377 TOP,
378 BOTTOM,
379 START,
380 END,
381 };
382
383 enum class TimePickerFormat {
384 HOUR_MINUTE,
385 HOUR_MINUTE_SECOND
386 };
387
388 enum class SrcType {
389 UNSUPPORTED = -1,
390 FILE = 0,
391 ASSET,
392 NETWORK,
393 MEMORY,
394 BASE64,
395 INTERNAL, // internal cached file resource
396 RESOURCE,
397 DATA_ABILITY,
398 DATA_ABILITY_DECODED,
399 RESOURCE_ID, // default resource which src is internal resource id
400 PIXMAP,
401 ASTC,
402 };
403
404 enum class WrapAlignment {
405 START,
406 CENTER,
407 END,
408 SPACE_AROUND,
409 SPACE_BETWEEN,
410 STRETCH,
411 SPACE_EVENLY,
412 BASELINE,
413 };
414
415 enum class WrapDirection {
416 HORIZONTAL,
417 VERTICAL,
418 HORIZONTAL_REVERSE,
419 VERTICAL_REVERSE,
420 };
421
422 enum class FlexWrap {
423 NO_WRAP,
424 WRAP,
425 WRAP_REVERSE,
426 };
427
428 enum class KeyDirection {
429 UP = 0,
430 DOWN,
431 LEFT,
432 RIGHT,
433 };
434
435 enum class PixelRoundPolicy {
436 FORCE_CEIL_START = 1,
437 FORCE_FLOOR_START = 1 << 1,
438 FORCE_CEIL_TOP = 1 << 2,
439 FORCE_FLOOR_TOP = 1 << 3,
440 FORCE_CEIL_END = 1 << 4,
441 FORCE_FLOOR_END = 1 << 5,
442 FORCE_CEIL_BOTTOM = 1 << 6,
443 FORCE_FLOOR_BOTTOM = 1 << 7,
444 };
445
446 enum class PixelRoundCalcPolicy {
447 NO_FORCE_ROUND = 0,
448 FORCE_CEIL = 1,
449 FORCE_FLOOR = 2,
450 };
451
452 const ImageRepeat IMAGE_REPEATS[] = {
453 ImageRepeat::REPEAT,
454 ImageRepeat::REPEAT_X,
455 ImageRepeat::REPEAT_Y,
456 ImageRepeat::NO_REPEAT,
457 };
458
459 enum class WindowModal : int32_t {
460 NORMAL = 0,
461 SEMI_MODAL = 1,
462 SEMI_MODAL_FULL_SCREEN = 2,
463 DIALOG_MODAL = 3,
464 CONTAINER_MODAL = 4,
465 FIRST_VALUE = NORMAL,
466 LAST_VALUE = CONTAINER_MODAL,
467 };
468
469 enum class WindowMode : uint32_t {
470 WINDOW_MODE_UNDEFINED = 0,
471 WINDOW_MODE_FULLSCREEN = 1,
472 WINDOW_MODE_SPLIT_PRIMARY = 100,
473 WINDOW_MODE_SPLIT_SECONDARY,
474 WINDOW_MODE_FLOATING,
475 WINDOW_MODE_PIP
476 };
477
478 enum class WindowType : uint32_t {
479 WINDOW_TYPE_UNDEFINED = 0,
480 WINDOW_TYPE_APP_BASE = 1,
481 WINDOW_TYPE_APP_END = 1003,
482 WINDOW_TYPE_FLOAT = 2106,
483 };
484
485 enum class PanelType {
486 MINI_BAR,
487 FOLDABLE_BAR,
488 TEMP_DISPLAY,
489 CUSTOM,
490 };
491
492 enum class PanelMode {
493 MINI,
494 HALF,
495 FULL,
496 AUTO,
497 CUSTOM,
498 };
499
500 enum class ColorScheme : int32_t {
501 SCHEME_LIGHT = 0,
502 SCHEME_TRANSPARENT = 1,
503 SCHEME_DARK = 2,
504 FIRST_VALUE = SCHEME_LIGHT,
505 LAST_VALUE = SCHEME_DARK,
506 };
507
508 enum class RenderStatus : int32_t {
509 UNKNOWN = -1,
510 DEFAULT = 0,
511 ACTIVITY = 1,
512 FOCUS = 2,
513 BLUR = 3,
514 DISABLE = 4,
515 WAITING = 5,
516 };
517
518 enum class BadgePosition {
519 RIGHT_TOP,
520 RIGHT,
521 LEFT,
522 };
523
524 enum class QrcodeType {
525 RECT,
526 CIRCLE,
527 };
528
529 enum class AnimationCurve {
530 FRICTION,
531 STANDARD,
532 };
533
534 enum class WindowBlurStyle {
535 STYLE_BACKGROUND_SMALL_LIGHT = 100,
536 STYLE_BACKGROUND_MEDIUM_LIGHT = 101,
537 STYLE_BACKGROUND_LARGE_LIGHT = 102,
538 STYLE_BACKGROUND_XLARGE_LIGHT = 103,
539 STYLE_BACKGROUND_SMALL_DARK = 104,
540 STYLE_BACKGROUND_MEDIUM_DARK = 105,
541 STYLE_BACKGROUND_LARGE_DARK = 106,
542 STYLE_BACKGROUND_XLARGE_DARK = 107,
543 };
544
545 enum class DisplayType { NO_SETTING = 0, FLEX, GRID, NONE, BLOCK, INLINE, INLINE_BLOCK, INLINE_FLEX };
546
547 enum class VisibilityType {
548 NO_SETTING = 0,
549 VISIBLE,
550 HIDDEN,
551 };
552
553 enum class RefreshType {
554 AUTO,
555 PULL_DOWN,
556 };
557
558 enum class TabBarMode {
559 FIXED,
560 SCROLLABLE,
561 FIXED_START,
562 };
563
564 enum class TabAnimateMode {
565 CONTENT_FIRST = 0,
566 ACTION_FIRST,
567 NO_ANIMATION,
568 MAX_VALUE,
569 };
570
571 enum class ShowInNavigationBar {
572 SHOW = 0,
573 POPUP,
574 };
575
576 enum class HorizontalAlign {
577 START = 1,
578 CENTER,
579 END,
580 };
581
582 enum class VerticalAlign {
583 TOP = 1,
584 CENTER,
585 BOTTOM,
586 BASELINE,
587 NONE,
588 };
589
590 enum class SwiperDynamicSyncSceneType {
591 GESTURE = 0,
592 ANIMATE,
593 };
594
595 namespace StringUtils {
ToString(const VerticalAlign & verticalAlign)596 inline std::string ToString(const VerticalAlign& verticalAlign)
597 {
598 static const LinearEnumMapNode<VerticalAlign, std::string> table[] = {
599 { VerticalAlign::TOP, "TOP" },
600 { VerticalAlign::CENTER, "CENTER" },
601 { VerticalAlign::BOTTOM, "BOTTOM" },
602 { VerticalAlign::BASELINE, "BASELINE" },
603 { VerticalAlign::NONE, "NONE" },
604 };
605 auto iter = BinarySearchFindIndex(table, ArraySize(table), verticalAlign);
606 return iter != -1 ? table[iter].value : "";
607 }
608 } // namespace StringUtils
609
610 enum class BarPosition {
611 START,
612 END,
613 };
614
615 enum class CalendarType {
616 NORMAL = 0,
617 SIMPLE,
618 };
619
620 enum class SideBarContainerType { EMBED, OVERLAY, AUTO };
621
622 enum class SideBarPosition { START, END };
623
624 enum class SideBarStatus {
625 SHOW,
626 HIDDEN,
627 CHANGING,
628 AUTO,
629 };
630
631 enum class HitTestMode {
632 /**
633 * Both self and children respond to the hit test for touch events,
634 * but block hit test of the other nodes which is masked by this node.
635 */
636 HTMDEFAULT = 0,
637
638 /**
639 * Self respond to the hit test for touch events,
640 * but block hit test of children and other nodes which is masked by this node.
641 */
642 HTMBLOCK,
643
644 /**
645 * Self and child respond to the hit test for touch events,
646 * and allow hit test of other nodes which is masked by this node.
647 */
648 HTMTRANSPARENT,
649
650 /**
651 * Self not respond to the hit test for touch events,
652 * but children respond to the hit test for touch events.
653 */
654 HTMNONE
655 };
656
657 enum class CopyOptions {
658 None = 0,
659 InApp,
660 Local,
661 Distributed,
662 };
663
664 enum class VisibleType {
665 VISIBLE,
666 INVISIBLE,
667 GONE,
668 };
669
670 enum class ShapeMode {
671 /*
672 * unspecified, follow theme.
673 */
674 DEFAULT = 0,
675 /*
676 * rect scrollbar.
677 */
678 RECT,
679 /*
680 * round scrollbar.
681 */
682 ROUND,
683 };
684
685 enum class DisplayMode {
686 /*
687 * do not display scrollbar.
688 */
689 OFF = 0,
690 /*
691 * display scrollbar on demand.
692 */
693 AUTO,
694 /*
695 * always display scrollbar.
696 */
697 ON,
698 };
699
700 enum class PositionMode {
701 /*
702 * display scrollbar on right.
703 */
704 RIGHT = 0,
705 /*
706 * display scrollbar on left.
707 */
708 LEFT,
709 /*
710 * display scrollbar on bottom.
711 */
712 BOTTOM,
713 };
714
715 enum class XComponentType { UNKNOWN = -1, SURFACE = 0, COMPONENT, TEXTURE, NODE };
716
717 enum class RenderMode { ASYNC_RENDER = 0, SYNC_RENDER };
718
719 inline constexpr uint32_t STATE_NORMAL = 0;
720 inline constexpr uint32_t STATE_PRESSED = 1;
721 inline constexpr uint32_t STATE_FOCUS = 1 << 1;
722 inline constexpr uint32_t STATE_CHECKED = 1 << 2;
723 inline constexpr uint32_t STATE_DISABLED = 1 << 3;
724 inline constexpr uint32_t STATE_WAITING = 1 << 4;
725 inline constexpr uint32_t STATE_HOVERED = 1 << 5;
726 inline constexpr uint32_t STATE_ACTIVE = 1 << 6;
727
728 enum class TabBarStyle {
729 NOSTYLE = 0,
730 SUBTABBATSTYLE,
731 BOTTOMTABBATSTYLE,
732 };
733
734 enum class GestureJudgeResult {
735 CONTINUE = 0,
736 REJECT = 1,
737 };
738
739 enum class GestureTypeName {
740 UNKNOWN = -1,
741 TAP_GESTURE = 0,
742 LONG_PRESS_GESTURE = 1,
743 PAN_GESTURE = 2,
744 PINCH_GESTURE = 3,
745 SWIPE_GESTURE = 4,
746 ROTATION_GESTURE = 5,
747 DRAG = 6,
748 CLICK = 7,
749 BOXSELECT = 8,
750 WEBSCROLL = 9,
751 TEXTFIELD_BOXSELECT = 10,
752 };
753
754 enum class ModifierKey {
755 CTRL = 0,
756 SHIFT = 1,
757 ALT = 2,
758 };
759
760 enum class FunctionKey {
761 ESC = 0,
762 F1 = 1,
763 F2 = 2,
764 F3 = 3,
765 F4 = 4,
766 F5 = 5,
767 F6 = 6,
768 F7 = 7,
769 F8 = 8,
770 F9 = 9,
771 F10 = 10,
772 F11 = 11,
773 F12 = 12,
774 TAB = 13,
775 DPAD_UP = 14,
776 DPAD_DOWN = 15,
777 DPAD_LEFT = 16,
778 DPAD_RIGHT = 17,
779 };
780
781 enum class ObscuredReasons {
782 PLACEHOLDER = 0,
783 };
784
785 enum class MaximizeMode : uint32_t {
786 MODE_AVOID_SYSTEM_BAR,
787 MODE_FULL_FILL,
788 MODE_RECOVER,
789 };
790
791 enum class RenderFit : int32_t {
792 CENTER = 0,
793 TOP,
794 BOTTOM,
795 LEFT,
796 RIGHT,
797 TOP_LEFT,
798 TOP_RIGHT,
799 BOTTOM_LEFT,
800 BOTTOM_RIGHT,
801 RESIZE_FILL,
802 RESIZE_CONTAIN,
803 RESIZE_CONTAIN_TOP_LEFT,
804 RESIZE_CONTAIN_BOTTOM_RIGHT,
805 RESIZE_COVER,
806 RESIZE_COVER_TOP_LEFT,
807 RESIZE_COVER_BOTTOM_RIGHT,
808 };
809
810 enum class KeyBoardAvoidMode : int32_t {
811 OFFSET = 0,
812 RESIZE,
813 };
814
815 enum class SwipeActionState : uint32_t {
816 COLLAPSED = 0,
817 EXPANDED,
818 ACTIONING,
819 };
820 /**
821 * souce is Rosen::Orientation
822 */
823 enum class Orientation : uint32_t {
824 BEGIN = 0,
825 UNSPECIFIED = BEGIN,
826 VERTICAL = 1,
827 HORIZONTAL = 2,
828 REVERSE_VERTICAL = 3,
829 REVERSE_HORIZONTAL = 4,
830 SENSOR = 5,
831 SENSOR_VERTICAL = 6,
832 SENSOR_HORIZONTAL = 7,
833 AUTO_ROTATION_RESTRICTED = 8,
834 AUTO_ROTATION_PORTRAIT_RESTRICTED = 9,
835 AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10,
836 LOCKED = 11,
837 END = LOCKED,
838 };
839
840 enum class NodeRenderType : uint32_t {
841 RENDER_TYPE_DISPLAY = 0,
842 RENDER_TYPE_TEXTURE,
843 };
844
845 enum class MarqueeUpdateStrategy : uint32_t {
846 DEFAULT = 0,
847 PRESERVE_POSITION,
848 };
849
850 enum class SafeAreaSyncType : uint32_t {
851 SYNC_TYPE_NONE = 0,
852 SYNC_TYPE_KEYBOARD,
853 SYNC_TYPE_AVOID_AREA,
854 SYNC_TYPE_WINDOW_IGNORE
855 };
856 } // namespace OHOS::Ace
857
858 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_LAYOUT_CONSTANTS_H
859