• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SELECT_SELECT_THEME_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SELECT_SELECT_THEME_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/layout/constants.h"
21 #include "core/components/common/properties/color.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 #include "core/components_ng/property/calc_length.h"
27 #include "core/components_ng/property/border_property.h"
28 
29 namespace OHOS::Ace {
30 
31 constexpr double SELECT_OPTION_LEFT_LENGTH = 16.0;
32 constexpr double SELECT_OPTION_TOP_LENGTH = 15.0;
33 constexpr double SELECT_OPTION_RIGHT_LENGTH = 16.0;
34 constexpr double SELECT_OPTION_BOTTOM_LENGTH = 15.0;
35 constexpr Dimension VERTICAL_INTERVAL = 14.4_vp;
36 constexpr Dimension MENU_END_ICON_WIDTH = 12.0_vp;
37 constexpr Dimension MENU_END_ICON_HEIGHT = 24.0_vp;
38 constexpr Dimension DEFAULT_MENU_WIDTH = 0.0_vp;
39 constexpr Dimension MIN_MENU_WIDTH = 64.0_vp;
40 
41 /**
42  * SelectTheme defines color and styles of SelectComponent. SelectTheme should be build
43  * using SelectTheme::Builder.
44  */
45 class SelectTheme final : public virtual Theme {
46     DECLARE_ACE_TYPE(SelectTheme, Theme);
47 
48 public:
49     class Builder final {
50     public:
51         Builder() = default;
52         ~Builder() = default;
53 
Build(const RefPtr<ThemeConstants> & themeConstants)54         RefPtr<SelectTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const
55         {
56             RefPtr<SelectTheme> theme = AceType::Claim(new SelectTheme());
57             if (!themeConstants) {
58                 return theme;
59             }
60             theme->disabledColor_ = themeConstants->GetColor(THEME_SELECT_DISABLED_COLOR);
61             theme->clickedColor_ = themeConstants->GetColor(THEME_SELECT_CLICKED_COLOR);
62             theme->selectedColor_ = themeConstants->GetColor(THEME_SELECT_SELECTED_COLOR);
63             theme->fontFamily_ = "sans-serif";
64             theme->fontSize_ = themeConstants->GetDimension(THEME_SELECT_FONT_SIZE);
65             theme->fontColor_ = themeConstants->GetColor(THEME_SELECT_FONT_COLOR);
66             theme->fontWeight_ = FontWeight::NORMAL;
67             theme->textDecoration_ = TextDecoration::NONE;
68             auto optionSize = themeConstants->GetInt(THEME_SELECT_OPTION_SHOW_COUNT);
69             theme->optionSize_ = optionSize < 0 ? theme->optionSize_ : static_cast<size_t>(optionSize);
70             theme->rrectSize_ = themeConstants->GetDimension(THEME_SELECT_ITSELF_RRECT_SIZE);
71             theme->popupBorderWidth_ = themeConstants->GetDimension(THEME_SELECT_POPUP_BORDER_WIDTH);
72             theme->popupShadowWidth_ = themeConstants->GetDimension(THEME_SELECT_POPUP_SHADOW_WIDTH);
73             theme->popupRRectSize_ = themeConstants->GetDimension(THEME_SELECT_POPUP_RRECT_SIZE);
74             theme->popupMinWidth_ = themeConstants->GetDimension(THEME_SELECT_POPUP_MIN_WIDTH);
75             theme->normalPadding_ = themeConstants->GetDimension(THEME_SELECT_NORMAL_PADDING);
76             theme->iconSize_ = themeConstants->GetDimension(THEME_SELECT_ITSELF_ICON_SIZE);
77             theme->isTV_ = themeConstants->GetInt(THEME_SELECT_IS_TV);
78             theme->horizontalSpacing_ = themeConstants->GetDimension(THEME_SELECT_POPUP_SPACING_HORIZONTAL);
79             theme->verticalSpacing_ = themeConstants->GetDimension(THEME_SELECT_POPUP_SPACING_VERTICAL);
80             theme->contentSpacing_ = themeConstants->GetDimension(THEME_SELECT_POPUP_SPACING_CONTENT);
81 
82             theme->selectShowTime_ = 250; // unit is ms.
83             theme->selectHideTime_ = 250; // unit is ms.
84             theme->menuShowTime_ = 250;   // unit is ms.
85             theme->menuHideTime_ = 250;   // unit is ms.
86             theme->hoverAnimationDuration_ = 250;
87             theme->pressAnimationDuration_ = 100;
88             theme->titleLeftPadding_ = Dimension(16.0, DimensionUnit::VP);
89             theme->titleTopPadding_ = Dimension(8.0, DimensionUnit::VP);
90             theme->titleRightPadding_ = Dimension(8.0, DimensionUnit::VP);
91             theme->titleBottomPadding_ = Dimension(16.0, DimensionUnit::VP);
92             theme->titleStyle_.SetFontSize(themeConstants->GetDimension(THEME_OHOS_TEXT_SIZE_HEADLINE7));
93             std::vector<std::string> families;
94             families.emplace_back("sans-serif");
95             theme->titleStyle_.SetFontFamilies(families);
96             theme->titleStyle_.SetFontWeight(FontWeight::W500);
97             theme->titleStyle_.SetTextColor(themeConstants->GetColor(THEME_OHOS_COLOR_TEXT_PRIMARY));
98             theme->titleStyle_.SetTextDecoration(TextDecoration::NONE);
99             theme->optionPadding_ = Edge(SELECT_OPTION_LEFT_LENGTH, SELECT_OPTION_TOP_LENGTH,
100                 SELECT_OPTION_RIGHT_LENGTH, SELECT_OPTION_BOTTOM_LENGTH, DimensionUnit::VP);
101             theme->optionInterval_ = theme->isTV_ ? Dimension(6.0, DimensionUnit::VP) : 0.0_vp;
102             theme->tvFocusTextColor_ = Color(0xE6000000);
103             theme->tvNormalBackColor_ = Color(0x33FFFFFF);
104             theme->tvBackColor_ = (theme->isTV_ ? Color(0x99000000) : Color::TRANSPARENT);
105             // disabled color
106             theme->normalDisableColor_ = themeConstants->GetColor(THEME_SELECT_OPTION_DISABLE_COLOR);
107             theme->focusedDisableColor_ = themeConstants->GetColor(THEME_SELECT_OPTION_FOCUSED_DISABLE_COLOR);
108             theme->normalTextDisableColor_ = themeConstants->GetColor(THEME_SELECT_OPTION_DISABLE_TEXT_COLOR);
109             theme->focusedTextDisableColor_ = themeConstants->GetColor(THEME_SELECT_OPTION_FOCUSED_DISABLE_TEXT_COLOR);
110             theme->optionTextStyle_.SetFontSize(themeConstants->GetDimension(THEME_OHOS_TEXT_SIZE_BODY1));
111             theme->optionTextStyle_.SetFontFamilies({ themeConstants->GetString(THEME_OHOS_TEXT_FONT_FAMILY_REGULAR) });
112             theme->optionTextStyle_.SetFontWeight(FontWeight::NORMAL);
113             theme->optionTextStyle_.SetTextColor(themeConstants->GetColor(THEME_SELECT_FONT_COLOR));
114             theme->optionTextStyle_.SetTextDecoration(TextDecoration::NONE);
115             Parse(themeConstants->GetThemeStyle(), theme);
116             return theme;
117         }
118 
Parse(const RefPtr<ThemeStyle> & style,const RefPtr<SelectTheme> & theme)119         void Parse(const RefPtr<ThemeStyle>& style, const RefPtr<SelectTheme>& theme) const
120         {
121             if (!style || !theme) {
122                 return;
123             }
124             auto pattern = style->GetAttr<RefPtr<ThemeStyle>>(THEME_PATTERN_SELECT, nullptr);
125             if (!pattern) {
126                 LOGE("Pattern of select is null, please check!");
127                 return;
128             }
129             const double defaultTextColorAlpha = 0.9;
130             const double defaultDisabledColorAlpha = 0.4;
131             const double defaultSecondaryColorAlpha = 0.6;
132             const double defaultTertiaryColorAlpha = 0.6;
133             const double bgColorSelectedAlpha = 0.2;
134 
135             theme->fontSize_ = pattern->GetAttr<Dimension>(PATTERN_TEXT_SIZE, theme->fontSize_);
136             theme->menuFontSize_ = pattern->GetAttr<Dimension>("menu_text_font_size", theme->menuFontSize_);
137             theme->menuTitleFontSize_ =
138                 pattern->GetAttr<Dimension>("menu_title_text_font_size", theme->menuTitleFontSize_);
139             theme->menuTitleFontColor_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, theme->menuTitleFontColor_);
140             theme->menuTitleHeight_ = pattern->GetAttr<Dimension>("menu_title_height", theme->menuTitleHeight_);
141             theme->fontColor_ =
142                 pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, theme->fontColor_)
143                     .BlendOpacity(pattern->GetAttr<double>("menu_text_primary_alpha", defaultTextColorAlpha));
144             theme->disabledFontColor_ = theme->fontColor_.BlendOpacity(
145                 pattern->GetAttr<double>("color_disabled_alpha", defaultDisabledColorAlpha));
146             theme->secondaryFontColor_ =
147                 pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, theme->fontColor_)
148                     .BlendOpacity(pattern->GetAttr<double>("menu_text_secondary_alpha", defaultSecondaryColorAlpha));
149             theme->menuFontColor_ =
150                 pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, theme->menuFontColor_)
151                     .BlendOpacity(pattern->GetAttr<double>("menu_text_primary_alpha", defaultTextColorAlpha));
152             theme->disabledMenuFontColor_ = theme->menuFontColor_.BlendOpacity(
153                 pattern->GetAttr<double>("menu_text_tertiary_alpha", defaultTertiaryColorAlpha));
154             theme->clickedColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_CLICKED, theme->clickedColor_);
155             theme->selectedColor_ =
156                 pattern->GetAttr<Color>(PATTERN_BG_COLOR_SELECTED, theme->selectedColor_)
157                     .BlendOpacity(pattern->GetAttr<double>("bg_color_selected_alpha", bgColorSelectedAlpha));
158             theme->selectedColorText_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR_SELECTED, theme->selectedColorText_);
159             theme->hoverColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_HOVERED, theme->hoverColor_);
160             theme->backgroundColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR, theme->backgroundColor_);
161             theme->disabledBackgroundColor_ = theme->disabledBackgroundColor_.BlendOpacity(
162                 pattern->GetAttr<double>("color_disabled_alpha", defaultDisabledColorAlpha));
163             theme->lineColor_ = pattern->GetAttr<Color>("line_color", theme->lineColor_);
164             theme->spinnerColor_ = pattern->GetAttr<Color>("select_icon_color", theme->spinnerColor_);
165             theme->disabledSpinnerColor_ = theme->spinnerColor_.BlendOpacity(
166                 pattern->GetAttr<double>("color_disabled_alpha", defaultDisabledColorAlpha));
167             theme->selectBorderRadius_ = pattern->GetAttr<Dimension>("border_radius", theme->selectBorderRadius_);
168             theme->menuBorderRadius_ = pattern->GetAttr<Dimension>("menu_border_radius", theme->menuBorderRadius_);
169             theme->innerBorderRadius_ = pattern->GetAttr<Dimension>("inner_border_radius", theme->innerBorderRadius_);
170             theme->menuIconPadding_ = pattern->GetAttr<Dimension>("menu_icon_padding", theme->menuIconPadding_);
171             theme->iconContentPadding_ =
172                 pattern->GetAttr<Dimension>("icon_content_padding", theme->iconContentPadding_);
173             theme->menuIconColor_ = pattern->GetAttr<Color>("menu_icon_color", theme->menuIconColor_);
174             theme->dividerPaddingVertical_ =
175                 pattern->GetAttr<Dimension>("divider_padding_vertical", theme->dividerPaddingVertical_);
176             theme->optionMinHeight_ = pattern->GetAttr<Dimension>("option_min_height", theme->optionMinHeight_);
177             theme->selectMenuPadding_ = pattern->GetAttr<Dimension>("select_menu_padding", theme->selectMenuPadding_);
178             theme->outPadding_ = pattern->GetAttr<Dimension>("out_padding", theme->outPadding_);
179             theme->defaultPaddingStart_ =
180                 pattern->GetAttr<Dimension>("default_padding_start", theme->defaultPaddingStart_);
181             theme->defaultPaddingEnd_ = pattern->GetAttr<Dimension>("default_padding_end", theme->defaultPaddingEnd_);
182             theme->defaultPaddingTop_ = pattern->GetAttr<Dimension>("default_padding_top", theme->defaultPaddingTop_);
183             theme->defaultPaddingBottomFixed_ =
184                 pattern->GetAttr<Dimension>("default_padding_bottom_fixed", theme->defaultPaddingBottomFixed_);
185             theme->contentSpinnerPadding_ =
186                 pattern->GetAttr<Dimension>("content_spinner_padding", theme->contentSpinnerPadding_);
187             theme->menuAnimationOffset_ =
188                 pattern->GetAttr<Dimension>("menu_animation_offset", theme->menuAnimationOffset_);
189             theme->spinnerWidth_ = pattern->GetAttr<Dimension>("spinner_width", theme->spinnerWidth_);
190             theme->spinnerHeight_ = pattern->GetAttr<Dimension>("spinner_height", theme->spinnerHeight_);
191             theme->defaultDividerWidth_ =
192                 pattern->GetAttr<Dimension>("default_divider_width", theme->defaultDividerWidth_);
193             theme->selectMinWidth_ = pattern->GetAttr<Dimension>("select_min_width", theme->selectMinWidth_);
194             theme->selectDefaultHeight_ = pattern->GetAttr<Dimension>("select_min_height", theme->selectDefaultHeight_);
195             theme->iconSideLength_ = pattern->GetAttr<Dimension>("icon_side_length", theme->iconSideLength_);
196             theme->endIconWidth_ = MENU_END_ICON_WIDTH;
197             theme->endIconHeight_ = MENU_END_ICON_HEIGHT;
198             theme->contentMargin_ = pattern->GetAttr<Dimension>("content_margin", theme->contentMargin_);
199         }
200     };
201 
202     ~SelectTheme() override = default;
203 
clone()204     RefPtr<SelectTheme> clone()
205     {
206         RefPtr<SelectTheme> theme = AceType::Claim(new SelectTheme());
207         theme->disabledColor_ = disabledColor_;
208         theme->clickedColor_ = clickedColor_;
209         theme->selectedColor_ = selectedColor_;
210         theme->fontSize_ = fontSize_;
211         theme->fontFamily_ = fontFamily_;
212         theme->fontColor_ = fontColor_;
213         theme->disabledFontColor_ = disabledFontColor_;
214         theme->secondaryFontColor_ = secondaryFontColor_;
215         theme->fontWeight_ = fontWeight_;
216         theme->textDecoration_ = textDecoration_;
217         theme->rrectSize_ = rrectSize_;
218         theme->iconSize_ = iconSize_;
219         theme->normalPadding_ = normalPadding_;
220         theme->optionSize_ = optionSize_;
221         theme->popupRRectSize_ = popupRRectSize_;
222         theme->popupMinWidth_ = popupMinWidth_;
223         theme->popupShadowWidth_ = popupShadowWidth_;
224         theme->popupBorderWidth_ = popupBorderWidth_;
225         theme->titleLeftPadding_ = titleLeftPadding_;
226         theme->titleTopPadding_ = titleTopPadding_;
227         theme->titleRightPadding_ = titleRightPadding_;
228         theme->titleBottomPadding_ = titleBottomPadding_;
229         theme->titleStyle_ = titleStyle_;
230         theme->isTV_ = isTV_;
231         theme->horizontalSpacing_ = horizontalSpacing_;
232         theme->verticalSpacing_ = verticalSpacing_;
233         theme->contentSpacing_ = contentSpacing_;
234         theme->menuHideTime_ = menuHideTime_;
235         theme->menuShowTime_ = menuShowTime_;
236         theme->selectShowTime_ = selectShowTime_;
237         theme->selectHideTime_ = selectHideTime_;
238         theme->hoverAnimationDuration_ = hoverAnimationDuration_;
239         theme->pressAnimationDuration_ = pressAnimationDuration_;
240         theme->optionPadding_ = optionPadding_;
241         theme->optionInterval_ = optionInterval_;
242         theme->optionMinHeight_ = optionMinHeight_;
243         theme->tvFocusTextColor_ = tvFocusTextColor_;
244         theme->tvNormalBackColor_ = tvNormalBackColor_;
245         theme->tvBackColor_ = tvBackColor_;
246         theme->focusedDisableColor_ = focusedDisableColor_;
247         theme->normalDisableColor_ = normalDisableColor_;
248         theme->focusedTextDisableColor_ = focusedTextDisableColor_;
249         theme->normalTextDisableColor_ = normalTextDisableColor_;
250         theme->spinnerColor_ = spinnerColor_;
251         theme->disabledSpinnerColor_ = disabledSpinnerColor_;
252         theme->backgroundColor_ = backgroundColor_;
253         theme->disabledBackgroundColor_ = disabledBackgroundColor_;
254         theme->hoverColor_ = hoverColor_;
255         theme->selectedColorText_ = selectedColorText_;
256         theme->lineColor_ = lineColor_;
257         theme->optionTextStyle_ = optionTextStyle_;
258         theme->selectBorderRadius_ = selectBorderRadius_;
259         theme->menuBorderRadius_ = menuBorderRadius_;
260         theme->innerBorderRadius_ = innerBorderRadius_;
261         theme->menuFontSize_ = menuFontSize_;
262         theme->menuTitleFontSize_ = menuTitleFontSize_;
263         theme->menuTitleFontColor_ = menuTitleFontColor_;
264         theme->menuTitleHeight_ = menuTitleHeight_;
265         theme->menuFontColor_ = menuFontColor_;
266         theme->disabledMenuFontColor_ = disabledMenuFontColor_;
267         theme->menuIconPadding_ = menuIconPadding_;
268         theme->iconContentPadding_ = iconContentPadding_;
269         theme->dividerPaddingVertical_ = dividerPaddingVertical_;
270         theme->menuIconColor_ = menuIconColor_;
271         theme->optionMinHeight_ = optionMinHeight_;
272         theme->selectMenuPadding_ = selectMenuPadding_;
273         theme->outPadding_ = outPadding_;
274         theme->defaultPaddingStart_ = defaultPaddingStart_;
275         theme->defaultPaddingEnd_ = defaultPaddingEnd_;
276         theme->defaultPaddingTop_ = defaultPaddingTop_;
277         theme->defaultPaddingBottomFixed_ = defaultPaddingBottomFixed_;
278         theme->contentSpinnerPadding_ = contentSpinnerPadding_;
279         theme->menuAnimationOffset_ = menuAnimationOffset_;
280         theme->spinnerWidth_ = spinnerWidth_;
281         theme->spinnerHeight_ = spinnerHeight_;
282         theme->defaultDividerWidth_ = defaultDividerWidth_;
283         theme->selectMinWidth_ = selectMinWidth_;
284         theme->selectDefaultHeight_ = selectDefaultHeight_;
285         theme->iconSideLength_ = iconSideLength_;
286         theme->endIconWidth_ = endIconWidth_;
287         theme->endIconHeight_ = endIconHeight_;
288         theme->contentMargin_ = contentMargin_;
289         return theme;
290     }
291 
GetSelectedColorText()292     const Color& GetSelectedColorText() const
293     {
294         return selectedColorText_;
295     }
296 
GetHoverColor()297     const Color& GetHoverColor() const
298     {
299         return hoverColor_;
300     }
301 
GetBackgroundColor()302     const Color& GetBackgroundColor() const
303     {
304         return backgroundColor_;
305     }
306 
GetDisabledBackgroundColor()307     const Color& GetDisabledBackgroundColor() const
308     {
309         return disabledBackgroundColor_;
310     }
311 
GetDisabledColor()312     const Color& GetDisabledColor() const
313     {
314         return disabledColor_;
315     }
SetDisabledColor(const Color & value)316     void SetDisabledColor(const Color& value)
317     {
318         disabledColor_ = value;
319     }
320 
GetClickedColor()321     const Color& GetClickedColor() const
322     {
323         return clickedColor_;
324     }
SetClickedColor(const Color & value)325     void SetClickedColor(const Color& value)
326     {
327         clickedColor_ = value;
328     }
329 
GetSelectedColor()330     const Color& GetSelectedColor() const
331     {
332         return selectedColor_;
333     }
334 
SetSelectedColor(const Color & value)335     void SetSelectedColor(const Color& value)
336     {
337         selectedColor_ = value;
338     }
339 
GetFontSize()340     const Dimension& GetFontSize() const
341     {
342         return fontSize_;
343     }
SetFontSize(const Dimension & value)344     void SetFontSize(const Dimension& value)
345     {
346         fontSize_ = value;
347     }
348 
GetFontColor()349     const Color& GetFontColor() const
350     {
351         return fontColor_;
352     }
SetFontColor(const Color & value)353     void SetFontColor(const Color& value)
354     {
355         fontColor_ = value;
356     }
357 
GetDisabledFontColor()358     const Color& GetDisabledFontColor() const
359     {
360         return disabledFontColor_;
361     }
362 
GetSecondaryFontColor()363     const Color& GetSecondaryFontColor() const
364     {
365         return secondaryFontColor_;
366     }
367 
GetFontFamily()368     const std::string& GetFontFamily() const
369     {
370         return fontFamily_;
371     }
SetFontFamily(const std::string & value)372     void SetFontFamily(const std::string& value)
373     {
374         fontFamily_ = value;
375     }
376 
GetFontWeight()377     FontWeight GetFontWeight() const
378     {
379         return fontWeight_;
380     }
SetFontWeight(FontWeight value)381     void SetFontWeight(FontWeight value)
382     {
383         fontWeight_ = value;
384     }
385 
GetTextDecoration()386     TextDecoration GetTextDecoration() const
387     {
388         return textDecoration_;
389     }
SetTextDecoration(TextDecoration value)390     void SetTextDecoration(TextDecoration value)
391     {
392         textDecoration_ = value;
393     }
394 
GetOptionSize()395     std::size_t GetOptionSize() const
396     {
397         return optionSize_;
398     }
SetOptionSize(std::size_t value)399     void SetOptionSize(std::size_t value)
400     {
401         optionSize_ = value;
402     }
403 
GetRRectSize()404     const Dimension& GetRRectSize() const
405     {
406         return rrectSize_;
407     }
SetRRectSize(const Dimension & value)408     void SetRRectSize(const Dimension& value)
409     {
410         rrectSize_ = value;
411     }
412 
GetPopupRRectSize()413     const Dimension& GetPopupRRectSize() const
414     {
415         return popupRRectSize_;
416     }
SetPopupRRectSize(const Dimension & value)417     void SetPopupRRectSize(const Dimension& value)
418     {
419         popupRRectSize_ = value;
420     }
421 
GetPopupBorderWidth()422     const Dimension& GetPopupBorderWidth() const
423     {
424         return popupBorderWidth_;
425     }
SetPopupBorderWidth(const Dimension & value)426     void SetPopupBorderWidth(const Dimension& value)
427     {
428         popupBorderWidth_ = value;
429     }
430 
GetPopupShadowWidth()431     const Dimension& GetPopupShadowWidth() const
432     {
433         return popupShadowWidth_;
434     }
SetPopupShadowWidth(const Dimension & value)435     void SetPopupShadowWidth(const Dimension& value)
436     {
437         popupShadowWidth_ = value;
438     }
439 
GetPopupMinWidth()440     const Dimension& GetPopupMinWidth() const
441     {
442         return popupMinWidth_;
443     }
SetPopupMinWidth(const Dimension & value)444     void SetPopupMinWidth(const Dimension& value)
445     {
446         popupMinWidth_ = value;
447     }
448 
GetNormalPadding()449     const Dimension& GetNormalPadding() const
450     {
451         return normalPadding_;
452     }
SetNormalPadding(const Dimension & value)453     void SetNormalPadding(const Dimension& value)
454     {
455         normalPadding_ = value;
456     }
457 
GetIconSize()458     const Dimension& GetIconSize() const
459     {
460         return iconSize_;
461     }
SetIconSize(const Dimension & value)462     void SetIconSize(const Dimension& value)
463     {
464         iconSize_ = value;
465     }
466 
GetTitleLeftPadding()467     const Dimension& GetTitleLeftPadding() const
468     {
469         return titleLeftPadding_;
470     }
SetTitleLeftPadding(const Dimension & value)471     void SetTitleLeftPadding(const Dimension& value)
472     {
473         titleLeftPadding_ = value;
474     }
475 
GetTitleTopPadding()476     const Dimension& GetTitleTopPadding() const
477     {
478         return titleTopPadding_;
479     }
SetTitleTopPadding(const Dimension & value)480     void SetTitleTopPadding(const Dimension& value)
481     {
482         titleTopPadding_ = value;
483     }
484 
GetTitleRightPadding()485     const Dimension& GetTitleRightPadding() const
486     {
487         return titleRightPadding_;
488     }
SetTitleRightPadding(const Dimension & value)489     void SetTitleRightPadding(const Dimension& value)
490     {
491         titleRightPadding_ = value;
492     }
493 
GetTitleBottomPadding()494     const Dimension& GetTitleBottomPadding() const
495     {
496         return titleBottomPadding_;
497     }
SetTitleBottomPadding(const Dimension & value)498     void SetTitleBottomPadding(const Dimension& value)
499     {
500         titleBottomPadding_ = value;
501     }
502 
GetTitleStyle()503     const TextStyle& GetTitleStyle()
504     {
505         return titleStyle_;
506     }
SetTitleStyle(const TextStyle & value)507     void SetTitleStyle(const TextStyle& value)
508     {
509         titleStyle_ = value;
510     }
511 
IsTV()512     bool IsTV() const
513     {
514         return isTV_;
515     }
SetIsTV(bool isTV)516     void SetIsTV(bool isTV)
517     {
518         isTV_ = isTV;
519     }
520 
GetHorizontalSpacing()521     const Dimension& GetHorizontalSpacing() const
522     {
523         return horizontalSpacing_;
524     }
SetHorizontalSpacing(const Dimension & horizontalSpacing)525     void SetHorizontalSpacing(const Dimension& horizontalSpacing)
526     {
527         horizontalSpacing_ = horizontalSpacing;
528     }
529 
GetVerticalSpacing()530     const Dimension& GetVerticalSpacing() const
531     {
532         return verticalSpacing_;
533     }
SetVerticalSpacing(const Dimension & verticalSpacing)534     void SetVerticalSpacing(const Dimension& verticalSpacing)
535     {
536         verticalSpacing_ = verticalSpacing;
537     }
538 
GetContentSpacing()539     const Dimension& GetContentSpacing() const
540     {
541         return contentSpacing_;
542     }
SetContentSpacing(const Dimension & contentSpacing)543     void SetContentSpacing(const Dimension& contentSpacing)
544     {
545         contentSpacing_ = contentSpacing;
546     }
547 
GetOptionPadding()548     const Edge& GetOptionPadding() const
549     {
550         return optionPadding_;
551     }
SetOptionPadding(const Edge & value)552     void SetOptionPadding(const Edge& value)
553     {
554         optionPadding_ = value;
555     }
556 
GetShowTime(bool isMenu)557     uint32_t GetShowTime(bool isMenu) const
558     {
559         if (isMenu) {
560             return menuShowTime_;
561         } else {
562             return selectShowTime_;
563         }
564     }
565 
GetHideTime(bool isMenu)566     uint32_t GetHideTime(bool isMenu) const
567     {
568         if (isMenu) {
569             return menuHideTime_;
570         } else {
571             return selectHideTime_;
572         }
573     }
574 
GetHoverAnimationDuration()575     int32_t GetHoverAnimationDuration() const
576     {
577         return hoverAnimationDuration_;
578     }
579 
GetPressAnimationDuration()580     int32_t GetPressAnimationDuration() const
581     {
582         return pressAnimationDuration_;
583     }
584 
585     SelectTheme() = default;
586 
IsAllowScale()587     bool IsAllowScale() const
588     {
589         return allowScale_;
590     }
591 
SetAllowScale(bool allowScale)592     void SetAllowScale(bool allowScale)
593     {
594         allowScale_ = allowScale;
595     }
596 
GetOptionInterval()597     const Dimension& GetOptionInterval() const
598     {
599         return optionInterval_;
600     }
601 
GetOptionMinHeight()602     const Dimension& GetOptionMinHeight() const
603     {
604         return optionMinHeight_;
605     }
606 
GetTvFocusTextColor()607     const Color& GetTvFocusTextColor() const
608     {
609         return tvFocusTextColor_;
610     }
611 
GetTvNormalBackColor()612     const Color& GetTvNormalBackColor() const
613     {
614         return tvNormalBackColor_;
615     }
616 
GetTvBackColor()617     const Color& GetTvBackColor() const
618     {
619         return tvBackColor_;
620     }
621 
GetFocusedDisableColor()622     const Color& GetFocusedDisableColor() const
623     {
624         return focusedDisableColor_;
625     }
626 
GetNormalDisableColor()627     const Color& GetNormalDisableColor() const
628     {
629         return normalDisableColor_;
630     }
631 
GetFocusedTextDisableColor()632     const Color& GetFocusedTextDisableColor() const
633     {
634         return focusedTextDisableColor_;
635     }
636 
GetNormalTextDisableColor()637     const Color& GetNormalTextDisableColor() const
638     {
639         return normalTextDisableColor_;
640     }
641 
GetSpinnerColor()642     const Color& GetSpinnerColor() const
643     {
644         return spinnerColor_;
645     }
646 
GetDisabledSpinnerColor()647     const Color& GetDisabledSpinnerColor() const
648     {
649         return disabledSpinnerColor_;
650     }
651 
GetMenuIconColor()652     const Color& GetMenuIconColor() const
653     {
654         return menuIconColor_;
655     }
656 
GetLineColor()657     const Color& GetLineColor() const
658     {
659         return lineColor_;
660     }
661 
GetOptionTextStyle()662     const TextStyle& GetOptionTextStyle() const
663     {
664         return optionTextStyle_;
665     }
666 
GetSelectBorderRadius()667     const Dimension& GetSelectBorderRadius() const
668     {
669         return selectBorderRadius_;
670     }
671 
GetMenuBorderRadius()672     const Dimension& GetMenuBorderRadius() const
673     {
674         return menuBorderRadius_;
675     }
676 
GetInnerBorderRadius()677     const Dimension& GetInnerBorderRadius() const
678     {
679         return innerBorderRadius_;
680     }
681 
GetMenuFontSize()682     const Dimension& GetMenuFontSize() const
683     {
684         return menuFontSize_;
685     }
686 
GetMenuTitleFontSize()687     const Dimension& GetMenuTitleFontSize() const
688     {
689         return menuTitleFontSize_;
690     }
691 
GetMenuTitleFontColor()692     const Color& GetMenuTitleFontColor() const
693     {
694         return menuTitleFontColor_;
695     }
696 
GetMenuTitleHeight()697     const Dimension& GetMenuTitleHeight() const
698     {
699         return menuTitleHeight_;
700     }
701 
GetMenuFontColor()702     const Color& GetMenuFontColor() const
703     {
704         return menuFontColor_;
705     }
706 
GetDisabledMenuFontColor()707     const Color& GetDisabledMenuFontColor() const
708     {
709         return disabledMenuFontColor_;
710     }
SetDisabledMenuFontColor(const Color & value)711     void SetDisabledMenuFontColor(const Color& value)
712     {
713         disabledMenuFontColor_ = value;
714     }
715 
GetMenuIconPadding()716     const Dimension& GetMenuIconPadding() const
717     {
718         return menuIconPadding_;
719     }
720 
GetIconContentPadding()721     const Dimension& GetIconContentPadding() const
722     {
723         return iconContentPadding_;
724     }
725 
GetDividerPaddingVertical()726     const Dimension& GetDividerPaddingVertical() const
727     {
728         return dividerPaddingVertical_;
729     }
730 
GetSelectMenuPadding()731     const Dimension& GetSelectMenuPadding() const
732     {
733         return selectMenuPadding_;
734     }
735 
GetOutPadding()736     const Dimension& GetOutPadding() const
737     {
738         return outPadding_;
739     }
740 
GetDefaultPaddingStart()741     const Dimension& GetDefaultPaddingStart() const
742     {
743         return defaultPaddingStart_;
744     }
745 
GetDefaultPaddingEnd()746     const Dimension& GetDefaultPaddingEnd() const
747     {
748         return defaultPaddingEnd_;
749     }
750 
GetDefaultPaddingTop()751     const Dimension& GetDefaultPaddingTop() const
752     {
753         return defaultPaddingTop_;
754     }
755 
GetDefaultPaddingBottomFixed()756     const Dimension& GetDefaultPaddingBottomFixed() const
757     {
758         return defaultPaddingBottomFixed_;
759     }
760 
GetContentSpinnerPadding()761     const Dimension& GetContentSpinnerPadding() const
762     {
763         return contentSpinnerPadding_;
764     }
765 
GetMenuAnimationOffset()766     const Dimension& GetMenuAnimationOffset() const
767     {
768         return menuAnimationOffset_;
769     }
770 
GetSpinnerWidth()771     const Dimension& GetSpinnerWidth() const
772     {
773         return spinnerWidth_;
774     }
775 
GetSpinnerHeight()776     const Dimension& GetSpinnerHeight() const
777     {
778         return spinnerHeight_;
779     }
780 
GetDefaultDividerWidth()781     const Dimension& GetDefaultDividerWidth() const
782     {
783         return defaultDividerWidth_;
784     }
785 
GetSelectMinWidth()786     const Dimension& GetSelectMinWidth() const
787     {
788         return selectMinWidth_;
789     }
790 
GetSelectDefaultHeight()791     const Dimension& GetSelectDefaultHeight() const
792     {
793         return selectDefaultHeight_;
794     }
795 
GetIconSideLength()796     const Dimension& GetIconSideLength() const
797     {
798         return iconSideLength_;
799     }
800 
GetEndIconWidth()801     const Dimension& GetEndIconWidth() const
802     {
803         return endIconWidth_;
804     }
805 
GetEndIconHeight()806     const Dimension& GetEndIconHeight() const
807     {
808         return endIconHeight_;
809     }
810 
GetContentMargin()811     const Dimension& GetContentMargin() const
812     {
813         return contentMargin_;
814     }
815 
816 private:
817     Color disabledColor_;
818     Color clickedColor_;
819     Color selectedColor_;
820 
821     Color backgroundColor_ = Color::WHITE;
822     Color disabledBackgroundColor_;
823     Color hoverColor_ = Color(0x0c000000);
824     Color selectedColorText_ = Color(0xff0a59f7);
825     Color lineColor_ = Color(0x33000000);
826     Color spinnerColor_ = Color(0xE5182431);
827     Color disabledSpinnerColor_;
828     Color menuIconColor_ = Color(0x99182431);
829     Color menuFontColor_;
830     Color disabledMenuFontColor_;
831     Color menuTitleFontColor_;
832 
833     bool allowScale_ = true;
834     Dimension fontSize_;
835     Color fontColor_;
836     Color disabledFontColor_;
837     Color secondaryFontColor_;
838     std::string fontFamily_;
839     FontWeight fontWeight_ { FontWeight::NORMAL };
840     TextDecoration textDecoration_ { TextDecoration::NONE };
841 
842     std::size_t optionSize_ { 0 };
843     Dimension rrectSize_;
844     Dimension iconSize_;
845     Dimension normalPadding_;
846 
847     Dimension popupRRectSize_;
848     Dimension popupBorderWidth_;
849     Dimension popupShadowWidth_;
850     Dimension popupMinWidth_;
851 
852     Dimension titleLeftPadding_;
853     Dimension titleTopPadding_;
854     Dimension titleRightPadding_;
855     Dimension titleBottomPadding_;
856     Dimension horizontalSpacing_;
857     Dimension verticalSpacing_;
858     Dimension contentSpacing_;
859     Dimension optionInterval_;
860     Dimension optionMinHeight_;
861 
862     Dimension selectBorderRadius_;
863     Dimension menuBorderRadius_;
864     Dimension innerBorderRadius_;
865     Dimension menuFontSize_;
866     Dimension menuTitleFontSize_;
867     Dimension menuTitleHeight_;
868     Dimension menuIconPadding_;
869     Dimension iconContentPadding_;
870     Dimension dividerPaddingVertical_;
871 
872     Dimension selectMenuPadding_;
873     Dimension outPadding_;
874     Dimension defaultPaddingStart_;
875     Dimension defaultPaddingEnd_;
876     Dimension defaultPaddingTop_;
877     Dimension defaultPaddingBottomFixed_;
878     Dimension contentSpinnerPadding_;
879     Dimension menuAnimationOffset_;
880     Dimension spinnerWidth_;
881     Dimension spinnerHeight_;
882     Dimension defaultDividerWidth_;
883 
884     Dimension selectMinWidth_;
885     Dimension selectDefaultHeight_;
886     Dimension iconSideLength_;
887     Dimension endIconWidth_;
888     Dimension endIconHeight_;
889     Dimension contentMargin_;
890 
891     Color tvFocusTextColor_;
892     Color tvNormalBackColor_;
893     Color tvBackColor_;
894 
895     Color focusedDisableColor_;
896     Color normalDisableColor_;
897     Color focusedTextDisableColor_;
898     Color normalTextDisableColor_;
899 
900     TextStyle titleStyle_;
901     TextStyle optionTextStyle_;
902     bool isTV_ = false;
903     uint32_t menuShowTime_ = 0;
904     uint32_t selectShowTime_ = 0;
905     uint32_t menuHideTime_ = 0;
906     uint32_t selectHideTime_ = 0;
907     int32_t hoverAnimationDuration_ = 0;
908     int32_t pressAnimationDuration_ = 0;
909 
910     Edge optionPadding_;
911 };
912 
913 } // namespace OHOS::Ace
914 
915 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SELECT_SELECT_THEME_H
916