• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_VIDEO_THEME_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_VIDEO_THEME_H
18 
19 #include "base/geometry/size.h"
20 #include "core/components/common/properties/color.h"
21 #include "core/components/common/properties/edge.h"
22 #include "core/components/common/properties/text_style.h"
23 #include "core/components/theme/theme.h"
24 #include "core/components/theme/theme_constants.h"
25 #include "core/components/theme/theme_constants_defines.h"
26 
27 namespace OHOS::Ace {
28 
29 /**
30  * VideoTheme defines color and styles of VideoComponent. VideoTheme should be built
31  * using VideoTheme::Builder.
32  */
33 class VideoTheme : public virtual Theme {
34     DECLARE_ACE_TYPE(VideoTheme, Theme);
35 
36 public:
37     class Builder {
38     public:
39         Builder() = default;
40         ~Builder() = default;
41 
Build(const RefPtr<ThemeConstants> & themeConstants)42         RefPtr<VideoTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const
43         {
44             RefPtr<VideoTheme> theme = AceType::Claim(new VideoTheme());
45             if (!themeConstants) {
46                 return theme;
47             }
48             theme->btnSize_ = Size(themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_WIDTH).Value(),
49                 themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_HEIGHT).Value());
50             theme->btnEdge_ = Edge(themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_PADDING_LEFT).Value(),
51                 themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_PADDING_TOP).Value(),
52                 themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_PADDING_RIGHT).Value(),
53                 themeConstants->GetDimension(THEME_VIDEO_BAR_BTN_PADDING_BOTTOM).Value());
54             theme->textEdge_ = Edge(themeConstants->GetDimension(THEME_VIDEO_BAR_TEXT_PADDING_LEFT).Value(),
55                 themeConstants->GetDimension(THEME_VIDEO_BAR_TEXT_PADDING_TOP).Value(),
56                 themeConstants->GetDimension(THEME_VIDEO_BAR_TEXT_PADDING_RIGHT).Value(),
57                 themeConstants->GetDimension(THEME_VIDEO_BAR_TEXT_PADDING_BOTTOM).Value());
58             theme->sliderEdge_ = Edge(themeConstants->GetDimension(THEME_VIDEO_BAR_SLIDER_PADDING_LEFT).Value(),
59                 themeConstants->GetDimension(THEME_VIDEO_BAR_SLIDER_PADDING_TOP).Value(),
60                 themeConstants->GetDimension(THEME_VIDEO_BAR_SLIDER_PADDING_RIGHT).Value(),
61                 themeConstants->GetDimension(THEME_VIDEO_BAR_SLIDER_PADDING_BOTTOM).Value());
62             theme->timeTextStyle_.SetFontSize(themeConstants->GetDimension(THEME_VIDEO_TEXT_FONTSIZE));
63             theme->timeTextStyle_.SetTextColor(themeConstants->GetColor(THEME_VIDEO_BAR_TIME_TEXT_COLOR));
64             theme->errorTextStyle_.SetFontSize(themeConstants->GetDimension(THEME_VIDEO_TEXT_FONTSIZE));
65             theme->errorTextStyle_.SetTextColor(themeConstants->GetColor(THEME_VIDEO_ERROR_TEXT_COLOR));
66             theme->bkgColor_ = themeConstants->GetColor(THEME_VIDEO_BAR_BACKGROUND);
67             return theme;
68         }
69     };
70 
71     ~VideoTheme() override = default;
72 
GetBtnSize()73     const Size& GetBtnSize() const
74     {
75         return btnSize_;
76     }
77 
GetBtnEdge()78     const Edge& GetBtnEdge() const
79     {
80         return btnEdge_;
81     }
82 
GetTextEdge()83     const Edge& GetTextEdge() const
84     {
85         return textEdge_;
86     }
87 
GetSliderEdge()88     const Edge& GetSliderEdge() const
89     {
90         return sliderEdge_;
91     }
92 
GetTimeTextStyle()93     const TextStyle& GetTimeTextStyle() const
94     {
95         return timeTextStyle_;
96     }
97 
GetErrorTextStyle()98     const TextStyle& GetErrorTextStyle() const
99     {
100         return errorTextStyle_;
101     }
102 
GetBkgColor()103     const Color& GetBkgColor() const
104     {
105         return bkgColor_;
106     }
107 
108 protected:
109     VideoTheme() = default;
110 
111 private:
112     Size btnSize_;
113     Edge btnEdge_;
114     Edge textEdge_;
115     Edge sliderEdge_;
116     TextStyle timeTextStyle_;
117     TextStyle errorTextStyle_;
118     Color bkgColor_;
119 };
120 
121 } // namespace OHOS::Ace
122 
123 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_VIDEO_THEME_H
124