• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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_ARC_SWIPER_INDICATOR_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_INDICATOR_ARC_SWIPER_INDICATOR_PATTERN_H
18 
19 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_pattern.h"
20 namespace OHOS::Ace::NG {
21 enum class SwiperDirection {
22     UNKNOWN = 0,
23     LEFT,
24     RIGHT
25 };
26 class ArcSwiperIndicatorPattern : public SwiperIndicatorPattern {
27 DECLARE_ACE_TYPE(ArcSwiperIndicatorPattern, SwiperIndicatorPattern);
28 public:
29     ArcSwiperIndicatorPattern() = default;
30     ~ArcSwiperIndicatorPattern() override = default;
31 
CreatePaintProperty()32     RefPtr<PaintProperty> CreatePaintProperty() override
33     {
34         return MakeRefPtr<CircleDotIndicatorPaintProperty>();
35     }
36     bool SetArcIndicatorHotRegion(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
37     PointF GetCenterPointF() override;
38     float GetAngleWithPoint(const PointF& conter, const PointF& point) override;
39     float GetEndAngle(const PointF& conter, const PointF& point, float startAngle) override;
40     void UpadateStartAngle() override;
41     void InitAccessibilityFocusEvent() override;
SetAccessibilityFocusd(bool isAccessibilityFocusd)42     void SetAccessibilityFocusd(bool isAccessibilityFocusd)
43     {
44         isAccessibilityFocusd_ = isAccessibilityFocusd;
45     }
46 
47 private:
48     bool CalculateArcIndicatorHotRegion(const RectF& frameRect, const OffsetF& contentOffset);
49     void CalculateCycle(float angle, float startAngle, const PointF& conter, const PointF& point);
50     float ConvertAngleWithArcDirection(SwiperArcDirection arcDirection, const float& angle);
51     bool CheckPointLocation(const PointF& conter, const PointF& point);
52     bool isAccessibilityFocusd_ = false;
53     int32_t dragCycle_ = 0;
54     SwiperDirection direction_ = SwiperDirection::UNKNOWN;
55     bool isUpageStartAngle_ = false;
56     bool isUpdateCycle_ = false;
57     float oldEndAngle_ = 0;
58 };
59 } // namespace OHOS::Ace::NG
60 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_INDICATOR_ARC_SWIPER_INDICATOR_PATTERN_H