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