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