• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_THEME_SHADOW_THEME_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_SHADOW_THEME_H
18 
19 #include <string>
20 #include "theme_attributes.h"
21 
22 #include "base/utils/device_config.h"
23 #include "core/components/common/properties/shadow.h"
24 #include "core/components/theme/theme.h"
25 #include "core/components/theme/theme_constants.h"
26 
27 namespace OHOS::Ace {
28 
29 enum class BlurStyle;
30 enum class ThemeColorMode;
31 
32 class ACE_FORCE_EXPORT ShadowTheme : public virtual Theme {
33     DECLARE_ACE_TYPE(ShadowTheme, Theme);
34 
35 public:
36     class Builder {
37     public:
38         Builder() = default;
39         ~Builder() = default;
40         RefPtr<ShadowTheme> Build(const RefPtr<ThemeConstants>& themeConstants);
41     };
42     ShadowTheme() = default;
43     ~ShadowTheme() override = default;
44     Shadow GetShadow(ShadowStyle style, ColorMode colorMode);
45     void SetThemeStyle(const RefPtr<ThemeStyle>& themeStyle);
46 
47 private:
48     static uint32_t GetKeyOfShadowStyle(ShadowStyle style, ColorMode colorMode);
49     Shadow ParseShadowParam(
50         const RefPtr<ThemeStyle>& themeStyle, ShadowStyle shadowStyle, const std::string& name, bool isDark);
51 
52     const static std::unordered_map<ShadowStyle, std::string> validShadowStyles_;
53     RefPtr<ThemeStyle> themeStyle_;
54     std::unordered_map<uint32_t, Shadow> shadowStyles_;
55 };
56 
57 } // namespace OHOS::Ace
58 
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_BLUR_STYLE_THEME_H
60