• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_THEME_TOKEN_COLORS_H
17 #define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_THEME_TOKEN_COLORS_H
18 
19 #include "ui/base/ace_type.h"
20 #include "ui/properties/color.h"
21 #include "ui/resource/resource_object.h"
22 
23 namespace OHOS::Ace {
24 
25 struct TokenColorData {
26     const char* colorName { nullptr };
27     const int32_t systemResourceId {0};
28 };
29 class ACE_FORCE_EXPORT TokenColors : public virtual AceType {
30     DECLARE_ACE_TYPE(TokenColors, AceType);
31 
32 public:
33     static constexpr int32_t BRAND = 0;
34     static constexpr int32_t WARNING = 1;
35     static constexpr int32_t ALERT = 2;
36     static constexpr int32_t CONFIRM = 3;
37 
38     static constexpr int32_t FONT_PRIMARY = 4;
39     static constexpr int32_t FONT_SECONDARY = 5;
40     static constexpr int32_t FONT_TERTIARY = 6;
41     static constexpr int32_t FONT_FOURTH = 7;
42     static constexpr int32_t FONT_EMPHASIZE = 8;
43 
44     static constexpr int32_t FONT_ON_PRIMARY = 9;
45     static constexpr int32_t FONT_ON_SECONDARY = 10;
46     static constexpr int32_t FONT_ON_TERTIARY = 11;
47     static constexpr int32_t FONT_ON_FOURTH = 12;
48 
49     static constexpr int32_t ICON_PRIMARY = 13;
50     static constexpr int32_t ICON_SECONDARY = 14;
51     static constexpr int32_t ICON_TERTIARY = 15;
52     static constexpr int32_t ICON_FOURTH = 16;
53     static constexpr int32_t ICON_EMPHASIZE = 17;
54     static constexpr int32_t ICON_SUB_EMPHASIZE = 18;
55 
56     static constexpr int32_t ICON_ON_PRIMARY = 19;
57     static constexpr int32_t ICON_ON_SECONDARY = 20;
58     static constexpr int32_t ICON_ON_TERTIARY = 21;
59     static constexpr int32_t ICON_ON_FOURTH = 22;
60 
61     static constexpr int32_t BACKGROUND_PRIMARY = 23;
62     static constexpr int32_t BACKGROUND_SECONDARY = 24;
63     static constexpr int32_t BACKGROUND_TERTIARY = 25;
64     static constexpr int32_t BACKGROUND_FOURTH = 26;
65     static constexpr int32_t BACKGROUND_EMPHASIZE = 27;
66 
67     static constexpr int32_t COMP_FOREGROUND_PRIMARY = 28;
68     static constexpr int32_t COMP_BACKGROUND_PRIMARY = 29;
69     static constexpr int32_t COMP_BACKGROUND_PRIMARY_TRAN = 30;
70     static constexpr int32_t COMP_BACKGROUND_PRIMARY_CONTRARY = 31;
71     static constexpr int32_t COMP_BACKGROUND_GRAY = 32;
72     static constexpr int32_t COMP_BACKGROUND_SECONDARY = 33;
73     static constexpr int32_t COMP_BACKGROUND_TERTIARY = 34;
74     static constexpr int32_t COMP_BACKGROUND_EMPHASIZE = 35;
75     static constexpr int32_t COMP_BACKGROUND_NEUTRAL = 36;
76     static constexpr int32_t COMP_EMPHASIZE_SECONDARY = 37;
77     static constexpr int32_t COMP_EMPHASIZE_TERTIARY = 38;
78     static constexpr int32_t COMP_DIVIDER = 39;
79     static constexpr int32_t COMP_COMMON_CONTRARY = 40;
80     static constexpr int32_t COMP_BACKGROUND_FOCUS = 41;
81     static constexpr int32_t COMP_FOCUSED_PRIMARY = 42;
82     static constexpr int32_t COMP_FOCUSED_SECONDARY = 43;
83     static constexpr int32_t COMP_FOCUSED_TERTIARY = 44;
84 
85     static constexpr int32_t INTERACTIVE_HOVER = 45;
86     static constexpr int32_t INTERACTIVE_PRESSED = 46;
87     static constexpr int32_t INTERACTIVE_FOCUS = 47;
88     static constexpr int32_t INTERACTIVE_ACTIVE = 48;
89     static constexpr int32_t INTERACTIVE_SELECT = 49;
90     static constexpr int32_t INTERACTIVE_CLICK = 50;
91     static constexpr int32_t TOTAL_NUMBER = 51;
92 
93     TokenColors() = default;
94     virtual ~TokenColors() = default;
95 
96     void SetColors(const std::vector<Color>& colors);
97     void SetColor(uint32_t idx, const Color& color);
98     const std::vector<Color>& GetColors();
99 
100     Color Brand() const;
101     Color Warning() const;
102     Color Alert() const;
103     Color Confirm() const;
104 
105     Color FontPrimary() const;
106     Color FontSecondary() const;
107     Color FontTertiary() const;
108     Color FontFourth() const;
109     Color FontEmphasize() const;
110 
111     Color FontOnPrimary() const;
112     Color FontOnSecondary() const;
113     Color FontOnTertiary() const;
114     Color FontOnFourth() const;
115 
116     Color IconPrimary() const;
117     Color IconSecondary() const;
118     Color IconTertiary() const;
119     Color IconFourth() const;
120     Color IconEmphasize() const;
121     Color IconSubEmphasize() const;
122 
123     Color IconOnPrimary() const;
124     Color IconOnSecondary() const;
125     Color IconOnTertiary() const;
126     Color IconOnFourth() const;
127 
128     Color BackgroundPrimary() const;
129     Color BackgroundSecondary() const;
130     Color BackgroundTertiary() const;
131     Color BackgroundFourth() const;
132     Color BackgroundEmphasize() const;
133 
134     Color CompForegroundPrimary() const;
135     Color CompBackgroundPrimary() const;
136     Color CompBackgroundPrimaryTran() const;
137     Color CompBackgroundPrimaryContrary() const;
138     Color CompBackgroundGray() const;
139     Color CompBackgroundSecondary() const;
140     Color CompBackgroundTertiary() const;
141     Color CompBackgroundEmphasize() const;
142     Color CompBackgroundNeutral() const;
143     Color CompEmphasizeSecondary() const;
144     Color CompEmphasizeTertiary() const;
145     Color CompDivider() const;
146     Color CompCommonContrary() const;
147     Color CompBackgroundFocus() const;
148     Color CompFocusedPrimary() const;
149     Color CompFocusedSecondary() const;
150     Color CompFocusedTertiary() const;
151 
152     Color InteractiveHover() const;
153     Color InteractivePressed() const;
154     Color InteractiveFocus() const;
155     Color InteractiveActive() const;
156     Color InteractiveSelect() const;
157     Color InteractiveClick() const;
158     static const char* GetColorNameByIndex(int32_t idx);
159 
160     static int32_t GetSystemColorResIdByIndex(int32_t idx);
161 
162     Color GetByIndex(uint32_t idx);
163 
164     static const TokenColorData& GetTokenColorDataByIndex(int32_t idx);
165 
SetResObjs(std::vector<RefPtr<ResourceObject>> && resObjs)166     void SetResObjs(std::vector<RefPtr<ResourceObject>>&& resObjs)
167     {
168         resObjs_ = std::move(resObjs);
169     }
170 
GetResObjs()171     const std::vector<RefPtr<ResourceObject>>& GetResObjs() const
172     {
173         return resObjs_;
174     }
175 
SetColorMode(const ColorMode & colorMode)176     void SetColorMode(const ColorMode& colorMode)
177     {
178         colorMode_ = colorMode;
179     }
180 private:
181     Color GetColorWithResourceObject(int32_t colorIndex) const;
182     std::vector<Color> colors_ = std::vector<Color>(TokenColors::TOTAL_NUMBER);
183     std::vector<RefPtr<ResourceObject>> resObjs_;
184     ColorMode colorMode_ = ColorMode::COLOR_MODE_UNDEFINED;
185 };
186 
187 } // namespace OHOS::Ace::NG
188 #endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_THEME_TOKEN_COLORS_H
189