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_BUTTON_BUTTON_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUTTON_BUTTON_THEME_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components/common/properties/text_style.h" 21 #include "core/components/theme/theme.h" 22 #include "core/components/theme/theme_constants.h" 23 #include "core/components/theme/theme_constants_defines.h" 24 25 namespace OHOS::Ace { 26 27 /** 28 * ButtonTheme defines color and styles of ButtonComponent. ButtonTheme should be built 29 * using ButtonTheme::Builder. 30 */ 31 class ButtonTheme : public virtual Theme { 32 DECLARE_ACE_TYPE(ButtonTheme, Theme); 33 34 public: 35 class Builder { 36 public: 37 Builder() = default; 38 ~Builder() = default; 39 Build(const RefPtr<ThemeConstants> & themeConstants)40 RefPtr<ButtonTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 41 { 42 RefPtr<ButtonTheme> theme = AceType::Claim(new ButtonTheme()); 43 if (!themeConstants) { 44 return theme; 45 } 46 ParsePattern(themeConstants, theme); 47 return theme; 48 } 49 50 private: ParsePattern(const RefPtr<ThemeConstants> & themeConstants,const RefPtr<ButtonTheme> & theme)51 void ParsePattern(const RefPtr<ThemeConstants>& themeConstants, const RefPtr<ButtonTheme>& theme) const 52 { 53 if (!themeConstants) { 54 return; 55 } 56 RefPtr<ThemeStyle> buttonPattern = themeConstants->GetPatternByName(THEME_PATTERN_BUTTON); 57 if (!buttonPattern) { 58 LOGW("find pattern of button fail"); 59 return; 60 } 61 theme->bgColor_ = buttonPattern->GetAttr<Color>("button_bg_color", Color()); 62 theme->roleWarningColor_ = buttonPattern->GetAttr<Color>("role_warning", Color()); 63 theme->clickedColor_ = buttonPattern->GetAttr<Color>("bg_color_clicked_blend", Color()); 64 theme->disabledColor_ = 65 theme->bgColor_.BlendOpacity(buttonPattern->GetAttr<double>(PATTERN_BG_COLOR_DISABLED_ALPHA, 0.0)); 66 theme->hoverColor_ = buttonPattern->GetAttr<Color>("bg_color_hovered_blend", Color()); 67 theme->borderColor_ = buttonPattern->GetAttr<Color>("border_color", Color()); 68 theme->borderWidth_ = buttonPattern->GetAttr<Dimension>("border_width", 0.0_vp); 69 theme->textStyle_.SetTextColor(buttonPattern->GetAttr<Color>("button_text_color", Color())); 70 theme->textDisabledColor_ = 71 buttonPattern->GetAttr<Color>(PATTERN_TEXT_COLOR, Color()) 72 .BlendOpacity(buttonPattern->GetAttr<double>("text_color_disabled_alpha", 0.0)); 73 theme->textWaitingColor_ = buttonPattern->GetAttr<Color>("waiting_button_text_color", Color()); 74 theme->normalTextColor_ = buttonPattern->GetAttr<Color>("normal_text_color", Color()); 75 theme->downloadBackgroundColor_ = 76 buttonPattern->GetAttr<Color>("download_button_bg_color", Color()) 77 .BlendOpacity(buttonPattern->GetAttr<double>("download_button_bg_color_alpha", 0.0)); 78 theme->downloadBorderColor_ = 79 buttonPattern->GetAttr<Color>("download_button_border_color", Color()) 80 .BlendOpacity(buttonPattern->GetAttr<double>("download_button_border_color_alpha", 0.0)); 81 theme->downloadProgressColor_ = 82 buttonPattern->GetAttr<Color>("download_button_process_color", Color()) 83 .BlendOpacity(buttonPattern->GetAttr<double>("download_button_process_color_alpha", 0.0)); 84 theme->downloadTextColor_ = buttonPattern->GetAttr<Color>("download_button_text_color", Color()); 85 theme->progressColor_ = buttonPattern->GetAttr<Color>("process_button_text_color", Color()); 86 theme->radius_ = buttonPattern->GetAttr<Dimension>("button_radius", 0.0_vp); 87 theme->bgFocusColor_ = buttonPattern->GetAttr<Color>("button_bg_focus_color", Color()); 88 theme->bgDisabledAlpha_ = buttonPattern->GetAttr<double>("bg_color_disabled_alpha", 0.0); 89 theme->textFocusColor_ = buttonPattern->GetAttr<Color>("button_text_focus_color", Color()); 90 theme->textStyle_.SetFontSize(buttonPattern->GetAttr<Dimension>("button_font_size", 0.0_fp)); 91 theme->textStyle_.SetFontWeight( 92 FontWeight(static_cast<int32_t>(buttonPattern->GetAttr<double>("button_font_weight", 0.0)))); 93 theme->minWidth_ = buttonPattern->GetAttr<Dimension>("button_min_width", 0.0_vp); 94 theme->height_ = buttonPattern->GetAttr<Dimension>("button_height", 0.0_vp); 95 theme->downloadHeight_ = buttonPattern->GetAttr<Dimension>("button_download_height", 0.0_vp); 96 theme->padding_ = Edge(buttonPattern->GetAttr<Dimension>("button_horizontal_padding", 0.0_vp).Value(), 97 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Value(), 98 buttonPattern->GetAttr<Dimension>("button_horizontal_padding", 0.0_vp).Value(), 99 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Value(), 100 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Unit()); 101 theme->minFontSize_ = buttonPattern->GetAttr<Dimension>("button_min_font_size", 0.0_fp); 102 ParseAdditionalStylePattern(buttonPattern, theme); 103 } ParseAdditionalStylePattern(const RefPtr<ThemeStyle> & buttonPattern,const RefPtr<ButtonTheme> & theme)104 void ParseAdditionalStylePattern( 105 const RefPtr<ThemeStyle>& buttonPattern, const RefPtr<ButtonTheme>& theme) const 106 { 107 int32_t maxlines = static_cast<int32_t>(buttonPattern->GetAttr<double>("button_text_max_lines", 0.0)); 108 theme->textMaxLines_ = maxlines < 0 ? theme->textMaxLines_ : static_cast<uint32_t>(maxlines); 109 theme->minCircleButtonDiameter_ = buttonPattern->GetAttr<Dimension>("min_circle_button_diameter", 0.0_vp); 110 theme->minCircleButtonIcon_ = buttonPattern->GetAttr<Dimension>("min_circle_button_icon_size", 0.0_vp); 111 theme->minCircleButtonPadding_ = 112 Edge(buttonPattern->GetAttr<Dimension>("min_circle_button_padding", 0.0_vp)); 113 theme->maxCircleButtonDiameter_ = buttonPattern->GetAttr<Dimension>("max_circle_button_diameter", 0.0_vp); 114 theme->maxCircleButtonIcon_ = buttonPattern->GetAttr<Dimension>("max_circle_button_icon_size", 0.0_vp); 115 theme->maxCircleButtonPadding_ = 116 Edge(buttonPattern->GetAttr<Dimension>("button_max_circle_button_padding", 0.0_vp)); 117 theme->progressFocusColor_ = buttonPattern->GetAttr<Color>("button_progress_focus_color", Color()); 118 theme->downloadFontSize_ = buttonPattern->GetAttr<Dimension>("button_download_font_size", 0.0_fp); 119 theme->progressDiameter_ = buttonPattern->GetAttr<Dimension>("button_progress_diameter", 0.0_vp); 120 theme->innerPadding_ = buttonPattern->GetAttr<Dimension>("button_inner_padding", 0.0_vp); 121 theme->borderWidthSmall_ = buttonPattern->GetAttr<Dimension>("width_border_small", 0.0_vp); 122 theme->borderColorSmall_ = buttonPattern->GetAttr<Color>("color_border_small", Color()); 123 theme->shadowNormal_ = static_cast<uint32_t>(buttonPattern->GetAttr<double>("shadow_default", 0.0)); 124 theme->shadowFocus_ = static_cast<uint32_t>(buttonPattern->GetAttr<double>("shadow_focus", 0.0)); 125 theme->scaleHoverOrFocus_ = buttonPattern->GetAttr<double>("scale_focus", 0.0); 126 theme->paddingText_ = buttonPattern->GetAttr<Dimension>("padding_text", 0.0_vp); 127 theme->textBackgroundFocus_ = buttonPattern->GetAttr<Color>("focus_bg_text", Color()); 128 theme->normalBackgroundFocus_ = buttonPattern->GetAttr<Color>("normal_button_focus_bgcolor", Color()); 129 theme->emphasizeBackgroundFocus_ = buttonPattern->GetAttr<Color>("emphasize_focus_color", Color()); 130 theme->bigFontSizeScale_ = buttonPattern->GetAttr<double>("button_aging_big_font_size_scale", 0.0); 131 theme->largeFontSizeScale_ = buttonPattern->GetAttr<double>("button_aging_large_font_size_scale", 0.0); 132 theme->maxFontSizeScale_ = buttonPattern->GetAttr<double>("button_aging_max_font_size_scale", 0.0); 133 theme->agingNormalPadding_ = buttonPattern->GetAttr<Dimension>("button_aging_normal_padding", 0.0_vp); 134 theme->agingSmallPadding_ = buttonPattern->GetAttr<Dimension>("button_aging_small_padding", 0.0_vp); 135 theme->agingTextMaxLines_ = 136 static_cast<uint32_t>(buttonPattern->GetAttr<double>("button_aging_text_max_lines", 0.0)); 137 theme->textButtonFontSize_ = buttonPattern->GetAttr<Dimension>("text_button_font_size", 0.0_fp); 138 theme->isApplyFontSize_ = 139 static_cast<bool>(buttonPattern->GetAttr<double>("apply_text_font_size", 0.0)); 140 ParseSubStylePattern(buttonPattern, theme); 141 } 142 ParseSubStylePattern(const RefPtr<ThemeStyle> & buttonPattern,const RefPtr<ButtonTheme> & theme)143 void ParseSubStylePattern(const RefPtr<ThemeStyle>& buttonPattern, const RefPtr<ButtonTheme>& theme) const 144 { 145 std::unordered_map<ButtonStyleMode, Color> normalBgColorMap_ = { { ButtonStyleMode::EMPHASIZE, 146 theme->bgColor_ }, 147 { ButtonStyleMode::NORMAL, buttonPattern->GetAttr<Color>("bg_color_normal", Color()) }, 148 { ButtonStyleMode::TEXT, Color::TRANSPARENT } }; 149 std::unordered_map<ButtonStyleMode, Color> errorBgColorMap_ = { { ButtonStyleMode::EMPHASIZE, 150 theme->roleWarningColor_ }, 151 { ButtonStyleMode::NORMAL, buttonPattern->GetAttr<Color>("bg_color_normal", Color()) }, 152 { ButtonStyleMode::TEXT, Color::TRANSPARENT } }; 153 theme->bgColorMap_.emplace(ButtonRole::NORMAL, normalBgColorMap_); 154 theme->bgColorMap_.emplace(ButtonRole::ERROR, errorBgColorMap_); 155 theme->textColorMap_.insert(std::pair<ButtonStyleMode, Color>( 156 ButtonStyleMode::EMPHASIZE, buttonPattern->GetAttr<Color>("emphasize_button_text_color", Color()))); 157 theme->textColorMap_.insert( 158 std::pair<ButtonStyleMode, Color>(ButtonStyleMode::NORMAL, theme->normalTextColor_)); 159 theme->textColorMap_.insert(std::pair<ButtonStyleMode, Color>( 160 ButtonStyleMode::TEXT, buttonPattern->GetAttr<Color>("text_button_text_color", Color()))); 161 theme->focusTextColorMap_.insert(std::pair<ButtonStyleMode, Color>( 162 ButtonStyleMode::NORMAL, buttonPattern->GetAttr<Color>("normal_button_text_focus_color", Color()))); 163 theme->focusTextColorMap_.insert(std::pair<ButtonStyleMode, Color>( 164 ButtonStyleMode::TEXT, buttonPattern->GetAttr<Color>("text_button_text_focus_color", Color()))); 165 theme->textColorByRoleMap_.insert( 166 std::pair<ButtonRole, Color>(ButtonRole::NORMAL, theme->normalTextColor_)); 167 theme->textColorByRoleMap_.insert( 168 std::pair<ButtonRole, Color>(ButtonRole::ERROR, theme->roleWarningColor_)); 169 theme->heightMap_.insert(std::pair<ControlSize, Dimension>(ControlSize::NORMAL, theme->height_)); 170 theme->heightMap_.insert(std::pair<ControlSize, Dimension>( 171 ControlSize::SMALL, buttonPattern->GetAttr<Dimension>("small_button_height", 0.0_vp))); 172 173 theme->textSizeMap_.insert(std::pair<ControlSize, Dimension>( 174 ControlSize::NORMAL, buttonPattern->GetAttr<Dimension>("button_font_size", 0.0_fp))); 175 theme->textSizeMap_.insert(std::pair<ControlSize, Dimension>( 176 ControlSize::SMALL, buttonPattern->GetAttr<Dimension>("small_button_font_size", 0.0_fp))); 177 178 theme->paddingMap_.insert(std::pair<ControlSize, Edge>(ControlSize::NORMAL, theme->padding_)); 179 theme->paddingMap_.insert(std::pair<ControlSize, Edge>(ControlSize::SMALL, 180 Edge(buttonPattern->GetAttr<Dimension>("small_button_horizontal_padding", 0.0_vp).Value(), 181 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Value(), 182 buttonPattern->GetAttr<Dimension>("small_button_horizontal_padding", 0.0_vp).Value(), 183 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Value(), 184 buttonPattern->GetAttr<Dimension>("button_vertical_padding", 0.0_vp).Unit()))); 185 theme->borderRadiusMap_.insert(std::pair<ControlSize, Dimension>( 186 ControlSize::NORMAL, buttonPattern->GetAttr<Dimension>("button_border_radius_normal", 20.0_vp))); 187 theme->borderRadiusMap_.insert(std::pair<ControlSize, Dimension>( 188 ControlSize::SMALL, buttonPattern->GetAttr<Dimension>("button_border_radius_small", 14.0_vp))); 189 } 190 }; 191 192 ~ButtonTheme() override = default; 193 GetRadius()194 const Dimension& GetRadius() const 195 { 196 return radius_; 197 } 198 GetBgColor()199 const Color& GetBgColor() const 200 { 201 return bgColor_; 202 } 203 GetBgFocusColor()204 const Color& GetBgFocusColor() const 205 { 206 return bgFocusColor_; 207 } 208 GetClickedColor()209 const Color& GetClickedColor() const 210 { 211 return clickedColor_; 212 } 213 GetDisabledColor()214 const Color& GetDisabledColor() const 215 { 216 return disabledColor_; 217 } 218 GetHoverColor()219 const Color& GetHoverColor() const 220 { 221 return hoverColor_; 222 } 223 GetBorderColor()224 const Color& GetBorderColor() const 225 { 226 return borderColor_; 227 } 228 GetBorderWidth()229 const Dimension& GetBorderWidth() const 230 { 231 return borderWidth_; 232 } 233 GetBgDisabledAlpha()234 double GetBgDisabledAlpha() const 235 { 236 return bgDisabledAlpha_; 237 } 238 GetTextFocusColor()239 const Color& GetTextFocusColor() const 240 { 241 return textFocusColor_; 242 } 243 GetTextDisabledColor()244 const Color& GetTextDisabledColor() const 245 { 246 return textDisabledColor_; 247 } 248 GetNormalTextColor()249 const Color& GetNormalTextColor() const 250 { 251 return normalTextColor_; 252 } 253 GetDownloadBackgroundColor()254 const Color& GetDownloadBackgroundColor() const 255 { 256 return downloadBackgroundColor_; 257 } 258 GetDownloadTextColor()259 const Color& GetDownloadTextColor() const 260 { 261 return downloadTextColor_; 262 } 263 GetTextWaitingColor()264 const Color& GetTextWaitingColor() const 265 { 266 return textWaitingColor_; 267 } 268 GetTextStyle()269 const TextStyle& GetTextStyle() const 270 { 271 return textStyle_; 272 } 273 GetMinWidth()274 const Dimension& GetMinWidth() const 275 { 276 return minWidth_; 277 } 278 GetHeight()279 const Dimension& GetHeight() const 280 { 281 return height_; 282 } 283 GetDownloadHeight()284 const Dimension& GetDownloadHeight() const 285 { 286 return downloadHeight_; 287 } 288 GetPadding()289 const Edge& GetPadding() const 290 { 291 return padding_; 292 } 293 GetMinFontSize()294 const Dimension& GetMinFontSize() const 295 { 296 return minFontSize_; 297 } 298 GetDownloadFontSize()299 const Dimension& GetDownloadFontSize() const 300 { 301 return downloadFontSize_; 302 } 303 GetMaxFontSize()304 const Dimension& GetMaxFontSize() const 305 { 306 return textStyle_.GetFontSize(); 307 } 308 GetTextMaxLines()309 uint32_t GetTextMaxLines() const 310 { 311 return textMaxLines_; 312 } 313 GetShadowNormal()314 uint32_t GetShadowNormal() const 315 { 316 return shadowNormal_; 317 } 318 GetShadowFocus()319 uint32_t GetShadowFocus() const 320 { 321 return shadowFocus_; 322 } 323 GetScaleHoverOrFocus()324 double GetScaleHoverOrFocus() const 325 { 326 return scaleHoverOrFocus_; 327 } 328 GetMinCircleButtonDiameter()329 const Dimension& GetMinCircleButtonDiameter() const 330 { 331 return minCircleButtonDiameter_; 332 } 333 GetMinCircleButtonIcon()334 const Dimension& GetMinCircleButtonIcon() const 335 { 336 return minCircleButtonIcon_; 337 } 338 GetMinCircleButtonPadding()339 const Edge& GetMinCircleButtonPadding() const 340 { 341 return minCircleButtonPadding_; 342 } 343 GetMaxCircleButtonDiameter()344 const Dimension& GetMaxCircleButtonDiameter() const 345 { 346 return maxCircleButtonDiameter_; 347 } 348 GetMaxCircleButtonIcon()349 const Dimension& GetMaxCircleButtonIcon() const 350 { 351 return maxCircleButtonIcon_; 352 } 353 GetMaxCircleButtonPadding()354 const Edge& GetMaxCircleButtonPadding() const 355 { 356 return maxCircleButtonPadding_; 357 } 358 GetProgressFocusColor()359 const Color& GetProgressFocusColor() const 360 { 361 return progressFocusColor_; 362 } 363 GetDownloadBorderColor()364 const Color& GetDownloadBorderColor() const 365 { 366 return downloadBorderColor_; 367 } 368 GetProgressColor()369 const Color& GetProgressColor() const 370 { 371 return progressColor_; 372 } 373 GetProgressDiameter()374 const Dimension& GetProgressDiameter() const 375 { 376 return progressDiameter_; 377 } 378 GetDownloadProgressColor()379 const Color& GetDownloadProgressColor() const 380 { 381 return downloadProgressColor_; 382 } 383 GetInnerPadding()384 const Dimension& GetInnerPadding() const 385 { 386 return innerPadding_; 387 } 388 GetBgColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)389 Color GetBgColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 390 { 391 auto bgColorMapByRole_ = bgColorMap_.find(buttonRole); 392 if (bgColorMapByRole_ != bgColorMap_.end()) { 393 std::unordered_map<ButtonStyleMode, Color> bgColorMapByStyle_ = bgColorMapByRole_->second; 394 auto result = bgColorMapByStyle_.find(buttonStyle); 395 if (result != bgColorMapByStyle_.end()) { 396 return result->second; 397 } 398 } 399 return bgColor_; 400 } 401 GetTextColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)402 const Color& GetTextColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 403 { 404 auto roleResult = textColorByRoleMap_.find(buttonRole); 405 auto result = textColorMap_.find(buttonStyle); 406 if (roleResult != textColorByRoleMap_.end() && result != textColorMap_.end()) { 407 if (buttonRole == ButtonRole::ERROR) { 408 if (buttonStyle == ButtonStyleMode::EMPHASIZE) { 409 return result->second; 410 } 411 return roleResult->second; 412 } 413 return result->second; 414 } 415 return normalTextColor_; 416 } 417 GetFocusTextColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)418 const Color& GetFocusTextColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 419 { 420 auto roleResult = textColorByRoleMap_.find(buttonRole); 421 auto result = focusTextColorMap_.find(buttonStyle); 422 if (roleResult == textColorByRoleMap_.end() || result == focusTextColorMap_.end()) { 423 return normalTextColor_; 424 } 425 if (buttonRole == ButtonRole::ERROR && buttonStyle != ButtonStyleMode::EMPHASIZE) { 426 return roleResult->second; 427 } 428 return result->second; 429 } 430 GetHeight(ControlSize controlSize)431 const Dimension& GetHeight(ControlSize controlSize) const 432 { 433 auto result = heightMap_.find(controlSize); 434 if (result != heightMap_.end()) { 435 return result->second; 436 } 437 return height_; 438 } 439 GetBorderRadius(ControlSize controlSize)440 const Dimension& GetBorderRadius(ControlSize controlSize) const 441 { 442 auto result = borderRadiusMap_.find(controlSize); 443 if (result != borderRadiusMap_.end()) { 444 return result->second; 445 } 446 return borderRadius_; 447 } 448 GetTextSize(ControlSize controlSize)449 const Dimension& GetTextSize(ControlSize controlSize) const 450 { 451 auto result = textSizeMap_.find(controlSize); 452 if (result != textSizeMap_.end()) { 453 return result->second; 454 } 455 return textStyle_.GetFontSize(); 456 } 457 GetPadding(ControlSize controlSize)458 const Edge& GetPadding(ControlSize controlSize) const 459 { 460 auto result = paddingMap_.find(controlSize); 461 if (result != paddingMap_.end()) { 462 return result->second; 463 } 464 return padding_; 465 } 466 GetBorderWidthSmall()467 const Dimension& GetBorderWidthSmall() const 468 { 469 return borderWidthSmall_; 470 } 471 GetPaddingText()472 const Dimension& GetPaddingText() const 473 { 474 return paddingText_; 475 } 476 GetBorderColorSmall()477 const Color& GetBorderColorSmall() const 478 { 479 return borderColorSmall_; 480 } 481 GetTextBackgroundFocus()482 const Color& GetTextBackgroundFocus() const 483 { 484 return textBackgroundFocus_; 485 } 486 GetNormalBackgroundFocus()487 const Color& GetNormalBackgroundFocus() const 488 { 489 return normalBackgroundFocus_; 490 } 491 GetEmphasizeBackgroundFocus()492 const Color& GetEmphasizeBackgroundFocus() const 493 { 494 return emphasizeBackgroundFocus_; 495 } 496 GetBigFontSizeScale()497 float GetBigFontSizeScale() const 498 { 499 return bigFontSizeScale_; 500 } 501 GetLargeFontSizeScale()502 float GetLargeFontSizeScale() const 503 { 504 return largeFontSizeScale_; 505 } 506 GetMaxFontSizeScale()507 float GetMaxFontSizeScale() const 508 { 509 return maxFontSizeScale_; 510 } 511 GetAgingNormalPadding()512 const Dimension& GetAgingNormalPadding() const 513 { 514 return agingNormalPadding_; 515 } 516 GetAgingSmallPadding()517 const Dimension& GetAgingSmallPadding() const 518 { 519 return agingSmallPadding_; 520 } 521 GetAgingTextMaxLines()522 uint32_t GetAgingTextMaxLines() const 523 { 524 return agingTextMaxLines_; 525 } 526 GetTextButtonFontSize()527 const Dimension& GetTextButtonFontSize() const 528 { 529 return textButtonFontSize_; 530 } 531 GetIsApplyTextFontSize()532 bool GetIsApplyTextFontSize() const 533 { 534 return isApplyFontSize_; 535 } 536 537 protected: 538 ButtonTheme() = default; 539 540 private: 541 Color bgColor_; 542 Color roleWarningColor_; 543 Color bgFocusColor_; 544 Color clickedColor_; 545 Color disabledColor_; 546 Color hoverColor_; 547 Color borderColor_; 548 Color textFocusColor_; 549 Color textDisabledColor_; 550 Color textWaitingColor_; 551 Color progressColor_; 552 Color progressFocusColor_; 553 Color normalTextColor_; 554 Color downloadBackgroundColor_; 555 Color downloadTextColor_; 556 Color downloadBorderColor_; 557 Color downloadProgressColor_; 558 Color focusBorderColor_; 559 Color borderColorSmall_; 560 Color textBackgroundFocus_; 561 Color normalBackgroundFocus_; 562 Color emphasizeBackgroundFocus_; 563 TextStyle textStyle_; 564 Edge padding_; 565 Edge minCircleButtonPadding_; 566 Edge maxCircleButtonPadding_; 567 568 Dimension radius_; 569 Dimension minWidth_; 570 Dimension height_; 571 Dimension progressDiameter_; 572 Dimension innerPadding_; 573 Dimension minFontSize_; 574 Dimension downloadFontSize_; 575 Dimension minCircleButtonDiameter_; 576 Dimension minCircleButtonIcon_; 577 Dimension maxCircleButtonDiameter_; 578 Dimension maxCircleButtonIcon_; 579 Dimension borderWidth_; 580 Dimension downloadHeight_; 581 Dimension borderRadius_; 582 Dimension focusBorderWidth_; 583 Dimension borderWidthSmall_; 584 Dimension paddingText_; 585 Dimension textButtonFontSize_; 586 std::unordered_map<ButtonRole, std::unordered_map<ButtonStyleMode, Color>> bgColorMap_; 587 std::unordered_map<ButtonStyleMode, Color> focusTextColorMap_; 588 std::unordered_map<ButtonRole, Color> textColorByRoleMap_; 589 std::unordered_map<ButtonStyleMode, Color> textColorMap_; 590 std::unordered_map<ControlSize, Dimension> heightMap_; 591 std::unordered_map<ControlSize, Dimension> textSizeMap_; 592 std::unordered_map<ControlSize, Edge> paddingMap_; 593 std::unordered_map<ControlSize, Dimension> borderRadiusMap_; 594 double bgDisabledAlpha_ = 1.0; 595 double scaleHoverOrFocus_ = 1.0; 596 uint32_t textMaxLines_ = 1; 597 uint32_t shadowNormal_ = 0; 598 uint32_t shadowFocus_ = 0; 599 float bigFontSizeScale_ = 1.75f; 600 float largeFontSizeScale_ = 2.0f; 601 float maxFontSizeScale_ = 3.2f; 602 Dimension agingNormalPadding_; 603 Dimension agingSmallPadding_; 604 uint32_t agingTextMaxLines_ = 2; 605 bool isApplyFontSize_ = false; 606 }; 607 608 } // namespace OHOS::Ace 609 610 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUTTON_BUTTON_THEME_H 611