1 /*
2  * Copyright (c) 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 #include "core/interfaces/native/node/node_scroll_bar_modifier.h"
16 
17 #include "interfaces/native/node/node_model.h"
18 
19 #include "base/geometry/calc_dimension.h"
20 #include "base/utils/utils.h"
21 #include "core/animation/curves.h"
22 #include "core/components/common/layout/constants.h"
23 #include "core/components/scroll/scroll_bar_theme.h"
24 #include "core/components/scroll/scroll_position_controller.h"
25 #include "core/components_ng/base/frame_node.h"
26 #include "core/components_ng/pattern/grid/grid_model_ng.h"
27 #include "core/components_ng/pattern/list/list_model_ng.h"
28 #include "core/components_ng/pattern/scroll/scroll_model_ng.h"
29 #include "core/components_ng/pattern/scroll_bar/scroll_bar_model_ng.h"
30 #include "core/components_ng/pattern/scrollable/scrollable_model_ng.h"
31 #include "core/components_ng/pattern/scrollable/scrollable_pattern.h"
32 #include "core/components_ng/pattern/scrollable/scrollable_properties.h"
33 #include "core/components_ng/pattern/waterflow/water_flow_model_ng.h"
34 #include "core/interfaces/native/node/node_api.h"
35 #include "frameworks/bridge/common/utils/utils.h"
36 
37 namespace OHOS::Ace::NG {
setScrollBarEnableNestedScroll(ArkUINodeHandle node,ArkUI_Bool value)38 void setScrollBarEnableNestedScroll(ArkUINodeHandle node, ArkUI_Bool value)
39 {
40     auto* frameNode = reinterpret_cast<FrameNode*>(node);
41     CHECK_NULL_VOID(frameNode);
42     ScrollBarModelNG::SetEnableNestedScroll(frameNode, static_cast<bool>(value));
43 }
44 
resetScrollBarEnableNestedScroll(ArkUINodeHandle node)45 void resetScrollBarEnableNestedScroll(ArkUINodeHandle node)
46 {
47     auto* frameNode = reinterpret_cast<FrameNode*>(node);
48     CHECK_NULL_VOID(frameNode);
49     ScrollBarModelNG::SetEnableNestedScroll(frameNode, false);
50 }
51 
52 namespace NodeModifier {
GetScrollBarModifier()53 const ArkUIScrollBarModifier* GetScrollBarModifier()
54 {
55     static const ArkUIScrollBarModifier modifier = { nullptr, nullptr, nullptr, nullptr, nullptr,
56         setScrollBarEnableNestedScroll, resetScrollBarEnableNestedScroll };
57     /* clang-format on */
58     return &modifier;
59 }
60 
GetCJUIScrollBarModifier()61 const CJUIScrollBarModifier* GetCJUIScrollBarModifier()
62 {
63     static const CJUIScrollBarModifier modifier = { nullptr, nullptr, nullptr, nullptr, nullptr,
64         setScrollBarEnableNestedScroll, resetScrollBarEnableNestedScroll };
65     /* clang-format on */
66     return &modifier;
67 }
68 
69 } // namespace NodeModifier
70 } // namespace OHOS::Ace::NG