1 /* 2 * Copyright (c) 2022-2025 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_NG_PATTERNS_SWIPER_INDICATOR_SWIPER_INDICATOR_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_INDICATOR_SWIPER_INDICATOR_PATTERN_H 18 19 #include "base/memory/ace_type.h" 20 #include "base/utils/utils.h" 21 #include "core/components_ng/base/frame_node.h" 22 #include "core/components_ng/pattern/pattern.h" 23 #include "core/components_ng/pattern/swiper/swiper_pattern.h" 24 #include "core/components_ng/pattern/swiper_indicator/circle_dot_indicator/circle_dot_indicator_layout_algorithm.h" 25 #include "core/components_ng/pattern/swiper_indicator/circle_dot_indicator/circle_dot_indicator_paint_method.h" 26 #include "core/components_ng/pattern/swiper_indicator/digit_indicator/digit_indicator_layout_algorithm.h" 27 #include "core/components_ng/pattern/swiper_indicator/dot_indicator/overlength_dot_indicator_paint_method.h" 28 #include "core/components_ng/pattern/swiper_indicator/dot_indicator/dot_indicator_layout_algorithm.h" 29 #include "core/components_ng/pattern/swiper_indicator/dot_indicator/dot_indicator_paint_method.h" 30 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_accessibility_property.h" 31 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_layout_property.h" 32 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_utils.h" 33 #include "core/components_ng/pattern/text/text_layout_property.h" 34 #include "core/components_ng/pattern/text/text_pattern.h" 35 namespace OHOS::Ace::NG { 36 class SwiperIndicatorPattern : public Pattern { 37 DECLARE_ACE_TYPE(SwiperIndicatorPattern, Pattern); 38 public: 39 SwiperIndicatorPattern() = default; 40 ~SwiperIndicatorPattern() override = default; SwiperIndicatorPattern(SwiperIndicatorType indicatorType)41 SwiperIndicatorPattern(SwiperIndicatorType indicatorType): swiperIndicatorType_(indicatorType) 42 {} 43 CreateLayoutProperty()44 RefPtr<LayoutProperty> CreateLayoutProperty() override 45 { 46 return MakeRefPtr<SwiperIndicatorLayoutProperty>(); 47 } 48 CreatePaintProperty()49 RefPtr<PaintProperty> CreatePaintProperty() override 50 { 51 if (swiperIndicatorType_ == SwiperIndicatorType::DOT) { 52 return MakeRefPtr<DotIndicatorPaintProperty>(); 53 } else { 54 return MakeRefPtr<PaintProperty>(); 55 } 56 } 57 CreateAccessibilityProperty()58 RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override 59 { 60 return MakeRefPtr<SwiperIndicatorAccessibilityProperty>(); 61 } 62 CreateLayoutAlgorithm()63 RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override 64 { 65 auto swiperNode = GetSwiperNode(); 66 CHECK_NULL_RETURN(swiperNode, nullptr); 67 auto swiperPattern = swiperNode->GetPattern<SwiperPattern>(); 68 CHECK_NULL_RETURN(swiperPattern, nullptr); 69 if (GetIndicatorType() == SwiperIndicatorType::DOT) { 70 auto indicatorLayoutAlgorithm = MakeRefPtr<DotIndicatorLayoutAlgorithm>(); 71 indicatorLayoutAlgorithm->SetIsHoverOrPress(isHover_ || isPressed_); 72 indicatorLayoutAlgorithm->SetHoverPoint(hoverPoint_); 73 auto indicatorDisplayCount = !swiperPattern->IsAutoLinear() ? 74 swiperPattern->DisplayIndicatorTotalCount() : swiperPattern->TotalCount(); 75 auto maxDisplayCount = swiperPattern->GetMaxDisplayCount(); 76 maxDisplayCount > 0 ? indicatorLayoutAlgorithm->SetIndicatorDisplayCount(maxDisplayCount) 77 : indicatorLayoutAlgorithm->SetIndicatorDisplayCount(indicatorDisplayCount); 78 indicatorLayoutAlgorithm->SetMaxDisplayCount(maxDisplayCount); 79 indicatorLayoutAlgorithm->SetIsBindIndicator(swiperPattern->IsBindIndicator()); 80 indicatorLayoutAlgorithm->SetIndicatorInteractive(swiperPattern->IsIndicatorInteractive()); 81 return indicatorLayoutAlgorithm; 82 } else if (swiperPattern->GetIndicatorType() == SwiperIndicatorType::ARC_DOT) { 83 auto indicatorLayoutAlgorithm = MakeRefPtr<CircleDotIndicatorLayoutAlgorithm>(); 84 return indicatorLayoutAlgorithm; 85 } else { 86 auto indicatorLayoutAlgorithm = MakeRefPtr<DigitIndicatorLayoutAlgorithm>(); 87 indicatorLayoutAlgorithm->SetIsHoverOrPress(isHover_ || isPressed_); 88 indicatorLayoutAlgorithm->SetHoverPoint(hoverPoint_); 89 return indicatorLayoutAlgorithm; 90 } 91 } 92 SetDotIndicatorPaintMethodInfo(const RefPtr<SwiperPattern> & swiperPattern,RefPtr<DotIndicatorPaintMethod> & paintMethod,RefPtr<SwiperLayoutProperty> & swiperLayoutProperty)93 void SetDotIndicatorPaintMethodInfo(const RefPtr<SwiperPattern>& swiperPattern, 94 RefPtr<DotIndicatorPaintMethod>& paintMethod, 95 RefPtr<SwiperLayoutProperty>& swiperLayoutProperty) 96 { 97 CHECK_NULL_VOID(swiperPattern); 98 CHECK_NULL_VOID(paintMethod); 99 CHECK_NULL_VOID(swiperLayoutProperty); 100 paintMethod->SetAxis(swiperPattern->GetDirection()); 101 paintMethod->SetCurrentIndex(swiperPattern->GetLoopIndex(swiperPattern->GetCurrentFirstIndex())); 102 paintMethod->SetCurrentIndexActual(swiperPattern->GetLoopIndex(swiperPattern->GetCurrentIndex())); 103 paintMethod->SetNextValidIndex(swiperPattern->GetNextValidIndex()); 104 paintMethod->SetHorizontalAndRightToLeft(swiperLayoutProperty->GetNonAutoLayoutDirection()); 105 paintMethod->SetItemCount(swiperPattern->DisplayIndicatorTotalCount()); 106 paintMethod->SetTotalItemCount(swiperPattern->TotalCount()); 107 paintMethod->SetIsAutoLinear(swiperPattern->IsAutoLinear()); 108 paintMethod->SetSwipeByGroup(swiperLayoutProperty->GetSwipeByGroup().value_or(false)); 109 paintMethod->SetDisplayCount(swiperLayoutProperty->GetDisplayCount().value_or(1)); 110 gestureState_ = swiperPattern->GetGestureState(); 111 paintMethod->SetGestureState(gestureState_); 112 paintMethod->SetTurnPageRate(swiperPattern->GetTurnPageRate()); 113 paintMethod->SetGroupTurnPageRate(swiperPattern->GetGroupTurnPageRate()); 114 paintMethod->SetIsLoop(swiperPattern->IsLoop()); 115 paintMethod->SetTouchBottomTypeLoop(swiperPattern->GetTouchBottomTypeLoop()); 116 paintMethod->SetIsHover(isHover_); 117 paintMethod->SetIsPressed(isPressed_); 118 paintMethod->SetHoverPoint(hoverPoint_); 119 if (mouseClickIndex_) { 120 mouseClickIndex_ = swiperPattern->GetLoopIndex(mouseClickIndex_.value()); 121 } 122 paintMethod->SetMouseClickIndex(mouseClickIndex_); 123 paintMethod->SetIsTouchBottom(touchBottomType_); 124 paintMethod->SetTouchBottomRate(swiperPattern->GetTouchBottomRate()); 125 auto currentTurnPageRate = !swiperPattern->IsAutoLinear() && 126 swiperLayoutProperty->GetSwipeByGroup().value_or(false) ? 127 swiperPattern->CalculateGroupTurnPageRate(0.0f) : swiperPattern->CalcCurrentTurnPageRate(true); 128 paintMethod->SetTouchBottomPageRate(currentTurnPageRate); 129 paintMethod->SetFirstIndex(swiperPattern->GetLoopIndex(swiperPattern->GetFirstIndexInVisibleArea())); 130 auto targetIndex = swiperPattern->GetTargetIndex(); 131 targetIndex ? paintMethod->SetTargetIndex(swiperPattern->GetLoopIndex(targetIndex.value())) 132 : paintMethod->SetTargetIndex(std::nullopt); 133 mouseClickIndex_ = std::nullopt; 134 } 135 CreateCircleDotIndicatorPaintMethod(RefPtr<SwiperPattern> swiperPattern)136 RefPtr<CircleDotIndicatorPaintMethod> CreateCircleDotIndicatorPaintMethod(RefPtr<SwiperPattern> swiperPattern) 137 { 138 auto swiperLayoutProperty = swiperPattern->GetLayoutProperty<SwiperLayoutProperty>(); 139 CHECK_NULL_RETURN(swiperLayoutProperty, nullptr); 140 auto paintMethod = MakeRefPtr<CircleDotIndicatorPaintMethod>(circleDotIndicatorModifier_); 141 paintMethod->SetAxis(swiperPattern->GetDirection()); 142 paintMethod->SetCurrentIndex(swiperPattern->GetLoopIndex(swiperPattern->GetCurrentFirstIndex())); 143 paintMethod->SetCurrentIndexActual(swiperPattern->GetLoopIndex(swiperPattern->GetCurrentIndex())); 144 paintMethod->SetNextValidIndex(swiperPattern->GetNextValidIndex()); 145 paintMethod->SetItemCount(swiperPattern->RealTotalCount()); 146 paintMethod->SetHorizontalAndRightToLeft(swiperLayoutProperty->GetNonAutoLayoutDirection()); 147 paintMethod->SetGestureState(swiperPattern->GetGestureState()); 148 paintMethod->SetTurnPageRate(swiperPattern->GetTurnPageRate()); 149 paintMethod->SetTouchBottomTypeLoop(swiperPattern->GetTouchBottomTypeLoop()); 150 paintMethod->SetIsLongPressed(isLongPressed_); 151 if (mouseClickIndex_) { 152 mouseClickIndex_ = swiperPattern->GetLoopIndex(mouseClickIndex_.value()); 153 } 154 paintMethod->SetIsTouchBottom(touchBottomType_); 155 paintMethod->SetMouseClickIndex(mouseClickIndex_); 156 paintMethod->SetTouchBottomRate(swiperPattern->GetTouchBottomRate()); 157 mouseClickIndex_ = std::nullopt; 158 return paintMethod; 159 } 160 CreateNodePaintMethod()161 RefPtr<NodePaintMethod> CreateNodePaintMethod() override 162 { 163 auto swiperNode = GetSwiperNode(); 164 CHECK_NULL_RETURN(swiperNode, nullptr); 165 auto swiperPattern = swiperNode->GetPattern<SwiperPattern>(); 166 CHECK_NULL_RETURN(swiperPattern, nullptr); 167 if (GetIndicatorType() == SwiperIndicatorType::DOT) { 168 if (swiperPattern->GetMaxDisplayCount() > 0) { 169 SetIndicatorInteractive(false); 170 return CreateOverlongDotIndicatorPaintMethod(swiperPattern); 171 } 172 173 SetIndicatorInteractive(swiperPattern->IsIndicatorInteractive()); 174 return CreateDotIndicatorPaintMethod(swiperPattern); 175 } else if (swiperPattern->GetIndicatorType() == SwiperIndicatorType::ARC_DOT) { 176 if (!circleDotIndicatorModifier_) { 177 circleDotIndicatorModifier_ = AceType::MakeRefPtr<CircleDotIndicatorModifier>(); 178 circleDotIndicatorModifier_->SetLongPointHeadCurve(swiperPattern->GetCurveIncludeMotion()); 179 } 180 181 auto paintMethod = CreateCircleDotIndicatorPaintMethod(swiperPattern); 182 return paintMethod; 183 } 184 return nullptr; 185 } 186 GetSwiperNode()187 virtual RefPtr<FrameNode> GetSwiperNode() const 188 { 189 auto host = GetHost(); 190 CHECK_NULL_RETURN(host, nullptr); 191 auto swiperNode = host->GetParent(); 192 CHECK_NULL_RETURN(swiperNode, nullptr); 193 return DynamicCast<FrameNode>(swiperNode); 194 } 195 GetFocusPattern()196 FocusPattern GetFocusPattern() const override 197 { 198 FocusPattern focusPattern = { FocusType::NODE, true, FocusStyleType::INNER_BORDER }; 199 auto pipelineContext = PipelineBase::GetCurrentContext(); 200 CHECK_NULL_RETURN(pipelineContext, FocusPattern()); 201 auto swiperTheme = pipelineContext->GetTheme<SwiperIndicatorTheme>(); 202 CHECK_NULL_RETURN(swiperTheme, FocusPattern()); 203 FocusPaintParam paintParam; 204 paintParam.SetPaintWidth(swiperTheme->GetFocusedBorderWidth()); 205 paintParam.SetPaintColor(swiperTheme->GetFocusedColor()); 206 focusPattern.SetFocusPaintParams(paintParam); 207 if (swiperIndicatorType_ != SwiperIndicatorType::DOT) { 208 return focusPattern; 209 } 210 auto focusStyleType = static_cast<FocusStyleType>(swiperTheme->GetFocusStyleType()); 211 focusPattern.SetStyleType(focusStyleType); 212 return focusPattern; 213 } 214 SetChangeIndexWithAnimation(bool withAnimation)215 void SetChangeIndexWithAnimation(bool withAnimation) 216 { 217 changeIndexWithAnimation_ = withAnimation; 218 } 219 SetJumpIndex(std::optional<int32_t> jumpIndex)220 void SetJumpIndex(std::optional<int32_t> jumpIndex) 221 { 222 jumpIndex_ = jumpIndex; 223 } 224 SetIsInFast(std::optional<bool> isInFast)225 void SetIsInFast(std::optional<bool> isInFast) 226 { 227 isInFast_ = isInFast; 228 } 229 SetStartIndex(std::optional<int32_t> startIndex)230 void SetStartIndex(std::optional<int32_t> startIndex) 231 { 232 startIndex_ = startIndex; 233 } 234 235 void DumpAdvanceInfo() override; 236 void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) override; 237 void SetIndicatorInteractive(bool isInteractive); SetArcIndicatorHotRegion(const RefPtr<LayoutWrapper> & dirty,const DirtySwapConfig & config)238 virtual bool SetArcIndicatorHotRegion(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) 239 { 240 return false; 241 } GetCenterPointF()242 virtual PointF GetCenterPointF() 243 { 244 return PointF(0.0, 0.0); 245 } GetAngleWithPoint(const PointF & conter,const PointF & point)246 virtual float GetAngleWithPoint(const PointF& conter, const PointF& point) 247 { 248 return 0.0; 249 } GetEndAngle(const PointF & conter,const PointF & point,float startAngle)250 virtual float GetEndAngle(const PointF& conter, const PointF& point, float startAngle) 251 { 252 return 0.0; 253 } UpadateStartAngle()254 virtual void UpadateStartAngle() {}; InitAccessibilityFocusEvent()255 virtual void InitAccessibilityFocusEvent(){}; 256 virtual Axis GetDirection() const; 257 virtual bool GetDotCurrentOffset(OffsetF& offset, float indicatorWidth, float indicatorHeight); 258 void OnModifyDone() override; 259 void IndicatorOnChange(); 260 void InitIndicatorEvent(); 261 virtual bool GetDigitFrameSize(RefPtr<GeometryNode>& geoNode, SizeF& frameSize) const; 262 virtual int32_t RealTotalCount() const; 263 virtual int32_t GetCurrentIndex() const; 264 void ResetDotModifier(); GetDotIndicatorModifier()265 const RefPtr<DotIndicatorModifier>& GetDotIndicatorModifier() const 266 { 267 return dotIndicatorModifier_; 268 } 269 270 private: 271 void OnAttachToFrameNode() override; 272 bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override; 273 void InitClickEvent(const RefPtr<GestureEventHub>& gestureHub); 274 void HandleClick(const GestureEvent& info); 275 void HandleMouseClick(const GestureEvent& info); 276 void HandleTouchClick(const GestureEvent& info); 277 void InitHoverMouseEvent(); 278 void HandleMouseEvent(const MouseInfo& info); 279 void HandleHoverEvent(bool isHover); 280 void HoverInAnimation(const Color& hoverColor); 281 void HoverOutAnimation(const Color& normalColor); 282 void HandleTouchEvent(const TouchEventInfo& info); 283 void HandleTouchDown(); 284 void HandleTouchUp(); 285 void HandleDragStart(const GestureEvent& info); 286 void GetMouseClickIndex(); 287 void UpdateTextContent(const RefPtr<SwiperIndicatorLayoutProperty>& layoutProperty, 288 const RefPtr<FrameNode>& firstTextNode, const RefPtr<FrameNode>& lastTextNode); 289 void UpdateTextContentSub( 290 const RefPtr<SwiperIndicatorLayoutProperty>& layoutProperty, 291 const RefPtr<FrameNode>& firstTextNode, const RefPtr<FrameNode>& lastTextNode); 292 bool CheckIsTouchBottom(const GestureEvent& info); 293 void InitLongPressEvent(const RefPtr<GestureEventHub>& gestureHub); 294 void HandleLongPress(GestureEvent& info); 295 bool CheckIsTouchBottom(const TouchLocationInfo& info); 296 float HandleTouchClickMargin(); 297 int32_t GetInitialIndex() const; 298 void GetInnerFocusPaintRect(RoundRect& paintRect); 299 void InitFocusEvent(); 300 void HandleFocusEvent(); 301 void HandleBlurEvent(); 302 void AddIsFocusActiveUpdateEvent(); 303 void RemoveIsFocusActiveUpdateEvent(); 304 void OnIsFocusActiveUpdate(bool isFocusAcitve); 305 RefPtr<OverlengthDotIndicatorPaintMethod> CreateOverlongDotIndicatorPaintMethod( 306 RefPtr<SwiperPattern> swiperPattern); 307 RefPtr<DotIndicatorPaintMethod> CreateDotIndicatorPaintMethod(RefPtr<SwiperPattern> swiperPattern); 308 void UpdateOverlongPaintMethod( 309 const RefPtr<SwiperPattern>& swiperPattern, RefPtr<OverlengthDotIndicatorPaintMethod>& overlongPaintMethod); 310 int32_t GetDisplayCurrentIndex() const; 311 void RegisterIndicatorChangeEvent(); 312 std::pair<int32_t, int32_t> CalculateStepAndItemCount() const; 313 std::pair<int32_t, int32_t> CalculateStepAndItemCountDefault() const; 314 void UpdateFocusable() const; 315 void CheckDragAndUpdate( 316 const RefPtr<SwiperPattern>& swiperPattern, int32_t animationStartIndex, int32_t animationEndIndex); 317 void UpdateOverlongPaintMethodWhenFast(const RefPtr<DotIndicatorPaintMethod>& paintMethodTemp, 318 int32_t& animationStartIndex, int32_t& animationEndIndex); 319 void UpdateOverlongPaintMethodWhenNormal(const RefPtr<DotIndicatorPaintMethod>& paintMethodTemp, 320 int32_t& animationStartIndex, int32_t& animationEndIndex); 321 void GetStatusForOverlongPaintMethodWhenNormal(const RefPtr<SwiperPattern>& swiperPattern, 322 const int32_t& animationStartIndex, const int32_t& animationEndIndex, 323 bool& keepStatus, bool& isSwiperTouchDown) const; 324 325 326 double GetIndicatorDragAngleThreshold(bool isMaxAngle); 327 RefPtr<ClickEvent> clickEvent_; 328 RefPtr<InputEvent> hoverEvent_; 329 RefPtr<TouchEventImpl> touchEvent_; 330 RefPtr<InputEvent> mouseEvent_; 331 RefPtr<LongPressEvent> longPressEvent_; 332 bool isHover_ = false; 333 bool isPressed_ = false; 334 bool isLongPressed_ = false; 335 PointF hoverPoint_; 336 PointF dragStartPoint_; 337 TouchBottomType touchBottomType_ = TouchBottomType::NONE; 338 bool isClicked_ = false; 339 bool isRepeatClicked_ = false; 340 bool focusEventInitialized_ = false; 341 std::function<void(bool)> isFocusActiveUpdateEvent_; 342 343 std::optional<int32_t> mouseClickIndex_ = std::nullopt; 344 RefPtr<DotIndicatorModifier> dotIndicatorModifier_; 345 RefPtr<CircleDotIndicatorModifier> circleDotIndicatorModifier_; 346 RefPtr<OverlengthDotIndicatorModifier> overlongDotIndicatorModifier_; 347 SwiperIndicatorType swiperIndicatorType_ = SwiperIndicatorType::DOT; 348 349 std::optional<int32_t> jumpIndex_; 350 std::optional<bool> isInFast_; 351 std::optional<int32_t> startIndex_; 352 std::optional<bool> changeIndexWithAnimation_; 353 std::optional<GestureState> keepGestureState_; 354 GestureState gestureState_ = GestureState::GESTURE_STATE_INIT; 355 ACE_DISALLOW_COPY_AND_MOVE(SwiperIndicatorPattern); 356 357 protected: 358 OffsetF CalculateAngleOffset(float centerX, float centerY, float radius, double angle); 359 OffsetF CalculateRectLayout(double angle, float radius, OffsetF angleOffset, Dimension& width, Dimension& height); FireChangeEvent()360 virtual void FireChangeEvent() const {} FireIndicatorIndexChangeEvent(int32_t index)361 virtual void FireIndicatorIndexChangeEvent(int32_t index) const {} 362 virtual void SwipeTo(std::optional<int32_t> mouseClickIndex); 363 virtual void ShowPrevious(); 364 virtual void ShowNext(); 365 virtual void ChangeIndex(int32_t index, bool useAnimation); 366 virtual bool IsHorizontalAndRightToLeft() const; 367 virtual TextDirection GetNonAutoLayoutDirection() const; 368 virtual void GetTextContentSub(std::string& firstContent, std::string& lastContent) const; 369 virtual int32_t GetCurrentShownIndex() const; 370 virtual int32_t DisplayIndicatorTotalCount() const; 371 virtual bool IsLoop() const; 372 virtual int32_t GetTouchCurrentIndex() const; 373 virtual std::pair<int32_t, int32_t> CalMouseClickIndexStartAndEnd(int32_t itemCount, int32_t currentIndex); 374 virtual void HandleLongDragUpdate(const TouchLocationInfo& info); 375 virtual void HandleDragEnd(double dragVelocity); 376 virtual void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub); 377 GetSwiperPattern()378 RefPtr<SwiperPattern> GetSwiperPattern() const 379 { 380 auto swiperNode = GetSwiperNode(); 381 CHECK_NULL_RETURN(swiperNode, nullptr); 382 return swiperNode->GetPattern<SwiperPattern>(); 383 } 384 GetIndicatorType()385 virtual SwiperIndicatorType GetIndicatorType() const 386 { 387 auto swiperPattern = GetSwiperPattern(); 388 CHECK_NULL_RETURN(swiperPattern, SwiperIndicatorType::DOT); 389 return swiperPattern->GetIndicatorType(); 390 } 391 IsHover()392 const bool& IsHover() const 393 { 394 return isHover_; 395 } 396 IsPressed()397 const bool& IsPressed() const 398 { 399 return isPressed_; 400 } 401 GetHoverPoint()402 const PointF& GetHoverPoint() const 403 { 404 return hoverPoint_; 405 } 406 GetOptinalMouseClickIndex()407 std::optional<int32_t> GetOptinalMouseClickIndex() const 408 { 409 return mouseClickIndex_; 410 } 411 SetMouseClickIndex(int32_t mouseClickIndex)412 void SetMouseClickIndex(int32_t mouseClickIndex) 413 { 414 if (mouseClickIndex_) { 415 mouseClickIndex_ = mouseClickIndex; 416 } 417 } 418 ResetOptinalMouseClickIndex()419 void ResetOptinalMouseClickIndex() 420 { 421 mouseClickIndex_ = std::nullopt; 422 } 423 GetTouchBottomType()424 const TouchBottomType& GetTouchBottomType() const 425 { 426 return touchBottomType_; 427 } 428 SetTouchBottomType(TouchBottomType touchBottomType)429 void SetTouchBottomType(TouchBottomType touchBottomType) 430 { 431 touchBottomType_ = touchBottomType; 432 } 433 SetDotIndicatorModifier(RefPtr<DotIndicatorModifier> dotIndicatorModifier)434 void SetDotIndicatorModifier(RefPtr<DotIndicatorModifier> dotIndicatorModifier) 435 { 436 dotIndicatorModifier_ = dotIndicatorModifier; 437 } 438 GetOverlengthDotIndicatorModifier()439 const RefPtr<OverlengthDotIndicatorModifier>& GetOverlengthDotIndicatorModifier() const 440 { 441 return overlongDotIndicatorModifier_; 442 } 443 SetOverlengthDotIndicatorModifier(RefPtr<OverlengthDotIndicatorModifier> overlongDotIndicatorModifier)444 void SetOverlengthDotIndicatorModifier(RefPtr<OverlengthDotIndicatorModifier> overlongDotIndicatorModifier) 445 { 446 overlongDotIndicatorModifier_ = overlongDotIndicatorModifier; 447 } 448 GetDragStartPoint()449 const PointF& GetDragStartPoint() const 450 { 451 return dragStartPoint_; 452 } 453 SetDragStartPoint(PointF dragStartPoint)454 void SetDragStartPoint(PointF dragStartPoint) 455 { 456 dragStartPoint_ = dragStartPoint; 457 } 458 459 virtual RectF CalcBoundsRect() const; 460 int32_t GetLoopIndex(int32_t originalIndex) const; 461 void ResetOverlongModifier(); 462 void UpdateDigitalIndicator(); 463 }; 464 } // namespace OHOS::Ace::NG 465 466 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_INDICATOR_SWIPER_INDICATOR_PATTERN_H 467