1 /* 2 * Copyright (c) 2023 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_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_SCROLL_NOTIFIER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_SCROLL_NOTIFIER_H 18 19 #include "core/components_ng/pattern/scrollable/scrollable_pattern.h" 20 #include "core/components_ng/pattern/scrollable/scrollable_properties.h" 21 #include "core/pipeline_ng/pipeline_context.h" 22 23 namespace OHOS::Ace::NG { 24 class SelectOverlayScrollNotifier { 25 public: NotifyOnScrollCallback(WeakPtr<ScrollablePattern> pattern,float offset,int32_t source)26 static inline void NotifyOnScrollCallback(WeakPtr<ScrollablePattern> pattern, float offset, int32_t source) 27 { 28 NotifyOnScrollEvent(pattern, offset, source); 29 } 30 NotifyOnScrollEnd(WeakPtr<ScrollablePattern> pattern)31 static inline void NotifyOnScrollEnd(WeakPtr<ScrollablePattern> pattern) 32 { 33 NotifyOnScrollEvent(pattern, 0, -1); 34 } 35 NotifyOnScrollEvent(WeakPtr<ScrollablePattern> pattern,float offset,int32_t source)36 static inline void NotifyOnScrollEvent(WeakPtr<ScrollablePattern> pattern, float offset, int32_t source) 37 { 38 auto scrollablePattern = pattern.Upgrade(); 39 CHECK_NULL_VOID(scrollablePattern); 40 auto host = scrollablePattern->GetHost(); 41 CHECK_NULL_VOID(host); 42 auto context = host->GetContext(); 43 CHECK_NULL_VOID(context); 44 context->GetSelectOverlayManager()->NotifyOnScrollCallback( 45 host->GetId(), scrollablePattern->GetAxis(), offset, source); 46 } 47 }; 48 } // namespace OHOS::Ace::NG 49 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_SCROLL_NOTIFIER_H 50