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_SWIPER_SWIPER_INDICATOR_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_SWIPER_INDICATOR_THEME_H 18 19 #include "core/components/theme/theme.h" 20 #include "core/components/theme/theme_constants.h" 21 #include "core/components/theme/theme_constants_defines.h" 22 #include "core/components_ng/property/gradient_property.h" 23 24 namespace OHOS::Ace { 25 namespace { 26 constexpr double SWIPER_ARROW_ALPHA_DISABLED = 0.4; 27 constexpr Dimension SWIPER_ARROW_SCALE = 24.0_vp; 28 constexpr Dimension SWIPER_ARROW_SMALL_ARROW_BACKGROUND_SIZE = 24.0_vp; 29 constexpr Dimension SWIPER_ARROW_SMALL_ARROW_SIZE = 18.0_vp; 30 constexpr Dimension SWIPER_ARROW_BIG_ARROW_BACKGROUND_SIZE = 32.0_vp; 31 constexpr Dimension SWIPER_ARROW_BIG_ARROW_SIZE = 24.0_vp; 32 constexpr Dimension SWIPER_ARROW_HORIZONTAL_MARGIN_DEFAULT = 8.0_vp; 33 constexpr Dimension SWIPER_ARROW_VERTICAL_MARGIN_DEFAULT = 8.0_vp; 34 constexpr Dimension SWIPER_FOCUSED_BORDER_WIDTH = 2.0_vp; 35 constexpr Dimension SWIPER_INDICATOR_DIGIT_PADDING_DEFAULT = 8.0_vp; 36 constexpr Dimension SWIPER_INDICATOR_DIGIT_VERTICAL_PADDING_DEFAULT = 8.0_vp; 37 constexpr Dimension SWIPER_INDICATOR_DIGIT_HEIGHT = 32.0_vp; 38 constexpr Dimension SWIPER_INDICATOR_DOT_PADDING_DEFAULT = 12.0_vp; 39 constexpr Dimension SWIPER_INDICATOR_DOT_ITEM_SPACE = 8.0_vp; 40 constexpr float INDICATOR_ZOOM_IN_SCALE = 1.33; 41 constexpr double INDICATOR_DRAG_MIN_ANGLE = 6.0f; 42 constexpr double INDICATOR_DRAG_MAX_ANGLE = 10.0f; 43 } // namespace 44 45 enum class OverlongType { 46 NONE = 0, 47 LEFT_NORMAL_RIGHT_FADEOUT, 48 LEFT_FADEOUT_RIGHT_NORMAL, 49 LEFT_FADEOUT_RIGHT_FADEOUT 50 }; 51 52 enum class OverlongIndicatorMove { 53 NONE = 0, 54 MOVE_FORWARD, 55 MOVE_BACKWARD 56 }; 57 58 enum class GestureState { 59 GESTURE_STATE_INIT, 60 GESTURE_STATE_NONE, 61 GESTURE_STATE_FOLLOW_LEFT, 62 GESTURE_STATE_FOLLOW_RIGHT, 63 GESTURE_STATE_RELEASE_LEFT, 64 GESTURE_STATE_RELEASE_RIGHT 65 }; 66 67 enum class TouchBottomTypeLoop { 68 TOUCH_BOTTOM_TYPE_LOOP_NONE, 69 TOUCH_BOTTOM_TYPE_LOOP_LEFT, 70 TOUCH_BOTTOM_TYPE_LOOP_RIGHT, 71 }; 72 73 enum class FadeOutState { 74 FADE_OUT_NONE, 75 FADE_OUT_LEFT, 76 FADE_OUT_RIGHT, 77 FADE_OUT_BILATERAL 78 }; 79 class SwiperIndicatorTheme : public virtual Theme { 80 DECLARE_ACE_TYPE(SwiperIndicatorTheme, Theme); 81 82 public: 83 class Builder { 84 public: 85 Builder() = default; 86 ~Builder() = default; 87 Build(const RefPtr<ThemeConstants> & themeConstants)88 RefPtr<SwiperIndicatorTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 89 { 90 RefPtr<SwiperIndicatorTheme> theme = AceType::MakeRefPtr<SwiperIndicatorTheme>(); 91 if (!themeConstants) { 92 return theme; 93 } 94 theme->leftSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_left"); 95 theme->rightSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_right"); 96 theme->upSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_up"); 97 theme->downSymbolId_ = themeConstants->GetSymbolByName("sys.symbol.chevron_down"); 98 ParsePattern(themeConstants, theme); 99 return theme; 100 } 101 102 private: ParsePattern(const RefPtr<ThemeConstants> & themeConstants,const RefPtr<SwiperIndicatorTheme> & theme)103 void ParsePattern(const RefPtr<ThemeConstants>& themeConstants, const RefPtr<SwiperIndicatorTheme>& theme) const 104 { 105 RefPtr<ThemeStyle> swiperPattern = themeConstants->GetPatternByName(THEME_PATTERN_SWIPER); 106 if (!swiperPattern) { 107 LOGW("find pattern of swiper fail"); 108 return; 109 } 110 theme->indicatorPaddingDot_ = swiperPattern->GetAttr<Dimension>("indicator_padding_dot", 12.0_vp); 111 theme->unSelectedColor_ = swiperPattern->GetAttr<Color>("color_focus_unselected", Color::TRANSPARENT); 112 theme->focusedBgColor_ = swiperPattern->GetAttr<Color>("color_focus_bg", Color::TRANSPARENT); 113 theme->indicatorBgHeight_ = swiperPattern->GetAttr<Dimension>("indicator_bg_height", 12.0_vp); 114 theme->focusedSelectedColor_ = 115 swiperPattern->GetAttr<Color>("indicator_color_focused_selected", Color::TRANSPARENT); 116 theme->scaleSwiper_ = swiperPattern->GetAttr<double>("indicator_scale_swiper", INDICATOR_ZOOM_IN_SCALE); 117 theme->indicatorFocusedPadding_ = swiperPattern->GetAttr<Dimension>("indicator_focused_padding", 0.0_vp); 118 theme->clipToBounds_ = static_cast<bool>(swiperPattern->GetAttr<int>("clip_bounds", 1)); 119 theme->focusStyleType_ = swiperPattern->GetAttr<int>("swiper_focus_style_type", 0); 120 theme->size_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_size", 0.0_vp); 121 theme->selectedSize_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_selected_size", 0.0_vp); 122 theme->isHasMask_ = static_cast<bool>(swiperPattern->GetAttr<double>("swiper_indicator_mask", 0.0)); 123 theme->indicatorPointPadding_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_point_padding", 0.0_vp); 124 theme->startEndPadding_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_start_end_padding", 0.0_vp); 125 theme->pressPadding_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_press_padding", 0.0_vp); 126 theme->pressPointPadding_ = 127 swiperPattern->GetAttr<Dimension>("swiper_indicator_press_point_padding", 0.0_vp); 128 theme->pressSize_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_press_size", 0.0_vp); 129 theme->hoverSize_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_hover_size", 0.0_vp); 130 theme->hotZoneSize_ = swiperPattern->GetAttr<Dimension>("swiper_indicator_hotzone_size", 0.0_vp); 131 theme->isIndicatorDisabled_ = 132 static_cast<bool>(swiperPattern->GetAttr<double>("swiper_indicator_disabled", 0.0)); 133 theme->animationCurve_ = 134 AnimationCurve(static_cast<int32_t>(swiperPattern->GetAttr<double>("swiper_animation_curve", 0.0))); 135 theme->animationOpacity_ = 136 static_cast<bool>(swiperPattern->GetAttr<double>("swiper_animation_opacity", 0.0)); 137 theme->color_ = swiperPattern->GetAttr<Color>("indicator_color", Color::TRANSPARENT); 138 theme->hotZoneColor_ = swiperPattern->GetAttr<Color>("indicator_hotzone_color", Color::TRANSPARENT); 139 theme->indicatorTextFocusColor_ = 140 swiperPattern->GetAttr<Color>("indicator_text_color_focused", Color::TRANSPARENT); 141 theme->digitalIndicatorTextStyle_.SetTextColor( 142 swiperPattern->GetAttr<Color>("indicator_text_font_color", Color::TRANSPARENT)); 143 theme->digitalIndicatorTextStyle_.SetFontSize( 144 swiperPattern->GetAttr<Dimension>("indicator_text_font_size", 14.0_vp)); 145 theme->selectedColor_ = swiperPattern->GetAttr<Color>("indicator_color_selected", Color::TRANSPARENT); 146 theme->hoverColor_ = swiperPattern->GetAttr<Color>("indicator_color_hover", Color::TRANSPARENT); 147 theme->pressedColor_ = swiperPattern->GetAttr<Color>("indicator_color_pressed", Color::TRANSPARENT); 148 theme->focusedColor_ = swiperPattern->GetAttr<Color>("indicator_color_focused", Color::TRANSPARENT); 149 theme->preAccessibilityText_ = 150 swiperPattern->GetAttr<std::string>("prev_arrow_accessibility_text", ""); 151 theme->nextAccessibilityText_ = 152 swiperPattern->GetAttr<std::string>("next_arrow_accessibility_text", ""); 153 ParsePattern2(themeConstants, theme, swiperPattern); 154 } 155 ParsePattern2(const RefPtr<ThemeConstants> & themeConstants,const RefPtr<SwiperIndicatorTheme> & theme,const RefPtr<ThemeStyle> swiperPattern)156 void ParsePattern2(const RefPtr<ThemeConstants>& themeConstants, const RefPtr<SwiperIndicatorTheme>& theme, 157 const RefPtr<ThemeStyle> swiperPattern) const 158 { 159 theme->focusedBorderWidth_ = SWIPER_FOCUSED_BORDER_WIDTH; 160 theme->hoverArrowBackgroundColor_ = 161 swiperPattern->GetAttr<Color>(ARROW_COLOR_BOARDCOLOR_HOVER, Color::TRANSPARENT); 162 theme->clickArrowBackgroundColor_ = 163 swiperPattern->GetAttr<Color>(ARROW_COLOR_BOARDCOLOR_CLICK, Color::TRANSPARENT); 164 theme->arrowColorPrimary_ = swiperPattern->GetAttr<Color>(ARROW_COLOR_PRIMARY, Color::TRANSPARENT); 165 theme->arrowColorPrimaryContrary_ = 166 swiperPattern->GetAttr<Color>(ARROW_COLOR_PRIMARY_CONTRARY, Color::TRANSPARENT); 167 theme->arrowDisabledAlpha_ = 168 swiperPattern->GetAttr<double>(ARROW_DISABLED_ALPHA, SWIPER_ARROW_ALPHA_DISABLED); 169 theme->arrowScale_ = SWIPER_ARROW_SCALE; 170 theme->arrowHorizontalMargin_ = 171 swiperPattern->GetAttr<Dimension>(ARROW_HORIZONTAL_MARGIN, SWIPER_ARROW_HORIZONTAL_MARGIN_DEFAULT); 172 theme->arrowVerticalMargin_ = 173 swiperPattern->GetAttr<Dimension>(ARROW_VERTICAL_MARGIN, SWIPER_ARROW_VERTICAL_MARGIN_DEFAULT); 174 theme->smallArrowBackgroundSize_ = SWIPER_ARROW_SMALL_ARROW_BACKGROUND_SIZE; 175 theme->smallArrowSize_ = SWIPER_ARROW_SMALL_ARROW_SIZE; 176 theme->smallArrowBackgroundColor_ = Color::TRANSPARENT; 177 theme->smallArrowColor_ = swiperPattern->GetAttr<Color>(ARROW_COLOR_PRIMARY, Color::TRANSPARENT); 178 theme->bigArrowBackgroundSize_ = SWIPER_ARROW_BIG_ARROW_BACKGROUND_SIZE; 179 theme->bigArrowSize_ = SWIPER_ARROW_BIG_ARROW_SIZE; 180 theme->bigArrowBackgroundColor_ = 181 swiperPattern->GetAttr<Color>(ARROW_COLOR_COMPONENT_NORMAL, Color::TRANSPARENT); 182 theme->bigArrowColor_ = swiperPattern->GetAttr<Color>(ARROW_COLOR_PRIMARY, Color::TRANSPARENT); 183 theme->indicatorDigitPadding_ = SWIPER_INDICATOR_DIGIT_PADDING_DEFAULT; 184 theme->indicatorDigitVerticalPadding_ = SWIPER_INDICATOR_DIGIT_VERTICAL_PADDING_DEFAULT; 185 theme->indicatorDotPadding_ = SWIPER_INDICATOR_DOT_PADDING_DEFAULT; 186 theme->indicatorDigitHeight_ = SWIPER_INDICATOR_DIGIT_HEIGHT; 187 theme->indicatorDotItemSpace_ = SWIPER_INDICATOR_DOT_ITEM_SPACE; 188 theme->arcSelectedItemColor_ = swiperPattern->GetAttr<Color>("dot_active_color", Color::TRANSPARENT); 189 theme->arcItemColor_ = swiperPattern->GetAttr<Color>("dot_color", Color::TRANSPARENT); 190 theme->arcMaskStartColor_ = swiperPattern->GetAttr<Color>("mask_color_start", Color::TRANSPARENT); 191 theme->arcMaskEndColor_ = swiperPattern->GetAttr<Color>("mask_color_end", Color::TRANSPARENT); 192 theme->arcContainerColor_ = swiperPattern->GetAttr<Color>("container_color", Color::TRANSPARENT); 193 theme->indicatorDragMinAngle_ = 194 swiperPattern->GetAttr<double>("swiper_indicator_drag_min_angle", INDICATOR_DRAG_MIN_ANGLE); 195 theme->indicatorDragMaxAngle_ = 196 swiperPattern->GetAttr<double>("swiper_indicator_drag_max_angle", INDICATOR_DRAG_MAX_ANGLE); 197 #ifdef SUPPORT_DIGITAL_CROWN 198 ParsePattern3(themeConstants, theme, swiperPattern); 199 #endif 200 } 201 202 #ifdef SUPPORT_DIGITAL_CROWN ParsePattern3(const RefPtr<ThemeConstants> & themeConstants,const RefPtr<SwiperIndicatorTheme> & theme,const RefPtr<ThemeStyle> swiperPattern)203 void ParsePattern3(const RefPtr<ThemeConstants>& themeConstants, const RefPtr<SwiperIndicatorTheme>& theme, 204 const RefPtr<ThemeStyle> swiperPattern) const 205 { 206 theme->slowVelocityThreshold_ = swiperPattern->GetAttr<double>("swiper_slow_velocity_threshold", 0.0f); 207 theme->mediumVelocityThreshold_ = swiperPattern->GetAttr<double>("swiper_medium_velocity_threshold", 0.0f); 208 theme->fastVelocityThreshold_ = swiperPattern->GetAttr<double>("swiper_fast_velocity_threshold", 0.0f); 209 theme->displayControlRatioVerySlow_ = 210 swiperPattern->GetAttr<double>("swiper_display_control_ratio_very_slow", 0.0f); 211 theme->displayControlRatioSlow_ = swiperPattern->GetAttr<double>("swiper_display_control_ratio_slow", 0.0f); 212 theme->displayControlRatioMedium_ = 213 swiperPattern->GetAttr<double>("swiper_display_control_ratio_medium", 0.0f); 214 theme->displayControlRatioFast_ = swiperPattern->GetAttr<double>("swiper_display_control_ratio_fast", 0.0f); 215 theme->crownSensitivityLow_ = swiperPattern->GetAttr<double>("swiper_crown_sensitivity_low", 0.0f); 216 theme->crownSensitivityMedium_ = swiperPattern->GetAttr<double>("swiper_crown_sensitivity_medium", 0.0f); 217 theme->crownSensitivityHigh_ = swiperPattern->GetAttr<double>("swiper_crown_sensitivity_high", 0.0f); 218 theme->springVelocityThreshold_ = swiperPattern->GetAttr<double>("swiper_spring_velocity_threshold", 0.0f); 219 theme->crownTranslocationRatio_ = swiperPattern->GetAttr<double>("swiper_crown_translocation_ratio", 0.0f); 220 } 221 #endif 222 }; 223 224 ~SwiperIndicatorTheme() override = default; 225 GetColor()226 const Color& GetColor() const 227 { 228 return color_; 229 } 230 GetSelectedColor()231 const Color& GetSelectedColor() const 232 { 233 return selectedColor_; 234 } 235 GetHoverColor()236 const Color& GetHoverColor() const 237 { 238 return hoverColor_; 239 } 240 GetPressedColor()241 const Color& GetPressedColor() const 242 { 243 return pressedColor_; 244 } 245 GetFocusedColor()246 const Color& GetFocusedColor() const 247 { 248 return focusedColor_; 249 } 250 GetFocusedBorderWidth()251 const Dimension& GetFocusedBorderWidth() const 252 { 253 return focusedBorderWidth_; 254 } 255 GetSize()256 const Dimension& GetSize() const 257 { 258 return size_; 259 } 260 GetSelectedSize()261 const Dimension& GetSelectedSize() const 262 { 263 return selectedSize_; 264 } 265 GetIndicatorMask()266 bool GetIndicatorMask() const 267 { 268 return isHasMask_; 269 } 270 GetIndicatorPointPadding()271 const Dimension& GetIndicatorPointPadding() const 272 { 273 return indicatorPointPadding_; 274 } 275 GetDigitalIndicatorTextStyle()276 const TextStyle& GetDigitalIndicatorTextStyle() const 277 { 278 return digitalIndicatorTextStyle_; 279 } 280 GetStartEndPadding()281 const Dimension& GetStartEndPadding() const 282 { 283 return startEndPadding_; 284 } 285 GetPressPadding()286 const Dimension& GetPressPadding() const 287 { 288 return pressPadding_; 289 } 290 GetPressPointPadding()291 const Dimension& GetPressPointPadding() const 292 { 293 return pressPointPadding_; 294 } 295 GetPressSize()296 const Dimension& GetPressSize() const 297 { 298 return pressSize_; 299 } 300 GetHoverSize()301 const Dimension& GetHoverSize() const 302 { 303 return hoverSize_; 304 } 305 GetHotZoneSize()306 const Dimension& GetHotZoneSize() const 307 { 308 return hotZoneSize_; 309 } 310 GetHotZoneColor()311 const Color& GetHotZoneColor() const 312 { 313 return hotZoneColor_; 314 } 315 GetIndicatorTextFocusColor()316 const Color& GetIndicatorTextFocusColor() const 317 { 318 return indicatorTextFocusColor_; 319 } 320 GetIndicatorDisabled()321 bool GetIndicatorDisabled() const 322 { 323 return isIndicatorDisabled_; 324 } 325 GetAnimationCurve()326 AnimationCurve GetAnimationCurve() const 327 { 328 return animationCurve_; 329 } 330 IsAnimationOpacity()331 bool IsAnimationOpacity() const 332 { 333 return animationOpacity_; 334 } 335 GetHoverArrowBackgroundColor()336 const Color& GetHoverArrowBackgroundColor() const 337 { 338 return hoverArrowBackgroundColor_; 339 } 340 GetClickArrowBackgroundColor()341 const Color& GetClickArrowBackgroundColor() const 342 { 343 return clickArrowBackgroundColor_; 344 } 345 GetArrowColorPrimary()346 const Color& GetArrowColorPrimary() const 347 { 348 return arrowColorPrimary_; 349 } 350 GetArrowColorPrimaryContrary()351 const Color& GetArrowColorPrimaryContrary() const 352 { 353 return arrowColorPrimaryContrary_; 354 } 355 GetIsShowArrowBackground()356 bool GetIsShowArrowBackground() const 357 { 358 return isShowArrowBackground_; 359 } 360 GetIsSidebarMiddle()361 bool GetIsSidebarMiddle() const 362 { 363 return isSidebarMiddle_; 364 } 365 GetSmallArrowBackgroundSize()366 const Dimension& GetSmallArrowBackgroundSize() const 367 { 368 return smallArrowBackgroundSize_; 369 } 370 GetSmallArrowSize()371 const Dimension& GetSmallArrowSize() const 372 { 373 return smallArrowSize_; 374 } GetSmallArrowBackgroundColor()375 const Color& GetSmallArrowBackgroundColor() const 376 { 377 return smallArrowBackgroundColor_; 378 } 379 GetSmallArrowColor()380 const Color& GetSmallArrowColor() const 381 { 382 return smallArrowColor_; 383 } GetBigArrowBackgroundSize()384 const Dimension& GetBigArrowBackgroundSize() const 385 { 386 return bigArrowBackgroundSize_; 387 } 388 GetBigArrowSize()389 const Dimension& GetBigArrowSize() const 390 { 391 return bigArrowSize_; 392 } GetBigArrowBackgroundColor()393 const Color& GetBigArrowBackgroundColor() const 394 { 395 return bigArrowBackgroundColor_; 396 } 397 GetBigArrowColor()398 const Color& GetBigArrowColor() const 399 { 400 return bigArrowColor_; 401 } 402 GetArrowDisabledAlpha()403 double GetArrowDisabledAlpha() const 404 { 405 return arrowDisabledAlpha_; 406 } 407 GetArrowScale()408 const Dimension& GetArrowScale() const 409 { 410 return arrowScale_; 411 } 412 GetArrowHorizontalMargin()413 const Dimension& GetArrowHorizontalMargin() const 414 { 415 return arrowHorizontalMargin_; 416 } 417 GetArrowVerticalMargin()418 const Dimension& GetArrowVerticalMargin() const 419 { 420 return arrowVerticalMargin_; 421 } 422 GetIndicatorDigitPadding()423 const Dimension& GetIndicatorDigitPadding() const 424 { 425 return indicatorDigitPadding_; 426 } 427 GetIndicatorDotPadding()428 const Dimension& GetIndicatorDotPadding() const 429 { 430 return indicatorDotPadding_; 431 } 432 GetIndicatorDigitHeight()433 const Dimension& GetIndicatorDigitHeight() const 434 { 435 return indicatorDigitHeight_; 436 } 437 GetIndicatorDigitVerticalPadding()438 const Dimension& GetIndicatorDigitVerticalPadding() const 439 { 440 return indicatorDigitVerticalPadding_; 441 } 442 GetArcItemColor()443 const Color& GetArcItemColor() const 444 { 445 return arcItemColor_; 446 } 447 GetArcSelectedItemColor()448 const Color& GetArcSelectedItemColor() const 449 { 450 return arcSelectedItemColor_; 451 } 452 GetArcContainerColor()453 const Color& GetArcContainerColor() const 454 { 455 return arcContainerColor_; 456 } 457 GetArcMaskColor()458 NG::Gradient GetArcMaskColor() const 459 { 460 NG::GradientColor beginGradientColor; 461 NG::GradientColor endGradientColor; 462 beginGradientColor.SetLinearColor(LinearColor(arcMaskStartColor_)); 463 beginGradientColor.SetDimension(Dimension(0.0f)); 464 endGradientColor.SetLinearColor(LinearColor(arcMaskEndColor_)); 465 endGradientColor.SetDimension(Dimension(1.0f)); 466 NG::Gradient gradient; 467 gradient.AddColor(beginGradientColor); 468 gradient.AddColor(endGradientColor); 469 470 return gradient; 471 } 472 GetIndicatorDotItemSpace()473 const Dimension& GetIndicatorDotItemSpace() const 474 { 475 return indicatorDotItemSpace_; 476 } 477 GetLeftSymbolId()478 uint32_t GetLeftSymbolId() const 479 { 480 return leftSymbolId_; 481 } 482 GetRightSymbolId()483 uint32_t GetRightSymbolId() const 484 { 485 return rightSymbolId_; 486 } 487 GetUpSymbolId()488 uint32_t GetUpSymbolId() const 489 { 490 return upSymbolId_; 491 } 492 GetDownSymbolId()493 uint32_t GetDownSymbolId() const 494 { 495 return downSymbolId_; 496 } 497 GetFocusedBgColor()498 const Color& GetFocusedBgColor() const 499 { 500 return focusedBgColor_; 501 } 502 GetFocusUnSelectedColor()503 const Color& GetFocusUnSelectedColor() const 504 { 505 return unSelectedColor_; 506 } 507 GetFocusedSelectedColor()508 const Color& GetFocusedSelectedColor() const 509 { 510 return focusedSelectedColor_; 511 } 512 GetIndicatorScale()513 float GetIndicatorScale() const 514 { 515 return scaleSwiper_; 516 } 517 GetIndicatorPaddingDot()518 const Dimension& GetIndicatorPaddingDot() const 519 { 520 return indicatorPaddingDot_; 521 } 522 GetIndicatorBgHeight()523 const Dimension& GetIndicatorBgHeight() const 524 { 525 return indicatorBgHeight_; 526 } 527 GetIndicatorFocusedPadding()528 const Dimension& GetIndicatorFocusedPadding() const 529 { 530 return indicatorFocusedPadding_; 531 } 532 GetClipEdge()533 bool GetClipEdge() const 534 { 535 return clipToBounds_; 536 } 537 GetFocusStyleType()538 int GetFocusStyleType() const 539 { 540 return focusStyleType_; 541 } 542 543 #ifdef SUPPORT_DIGITAL_CROWN GetSlowVelocityThreshold()544 double GetSlowVelocityThreshold() const 545 { 546 return slowVelocityThreshold_; 547 } 548 GetMediumVelocityThreshold()549 double GetMediumVelocityThreshold() const 550 { 551 return mediumVelocityThreshold_; 552 } 553 GetFastVelocityThreshold()554 double GetFastVelocityThreshold() const 555 { 556 return fastVelocityThreshold_; 557 } 558 GetDisplayControlRatioVerySlow()559 double GetDisplayControlRatioVerySlow() const 560 { 561 return displayControlRatioVerySlow_; 562 } 563 GetDisplayControlRatioSlow()564 double GetDisplayControlRatioSlow() const 565 { 566 return displayControlRatioSlow_; 567 } 568 GetDisplayControlRatioMedium()569 double GetDisplayControlRatioMedium() const 570 { 571 return displayControlRatioMedium_; 572 } 573 GetDisplayControlRatioFast()574 double GetDisplayControlRatioFast() const 575 { 576 return displayControlRatioFast_; 577 } 578 GetCrownSensitivityLow()579 double GetCrownSensitivityLow() const 580 { 581 return crownSensitivityLow_; 582 } 583 GetCrownSensitivityMedium()584 double GetCrownSensitivityMedium() const 585 { 586 return crownSensitivityMedium_; 587 } 588 GetCrownSensitivityHigh()589 double GetCrownSensitivityHigh() const 590 { 591 return crownSensitivityHigh_; 592 } 593 GetSpringVelocityThreshold()594 double GetSpringVelocityThreshold() const 595 { 596 return springVelocityThreshold_; 597 } 598 GetCrownTranslocationRatio()599 double GetCrownTranslocationRatio() const 600 { 601 return crownTranslocationRatio_; 602 } 603 #endif 604 GetIndicatorDragMinAngle()605 double GetIndicatorDragMinAngle() const 606 { 607 return indicatorDragMinAngle_; 608 } 609 GetIndicatorDragMaxAngle()610 double GetIndicatorDragMaxAngle() const 611 { 612 return indicatorDragMaxAngle_; 613 } 614 GetPreAccessibilityText()615 const std::string& GetPreAccessibilityText() const 616 { 617 return preAccessibilityText_; 618 } 619 GetNextAccessibilityText()620 const std::string& GetNextAccessibilityText() const 621 { 622 return nextAccessibilityText_; 623 } 624 protected: 625 SwiperIndicatorTheme() = default; 626 627 private: 628 Color color_; 629 Color selectedColor_; 630 Color hoverColor_; 631 Color pressedColor_; 632 Color focusedColor_; 633 Dimension focusedBorderWidth_; 634 Dimension size_; 635 Dimension selectedSize_; 636 Dimension indicatorPointPadding_; 637 bool isHasMask_ = false; 638 TextStyle digitalIndicatorTextStyle_; 639 Dimension startEndPadding_; 640 Dimension pressPadding_; 641 Dimension pressPointPadding_; 642 Dimension pressSize_; 643 Dimension hoverSize_; 644 Dimension hotZoneSize_; 645 Color hotZoneColor_; 646 Color indicatorTextFocusColor_; 647 bool isIndicatorDisabled_ = false; 648 AnimationCurve animationCurve_ = { AnimationCurve::FRICTION }; 649 bool animationOpacity_ = true; 650 Color hoverArrowBackgroundColor_; 651 Color clickArrowBackgroundColor_; 652 Color arrowColorPrimary_; 653 Color arrowColorPrimaryContrary_; 654 bool isShowArrowBackground_ = false; 655 bool isSidebarMiddle_ = false; 656 Dimension smallArrowBackgroundSize_; 657 Dimension smallArrowSize_; 658 Color smallArrowBackgroundColor_; 659 Color smallArrowColor_; 660 Dimension bigArrowBackgroundSize_; 661 Dimension bigArrowSize_; 662 Color bigArrowBackgroundColor_; 663 Color bigArrowColor_; 664 double arrowDisabledAlpha_ = 0.4; 665 Dimension arrowScale_; 666 Dimension arrowHorizontalMargin_; 667 Dimension arrowVerticalMargin_; 668 Dimension indicatorDigitPadding_; 669 Dimension indicatorDigitVerticalPadding_; 670 Dimension indicatorDotPadding_; 671 Dimension indicatorDigitHeight_; 672 Dimension indicatorDotItemSpace_; 673 Color arcItemColor_; 674 Color arcSelectedItemColor_; 675 Color arcContainerColor_; 676 Color arcMaskStartColor_; 677 Color arcMaskEndColor_; 678 uint32_t leftSymbolId_ = 0; 679 uint32_t rightSymbolId_ = 0; 680 uint32_t upSymbolId_ = 0; 681 uint32_t downSymbolId_ = 0; 682 Color unSelectedColor_; 683 Color focusedBgColor_; 684 Color focusedSelectedColor_; 685 Dimension indicatorBgHeight_; 686 float scaleSwiper_ = INDICATOR_ZOOM_IN_SCALE; 687 Dimension indicatorPaddingDot_; 688 Dimension indicatorFocusedPadding_; 689 bool clipToBounds_ = true; 690 int focusStyleType_ = 0; 691 #ifdef SUPPORT_DIGITAL_CROWN 692 double slowVelocityThreshold_ = 0.0f; 693 double mediumVelocityThreshold_ = 0.0f; 694 double fastVelocityThreshold_ = 0.0f; 695 double displayControlRatioVerySlow_ = 0.0f; 696 double displayControlRatioSlow_ = 0.0f; 697 double displayControlRatioMedium_ = 0.0f; 698 double displayControlRatioFast_ = 0.0f; 699 double crownSensitivityLow_ = 0.0f; 700 double crownSensitivityMedium_ = 0.0f; 701 double crownSensitivityHigh_ = 0.0f; 702 double springVelocityThreshold_ = 0.0f; 703 double crownTranslocationRatio_ = 0.0f; 704 #endif 705 double indicatorDragMinAngle_ = INDICATOR_DRAG_MIN_ANGLE; 706 double indicatorDragMaxAngle_ = INDICATOR_DRAG_MAX_ANGLE; 707 std::string preAccessibilityText_; 708 std::string nextAccessibilityText_; 709 }; 710 711 } // namespace OHOS::Ace 712 713 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_SWIPER_INDICATOR_THEME_H 714