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::MakeRefPtr<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 theme->pasteText_ = buttonPattern->GetAttr<std::string>("textoverlay_paste", ""); 190 theme->cancelText_ = buttonPattern->GetAttr<std::string>("common_cancel_text", ""); 191 } 192 }; 193 194 ~ButtonTheme() override = default; 195 GetRadius()196 const Dimension& GetRadius() const 197 { 198 return radius_; 199 } 200 GetBgColor()201 const Color& GetBgColor() const 202 { 203 return bgColor_; 204 } 205 GetBgFocusColor()206 const Color& GetBgFocusColor() const 207 { 208 return bgFocusColor_; 209 } 210 GetClickedColor()211 const Color& GetClickedColor() const 212 { 213 return clickedColor_; 214 } 215 GetDisabledColor()216 const Color& GetDisabledColor() const 217 { 218 return disabledColor_; 219 } 220 GetHoverColor()221 const Color& GetHoverColor() const 222 { 223 return hoverColor_; 224 } 225 GetBorderColor()226 const Color& GetBorderColor() const 227 { 228 return borderColor_; 229 } 230 GetBorderWidth()231 const Dimension& GetBorderWidth() const 232 { 233 return borderWidth_; 234 } 235 GetBgDisabledAlpha()236 double GetBgDisabledAlpha() const 237 { 238 return bgDisabledAlpha_; 239 } 240 GetTextFocusColor()241 const Color& GetTextFocusColor() const 242 { 243 return textFocusColor_; 244 } 245 GetTextDisabledColor()246 const Color& GetTextDisabledColor() const 247 { 248 return textDisabledColor_; 249 } 250 GetNormalTextColor()251 const Color& GetNormalTextColor() const 252 { 253 return normalTextColor_; 254 } 255 GetDownloadBackgroundColor()256 const Color& GetDownloadBackgroundColor() const 257 { 258 return downloadBackgroundColor_; 259 } 260 GetDownloadTextColor()261 const Color& GetDownloadTextColor() const 262 { 263 return downloadTextColor_; 264 } 265 GetTextWaitingColor()266 const Color& GetTextWaitingColor() const 267 { 268 return textWaitingColor_; 269 } 270 GetTextStyle()271 const TextStyle& GetTextStyle() const 272 { 273 return textStyle_; 274 } 275 GetMinWidth()276 const Dimension& GetMinWidth() const 277 { 278 return minWidth_; 279 } 280 GetHeight()281 const Dimension& GetHeight() const 282 { 283 return height_; 284 } 285 GetDownloadHeight()286 const Dimension& GetDownloadHeight() const 287 { 288 return downloadHeight_; 289 } 290 GetPadding()291 const Edge& GetPadding() const 292 { 293 return padding_; 294 } 295 GetMinFontSize()296 const Dimension& GetMinFontSize() const 297 { 298 return minFontSize_; 299 } 300 GetDownloadFontSize()301 const Dimension& GetDownloadFontSize() const 302 { 303 return downloadFontSize_; 304 } 305 GetMaxFontSize()306 const Dimension& GetMaxFontSize() const 307 { 308 return textStyle_.GetFontSize(); 309 } 310 GetTextMaxLines()311 uint32_t GetTextMaxLines() const 312 { 313 return textMaxLines_; 314 } 315 GetShadowNormal()316 uint32_t GetShadowNormal() const 317 { 318 return shadowNormal_; 319 } 320 GetShadowFocus()321 uint32_t GetShadowFocus() const 322 { 323 return shadowFocus_; 324 } 325 GetScaleHoverOrFocus()326 double GetScaleHoverOrFocus() const 327 { 328 return scaleHoverOrFocus_; 329 } 330 GetMinCircleButtonDiameter()331 const Dimension& GetMinCircleButtonDiameter() const 332 { 333 return minCircleButtonDiameter_; 334 } 335 GetMinCircleButtonIcon()336 const Dimension& GetMinCircleButtonIcon() const 337 { 338 return minCircleButtonIcon_; 339 } 340 GetMinCircleButtonPadding()341 const Edge& GetMinCircleButtonPadding() const 342 { 343 return minCircleButtonPadding_; 344 } 345 GetMaxCircleButtonDiameter()346 const Dimension& GetMaxCircleButtonDiameter() const 347 { 348 return maxCircleButtonDiameter_; 349 } 350 GetMaxCircleButtonIcon()351 const Dimension& GetMaxCircleButtonIcon() const 352 { 353 return maxCircleButtonIcon_; 354 } 355 GetMaxCircleButtonPadding()356 const Edge& GetMaxCircleButtonPadding() const 357 { 358 return maxCircleButtonPadding_; 359 } 360 GetProgressFocusColor()361 const Color& GetProgressFocusColor() const 362 { 363 return progressFocusColor_; 364 } 365 GetDownloadBorderColor()366 const Color& GetDownloadBorderColor() const 367 { 368 return downloadBorderColor_; 369 } 370 GetProgressColor()371 const Color& GetProgressColor() const 372 { 373 return progressColor_; 374 } 375 GetProgressDiameter()376 const Dimension& GetProgressDiameter() const 377 { 378 return progressDiameter_; 379 } 380 GetDownloadProgressColor()381 const Color& GetDownloadProgressColor() const 382 { 383 return downloadProgressColor_; 384 } 385 GetInnerPadding()386 const Dimension& GetInnerPadding() const 387 { 388 return innerPadding_; 389 } 390 GetBgColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)391 Color GetBgColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 392 { 393 auto bgColorMapByRole_ = bgColorMap_.find(buttonRole); 394 if (bgColorMapByRole_ != bgColorMap_.end()) { 395 std::unordered_map<ButtonStyleMode, Color> bgColorMapByStyle_ = bgColorMapByRole_->second; 396 auto result = bgColorMapByStyle_.find(buttonStyle); 397 if (result != bgColorMapByStyle_.end()) { 398 return result->second; 399 } 400 } 401 return bgColor_; 402 } 403 GetTextColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)404 const Color& GetTextColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 405 { 406 auto roleResult = textColorByRoleMap_.find(buttonRole); 407 auto result = textColorMap_.find(buttonStyle); 408 if (roleResult != textColorByRoleMap_.end() && result != textColorMap_.end()) { 409 if (buttonRole == ButtonRole::ERROR) { 410 if (buttonStyle == ButtonStyleMode::EMPHASIZE) { 411 return result->second; 412 } 413 return roleResult->second; 414 } 415 return result->second; 416 } 417 return normalTextColor_; 418 } 419 GetFocusTextColor(ButtonStyleMode buttonStyle,ButtonRole buttonRole)420 const Color& GetFocusTextColor(ButtonStyleMode buttonStyle, ButtonRole buttonRole) const 421 { 422 auto roleResult = textColorByRoleMap_.find(buttonRole); 423 auto result = focusTextColorMap_.find(buttonStyle); 424 if (roleResult == textColorByRoleMap_.end() || result == focusTextColorMap_.end()) { 425 return normalTextColor_; 426 } 427 if (buttonRole == ButtonRole::ERROR && buttonStyle != ButtonStyleMode::EMPHASIZE) { 428 return roleResult->second; 429 } 430 return result->second; 431 } 432 GetHeight(ControlSize controlSize)433 const Dimension& GetHeight(ControlSize controlSize) const 434 { 435 auto result = heightMap_.find(controlSize); 436 if (result != heightMap_.end()) { 437 return result->second; 438 } 439 return height_; 440 } 441 GetBorderRadius(ControlSize controlSize)442 const Dimension& GetBorderRadius(ControlSize controlSize) const 443 { 444 auto result = borderRadiusMap_.find(controlSize); 445 if (result != borderRadiusMap_.end()) { 446 return result->second; 447 } 448 return borderRadius_; 449 } 450 GetTextSize(ControlSize controlSize)451 const Dimension& GetTextSize(ControlSize controlSize) const 452 { 453 auto result = textSizeMap_.find(controlSize); 454 if (result != textSizeMap_.end()) { 455 return result->second; 456 } 457 return textStyle_.GetFontSize(); 458 } 459 GetPadding(ControlSize controlSize)460 const Edge& GetPadding(ControlSize controlSize) const 461 { 462 auto result = paddingMap_.find(controlSize); 463 if (result != paddingMap_.end()) { 464 return result->second; 465 } 466 return padding_; 467 } 468 GetBorderWidthSmall()469 const Dimension& GetBorderWidthSmall() const 470 { 471 return borderWidthSmall_; 472 } 473 GetPaddingText()474 const Dimension& GetPaddingText() const 475 { 476 return paddingText_; 477 } 478 GetBorderColorSmall()479 const Color& GetBorderColorSmall() const 480 { 481 return borderColorSmall_; 482 } 483 GetTextBackgroundFocus()484 const Color& GetTextBackgroundFocus() const 485 { 486 return textBackgroundFocus_; 487 } 488 GetNormalBackgroundFocus()489 const Color& GetNormalBackgroundFocus() const 490 { 491 return normalBackgroundFocus_; 492 } 493 GetEmphasizeBackgroundFocus()494 const Color& GetEmphasizeBackgroundFocus() const 495 { 496 return emphasizeBackgroundFocus_; 497 } 498 GetBigFontSizeScale()499 float GetBigFontSizeScale() const 500 { 501 return bigFontSizeScale_; 502 } 503 GetLargeFontSizeScale()504 float GetLargeFontSizeScale() const 505 { 506 return largeFontSizeScale_; 507 } 508 GetMaxFontSizeScale()509 float GetMaxFontSizeScale() const 510 { 511 return maxFontSizeScale_; 512 } 513 GetAgingNormalPadding()514 const Dimension& GetAgingNormalPadding() const 515 { 516 return agingNormalPadding_; 517 } 518 GetAgingSmallPadding()519 const Dimension& GetAgingSmallPadding() const 520 { 521 return agingSmallPadding_; 522 } 523 GetAgingTextMaxLines()524 uint32_t GetAgingTextMaxLines() const 525 { 526 return agingTextMaxLines_; 527 } 528 GetTextButtonFontSize()529 const Dimension& GetTextButtonFontSize() const 530 { 531 return textButtonFontSize_; 532 } 533 GetIsApplyTextFontSize()534 bool GetIsApplyTextFontSize() const 535 { 536 return isApplyFontSize_; 537 } 538 GetPasteText()539 const std::string& GetPasteText() const 540 { 541 return pasteText_; 542 } 543 GetCancelText()544 const std::string& GetCancelText() const 545 { 546 return cancelText_; 547 } 548 549 protected: 550 ButtonTheme() = default; 551 552 private: 553 Color bgColor_; 554 Color roleWarningColor_; 555 Color bgFocusColor_; 556 Color clickedColor_; 557 Color disabledColor_; 558 Color hoverColor_; 559 Color borderColor_; 560 Color textFocusColor_; 561 Color textDisabledColor_; 562 Color textWaitingColor_; 563 Color progressColor_; 564 Color progressFocusColor_; 565 Color normalTextColor_; 566 Color downloadBackgroundColor_; 567 Color downloadTextColor_; 568 Color downloadBorderColor_; 569 Color downloadProgressColor_; 570 Color focusBorderColor_; 571 Color borderColorSmall_; 572 Color textBackgroundFocus_; 573 Color normalBackgroundFocus_; 574 Color emphasizeBackgroundFocus_; 575 TextStyle textStyle_; 576 Edge padding_; 577 Edge minCircleButtonPadding_; 578 Edge maxCircleButtonPadding_; 579 580 Dimension radius_; 581 Dimension minWidth_; 582 Dimension height_; 583 Dimension progressDiameter_; 584 Dimension innerPadding_; 585 Dimension minFontSize_; 586 Dimension downloadFontSize_; 587 Dimension minCircleButtonDiameter_; 588 Dimension minCircleButtonIcon_; 589 Dimension maxCircleButtonDiameter_; 590 Dimension maxCircleButtonIcon_; 591 Dimension borderWidth_; 592 Dimension downloadHeight_; 593 Dimension borderRadius_; 594 Dimension focusBorderWidth_; 595 Dimension borderWidthSmall_; 596 Dimension paddingText_; 597 Dimension textButtonFontSize_; 598 std::unordered_map<ButtonRole, std::unordered_map<ButtonStyleMode, Color>> bgColorMap_; 599 std::unordered_map<ButtonStyleMode, Color> focusTextColorMap_; 600 std::unordered_map<ButtonRole, Color> textColorByRoleMap_; 601 std::unordered_map<ButtonStyleMode, Color> textColorMap_; 602 std::unordered_map<ControlSize, Dimension> heightMap_; 603 std::unordered_map<ControlSize, Dimension> textSizeMap_; 604 std::unordered_map<ControlSize, Edge> paddingMap_; 605 std::unordered_map<ControlSize, Dimension> borderRadiusMap_; 606 double bgDisabledAlpha_ = 1.0; 607 double scaleHoverOrFocus_ = 1.0; 608 uint32_t textMaxLines_ = 1; 609 uint32_t shadowNormal_ = 0; 610 uint32_t shadowFocus_ = 0; 611 float bigFontSizeScale_ = 1.75f; 612 float largeFontSizeScale_ = 2.0f; 613 float maxFontSizeScale_ = 3.2f; 614 Dimension agingNormalPadding_; 615 Dimension agingSmallPadding_; 616 uint32_t agingTextMaxLines_ = 2; 617 bool isApplyFontSize_ = false; 618 std::string pasteText_; 619 std::string cancelText_; 620 }; 621 622 } // namespace OHOS::Ace 623 624 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUTTON_BUTTON_THEME_H 625