1 /* 2 * Copyright (c) 2022 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_PATTERN_SCROLL_SCROLL_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLL_SCROLL_MODEL_H 18 19 #include <memory> 20 21 #include "core/components/common/layout/constants.h" 22 #include "core/components/scroll_bar/scroll_proxy.h" 23 #include "core/components_ng/pattern/scroll/scroll_event_hub.h" 24 25 namespace OHOS::Ace { 26 27 class ScrollBarTheme; 28 class ScrollControllerBase; 29 30 class ScrollModel { 31 public: 32 static ScrollModel* GetInstance(); 33 virtual ~ScrollModel() = default; 34 35 virtual void Create() = 0; 36 virtual RefPtr<ScrollControllerBase> GetOrCreateController() = 0; 37 virtual RefPtr<ScrollProxy> CreateScrollBarProxy() = 0; 38 virtual void SetAxis(Axis axis) = 0; 39 virtual void SetOnScrollBegin(NG::ScrollBeginEvent&& event) = 0; 40 virtual void SetOnScrollFrameBegin(NG::ScrollFrameBeginEvent&& event) = 0; 41 virtual void SetOnScroll(NG::OnScrollEvent&& event) = 0; 42 virtual void SetOnScrollEdge(NG::ScrollEdgeEvent&& event) = 0; 43 virtual void SetOnScrollEnd(NG::ScrollEndEvent&& event) = 0; 44 virtual void SetOnScrollStart(NG::ScrollStartEvent&& event) = 0; 45 virtual void SetOnScrollStop(NG::ScrollStopEvent&& event) = 0; 46 virtual void SetScrollBarProxy(const RefPtr<ScrollProxy>& proxy) = 0; 47 virtual void InitScrollBar(const RefPtr<ScrollBarTheme>& theme, const std::pair<bool, Color>& color, 48 const std::pair<bool, Dimension>& width, EdgeEffect effect) = 0; 49 virtual void SetDisplayMode(int displayMode) = 0; 50 virtual void SetScrollBarWidth(const Dimension& dimension) = 0; 51 virtual void SetScrollBarColor(const Color& color) = 0; 52 virtual void SetEdgeEffect(EdgeEffect edgeEffect) = 0; 53 virtual void SetHasWidth(bool hasWidth) = 0; 54 virtual void SetHasHeight(bool hasHeight) = 0; 55 56 private: 57 static std::unique_ptr<ScrollModel> instance_; 58 }; 59 60 } // namespace OHOS::Ace 61 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLL_SCROLL_MODEL_H 62