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_BASE_PROPERTIES_SWIPER_INDICATOR_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_PROPERTIES_SWIPER_INDICATOR_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components/swiper/swiper_indicator_theme.h" 21 22 namespace OHOS::Ace { 23 24 class ACE_EXPORT SwiperIndicator : public AceType { 25 DECLARE_ACE_TYPE(SwiperIndicator, AceType); 26 27 public: InitStyle(const RefPtr<SwiperIndicatorTheme> & theme)28 void InitStyle(const RefPtr<SwiperIndicatorTheme>& theme) 29 { 30 if (!theme) { 31 LOGD("param theme is nullptr"); 32 return; 33 } 34 color_ = theme->GetColor(); 35 selectedColor_ = theme->GetSelectedColor(); 36 size_ = theme->GetSize(); 37 selectedSize_ = theme->GetSelectedSize(); 38 isHasIndicatorMask_ = theme->GetIndicatorMask(); 39 indicatorPointPadding_ = theme->GetIndicatorPointPadding(); 40 digitalIndicatorTextStyle_ = theme->GetDigitalIndicatorTextStyle(); 41 startEndPadding_ = theme->GetStartEndPadding(); 42 pressPadding_ = theme->GetPressPadding(); 43 pressPointPadding_ = theme->GetPressPointPadding(); 44 pressSize_ = theme->GetPressSize(); 45 hoverSize_ = theme->GetHoverSize(); 46 hotZoneSize_ = theme->GetHotZoneSize(); 47 hotZoneColor_ = theme->GetHotZoneColor(); 48 indicatorTextFocusColor_ = theme->GetIndicatorTextFocusColor(); 49 isIndicatorDisabled_ = theme->GetIndicatorDisabled(); 50 } 51 GetColor()52 const Color& GetColor() const 53 { 54 return color_; 55 } SetColor(const Color & color)56 void SetColor(const Color& color) 57 { 58 color_ = color; 59 } 60 GetSelectedColor()61 const Color& GetSelectedColor() const 62 { 63 return selectedColor_; 64 } SetSelectedColor(const Color & selectedColor)65 void SetSelectedColor(const Color& selectedColor) 66 { 67 selectedColor_ = selectedColor; 68 } 69 GetSize()70 const Dimension& GetSize() const 71 { 72 return size_; 73 } SetSize(const Dimension & size)74 void SetSize(const Dimension& size) 75 { 76 size_ = size; 77 } 78 GetSelectedSize()79 const Dimension& GetSelectedSize() const 80 { 81 return selectedSize_; 82 } SetSelectedSize(const Dimension & selectedSize)83 void SetSelectedSize(const Dimension& selectedSize) 84 { 85 selectedSize_ = selectedSize; 86 } 87 GetTop()88 const Dimension& GetTop() const 89 { 90 return top_; 91 } SetTop(const Dimension & top)92 void SetTop(const Dimension& top) 93 { 94 top_ = top; 95 } 96 GetLeft()97 const Dimension& GetLeft() const 98 { 99 return left_; 100 } SetLeft(const Dimension & left)101 void SetLeft(const Dimension& left) 102 { 103 left_ = left; 104 } 105 GetBottom()106 const Dimension& GetBottom() const 107 { 108 return bottom_; 109 } SetBottom(const Dimension & bottom)110 void SetBottom(const Dimension& bottom) 111 { 112 bottom_ = bottom; 113 } 114 GetRight()115 const Dimension& GetRight() const 116 { 117 return right_; 118 } 119 SetRight(const Dimension & right)120 void SetRight(const Dimension& right) 121 { 122 right_ = right; 123 } 124 GetIndicatorMask()125 bool GetIndicatorMask() const 126 { 127 return isHasIndicatorMask_; 128 } 129 SetIndicatorMask(bool isHasIndicatorMask)130 void SetIndicatorMask(bool isHasIndicatorMask) 131 { 132 isHasIndicatorMask_ = isHasIndicatorMask; 133 } 134 SetIndicatorPointPadding(const Dimension & indicatorPointPadding)135 void SetIndicatorPointPadding(const Dimension& indicatorPointPadding) 136 { 137 indicatorPointPadding_ = indicatorPointPadding; 138 } 139 GetIndicatorPointPadding()140 const Dimension& GetIndicatorPointPadding() const 141 { 142 return indicatorPointPadding_; 143 } 144 145 static constexpr double DEFAULT_POSITION { -1.0 }; 146 GetDigitalIndicatorTextStyle()147 const TextStyle& GetDigitalIndicatorTextStyle() const 148 { 149 return digitalIndicatorTextStyle_; 150 } 151 SetStartEndPadding(const Dimension & startEndPadding)152 void SetStartEndPadding(const Dimension& startEndPadding) 153 { 154 startEndPadding_ = startEndPadding; 155 } 156 GetStartEndPadding()157 const Dimension& GetStartEndPadding() const 158 { 159 return startEndPadding_; 160 } 161 SetPressPadding(const Dimension & pressPadding)162 void SetPressPadding(const Dimension& pressPadding) 163 { 164 pressPadding_ = pressPadding; 165 } 166 GetPressPadding()167 const Dimension& GetPressPadding() const 168 { 169 return pressPadding_; 170 } 171 SetPressPointPadding(const Dimension & pressPointPadding)172 void SetPressPointPadding(const Dimension& pressPointPadding) 173 { 174 pressPointPadding_ = pressPointPadding; 175 } 176 GetPressPointPadding()177 const Dimension& GetPressPointPadding() const 178 { 179 return pressPointPadding_; 180 } 181 SetPressSize(const Dimension & pressSize)182 void SetPressSize(const Dimension& pressSize) 183 { 184 pressSize_ = pressSize; 185 } 186 GetPressSize()187 const Dimension& GetPressSize() const 188 { 189 return pressSize_; 190 } 191 SetHoverSize(const Dimension & hoverSize)192 void SetHoverSize(const Dimension& hoverSize) 193 { 194 hoverSize_ = hoverSize; 195 } 196 GetHoverSize()197 const Dimension& GetHoverSize() const 198 { 199 return hoverSize_; 200 } 201 SetHotZoneSize(const Dimension & hotZoneSize)202 void SetHotZoneSize(const Dimension& hotZoneSize) 203 { 204 hotZoneSize_ = hotZoneSize; 205 } 206 GetHotZoneSize()207 const Dimension& GetHotZoneSize() const 208 { 209 return hotZoneSize_; 210 } 211 SetHotZoneColor(const Color & hotZoneColor)212 void SetHotZoneColor(const Color& hotZoneColor) 213 { 214 hotZoneColor_ = hotZoneColor; 215 } 216 GetHotZoneColor()217 const Color& GetHotZoneColor() const 218 { 219 return hotZoneColor_; 220 } 221 GetIndicatorTextFocusColor()222 const Color& GetIndicatorTextFocusColor() const 223 { 224 return indicatorTextFocusColor_; 225 } 226 GetIndicatorDisabled()227 bool GetIndicatorDisabled() const 228 { 229 return isIndicatorDisabled_; 230 } 231 SetIndicatorDisabled(bool isIndicatorDisabled)232 void SetIndicatorDisabled(bool isIndicatorDisabled) 233 { 234 isIndicatorDisabled_ = isIndicatorDisabled; 235 } 236 237 private: 238 Color color_; 239 Color selectedColor_; 240 Dimension size_; 241 Dimension selectedSize_; 242 Dimension top_ { DEFAULT_POSITION, DimensionUnit::PX }; 243 Dimension left_ { DEFAULT_POSITION, DimensionUnit::PX }; 244 Dimension bottom_ { DEFAULT_POSITION, DimensionUnit::PX }; 245 Dimension right_ { DEFAULT_POSITION, DimensionUnit::PX }; 246 Dimension indicatorPointPadding_ { 8.0, DimensionUnit::VP }; 247 bool isHasIndicatorMask_ { false }; 248 TextStyle digitalIndicatorTextStyle_; 249 Dimension startEndPadding_; 250 Dimension pressPadding_; 251 Dimension pressPointPadding_; 252 Dimension pressSize_; 253 Dimension hoverSize_; 254 Dimension hotZoneSize_; 255 Color hotZoneColor_; 256 Color indicatorTextFocusColor_; 257 bool isIndicatorDisabled_ { false }; 258 }; 259 260 } // namespace OHOS::Ace 261 262 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_PROPERTIES_SWIPER_INDICATOR_H 263