1 /* 2 * Copyright (c) 2021-2023 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_PICKER_PICKER_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_THEME_H 18 19 #include "base/geometry/dimension.h" 20 #include "base/utils/system_properties.h" 21 #include "core/components/common/layout/constants.h" 22 #include "core/components/common/properties/border.h" 23 #include "core/components/common/properties/color.h" 24 #include "core/components/common/properties/decoration.h" 25 #include "core/components/common/properties/edge.h" 26 #include "core/components/common/properties/text_style.h" 27 #include "core/components/picker/picker_data.h" 28 #include "core/components/theme/theme.h" 29 #include "core/components/theme/theme_constants.h" 30 #include "core/components/theme/theme_constants_defines.h" 31 #ifdef SUPPORT_DIGITAL_CROWN 32 #include "core/event/crown_event.h" 33 #endif 34 #include "core/components_ng/pattern/picker/picker_type_define.h" 35 36 namespace OHOS::Ace { 37 namespace { 38 constexpr Dimension DIVIDER_THICKNESS = 1.0_px; 39 constexpr Dimension PICKER_FOCUS_PADDING = 2.0_vp; 40 constexpr uint32_t FOCUS_AREA_TYPE_IMPL = 1; 41 } // namespace 42 43 class PickerTheme : public virtual Theme { 44 DECLARE_ACE_TYPE(PickerTheme, Theme); 45 46 public: 47 class Builder { 48 public: 49 Builder() = default; 50 ~Builder() = default; 51 SetDigitalCrownSensitivity(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)52 void SetDigitalCrownSensitivity(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 53 { 54 #ifdef SUPPORT_DIGITAL_CROWN 55 CHECK_NULL_VOID(themeStyle); 56 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 57 if (pattern) { 58 auto sensitivity = pattern->GetAttr<int>("picker_crown_sensitivity", 59 OHOS::Ace::NG::DEFAULT_CROWNSENSITIVITY); 60 if (sensitivity >= static_cast<int32_t>(OHOS::Ace::CrownSensitivity::LOW) 61 && sensitivity <= static_cast<int32_t>(OHOS::Ace::CrownSensitivity::HIGH)) { 62 theme->crownSensitivity_ = sensitivity; 63 } 64 } 65 #endif 66 } 67 Build(const RefPtr<ThemeConstants> & themeConstants)68 RefPtr<PickerTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 69 { 70 RefPtr<PickerTheme> theme = AceType::Claim(new PickerTheme()); 71 InitTheme(theme, themeConstants); 72 return theme; 73 } 74 75 protected: InitTheme(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeConstants> & themeConstants)76 void InitTheme(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeConstants>& themeConstants) const 77 { 78 CHECK_NULL_VOID(themeConstants); 79 auto themeStyle = themeConstants->GetThemeStyle(); 80 CHECK_NULL_VOID(themeStyle); 81 InitializeTextStyles(theme, themeStyle); 82 theme->optionSizeUnit_ = DimensionUnit::VP; 83 theme->lunarWidth_ = 84 Dimension(36.0, DimensionUnit::VP); // 36.0: lunarWidth, this width do not need setting by outer. 85 theme->lunarHeight_ = 86 Dimension(18.0, DimensionUnit::VP); // 18.0: lunarHeight, this height do not need setting by outer. 87 theme->rotateInterval_ = 15.0; // when rotate 15.0 angle handle scroll of picker column. 88 theme->dividerThickness_ = DIVIDER_THICKNESS; 89 Parse(themeStyle, theme); 90 InitializeSelectorItemStyles(theme, themeStyle); 91 } 92 93 private: 94 void Parse(const RefPtr<ThemeStyle>& style, const RefPtr<PickerTheme>& theme) const; 95 InitializeButtonTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)96 void InitializeButtonTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 97 { 98 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 99 if (pattern) { 100 theme->buttonStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_button_font_size", 0.0_fp)); 101 theme->buttonStyle_.SetTextColor(pattern->GetAttr<Color>("picker_button_text_color", Color())); 102 } 103 } 104 InitializeTitleTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)105 void InitializeTitleTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 106 { 107 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 108 if (pattern) { 109 theme->titleStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_title_font_size", 0.0_fp)); 110 theme->titleStyle_.SetTextColor(pattern->GetAttr<Color>("picker_title_text_color", Color())); 111 } 112 theme->titleStyle_.SetFontWeight(FontWeight::W500); 113 theme->titleStyle_.SetMaxLines(1); 114 theme->titleStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 115 } 116 InitializeItemTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)117 void InitializeItemTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 118 { 119 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 120 if (pattern) { 121 theme->selectedOptionStyle_.SetTextColor( 122 pattern->GetAttr<Color>("selected_text_color", Color(0x007DFF))); 123 theme->selectedOptionStyle_.SetFontSize( 124 pattern->GetAttr<Dimension>("selected_text_size", 20.0_fp)); 125 theme->selectedOptionStyle_.SetFontWeight(FontWeight::MEDIUM); 126 theme->selectedOptionStyle_.SetAdaptTextSize(theme->selectedOptionStyle_.GetFontSize(), 127 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 128 theme->selectedOptionStyle_.SetMaxLines(1); 129 theme->selectedOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 130 131 theme->normalOptionStyle_.SetTextColor( 132 pattern->GetAttr<Color>("text_color", Color(0xff182431))); 133 theme->normalOptionStyle_.SetFontSize( 134 pattern->GetAttr<Dimension>("text_size", 16.0_fp)); 135 theme->normalOptionStyle_.SetFontWeight(FontWeight::REGULAR); 136 theme->normalOptionStyle_.SetAdaptTextSize(theme->normalOptionStyle_.GetFontSize(), 137 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 138 theme->normalOptionStyle_.SetMaxLines(1); 139 theme->normalOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 140 141 theme->disappearOptionStyle_.SetTextColor( 142 pattern->GetAttr<Color>("disappear_text_color", Color(0xff182431))); 143 theme->disappearOptionStyle_.SetFontSize( 144 pattern->GetAttr<Dimension>("disappear_text_size", 14.0_fp)); 145 theme->disappearOptionStyle_.SetFontWeight(FontWeight::REGULAR); 146 theme->disappearOptionStyle_.SetAdaptTextSize(theme->disappearOptionStyle_.GetFontSize(), 147 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 148 theme->disappearOptionStyle_.SetMaxLines(1); 149 theme->disappearOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 150 theme->focusOptionStyle_.SetFontSize( 151 pattern->GetAttr<Dimension>("picker_focus_option_font_size", 0.0_fp)); 152 theme->focusOptionStyle_.SetTextColor( 153 pattern->GetAttr<Color>("picker_focus_option_text_color", Color())); 154 theme->focusOptionStyle_.SetFontWeight( 155 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("picker_focus_option_weight", 0.0)))); 156 theme->focusOptionStyle_.SetAdaptTextSize(theme->focusOptionStyle_.GetFontSize(), 157 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 158 theme->backgroundColor_ = pattern->GetAttr<Color>("picker_background_color", Color(0xffffffff)); 159 theme->showCircleDial_= static_cast<bool>(pattern->GetAttr<int>("picker_digital_circle", 0)); 160 SetDigitalCrownSensitivity(theme, themeStyle); 161 } 162 theme->focusOptionStyle_.SetMaxLines(1); 163 theme->focusOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 164 165 if (SystemProperties::GetDeviceType() == DeviceType::PHONE) { 166 theme->focusOptionStyle_ = theme->selectedOptionStyle_; // focus style the same with selected on phone 167 } 168 } 169 InitializeSelectorItemStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)170 void InitializeSelectorItemStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 171 { 172 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 173 if (!pattern) { 174 return; 175 } 176 theme->focusImplType_ = static_cast<uint32_t>(pattern->GetAttr<int>("picker_focus_area_type", 0)); 177 theme->selectorItemRadius_ = pattern->GetAttr<Dimension>("picker_selector_item_radius", 8.0_vp); 178 theme->selectorItemSpace_ = pattern->GetAttr<Dimension>("picker_selector_item_space", 4.0_vp); 179 theme->selectorItemBorderWidth_ = pattern->GetAttr<Dimension>("picker_selector_item_border_width", 0.0_vp); 180 theme->selectorItemFocusBorderWidth_ = 181 pattern->GetAttr<Dimension>("picker_selector_item_focus_border_width", 0.0_vp); 182 theme->selectorItemBorderColor_ = 183 pattern->GetAttr<Color>("picker_selector_item_border_color", Color::TRANSPARENT); 184 theme->selectorItemFocusBorderColor_ = 185 pattern->GetAttr<Color>("picker_selector_item_focus_border_color", Color::TRANSPARENT); 186 theme->selectorItemFocusBgColor_ = 187 pattern->GetAttr<Color>("picker_selector_item_focus_bg_color", Color::TRANSPARENT); 188 theme->selectorItemNormalBgColor_ = 189 pattern->GetAttr<Color>("picker_selector_item_normal_bg_color", Color::TRANSPARENT); 190 191 if (FOCUS_AREA_TYPE_IMPL == theme->focusImplType_) { 192 theme->focusOptionStyle_.SetFontSize(pattern->GetAttr<Dimension>( 193 "picker_focus_option_font_size", theme->selectedOptionStyle_.GetFontSize())); 194 theme->focusOptionStyle_.SetTextColor(pattern->GetAttr<Color>( 195 "picker_focus_option_text_color", theme->selectedOptionStyle_.GetTextColor())); 196 theme->dividerColor_ = pattern->GetAttr<Color>("picker_select_divider_color", Color::TRANSPARENT); 197 theme->focusColor_ = pattern->GetAttr<Color>("picker_focus_color", Color(0xff0a59f7)); 198 theme->focusPadding_ = pattern->GetAttr<Dimension>("picker_focus_padding", PICKER_FOCUS_PADDING); 199 } 200 } 201 InitializeTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)202 void InitializeTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 203 { 204 InitializeItemTextStyles(theme, themeStyle); 205 InitializeTitleTextStyles(theme, themeStyle); 206 InitializeButtonTextStyles(theme, themeStyle); 207 } 208 }; 209 210 ~PickerTheme() override = default; 211 PickerTheme() = default; clone()212 RefPtr<PickerTheme> clone() const 213 { 214 auto theme = AceType::Claim(new PickerTheme()); 215 theme->selectedOptionSize_ = selectedOptionSize_; 216 theme->selectedOptionStyle_ = selectedOptionStyle_; 217 theme->normalOptionSize_ = normalOptionSize_; 218 theme->normalOptionStyle_ = normalOptionStyle_; 219 theme->disappearOptionStyle_ = disappearOptionStyle_; 220 theme->showOptionCount_ = showOptionCount_; 221 theme->optionSizeUnit_ = optionSizeUnit_; 222 theme->popupDecoration_ = popupDecoration_; 223 theme->focusColor_ = focusColor_; 224 theme->popupEdge_ = popupEdge_; 225 theme->focusOptionStyle_ = focusOptionStyle_; 226 theme->focusOptionDecoration_ = focusOptionDecoration_; 227 theme->selectedOptionDecoration_ = selectedOptionDecoration_; 228 theme->buttonStyle_ = buttonStyle_; 229 theme->showButtons_ = showButtons_; 230 theme->buttonWidth_ = buttonWidth_; 231 theme->buttonHeight_ = buttonHeight_; 232 theme->buttonTopPadding_ = buttonTopPadding_; 233 theme->jumpInterval_ = jumpInterval_; 234 theme->columnIntervalMargin_ = columnIntervalMargin_; 235 theme->focusRadius_ = focusRadius_; 236 theme->optionPadding_ = optionPadding_; 237 theme->titleStyle_ = titleStyle_; 238 theme->titleBottomPadding_ = titleBottomPadding_; 239 theme->popupOutDecoration_ = popupOutDecoration_; 240 theme->lunarWidth_ = lunarWidth_; 241 theme->lunarHeight_ = lunarHeight_; 242 theme->timeSplitter_ = timeSplitter_; 243 theme->rotateInterval_ = rotateInterval_; 244 theme->deviceHeightLimit_ = deviceHeightLimit_; 245 theme->dividerThickness_ = dividerThickness_; 246 theme->dividerSpacing_ = dividerSpacing_; 247 theme->dividerColor_ = dividerColor_; 248 theme->gradientHeight_ = gradientHeight_; 249 theme->columnFixedWidth_ = columnFixedWidth_; 250 theme->disappearOptionStyle_ = disappearOptionStyle_; 251 theme->pressColor_ = pressColor_; 252 theme->hoverColor_ = hoverColor_; 253 theme->lunarswitchTextColor_ = lunarswitchTextColor_; 254 theme->lunarswitchTextSize_ = lunarswitchTextSize_; 255 theme->defaultStartDate_ = defaultStartDate_; 256 theme->defaultEndDate_ = defaultEndDate_; 257 cloneSelectorProps(theme); 258 return theme; 259 } 260 cloneSelectorProps(RefPtr<PickerTheme> theme)261 void cloneSelectorProps(RefPtr<PickerTheme> theme) const 262 { 263 theme->focusImplType_ = focusImplType_; 264 theme->selectorItemRadius_ = selectorItemRadius_; 265 theme->selectorItemSpace_ = selectorItemSpace_; 266 theme->selectorItemBorderWidth_ = selectorItemBorderWidth_; 267 theme->selectorItemFocusBorderWidth_ = selectorItemFocusBorderWidth_; 268 theme->selectorItemBorderColor_ = selectorItemBorderColor_; 269 theme->selectorItemFocusBorderColor_ = selectorItemFocusBorderColor_; 270 theme->selectorItemFocusBgColor_ = selectorItemFocusBgColor_; 271 theme->selectorItemNormalBgColor_ = selectorItemNormalBgColor_; 272 theme->focusPadding_ = focusPadding_; 273 } 274 GetOptionStyle(bool selected,bool focus)275 const TextStyle& GetOptionStyle(bool selected, bool focus) const 276 { 277 if (!selected) { 278 return normalOptionStyle_; 279 } 280 281 if (focus) { 282 return focusOptionStyle_; 283 } 284 285 return selectedOptionStyle_; 286 } SetOptionStyle(bool selected,bool focus,const TextStyle & value)287 void SetOptionStyle(bool selected, bool focus, const TextStyle& value) 288 { 289 if (!selected) { 290 normalOptionStyle_ = value; 291 } else if (focus) { 292 focusOptionStyle_ = value; 293 } else { 294 selectedOptionStyle_ = value; 295 } 296 } 297 GetDisappearOptionStyle()298 const TextStyle& GetDisappearOptionStyle() const 299 { 300 return disappearOptionStyle_; 301 } SetDisappearOptionStyle(const TextStyle & value)302 void SetDisappearOptionStyle(const TextStyle& value) 303 { 304 disappearOptionStyle_ = value; 305 } 306 GetButtonStyle()307 const TextStyle& GetButtonStyle() const 308 { 309 return buttonStyle_; 310 } 311 GetOptionDecoration(bool focus)312 const RefPtr<Decoration>& GetOptionDecoration(bool focus) 313 { 314 if (focus) { 315 return focusOptionDecoration_; 316 } 317 318 return selectedOptionDecoration_; 319 } SetOptionDecoration(bool focus,const RefPtr<Decoration> & value)320 void SetOptionDecoration(bool focus, const RefPtr<Decoration>& value) 321 { 322 if (focus) { 323 focusOptionDecoration_ = value; 324 } else { 325 selectedOptionDecoration_ = value; 326 } 327 } 328 GetOptionSize(bool selected)329 const Size& GetOptionSize(bool selected) const 330 { 331 if (selected) { 332 return selectedOptionSize_; 333 } 334 335 return normalOptionSize_; 336 } 337 GetShowOptionCount()338 uint32_t GetShowOptionCount() const 339 { 340 return showOptionCount_; 341 } 342 GetOptionSizeUnit()343 DimensionUnit GetOptionSizeUnit() const 344 { 345 return optionSizeUnit_; 346 } 347 GetPopupDecoration(bool isOutBox)348 const RefPtr<Decoration>& GetPopupDecoration(bool isOutBox) const 349 { 350 if (!isOutBox) { 351 return popupDecoration_; 352 } 353 return popupOutDecoration_; 354 } 355 GetFocusColor()356 const Color& GetFocusColor() const 357 { 358 return focusColor_; 359 } 360 GetPopupEdge()361 const Edge& GetPopupEdge() const 362 { 363 return popupEdge_; 364 } 365 GetShowButtons()366 bool GetShowButtons() const 367 { 368 return showButtons_; 369 } 370 GetButtonWidth()371 const Dimension& GetButtonWidth() const 372 { 373 return buttonWidth_; 374 } 375 GetButtonHeight()376 const Dimension& GetButtonHeight() const 377 { 378 return buttonHeight_; 379 } 380 GetButtonTopPadding()381 const Dimension& GetButtonTopPadding() const 382 { 383 return buttonTopPadding_; 384 } 385 GetJumpInterval()386 const Dimension& GetJumpInterval() const 387 { 388 return jumpInterval_; 389 } 390 GetColumnIntervalMargin()391 const Dimension& GetColumnIntervalMargin() const 392 { 393 return columnIntervalMargin_; 394 } 395 GetFocusRadius()396 const Radius& GetFocusRadius() const 397 { 398 return focusRadius_; 399 } 400 GetOptionPadding()401 double GetOptionPadding() const 402 { 403 return optionPadding_; 404 } SetOptionPadding(double value)405 void SetOptionPadding(double value) 406 { 407 optionPadding_ = value; 408 } 409 GetTitleStyle()410 const TextStyle& GetTitleStyle() const 411 { 412 return titleStyle_; 413 } 414 GetTitleBottomPadding()415 const Dimension& GetTitleBottomPadding() const 416 { 417 return titleBottomPadding_; 418 } 419 GetLunarWidth()420 const Dimension& GetLunarWidth() const 421 { 422 return lunarWidth_; 423 } 424 GetLunarHeight()425 const Dimension& GetLunarHeight() const 426 { 427 return lunarHeight_; 428 } 429 HasTimeSplitter()430 bool HasTimeSplitter() const 431 { 432 return (timeSplitter_ > 0); 433 } 434 GetRotateInterval()435 double GetRotateInterval() const 436 { 437 return rotateInterval_; 438 } 439 GetDeviceHeightLimit()440 double GetDeviceHeightLimit() const 441 { 442 return deviceHeightLimit_; 443 } 444 GetDividerThickness()445 const Dimension& GetDividerThickness() const 446 { 447 return dividerThickness_; 448 } 449 GetDividerSpacing()450 const Dimension& GetDividerSpacing() const 451 { 452 return dividerSpacing_; 453 } 454 GetDividerColor()455 const Color& GetDividerColor() const 456 { 457 return dividerColor_; 458 } 459 GetGradientHeight()460 const Dimension& GetGradientHeight() const 461 { 462 return gradientHeight_; 463 } 464 GetColumnFixedWidth()465 const Dimension& GetColumnFixedWidth() const 466 { 467 return columnFixedWidth_; 468 } 469 GetColumnBottomTotalHeight(bool hasLunar)470 Dimension GetColumnBottomTotalHeight(bool hasLunar) const 471 { 472 if (hasLunar) { 473 return buttonHeight_ + lunarHeight_ + buttonTopPadding_ * 2 + popupEdge_.Bottom(); //2: double padding 474 } else { 475 return buttonHeight_ + buttonTopPadding_ + popupEdge_.Bottom(); 476 } 477 } 478 GetPressColor()479 const Color& GetPressColor() const 480 { 481 return pressColor_; 482 } 483 GetHoverColor()484 const Color& GetHoverColor() const 485 { 486 return hoverColor_; 487 } 488 GetPaddingHorizontal()489 const Dimension& GetPaddingHorizontal() const 490 { 491 return paddingHorizontal_; 492 } 493 GetContentMarginVertical()494 const Dimension& GetContentMarginVertical() const 495 { 496 return contentMarginVertical_; 497 } 498 GetLunarSwitchTextSize()499 const Dimension& GetLunarSwitchTextSize() const 500 { 501 return lunarswitchTextSize_; 502 } 503 GetLunarSwitchTextColor()504 const Color& GetLunarSwitchTextColor() const 505 { 506 return lunarswitchTextColor_; 507 } 508 GetDefaultStartDate()509 const PickerDate& GetDefaultStartDate() const 510 { 511 return defaultStartDate_; 512 } 513 GetDefaultEndDate()514 const PickerDate& GetDefaultEndDate() const 515 { 516 return defaultEndDate_; 517 } 518 GetDefaultStartTime()519 const PickerTime& GetDefaultStartTime() const 520 { 521 return defaultStartTime_; 522 } 523 GetDefaultEndTime()524 const PickerTime& GetDefaultEndTime() const 525 { 526 return defaultEndTime_; 527 } 528 GetShowCountLandscape()529 uint32_t GetShowCountLandscape() const 530 { 531 return showCountLandscape_; 532 } 533 GetShowCountPortrait()534 uint32_t GetShowCountPortrait() const 535 { 536 return showCountPortrait_; 537 } 538 GetTitleFontScaleLimit()539 double GetTitleFontScaleLimit() 540 { 541 return titleFontScaleLimit_; 542 } 543 GetGradientHeightLimit()544 const Dimension& GetGradientHeightLimit() const 545 { 546 return gradientHeightLimit_; 547 } 548 GetDividerSpacingLimit()549 const Dimension& GetDividerSpacingLimit() const 550 { 551 return dividerSpacingHeightLimit_; 552 } 553 GetPickerDialogFontPadding()554 const Dimension& GetPickerDialogFontPadding() const 555 { 556 return pickerDialogFontPadding_; 557 } 558 GetUseSetSelectedTextStyle()559 const Dimension& GetUseSetSelectedTextStyle() const 560 { 561 return selectedTextStyle_; 562 } 563 GetUserSetNormalTextStyle()564 const Dimension& GetUserSetNormalTextStyle() const 565 { 566 return normalTextStyle_; 567 } 568 GetUserSetDisappearTextStyle()569 const Dimension& GetUserSetDisappearTextStyle() const 570 { 571 return disappearTextStyle_; 572 } 573 GetNormalFontScale()574 double GetNormalFontScale() const 575 { 576 return pickerDialogNormalFontScale_; 577 } 578 GetMaxOneFontScale()579 double GetMaxOneFontScale() const 580 { 581 return pickerDialogMaxOneFontScale_; 582 } 583 GetMaxTwoFontScale()584 double GetMaxTwoFontScale() const 585 { 586 return pickerDialogMaxTwoFontScale_; 587 } 588 GetMaxThirdFontScale()589 double GetMaxThirdFontScale() const 590 { 591 return pickerDialogMaxThirdFontScale_; 592 } 593 NeedButtonFocusAreaType()594 bool NeedButtonFocusAreaType() const 595 { 596 return focusImplType_ == FOCUS_AREA_TYPE_IMPL; 597 } 598 GetSelectorItemRadius()599 const Dimension& GetSelectorItemRadius() const 600 { 601 return selectorItemRadius_; 602 } 603 GetSelectorItemSpace()604 const Dimension& GetSelectorItemSpace() const 605 { 606 return selectorItemSpace_; 607 } 608 GetSelectorItemBorderWidth()609 const Dimension& GetSelectorItemBorderWidth() const 610 { 611 return selectorItemBorderWidth_; 612 } 613 GetSelectorItemFocusBorderWidth()614 const Dimension& GetSelectorItemFocusBorderWidth() const 615 { 616 return selectorItemFocusBorderWidth_; 617 } 618 GetFocusPadding()619 const Dimension& GetFocusPadding() const 620 { 621 return focusPadding_; 622 } 623 GetSelectorItemBorderColor()624 const Color& GetSelectorItemBorderColor() const 625 { 626 return selectorItemBorderColor_; 627 } 628 GetSelectorItemFocusBorderColor()629 const Color& GetSelectorItemFocusBorderColor() const 630 { 631 return selectorItemFocusBorderColor_; 632 } 633 GetSelectorItemFocusBgColor()634 const Color& GetSelectorItemFocusBgColor() const 635 { 636 return selectorItemFocusBgColor_; 637 } 638 GetSelectorItemNormalBgColor()639 const Color& GetSelectorItemNormalBgColor() const 640 { 641 return selectorItemNormalBgColor_; 642 } 643 GetBackgroundColor()644 const Color& GetBackgroundColor() const 645 { 646 return backgroundColor_; 647 } 648 GetDigitalCrownSensitivity()649 int32_t GetDigitalCrownSensitivity() const 650 { 651 return crownSensitivity_; 652 } 653 IsCircleDial()654 bool IsCircleDial() const 655 { 656 return showCircleDial_; 657 } 658 659 private: 660 661 Color focusColor_; 662 Color hoverColor_; 663 Color pressColor_; 664 Color lunarswitchTextColor_; 665 Color backgroundColor_; 666 int32_t crownSensitivity_ = OHOS::Ace::NG::DEFAULT_CROWNSENSITIVITY; 667 bool showCircleDial_ = false; 668 669 Radius focusRadius_; 670 uint32_t showOptionCount_ = 0; 671 bool showButtons_ = false; 672 Dimension jumpInterval_; 673 674 // popup style 675 RefPtr<Decoration> popupDecoration_; 676 RefPtr<Decoration> popupOutDecoration_; 677 Edge popupEdge_; 678 679 // column 680 Dimension columnIntervalMargin_; 681 682 // text style 683 TextStyle focusOptionStyle_; 684 TextStyle selectedOptionStyle_; 685 TextStyle normalOptionStyle_; 686 TextStyle disappearOptionStyle_; 687 TextStyle buttonStyle_; 688 TextStyle titleStyle_; 689 690 // text around decoration 691 RefPtr<Decoration> selectedOptionDecoration_; 692 RefPtr<Decoration> focusOptionDecoration_; 693 694 // option size 695 Size selectedOptionSize_; 696 Size normalOptionSize_; 697 double optionPadding_ = 0.0; 698 DimensionUnit optionSizeUnit_ = DimensionUnit::PX; 699 700 // buttons size 701 Dimension buttonWidth_; 702 Dimension buttonHeight_; 703 Dimension buttonTopPadding_; 704 Dimension titleBottomPadding_; 705 706 // lunar size 707 Dimension lunarWidth_; 708 Dimension lunarHeight_; 709 710 uint32_t timeSplitter_ = 0; 711 712 double rotateInterval_ = 0.0; 713 Dimension dividerThickness_; 714 Dimension dividerSpacing_; 715 Color dividerColor_; 716 Dimension gradientHeight_; 717 Dimension columnFixedWidth_; 718 719 Dimension paddingHorizontal_; 720 Dimension contentMarginVertical_; 721 Dimension lunarswitchTextSize_; 722 723 PickerDate defaultStartDate_ = PickerDate(1970, 1, 1); 724 PickerDate defaultEndDate_ = PickerDate(2100, 12, 31); 725 PickerTime defaultStartTime_ = PickerTime(0, 0, 0); 726 PickerTime defaultEndTime_ = PickerTime(23, 59, 59); 727 728 uint32_t showCountLandscape_ = 3; 729 uint32_t showCountPortrait_ = 5; 730 double deviceHeightLimit_ = 640.0; 731 Dimension gradientHeightLimit_ = 54.0_vp; 732 Dimension dividerSpacingHeightLimit_ = 64.0_vp; 733 Dimension pickerDialogFontPadding_ = 8.0_vp; 734 Dimension selectedTextStyle_ = 40.0_vp; 735 Dimension normalTextStyle_ = 32.0_vp; 736 Dimension disappearTextStyle_ = 28.0_vp; 737 double pickerDialogNormalFontScale_ = 1.0f; 738 double pickerDialogMaxOneFontScale_ = 1.75f; 739 double pickerDialogMaxTwoFontScale_ = 2.0f; 740 double pickerDialogMaxThirdFontScale_ = 3.2f; 741 double titleFontScaleLimit_ = 1.45f; 742 743 uint32_t focusImplType_ = 0; 744 Dimension selectorItemRadius_; 745 Dimension selectorItemSpace_; 746 Dimension selectorItemBorderWidth_; 747 Dimension selectorItemFocusBorderWidth_; 748 Dimension focusPadding_; 749 Color selectorItemBorderColor_; 750 Color selectorItemFocusBorderColor_; 751 Color selectorItemFocusBgColor_; 752 Color selectorItemNormalBgColor_; 753 }; 754 755 } // namespace OHOS::Ace 756 757 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_THEME_H 758