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_TEXT_OVERLAY_TEXT_OVERLAY_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_OVERLAY_TEXT_OVERLAY_THEME_H 18 19 #include <unordered_map> 20 #include "base/geometry/dimension.h" 21 #include "core/components/common/properties/border.h" 22 #include "core/components/common/properties/border_edge.h" 23 #include "core/components/common/properties/color.h" 24 #include "core/components/common/properties/edge.h" 25 #include "core/components/common/properties/radius.h" 26 #include "core/components/common/properties/text_style.h" 27 #include "core/components/theme/theme.h" 28 #include "core/components/theme/theme_constants.h" 29 #include "core/components/theme/theme_constants_defines.h" 30 31 namespace OHOS::Ace { 32 33 /** 34 * DialogTheme defines color and styles of PopupComponent. PopupTheme should be built 35 * using DialogTheme::Builder. 36 */ 37 class TextOverlayTheme : public virtual Theme { 38 DECLARE_ACE_TYPE(TextOverlayTheme, Theme); 39 40 public: 41 class Builder { 42 public: 43 Builder() = default; 44 ~Builder() = default; 45 Build(const RefPtr<ThemeConstants> & themeConstants)46 RefPtr<TextOverlayTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 47 { 48 RefPtr<TextOverlayTheme> theme = AceType::MakeRefPtr<TextOverlayTheme>(); 49 if (!themeConstants) { 50 return theme; 51 } 52 ParseThemeConstants(themeConstants, theme); 53 ParsePattern(themeConstants->GetThemeStyle(), theme); 54 ParseMenuPattern(themeConstants->GetThemeStyle(), theme); 55 ParseAIMenu(themeConstants->GetThemeStyle(), theme); 56 ParseAIPreviewMenu(themeConstants->GetThemeStyle(), theme); 57 return theme; 58 } 59 60 protected: ParseThemeConstants(const RefPtr<ThemeConstants> & themeConstants,const RefPtr<TextOverlayTheme> & theme)61 void ParseThemeConstants( 62 const RefPtr<ThemeConstants>& themeConstants, const RefPtr<TextOverlayTheme>& theme) const 63 { 64 theme->moreSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_down"); 65 theme->backSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_up"); 66 theme->cutSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.cut"); 67 theme->copySymbolId_ = themeConstants->GetSymbolByName("sys.symbol.plus_square_on_square"); 68 theme->copyAllSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.checkmark_square_on_square"); 69 theme->pasteSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.plus_square_dashed_on_square"); 70 theme->cameraInputSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.auto_camera"); 71 theme->aiWriteSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.edit_badge_star"); 72 theme->searchSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.magnifyingglass"); 73 theme->translateSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.translate_c2e"); 74 theme->shareSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.share"); 75 theme->aiMenuSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.AI_retouch"); 76 theme->askCeliaSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.AI_retouch"); 77 } 78 ParsePattern(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<TextOverlayTheme> & theme)79 void ParsePattern(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<TextOverlayTheme>& theme) const 80 { 81 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("text_overlay_pattern", nullptr); 82 if (!themeStyle || !theme || !pattern) { 83 return; 84 } 85 const double defaultTertiaryColorAlpha = 0.4; 86 87 theme->menuBorder_ = Border(BorderEdge( 88 pattern->GetAttr<Color>("text_overlay_menu_border_color", Color()), 89 pattern->GetAttr<Dimension>("text_overlay_menu_border_width", 0.0_vp), 90 BorderStyle( 91 static_cast<int32_t>(pattern->GetAttr<double>("text_overlay_menu_border_style", 0.0))))); 92 theme->menuPadding_ = Edge(pattern->GetAttr<Dimension>("text_overlay_menu_padding_left", 0.0_vp), 93 pattern->GetAttr<Dimension>("text_overlay_menu_padding_top", 0.0_vp), 94 pattern->GetAttr<Dimension>("text_overlay_menu_padding_right", 0.0_vp), 95 pattern->GetAttr<Dimension>("text_overlay_menu_padding_bottom", 0.0_vp)); 96 theme->menuSpacingWithText_ = 97 pattern->GetAttr<Dimension>("text_overlay_menu_spacing_with_text", 0.0_vp); 98 theme->menuSafeSpacing_ = pattern->GetAttr<Dimension>("text_overlay_menu_safe_spacing", 16.0_vp); 99 theme->menuButtonWidth_ = pattern->GetAttr<Dimension>("text_overlay_menu_button_width", 0.0_vp); 100 theme->menuButtonHeight_ = pattern->GetAttr<Dimension>("text_overlay_menu_button_height", 0.0_vp); 101 theme->menuButtonTextStyle_.SetFontWeight(FontWeight( 102 static_cast<int32_t>(pattern->GetAttr<double>("text_overlay_button_text_font_weight", 0.0)))); 103 theme->menuButtonPadding_ = 104 Edge(pattern->GetAttr<Dimension>("text_overlay_menu_button_padding_left", 0.0_vp).Value(), 105 pattern->GetAttr<Dimension>("text_overlay_menu_button_padding_top", 0.0_vp).Value(), 106 pattern->GetAttr<Dimension>("text_overlay_menu_button_padding_right", 0.0_vp).Value(), 107 pattern->GetAttr<Dimension>("text_overlay_menu_button_padding_bottom", 0.0_vp).Value(), 108 pattern->GetAttr<Dimension>("text_overlay_menu_padding_left", 0.0_vp).Unit()); 109 theme->menuButtonRadius_ = pattern->GetAttr<Dimension>("text_overlay_menu_button_radius", 14.0_vp); 110 theme->iconColor_ = pattern->GetAttr<Color>("icon_color", Color()); 111 theme->menuIconColor_ = pattern->GetAttr<Color>("memu_icon_color", Color()); 112 theme->handleColor_ = pattern->GetAttr<Color>("handle_outer_color", Color()); 113 theme->handleColorInner_ = pattern->GetAttr<Color>("handle_inner_color", Color()); 114 theme->menuBackgroundColor_ = pattern->GetAttr<Color>("menu_bg_color", Color()); 115 theme->buttonHoverColor_ = pattern->GetAttr<Color>("button_bg_color_hovered", Color()); 116 theme->buttonClickedColor_ = pattern->GetAttr<Color>("button_bg_color_clicked", Color()); 117 theme->moreOrBackIconColor_ = pattern->GetAttr<Color>("more_or_back_icon_color", Color()); 118 theme->menuButtonTextStyle_.SetTextColor( 119 pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, Color())); 120 theme->menuButtonTextStyle_.SetFontSize( 121 pattern->GetAttr<Dimension>("text_overlay_text_font_size", 14.0_fp)); 122 theme->handleDiameter_ = pattern->GetAttr<Dimension>("handle_outer_diameter", 14.0_vp); 123 theme->handleDiameterInner_ = pattern->GetAttr<Dimension>("handle_inner_diameter", 12.0_vp); 124 theme->alphaDisabled_ = 125 pattern->GetAttr<double>(PATTERN_BG_COLOR_DISABLED_ALPHA, defaultTertiaryColorAlpha); 126 theme->cameraInput_ = pattern->GetAttr<std::string>("camera_input", "Camera input"); 127 theme->aiWrite_ = pattern->GetAttr<std::string>("ai_write_menu_name", "Celia writer"); 128 theme->symbolSize_ = pattern->GetAttr<Dimension>("more_or_back_symbol_size", 24.0_vp); 129 theme->symbolColor_ = pattern->GetAttr<Color>("more_or_back_symbol_color", Color()); 130 } 131 ParseMenuPattern(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<TextOverlayTheme> & theme)132 void ParseMenuPattern(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<TextOverlayTheme>& theme) const 133 { 134 CHECK_NULL_VOID(themeStyle && theme); 135 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("text_overlay_pattern", nullptr); 136 CHECK_NULL_VOID(pattern); 137 theme->copyLabelInfo_ = pattern->GetAttr<std::string>("text_overlay_menu_copy", "Ctrl+C"); 138 theme->pasteLabelInfo_ = pattern->GetAttr<std::string>("text_overlay_menu_paste", "Ctrl+V"); 139 theme->selectAllLabelInfo_ = pattern->GetAttr<std::string>("text_overlay_menu_select_all", "Ctrl+A"); 140 theme->cutLabelInfo_ = pattern->GetAttr<std::string>("text_overlay_menu_cut", "Ctrl+X"); 141 theme->showShortcut_ = static_cast<bool>(pattern->GetAttr<double>("text_overlay_menu_show_shortcut", 0.0)); 142 theme->enableSelectionMenu_ = static_cast<bool>(pattern->GetAttr<double>("text_overlay_menu_enable", 1.0)); 143 theme->cutLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_cut_label", "Cut"); 144 theme->copyLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_copy_label", "Copy"); 145 theme->pasteLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_paste_label", "Paste"); 146 theme->selectAllLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_select_all_label", "Select all"); 147 theme->translateLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_translate_label", "Translate"); 148 theme->shareLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_share_label", "Share"); 149 theme->searchLabel_ = pattern->GetAttr<std::string>("text_overlay_menu_search_label", "Search"); 150 theme->moreAccessibilityText_ = 151 pattern->GetAttr<std::string>("text_overlay_menu_more_accessibility_text", "more"); 152 theme->backAccessibilityText_ = 153 pattern->GetAttr<std::string>("text_overlay_menu_back_accessibility_text", "back"); 154 } ParseAIMenu(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<TextOverlayTheme> & theme)155 void ParseAIMenu(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<TextOverlayTheme>& theme) const 156 { 157 CHECK_NULL_VOID(themeStyle && theme); 158 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("text_overlay_pattern", nullptr); 159 CHECK_NULL_VOID(pattern); 160 161 // Get value from global resource after value exists in resource 162 theme->aiMenuTypeOptionNames_[OHOS::Ace::TextDataDetectType::ADDRESS] = 163 pattern->GetAttr<std::string>("general_ai_menu_address", "Get Directions"); 164 theme->aiMenuTypeOptionNames_[OHOS::Ace::TextDataDetectType::DATE_TIME] = 165 pattern->GetAttr<std::string>("general_ai_menu_date", "Create calendar reminder"); 166 theme->aiMenuTypeOptionNames_[OHOS::Ace::TextDataDetectType::EMAIL] = 167 pattern->GetAttr<std::string>("general_ai_menu_email", "Compose email"); 168 theme->aiMenuTypeOptionNames_[OHOS::Ace::TextDataDetectType::PHONE_NUMBER] = 169 pattern->GetAttr<std::string>("general_ai_menu_phone_number", "Call now"); 170 theme->aiMenuTypeOptionNames_[OHOS::Ace::TextDataDetectType::URL] = 171 pattern->GetAttr<std::string>("general_ai_menu_url", "Open"); 172 173 theme->aiMenuFontGradientColors_ = { 174 pattern->GetAttr<Color>("ai_intelligent_gradient_color1", Color()), 175 pattern->GetAttr<Color>("ai_intelligent_gradient_color2", Color()), 176 pattern->GetAttr<Color>("ai_intelligent_gradient_color3", Color()), 177 pattern->GetAttr<Color>("ai_intelligent_gradient_color4", Color()) }; 178 theme->aiMenuFontGradientScalars_ = { 179 pattern->GetAttr<double>("ai_intelligent_gradient_scalar1", 0.0), 180 pattern->GetAttr<double>("ai_intelligent_gradient_scalar2", 0.0), 181 pattern->GetAttr<double>("ai_intelligent_gradient_scalar3", 0.0), 182 pattern->GetAttr<double>("ai_intelligent_gradient_scalar4", 0.0) }; 183 theme->aiMenuSymbolColor_ = pattern->GetAttr<Color>("ai_intelligent_gradient_color1", Color(0xFF42CBF7)); 184 185 theme->askCelia_ = pattern->GetAttr<std::string>("general_ai_ask_celia", "Ask Celia"); 186 } 187 ParseAIPreviewMenu(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<TextOverlayTheme> & theme)188 void ParseAIPreviewMenu(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<TextOverlayTheme>& theme) const 189 { 190 CHECK_NULL_VOID(themeStyle && theme); 191 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("text_overlay_pattern", nullptr); 192 CHECK_NULL_VOID(pattern); 193 theme->previewMenuPadding_ = pattern->GetAttr<Dimension>("text_overlay_menu_button_padding_left", 0.0_vp); 194 theme->aiMenuTypePreviewOptionNames_[TextDataDetectType::URL] = 195 pattern->GetAttr<std::string>("general_ai_preview_menu_url_open_browser_app", ""); 196 auto failedValue = pattern->GetAttr<std::string>("general_ai_preview_menu_display_failed", ""); 197 theme->aiMenuPreviewDisplayFailedContent_[TextDataDetectType::URL] = failedValue; 198 auto addressValue = failedValue + "\n" + 199 pattern->GetAttr<std::string>("general_ai_preview_menu_address_install_map_app", ""); 200 theme->aiMenuPreviewDisplayFailedContent_[TextDataDetectType::ADDRESS] = addressValue; 201 std::string dataValue; 202 if (SystemProperties::GetPreviewStatus() == 0) { 203 dataValue = failedValue + "\n" + 204 pattern->GetAttr<std::string>("general_ai_preview_menu_date_install_calendar_app", 205 "Click to install the Calendar app"); 206 } else { 207 dataValue = failedValue + "\n" + 208 pattern->GetAttr<std::string>( 209 "general_ai_preview_menu_date_retry", "Please install the Calendar app and try again."); 210 } 211 theme->aiMenuPreviewDisplayFailedContent_[TextDataDetectType::DATE_TIME] = dataValue; 212 theme->previewFailedFontColor_ = 213 pattern->GetAttr<Color>("general_ai_preview_menu_display_failed_font_color", Color()); 214 theme->previewFailedFontSize_ = 215 pattern->GetAttr<Dimension>("general_ai_preview_menu_display_failed_font_size", 14.0_fp); 216 theme->locationTitle_ = pattern->GetAttr<std::string>("general_ai_location_title", "位置"); 217 theme->linkTitle_ = pattern->GetAttr<std::string>("general_ai_link_title", "网址"); 218 theme->previewContentSpace_ = pattern->GetAttr<Dimension>("general_ai_content_space", 2.0_vp); 219 } 220 }; 221 222 ~TextOverlayTheme() override = default; 223 GetMenuBorder()224 const Border& GetMenuBorder() const 225 { 226 return menuBorder_; 227 } 228 GetMenuBackgroundColor()229 const Color& GetMenuBackgroundColor() const 230 { 231 return menuBackgroundColor_; 232 } 233 GetHandleColor()234 const Color& GetHandleColor() const 235 { 236 return handleColor_; 237 } 238 GetHandleColorInner()239 const Color& GetHandleColorInner() const 240 { 241 return handleColorInner_; 242 } 243 GetButtonClickedColor()244 const Color& GetButtonClickedColor() const 245 { 246 return buttonClickedColor_; 247 } 248 GetButtonHoverColor()249 const Color& GetButtonHoverColor() const 250 { 251 return buttonHoverColor_; 252 } 253 GetIconColor()254 const Color& GetIconColor() const 255 { 256 return iconColor_; 257 } 258 GetMenuIconColor()259 const Color& GetMenuIconColor() const 260 { 261 return menuIconColor_; 262 } 263 GetMoreOrBackIconColor()264 const Color& GetMoreOrBackIconColor() const 265 { 266 return moreOrBackIconColor_; 267 } 268 GetMenuPadding()269 const Edge& GetMenuPadding() const 270 { 271 return menuPadding_; 272 } 273 GetMenuButtonPadding()274 const Edge& GetMenuButtonPadding() const 275 { 276 return menuButtonPadding_; 277 } 278 GetHandleDiameter()279 const Dimension& GetHandleDiameter() const 280 { 281 return handleDiameter_; 282 } 283 GetHandleDiameterStrokeWidth()284 const Dimension GetHandleDiameterStrokeWidth() const 285 { 286 return 2.0_vp; 287 } 288 GetHandleDiameterInner()289 const Dimension& GetHandleDiameterInner() const 290 { 291 return handleDiameterInner_; 292 } 293 GetMenuSpacingWithText()294 const Dimension& GetMenuSpacingWithText() const 295 { 296 return menuSpacingWithText_; 297 } 298 GetMenuSafeSpacing()299 const Dimension& GetMenuSafeSpacing() const 300 { 301 return menuSafeSpacing_; 302 } 303 GetMenuButtonWidth()304 const Dimension& GetMenuButtonWidth() const 305 { 306 return menuButtonWidth_; 307 } 308 GetMenuButtonHeight()309 const Dimension& GetMenuButtonHeight() const 310 { 311 return menuButtonHeight_; 312 } 313 GetMenuButtonTextStyle()314 const TextStyle& GetMenuButtonTextStyle() const 315 { 316 return menuButtonTextStyle_; 317 } 318 GetMenuToolbarHeight()319 Dimension GetMenuToolbarHeight() const 320 { 321 return 40.0_vp; 322 } 323 GetDefaultMenuPositionX()324 float GetDefaultMenuPositionX() 325 { 326 return Dimension(16.0_vp).ConvertToPx(); 327 } 328 GetDefaultMenuPositionY()329 float GetDefaultMenuPositionY() 330 { 331 return Dimension(16.0_vp).ConvertToPx(); 332 } 333 GetHandleLineWidth()334 Dimension GetHandleLineWidth() const 335 { 336 return 2.0_vp; 337 } 338 GetHandleHotZoneRadius()339 Dimension GetHandleHotZoneRadius() const 340 { 341 return handleDiameter_; 342 } 343 GetAlphaDisabled()344 double GetAlphaDisabled() const 345 { 346 return alphaDisabled_; 347 } 348 GetCameraInput()349 const std::string& GetCameraInput() const 350 { 351 return cameraInput_; 352 } 353 GetAIWrite()354 const std::string& GetAIWrite() const 355 { 356 return aiWrite_; 357 } 358 GetCopyLabelInfo()359 const std::string& GetCopyLabelInfo() const 360 { 361 return copyLabelInfo_; 362 } 363 GetPasteLabelInfo()364 const std::string& GetPasteLabelInfo() const 365 { 366 return pasteLabelInfo_; 367 } 368 GetSelectAllLabelInfo()369 const std::string& GetSelectAllLabelInfo() const 370 { 371 return selectAllLabelInfo_; 372 } 373 GetCutLabelInfo()374 const std::string& GetCutLabelInfo() const 375 { 376 return cutLabelInfo_; 377 } 378 GetShowShortcut()379 bool GetShowShortcut() const 380 { 381 return showShortcut_; 382 } 383 GetMoreSymbolId()384 const uint32_t& GetMoreSymbolId() const 385 { 386 return moreSymbolId_; 387 } 388 GetBackSymbolId()389 const uint32_t& GetBackSymbolId() const 390 { 391 return backSymbolId_; 392 } 393 GetCutSymbolId()394 const uint32_t& GetCutSymbolId() const 395 { 396 return cutSymbolId_; 397 } 398 GetCopySymbolId()399 const uint32_t& GetCopySymbolId() const 400 { 401 return copySymbolId_; 402 } 403 GetCopyAllSymbolId()404 const uint32_t& GetCopyAllSymbolId() const 405 { 406 return copyAllSymbolId_; 407 } 408 GetPasteSymbolId()409 const uint32_t& GetPasteSymbolId() const 410 { 411 return pasteSymbolId_; 412 } 413 GetCameraInputSymbolId()414 const uint32_t& GetCameraInputSymbolId() const 415 { 416 return cameraInputSymbolId_; 417 } 418 GetAIWriteSymbolId()419 const uint32_t& GetAIWriteSymbolId() const 420 { 421 return aiWriteSymbolId_; 422 } 423 GetSearchSymbolId()424 const uint32_t& GetSearchSymbolId() const 425 { 426 return searchSymbolId_; 427 } 428 GetTranslateSymbolId()429 const uint32_t& GetTranslateSymbolId() const 430 { 431 return translateSymbolId_; 432 } 433 GetShareSymbolId()434 const uint32_t& GetShareSymbolId() const 435 { 436 return shareSymbolId_; 437 } 438 GetSymbolSize()439 const Dimension& GetSymbolSize() const 440 { 441 return symbolSize_; 442 } 443 GetSymbolColor()444 const Color& GetSymbolColor() const 445 { 446 return symbolColor_; 447 } 448 GetEnableSelectionMenu()449 bool GetEnableSelectionMenu() const 450 { 451 return enableSelectionMenu_; 452 } 453 GetCutLabel()454 const std::string& GetCutLabel() const 455 { 456 return cutLabel_; 457 } 458 GetCopyLabel()459 const std::string& GetCopyLabel() const 460 { 461 return copyLabel_; 462 } 463 GetPasteLabel()464 const std::string& GetPasteLabel() const 465 { 466 return pasteLabel_; 467 } 468 GetSelectAllLabel()469 const std::string& GetSelectAllLabel() const 470 { 471 return selectAllLabel_; 472 } 473 GetTranslateLabel()474 const std::string& GetTranslateLabel() const 475 { 476 return translateLabel_; 477 } 478 GetShareLabel()479 const std::string& GetShareLabel() const 480 { 481 return shareLabel_; 482 } 483 GetSearchLabel()484 const std::string& GetSearchLabel() const 485 { 486 return searchLabel_; 487 } 488 GetMoreAccessibilityText()489 const std::string& GetMoreAccessibilityText() const 490 { 491 return moreAccessibilityText_; 492 } 493 GetBackAccessibilityText()494 const std::string& GetBackAccessibilityText() const 495 { 496 return backAccessibilityText_; 497 } 498 GetAiMenuOptionName(OHOS::Ace::TextDataDetectType type)499 const std::string GetAiMenuOptionName(OHOS::Ace::TextDataDetectType type) const 500 { 501 if (type == TextDataDetectType::INVALID) { 502 return "invalid"; 503 } 504 auto findIter = aiMenuTypeOptionNames_.find(type); 505 if (findIter != aiMenuTypeOptionNames_.end()) { 506 return findIter->second; 507 } else { 508 return "No such type"; 509 } 510 } 511 GetAiMenuPreviewOptionName(OHOS::Ace::TextDataDetectType type)512 const std::string GetAiMenuPreviewOptionName(OHOS::Ace::TextDataDetectType type) const 513 { 514 if (type == TextDataDetectType::INVALID) { 515 return ""; 516 } 517 auto findIter = aiMenuTypePreviewOptionNames_.find(type); 518 if (findIter != aiMenuTypePreviewOptionNames_.end()) { 519 return findIter->second; 520 } else { 521 return ""; 522 } 523 } 524 GetPreviewDisplayFailedContent(OHOS::Ace::TextDataDetectType type)525 const std::string GetPreviewDisplayFailedContent(OHOS::Ace::TextDataDetectType type) const 526 { 527 if (type == TextDataDetectType::INVALID) { 528 return ""; 529 } 530 auto findIter = aiMenuPreviewDisplayFailedContent_.find(type); 531 if (findIter != aiMenuPreviewDisplayFailedContent_.end()) { 532 return findIter->second; 533 } else { 534 return ""; 535 } 536 } 537 GetPreviewFailedFontColor()538 const Color& GetPreviewFailedFontColor() 539 { 540 return previewFailedFontColor_; 541 } 542 GetPreviewFailedFontSize()543 const Dimension& GetPreviewFailedFontSize() 544 { 545 return previewFailedFontSize_; 546 } 547 GetAiMenuFontGradientColors()548 const std::vector<Color>& GetAiMenuFontGradientColors() const 549 { 550 return aiMenuFontGradientColors_; 551 } 552 GetAiMenuFontGradientScalars()553 const std::vector<float>& GetAiMenuFontGradientScalars() const 554 { 555 return aiMenuFontGradientScalars_; 556 } 557 GetAIMenuSymbolId()558 const uint32_t& GetAIMenuSymbolId() const 559 { 560 return aiMenuSymbolId_; 561 } 562 GetAIMenuSymbolColor()563 const Color& GetAIMenuSymbolColor() const 564 { 565 return aiMenuSymbolColor_; 566 } 567 GetMenuButtonRadius()568 const Dimension& GetMenuButtonRadius() const 569 { 570 return menuButtonRadius_; 571 } 572 GetAskCeliaSymbolId()573 const uint32_t& GetAskCeliaSymbolId() const 574 { 575 return askCeliaSymbolId_; 576 } 577 GetAskCelia()578 const std::string& GetAskCelia() const 579 { 580 return askCelia_; 581 } 582 GetLocationTitle()583 std::string GetLocationTitle() 584 { 585 return locationTitle_; 586 } 587 GetLinkTitle()588 std::string GetLinkTitle() 589 { 590 return linkTitle_; 591 } 592 GetPreviewContentSpace()593 Dimension GetPreviewContentSpace() 594 { 595 return previewContentSpace_; 596 } 597 GetPreviewMenuPadding()598 Dimension GetPreviewMenuPadding() 599 { 600 return previewMenuPadding_; 601 } 602 protected: 603 TextOverlayTheme() = default; 604 TextStyle menuButtonTextStyle_; 605 Color buttonClickedColor_; 606 Color buttonHoverColor_; 607 608 private: 609 Border menuBorder_; 610 Color iconColor_; 611 Color menuIconColor_; 612 Color menuBackgroundColor_; 613 Color handleColor_; 614 Color handleColorInner_; 615 Color moreOrBackIconColor_; 616 Color previewFailedFontColor_; 617 Edge menuPadding_; 618 Edge menuButtonPadding_; 619 Dimension handleDiameter_; 620 Dimension handleDiameterInner_; 621 Dimension menuSpacingWithText_; 622 Dimension menuSafeSpacing_; 623 Dimension menuButtonWidth_; 624 Dimension menuButtonHeight_; 625 Dimension previewFailedFontSize_; 626 Dimension previewMenuPadding_; 627 double alphaDisabled_ = 0.0; 628 std::string cameraInput_; 629 std::string aiWrite_; 630 std::string copyLabelInfo_; 631 std::string pasteLabelInfo_; 632 std::string selectAllLabelInfo_; 633 std::string cutLabelInfo_; 634 bool showShortcut_ = false; 635 bool enableSelectionMenu_ = true; 636 std::string cutLabel_; 637 std::string copyLabel_; 638 std::string pasteLabel_; 639 std::string selectAllLabel_; 640 std::string translateLabel_; 641 std::string shareLabel_; 642 std::string searchLabel_; 643 std::string moreAccessibilityText_; 644 std::string backAccessibilityText_; 645 std::string locationTitle_ = ""; 646 std::string linkTitle_ = ""; 647 648 Dimension previewContentSpace_; 649 Dimension symbolSize_; 650 Color symbolColor_; 651 uint32_t moreSymbolId_ = 0; 652 uint32_t backSymbolId_ = 0; 653 uint32_t cutSymbolId_ = 0; 654 uint32_t copySymbolId_ = 0; 655 uint32_t copyAllSymbolId_ = 0; 656 uint32_t pasteSymbolId_ = 0; 657 uint32_t cameraInputSymbolId_ = 0; 658 uint32_t aiWriteSymbolId_ = 0; 659 uint32_t searchSymbolId_ = 0; 660 uint32_t translateSymbolId_ = 0; 661 uint32_t shareSymbolId_ = 0; 662 uint32_t aiMenuSymbolId_ = 0; 663 uint32_t askCeliaSymbolId_ = 0; 664 665 std::unordered_map<OHOS::Ace::TextDataDetectType, std::string> aiMenuPreviewDisplayFailedContent_; 666 std::unordered_map<OHOS::Ace::TextDataDetectType, std::string> aiMenuTypePreviewOptionNames_; 667 std::unordered_map<OHOS::Ace::TextDataDetectType, std::string> aiMenuTypeOptionNames_; 668 std::vector<Color> aiMenuFontGradientColors_; 669 std::vector<float> aiMenuFontGradientScalars_; 670 Color aiMenuSymbolColor_; 671 Dimension menuButtonRadius_; 672 std::string askCelia_; 673 }; 674 675 } // namespace OHOS::Ace 676 677 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_OVERLAY_TEXT_OVERLAY_THEME_H 678