1 /*
2 * Copyright (c) 2021 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 #include "core/components/common/properties/shadow_config.h"
17
18 namespace OHOS::Ace {
19 const Shadow ShadowConfig::NoneShadow = Shadow(0.0f, Offset(), Color(), ShadowStyle::None);
20
21 const Shadow ShadowConfig::DefaultShadowXS =
22 Shadow(5.0f, Offset(0.0, 0.0), Color(0x32000000), ShadowStyle::OuterDefaultXS);
23 const Shadow ShadowConfig::DefaultShadowS =
24 Shadow(100.0f, Offset(0.0, 0.0), Color(0x0b000000), ShadowStyle::OuterDefaultSM);
25 const Shadow ShadowConfig::DefaultShadowM =
26 Shadow(185.0f, Offset(0.0, 60.0), Color(0x28000000), ShadowStyle::OuterDefaultMD);
27 const Shadow ShadowConfig::DefaultShadowL =
28 Shadow(200.0f, Offset(0.0, 10.0), Color(0x26000000), ShadowStyle::OuterDefaultLG);
29 const Shadow ShadowConfig::FloatingShadowS =
30 Shadow(230.0f, Offset(0.0, 50.0), Color(0x15000000), ShadowStyle::OuterFloatingSM);
31 const Shadow ShadowConfig::FloatingShadowM =
32 Shadow(215.0f, Offset(0.0, 30.0), Color(0x31000000), ShadowStyle::OuterFloatingMD);
33
34 const Shadow ShadowConfig::DefaultShadowXSDark =
35 Shadow(5.0f, Offset(0.0, 0.0), Color(0x4c000000), ShadowStyle::OuterDefaultXS);
36 const Shadow ShadowConfig::DefaultShadowSDark =
37 Shadow(130.0f, Offset(0.0, 0.0), Color(0x2b000000), ShadowStyle::OuterDefaultSM);
38 const Shadow ShadowConfig::DefaultShadowMDark =
39 Shadow(120.0f, Offset(0.0, 45.0), Color(0x60000000), ShadowStyle::OuterDefaultMD);
40 const Shadow ShadowConfig::DefaultShadowLDark =
41 Shadow(200.0f, Offset(0.0, 60.0), Color(0x59000000), ShadowStyle::OuterDefaultLG);
42 const Shadow ShadowConfig::FloatingShadowSDark =
43 Shadow(150.0f, Offset(0.0, 30.0), Color(0x3c000000), ShadowStyle::OuterFloatingSM);
44 const Shadow ShadowConfig::FloatingShadowMDark =
45 Shadow(200.0f, Offset(0.0, 30.0), Color(0x38000000), ShadowStyle::OuterFloatingMD);
46
GetShadowConfig(int shadowLevel)47 const Shadow& ShadowConfig::GetShadowConfig(int shadowLevel)
48 {
49 switch (static_cast<ShadowStyle>(shadowLevel)) {
50 case ShadowStyle::OuterDefaultXS:
51 return DefaultShadowXS;
52 case ShadowStyle::OuterDefaultSM:
53 return DefaultShadowS;
54 case ShadowStyle::OuterDefaultMD:
55 return DefaultShadowM;
56 case ShadowStyle::OuterDefaultLG:
57 return DefaultShadowL;
58 case ShadowStyle::OuterFloatingSM:
59 return FloatingShadowS;
60 case ShadowStyle::OuterFloatingMD:
61 return FloatingShadowM;
62 default: {
63 return NoneShadow;
64 }
65 }
66 }
67 } // namespace OHOS::Ace
68