• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 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_SCROLL_INNER_SCROLL_BAR_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLL_INNER_SCROLL_BAR_H
18 
19 #include <cmath>
20 
21 #include "base/geometry/dimension.h"
22 #include "base/geometry/offset.h"
23 #include "base/geometry/rect.h"
24 #include "base/utils/utils.h"
25 #include "core/animation/friction_motion.h"
26 #include "core/components/common/layout/constants.h"
27 #include "core/components/common/properties/color.h"
28 #include "core/components/common/properties/edge.h"
29 #include "core/components/scroll/scroll_bar_theme.h"
30 #include "core/components_ng/base/frame_scene_status.h"
31 #include "core/components_ng/event/input_event.h"
32 #include "core/components_ng/event/touch_event.h"
33 #include "core/components_ng/gestures/recognizers/pan_recognizer.h"
34 #include "core/components_ng/pattern/scroll/inner/scroll_bar_overlay_modifier.h"
35 #include "core/components_ng/pattern/scrollable/scrollable_properties.h"
36 #include "core/components_ng/property/border_property.h"
37 #include "core/components_ng/gestures/recognizers/long_press_recognizer.h"
38 #include "core/pipeline_ng/pipeline_context.h"
39 
40 namespace OHOS::Ace::NG {
41 
42 constexpr double FACTOR_HALF = 0.5;
43 constexpr double DEFAULT_TOPANGLE = 60.0;
44 constexpr double DEFAULT_BOTTOMANGLE = 120.0;
45 constexpr double DEFAULT_MINANGLE = 10.0;
46 constexpr double STRAIGHT_ANGLE = 180.0;
47 constexpr double BAR_FRICTION = 0.9;
48 constexpr Color PRESSED_BLEND_COLOR = Color(0x19000000);
49 using DragFRCSceneCallback = std::function<void(double velocity, NG::SceneStatus sceneStatus)>;
50 using ScrollBarPositionCallback = std::function<bool(double, int32_t source, bool isMouseWheelScroll)>;
51 
52 enum class BarDirection {
53     BAR_NONE = 0,
54     PAGE_UP,
55     PAGE_DOWN,
56 };
57 
58 class ScrollBar : public AceType {
59     DECLARE_ACE_TYPE(ScrollBar, AceType);
60 
61 public:
62     ScrollBar();
63     ScrollBar(DisplayMode displayMode, ShapeMode shapeMode = ShapeMode::RECT,
64         PositionMode positionMode = PositionMode::RIGHT);
65     ~ScrollBar() override = default;
66 
67     virtual bool InBarTouchRegion(const Point& point) const;
68     virtual bool InBarHoverRegion(const Point& point) const;
69     virtual bool InBarRectRegion(const Point& point) const;
70     bool NeedScrollBar() const;
71     bool NeedPaint() const;
72     void UpdateScrollBarRegion(
73         const Offset& offset, const Size& size, const Offset& lastOffset, double estimatedHeight, int32_t scrollSource);
74     double GetNormalWidthToPx() const;
75     virtual float CalcPatternOffset(float scrollBarOffset) const;
76 
GetShapeMode()77     ShapeMode GetShapeMode() const
78     {
79         return shapeMode_;
80     }
GetDisplayMode()81     DisplayMode GetDisplayMode() const
82     {
83         return displayMode_;
84     }
GetPositionMode()85     PositionMode GetPositionMode() const
86     {
87         return positionMode_;
88     }
SetPadding(const Edge & padding)89     void SetPadding(const Edge& padding)
90     {
91         padding_ = padding;
92     }
GetPadding()93     const Edge& GetPadding() const
94     {
95         return padding_;
96     }
97     void SetBackgroundColor(const Color& backgroundColor, const bool isRoundScroll = false)
98     {
99         if (isRoundScroll) {
100             arcBackgroundColor_ = backgroundColor;
101             return;
102         }
103         backgroundColor_ = backgroundColor;
104     }
GetBackgroundColor()105     const Color& GetBackgroundColor() const
106     {
107         return backgroundColor_;
108     }
109     void SetForegroundColor(const Color& foregroundColor, const bool isRoundScroll = false)
110     {
111         if (isRoundScroll) {
112             arcForegroundColor_ = foregroundColor;
113             return;
114         }
115         foregroundColor_ = foregroundColor;
116     }
SetForegroundHoverBlendColor(const Color & foregroundHoverBlendColor)117     void SetForegroundHoverBlendColor(const Color& foregroundHoverBlendColor)
118     {
119         foregroundHoverBlendColor_ = foregroundHoverBlendColor;
120     }
SetForegroundPressedBlendColor(const Color & foregroundPressedBlendColor)121     void SetForegroundPressedBlendColor(const Color& foregroundPressedBlendColor)
122     {
123         foregroundPressedBlendColor_ = foregroundPressedBlendColor;
124     }
GetTopAngle()125     double GetTopAngle() const
126     {
127         return topAngle_;
128     }
GetBottomAngle()129     double GetBottomAngle() const
130     {
131         return bottomAngle_;
132     }
GetTrickStartAngle()133     double GetTrickStartAngle() const
134     {
135         return trickStartAngle_;
136     }
GetTrickSweepAngle()137     double GetTrickSweepAngle() const
138     {
139         return trickSweepAngle_;
140     }
SetMinHeight(const Dimension & minHeight)141     void SetMinHeight(const Dimension& minHeight)
142     {
143         minHeight_ = minHeight;
144     }
GetMinHeight()145     const Dimension& GetMinHeight() const
146     {
147         return minHeight_;
148     }
SetMinDynamicHeight(const Dimension & minDynamicHeight)149     void SetMinDynamicHeight(const Dimension& minDynamicHeight)
150     {
151         minDynamicHeight_ = minDynamicHeight;
152     }
GetMinDynamicHeight()153     const Dimension& GetMinDynamicHeight() const
154     {
155         return minDynamicHeight_;
156     }
SetInactiveWidth(const Dimension & inactiveWidth)157     void SetInactiveWidth(const Dimension& inactiveWidth)
158     {
159         inactiveWidth_ = inactiveWidth;
160     }
SetActiveWidth(const Dimension & activeWidth)161     void SetActiveWidth(const Dimension& activeWidth)
162     {
163         activeWidth_ = activeWidth;
164     }
GetActiveWidth()165     const Dimension& GetActiveWidth() const
166     {
167         return activeWidth_;
168     }
GetActiveRect()169     const Rect& GetActiveRect() const
170     {
171         return activeRect_;
172     }
SetTouchWidth(const Dimension & touchWidth)173     void SetTouchWidth(const Dimension& touchWidth)
174     {
175         touchWidth_ = touchWidth;
176     }
GetTouchWidth()177     const Dimension& GetTouchWidth() const
178     {
179         return touchWidth_;
180     }
GetBarRect()181     const Rect& GetBarRect() const
182     {
183         return barRect_;
184     }
IsScrollable()185     bool IsScrollable() const
186     {
187         return isScrollable_;
188     }
GetPositionModeUpdate()189     bool GetPositionModeUpdate() const
190     {
191         return positionModeUpdate_;
192     }
193 
SetShapeMode(ShapeMode shapeMode)194     void SetShapeMode(ShapeMode shapeMode)
195     {
196         shapeMode_ = shapeMode;
197     }
GetOutBoundary()198     double GetOutBoundary() const
199     {
200         return outBoundary_;
201     }
SetOutBoundary(double outBoundary)202     void SetOutBoundary(double outBoundary)
203     {
204         outBoundary_ = outBoundary;
205     }
SetPosition(const Dimension & position)206     void SetPosition(const Dimension& position)
207     {
208         position_ = position;
209     }
GetPosition()210     const Dimension& GetPosition() const
211     {
212         return position_;
213     }
SetPressed(bool press)214     void SetPressed(bool press)
215     {
216         isPressed_ = press;
217     }
IsPressed()218     bool IsPressed() const
219     {
220         return isPressed_;
221     }
IsDriving()222     bool IsDriving() const
223     {
224         return isDriving_;
225     }
SetHover(bool hover)226     void SetHover(bool hover)
227     {
228         isHover_ = hover;
229     }
IsHover()230     bool IsHover() const
231     {
232         return isHover_;
233     }
SetHoverSlider(bool hover)234     void SetHoverSlider(bool hover)
235     {
236         isHoverSlider_ = hover;
237     }
IsHoverSlider()238     bool IsHoverSlider() const
239     {
240         return isHoverSlider_;
241     }
GetOpacityAnimationType()242     OpacityAnimationType GetOpacityAnimationType() const
243     {
244         return opacityAnimationType_;
245     }
SetOpacityAnimationType(OpacityAnimationType opacityAnimationType)246     void SetOpacityAnimationType(OpacityAnimationType opacityAnimationType)
247     {
248         opacityAnimationType_ = opacityAnimationType;
249     }
GetHoverAnimationType()250     HoverAnimationType GetHoverAnimationType() const
251     {
252         return hoverAnimationType_;
253     }
SetHoverAnimationType(HoverAnimationType hoverAnimationType)254     void SetHoverAnimationType(HoverAnimationType hoverAnimationType)
255     {
256         hoverAnimationType_ = hoverAnimationType;
257     }
GetNeedAdaptAnimation()258     bool GetNeedAdaptAnimation() const
259     {
260         return needAdaptAnimation_;
261     }
SetMarkNeedRenderFunc(std::function<void ()> && func)262     void SetMarkNeedRenderFunc(std::function<void()>&& func)
263     {
264         markNeedRenderFunc_ = func;
265     }
GetTouchEvent()266     RefPtr<TouchEventImpl> GetTouchEvent()
267     {
268         return touchEvent_;
269     }
GetMouseEvent()270     RefPtr<InputEvent> GetMouseEvent()
271     {
272         return mouseEvent_;
273     }
GetHoverEvent()274     RefPtr<InputEvent> GetHoverEvent() const
275     {
276         return hoverEvent_;
277     }
SetIsUserNormalWidth(bool isUserNormalWidth)278     void SetIsUserNormalWidth(bool isUserNormalWidth)
279     {
280         isUserNormalWidth_ = isUserNormalWidth;
281     }
GetIsUserNormalWidth()282     bool GetIsUserNormalWidth() const
283     {
284         return isUserNormalWidth_;
285     }
SetStartReservedHeight(const Dimension & startReservedHeight)286     void SetStartReservedHeight(const Dimension& startReservedHeight)
287     {
288         startReservedHeight_ = startReservedHeight;
289     }
GetStartReservedHeight()290     const Dimension& GetStartReservedHeight() const
291     {
292         return startReservedHeight_;
293     }
SetEndReservedHeight(const Dimension & endReservedHeight)294     void SetEndReservedHeight(const Dimension& endReservedHeight)
295     {
296         endReservedHeight_ = endReservedHeight;
297     }
GetEndReservedHeight()298     const Dimension& GetEndReservedHeight() const
299     {
300         return endReservedHeight_;
301     }
SetHostBorderRadius(const BorderRadiusProperty & hostBorderRadius)302     void SetHostBorderRadius(const BorderRadiusProperty& hostBorderRadius)
303     {
304         hostBorderRadius_ = hostBorderRadius;
305     }
GetHostBorderRadius()306     const BorderRadiusProperty& GetHostBorderRadius() const
307     {
308         return hostBorderRadius_;
309     }
SetScrollPositionCallback(ScrollBarPositionCallback && callback)310     void SetScrollPositionCallback(ScrollBarPositionCallback&& callback)
311     {
312         scrollPositionCallback_ = std::move(callback);
313     }
GetScrollPositionCallback()314     const ScrollBarPositionCallback& GetScrollPositionCallback() const
315     {
316         return scrollPositionCallback_;
317     }
SetScrollEndCallback(ScrollEndCallback && scrollEndCallback)318     void SetScrollEndCallback(ScrollEndCallback&& scrollEndCallback)
319     {
320         scrollEndCallback_ = std::move(scrollEndCallback);
321     }
GetScrollEndCallback()322     const ScrollEndCallback& GetScrollEndCallback() const
323     {
324         return scrollEndCallback_;
325     }
SetStartSnapAnimationCallback(StartSnapAnimationCallback && startSnapAnimationCallback)326     void SetStartSnapAnimationCallback(StartSnapAnimationCallback&& startSnapAnimationCallback)
327     {
328         startSnapAnimationCallback_ = std::move(startSnapAnimationCallback);
329     }
SetDragFRCSceneCallback(DragFRCSceneCallback && dragFRCSceneCallback)330     void SetDragFRCSceneCallback(DragFRCSceneCallback&& dragFRCSceneCallback)
331     {
332         dragFRCSceneCallback_ = std::move(dragFRCSceneCallback);
333     }
SetDragStartPosition(float position)334     void SetDragStartPosition(float position)
335     {
336         dragStartPosition_ = position;
337     }
SetDragEndPosition(float position)338     void SetDragEndPosition(float position)
339     {
340         dragEndPosition_ = position;
341     }
GetDragOffset()342     float GetDragOffset()
343     {
344         return dragEndPosition_ - dragStartPosition_;
345     }
IsReverse()346     bool IsReverse()
347     {
348         return isReverse_;
349     }
GetTouchRegion()350     Rect GetTouchRegion() const
351     {
352         return touchRegion_;
353     }
GetClickEvent()354     RefPtr<ClickEvent> GetClickEvent()
355     {
356         return clickevent_;
357     }
SetAxis(Axis axis)358     void SetAxis(Axis axis)
359     {
360         axis_ = axis;
361     }
SetScrollBarMargin(const ScrollBarMargin & scrollBarMargin)362     void SetScrollBarMargin(const ScrollBarMargin& scrollBarMargin)
363     {
364         scrollBarMargin_ = scrollBarMargin;
365         isScrollBarMarginUpdate_ = true;
366     }
GetScrollBarMargin()367     const std::optional<ScrollBarMargin>& GetScrollBarMargin() const
368     {
369         return scrollBarMargin_;
370     }
371     void OnCollectTouchTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
372         TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
373         ResponseLinkResult& responseLinkResult, bool inBarRect = false);
374     Color GetForegroundColor() const;
375     void SetHoverWidth(const RefPtr<ScrollBarTheme>& theme);
376     void SetNormalWidth(const Dimension& normalWidth, const RefPtr<PipelineContext>& context = nullptr);
377     void SetScrollable(bool isScrollable);
378     void SetPositionMode(PositionMode positionMode);
379     void SetDisplayMode(DisplayMode displayMode);
380     void PlayScrollBarDisappearAnimation();
381     void PlayScrollBarAppearAnimation();
382     void PlayScrollBarGrowAnimation();
383     void PlayScrollBarShrinkAnimation();
384     void PlayScrollBarAdaptAnimation();
385     void MarkNeedRender();
386     void SetGestureEvent();
387     void SetMouseEvent();
388     void SetHoverEvent();
389     void FlushBarWidth(const RefPtr<PipelineContext>& context = nullptr);
390     virtual void CalcReservedHeight(const RefPtr<PipelineContext>& context = nullptr);
391     void ScheduleDisappearDelayTask();
392     float GetMainOffset(const Offset& offset) const;
393     float GetMainSize(const Size& size) const;
394     void SetReverse(bool reverse);
395     BarDirection CheckBarDirection(const Point& point);
396     Axis GetPanDirection() const;
397     // infos for dump
398     void AddScrollBarLayoutInfo();
399     void GetShapeModeDumpInfo();
400     void GetShapeModeDumpInfo(std::unique_ptr<JsonValue>& json);
401     void GetPositionModeDumpInfo();
402     void GetPositionModeDumpInfo(std::unique_ptr<JsonValue>& json);
403     void GetAxisDumpInfo();
404     void GetAxisDumpInfo(std::unique_ptr<JsonValue>& json);
405     void GetPanDirectionDumpInfo();
406     void GetPanDirectionDumpInfo(std::unique_ptr<JsonValue>& json);
407     void DumpAdvanceInfo();
408     void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json);
409     void StopFlingAnimation();
SetScrollPageCallback(ScrollPageCallback && scrollPageCallback)410     void SetScrollPageCallback(ScrollPageCallback&& scrollPageCallback)
411     {
412         scrollPageCallback_ = std::move(scrollPageCallback);
413     }
414     void OnCollectLongPressTarget(const OffsetF& coordinateOffset, const GetEventTargetImpl& getEventTargetImpl,
415         TouchTestResult& result, const RefPtr<FrameNode>& frameNode, const RefPtr<TargetComponent>& targetComponent,
416         ResponseLinkResult& responseLinkResult);
417     void InitLongPressEvent();
418     void HandleLongPress(bool smooth);
419     bool AnalysisUpOrDown(Point point, bool& reverse);
420     void ScheduleCaretLongPress();
421 
SetArcActiveBackgroundWidth(const Dimension & activeBackgroundWidth)422     void SetArcActiveBackgroundWidth(const Dimension& activeBackgroundWidth)
423     {
424         arcActiveBackgroundWidth_ = activeBackgroundWidth;
425     }
426 
SetArcActiveScrollBarWidth(const Dimension & activeScrollBarWidth)427     void SetArcActiveScrollBarWidth(const Dimension& activeScrollBarWidth)
428     {
429         arcActiveScrollBarWidth_ = activeScrollBarWidth;
430     }
431 
SetArcBackgroundColor(const Color & backgroundColor)432     void SetArcBackgroundColor(const Color& backgroundColor)
433     {
434         arcBackgroundColor_ = backgroundColor;
435     }
436 
GetArcBackgroundColor()437     const Color& GetArcBackgroundColor() const
438     {
439         return arcBackgroundColor_;
440     }
441 
SetArcForegroundColor(const Color & foregroundColor)442     void SetArcForegroundColor(const Color& foregroundColor)
443     {
444         arcForegroundColor_ = foregroundColor;
445     }
446 
GetArcForegroundColor()447     Color GetArcForegroundColor() const
448     {
449         return IsPressed() ? arcForegroundColor_.BlendColor(PRESSED_BLEND_COLOR) : arcForegroundColor_;
450     }
451 
452 protected:
453     void InitTheme();
454     virtual void SetBarRegion(const Offset& offset, const Size& size, const RefPtr<PipelineContext>& context = nullptr);
455     virtual void SetRoundTrickRegion(const Offset& offset, const Size& size, const Offset& lastOffset,
456         double mainScrollExtent);
457     double NormalizeToPx(const Dimension& dimension, const RefPtr<PipelineContext>& context = nullptr) const;
GetNormalWidth()458     Dimension GetNormalWidth()
459     {
460         return normalWidth_;
461     }
462 
SetMouseEventMember(RefPtr<InputEvent> mouseEvent)463     void SetMouseEventMember(RefPtr<InputEvent> mouseEvent)
464     {
465         mouseEvent_ = mouseEvent;
466     }
467 
GetIsMousePressed()468     bool GetIsMousePressed()
469     {
470         return isMousePressed_;
471     }
472 
SetIsMousePressed(bool isMousePressed)473     void SetIsMousePressed(bool isMousePressed)
474     {
475         isMousePressed_ = isMousePressed;
476     }
477 
GetLocationInfo()478     Offset GetLocationInfo()
479     {
480         return locationInfo_;
481     }
482 
SetLocationInfo(Offset locationInfo)483     void SetLocationInfo(Offset locationInfo)
484     {
485         locationInfo_ = locationInfo;
486     }
487 
GetLongPressRecognizer()488     RefPtr<LongPressRecognizer> GetLongPressRecognizer()
489     {
490         return longPressRecognizer_;
491     }
492 
SetLongPressRecognizer(RefPtr<LongPressRecognizer> longPressRecognizer)493     void SetLongPressRecognizer(RefPtr<LongPressRecognizer> longPressRecognizer)
494     {
495         longPressRecognizer_ = longPressRecognizer;
496     }
497 
SetTouchEvent(RefPtr<TouchEventImpl> touchEvent)498     void SetTouchEvent(RefPtr<TouchEventImpl> touchEvent)
499     {
500         touchEvent_ = touchEvent;
501     }
502 
SetPanRecognizer(RefPtr<PanRecognizer> panRecognizer)503     void SetPanRecognizer(RefPtr<PanRecognizer> panRecognizer)
504     {
505         panRecognizer_ = panRecognizer;
506     }
507 
GetPanRecognizer()508     RefPtr<PanRecognizer> GetPanRecognizer()
509     {
510         return panRecognizer_;
511     }
512 
CallInitPanRecognizer()513     void CallInitPanRecognizer()
514     {
515         InitPanRecognizer();
516     }
517 
GetEstimatedHeigh()518     double GetEstimatedHeigh() const
519     {
520         return estimatedHeight_;
521     }
522 
GetViewPortSize()523     Size GetViewPortSize() const
524     {
525         return viewPortSize_;
526     }
527 
IsDriving_()528     bool IsDriving_() const
529     {
530         return isDriving_;
531     }
532 
GetThemeNormalWidth()533     Dimension GetThemeNormalWidth()
534     {
535         return themeNormalWidth_;
536     }
537 
GetBarRegionSize()538     double GetBarRegionSize() const
539     {
540         return barRegionSize_;
541     }
542 
SetBarRegionSize(double barRegionSize)543     void SetBarRegionSize(double barRegionSize)
544     {
545         barRegionSize_ = barRegionSize;
546     }
547 
GetOffsetScale()548     double GetOffsetScale() const
549     {
550         return offsetScale_;
551     }
552 
SetOffsetScale(double offsetScale)553     void SetOffsetScale(double offsetScale)
554     {
555         offsetScale_ = offsetScale;
556     }
557 
SetArcNormalBackgroundWidth(const Dimension & normalBackgroundWidth)558     void SetArcNormalBackgroundWidth(const Dimension& normalBackgroundWidth)
559     {
560         arcNormalBackgroundWidth_ = normalBackgroundWidth;
561     }
562 
GetArcNormalBackgroundWidth()563     const Dimension& GetArcNormalBackgroundWidth() const
564     {
565         return arcNormalBackgroundWidth_;
566     }
567 
GetArcActiveBackgroundWidth()568     const Dimension& GetArcActiveBackgroundWidth() const
569     {
570         return arcActiveBackgroundWidth_;
571     }
572 
SetArcNormalMaxOffsetAngle(double normalMaxOffsetAngle)573     void SetArcNormalMaxOffsetAngle(double normalMaxOffsetAngle)
574     {
575         arcNormalMaxOffsetAngle_ = normalMaxOffsetAngle;
576     }
577 
GetArcNormalMaxOffsetAngle()578     double GetArcNormalMaxOffsetAngle() const
579     {
580         return arcNormalMaxOffsetAngle_;
581     }
582 
SetArcNormalStartAngle(double normalStartAngle)583     void SetArcNormalStartAngle(double normalStartAngle)
584     {
585         arcNormalStartAngle_ = normalStartAngle;
586     }
587 
GetArcNormalStartAngle()588     double GetArcNormalStartAngle() const
589     {
590         if (positionMode_ == PositionMode::LEFT) {
591             return -arcNormalStartAngle_ - STRAIGHT_ANGLE;
592         }
593         return arcNormalStartAngle_;
594     }
595 
SetArcActiveStartAngle(double activeStartAngle)596     void SetArcActiveStartAngle(double activeStartAngle)
597     {
598         arcActiveStartAngle_ = activeStartAngle;
599     }
600 
GetArcActiveStartAngle()601     double GetArcActiveStartAngle() const
602     {
603         if (positionMode_ == PositionMode::LEFT) {
604             return -arcActiveStartAngle_ - STRAIGHT_ANGLE;
605         }
606         return arcActiveStartAngle_;
607     }
608 
SetArcActiveMaxOffsetAngle(double activeMaxOffsetAngle)609     void SetArcActiveMaxOffsetAngle(double activeMaxOffsetAngle)
610     {
611         arcActiveMaxOffsetAngle_ = activeMaxOffsetAngle;
612     }
613 
GetArcActiveMaxOffsetAngle()614     double GetArcActiveMaxOffsetAngle() const
615     {
616         return arcActiveMaxOffsetAngle_;
617     }
618 
SetArcNormalScrollBarWidth(const Dimension & normalScrollBarWidth)619     void SetArcNormalScrollBarWidth(const Dimension& normalScrollBarWidth)
620     {
621         arcNormalScrollBarWidth_ = normalScrollBarWidth;
622     }
623 
GetArcNormalScrollBarWidth()624     const Dimension& GetArcNormalScrollBarWidth() const
625     {
626         return arcNormalScrollBarWidth_;
627     }
628 
GetArcActiveScrollBarWidth()629     const Dimension& GetArcActiveScrollBarWidth() const
630     {
631         return arcActiveScrollBarWidth_;
632     }
633 
GetMinAngle()634     double GetMinAngle() const
635     {
636         return minAngle_;
637     }
638 
639 private:
640     void SetRectTrickRegion(const Offset& offset, const Size& size, const Offset& lastOffset, double mainScrollExtent,
641         int32_t scrollSource, const RefPtr<PipelineContext>& context = nullptr);
642 
643     void UpdateActiveRectSize(double activeSize);
644     void UpdateActiveRectOffset(double activeMainOffset);
645 
646     void InitPanRecognizer();
647     void HandleDragStart(const GestureEvent& info);
648     void HandleDragUpdate(const GestureEvent& info);
649     void HandleDragEnd(const GestureEvent& info);
650     void ProcessFrictionMotion(double value);
651     void ProcessFrictionMotionStop();
652     void CalcScrollBarRegion(double activeMainOffset, double activeSize, const Offset& offset, const Size& size,
653         double& inactiveMainOffset, double& inactiveSize);
654     void GetRadiusAndPadding(
655         float& startRadius, float& endRadius, float& padding, const RefPtr<PipelineContext>& context = nullptr);
656     DisplayMode displayMode_ = DisplayMode::AUTO;
657     ShapeMode shapeMode_ = ShapeMode::RECT;
658     PositionMode positionMode_ = PositionMode::RIGHT;
659     BorderRadiusProperty hostBorderRadius_;
660     Edge padding_;
661     Color backgroundColor_;
662     Color foregroundColor_;
663     Color foregroundHoverBlendColor_;
664     Color foregroundPressedBlendColor_;
665     Rect touchRegion_;
666     Rect hoverRegion_;
667     Rect barRect_;
668     Rect activeRect_;
669     Dimension minHeight_;           // this is min static height
670     Dimension minDynamicHeight_;    // this is min dynamic height when on the top or bottom
671     Dimension startReservedHeight_; // this is reservedHeight on the start
672     Dimension endReservedHeight_;   // this is reservedHeight on the end
673     Dimension inactiveWidth_;
674     Dimension activeWidth_;
675     Dimension normalWidth_;         // user-set width of the scrollbar
676     Dimension themeNormalWidth_;
677     Dimension touchWidth_;
678     Dimension hoverWidth_;
679     double barWidth_ = 0.0;         // actual width of the scrollbar
680     Dimension position_;
681     int32_t fingerId_ = -1;
682     double trickStartAngle_ = 0.0;
683     double trickSweepAngle_ = 0.0;
684     double topAngle_ = DEFAULT_TOPANGLE;
685     double bottomAngle_ = DEFAULT_BOTTOMANGLE;
686     double minAngle_ = DEFAULT_MINANGLE;
687     double outBoundary_ = 0.0;
688     double offsetScale_ = 1.0f;
689     double scrollableOffset_ = 0.0;
690     double barRegionSize_ = 0.0;
691     double friction_ = BAR_FRICTION;
692     double frictionPosition_ = 0.0;
693     float dragStartPosition_ = 0.0f;
694     float dragEndPosition_ = 0.0f;
695     bool isScrollable_ = false;
696     bool isPressed_ = false;
697     bool isDriving_ = false; // false: scroll driving; true: bar driving
698     bool isHover_ = false;
699     bool isHoverSlider_ = false;
700     bool positionModeUpdate_ = false;
701     bool normalWidthUpdate_ = false;
702     bool isUserNormalWidth_ = false;
703     bool needAdaptAnimation_ = false;
704     bool isReverse_ = false;
705     bool isReverseUpdate_ = false;
706     bool isShowScrollBar_ = false;
707     bool isScrollBarMarginUpdate_ = false;
708     Offset paintOffset_;
709     Size viewPortSize_;
710     Offset lastOffset_;
711     double estimatedHeight_ = 0.0;
712     RefPtr<TouchEventImpl> touchEvent_;
713     RefPtr<InputEvent> mouseEvent_;
714     RefPtr<InputEvent> hoverEvent_;
715     RefPtr<PanRecognizer> panRecognizer_;
716     RefPtr<Animator> frictionController_;
717     RefPtr<FrictionMotion> frictionMotion_;
718     std::function<void()> markNeedRenderFunc_;
719     ScrollBarPositionCallback scrollPositionCallback_;
720     ScrollEndCallback scrollEndCallback_;
721     StartSnapAnimationCallback startSnapAnimationCallback_;
722     ScrollPageCallback scrollPageCallback_;
723     OpacityAnimationType opacityAnimationType_ = OpacityAnimationType::NONE;
724     HoverAnimationType hoverAnimationType_ = HoverAnimationType::NONE;
725     CancelableCallback<void()> disappearDelayTask_;
726     Axis axis_ = Axis::VERTICAL;
727     std::optional<ScrollBarMargin> scrollBarMargin_;
728     DragFRCSceneCallback dragFRCSceneCallback_;
729     // dump info
730     std::list<InnerScrollBarLayoutInfo> innerScrollBarLayoutInfos_;
731     bool needAddLayoutInfo = false;
732 
733     RefPtr<ClickEvent> clickevent_;
734     RefPtr<LongPressRecognizer> longPressRecognizer_;
735     Offset locationInfo_;
736     bool isMousePressed_ = false;
737 
738     //arcScrollBar info
739     Dimension arcNormalBackgroundWidth_;
740     Dimension arcActiveBackgroundWidth_;
741     double arcNormalStartAngle_ = 0.0;
742     double arcActiveStartAngle_ = 0.0;
743     double arcNormalMaxOffsetAngle_ = 0.0;
744     double arcActiveMaxOffsetAngle_ = 0.0;
745     Dimension arcNormalScrollBarWidth_;
746     Dimension arcActiveScrollBarWidth_;
747     Color arcBackgroundColor_;
748     Color arcForegroundColor_;
749 };
750 
751 } // namespace OHOS::Ace::NG
752 
753 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLL_INNER_SCROLL_BAR_H
754