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_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_PROXY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_PROXY_H
18 
19 #include <cstdint>
20 
21 #include "base/geometry/ng/rect_t.h"
22 #include "base/memory/ace_type.h"
23 #include "base/memory/referenced.h"
24 #include "base/utils/noncopyable.h"
25 #include "core/components_ng/pattern/select_overlay/select_overlay_property.h"
26 
27 namespace OHOS::Ace::NG {
28 
29 // SelectOverlayProxy is the class to control select handle and select menu.
30 class ACE_EXPORT SelectOverlayProxy : public virtual AceType {
31     DECLARE_ACE_TYPE(SelectOverlayProxy, AceType);
32 
33 public:
SelectOverlayProxy(int32_t selectOverlayId)34     explicit SelectOverlayProxy(int32_t selectOverlayId) : selectOverlayId_(selectOverlayId) {}
35     ~SelectOverlayProxy() override = default;
36 
37     void UpdateFirstSelectHandleInfo(const SelectHandleInfo& info) const;
38 
39     void UpdateSecondSelectHandleInfo(const SelectHandleInfo& info) const;
40 
41     void UpdateFirstAndSecondHandleInfo(const SelectHandleInfo& firstInfo, const SelectHandleInfo& secondInfo) const;
42 
43     void UpdateSelectMenuInfo(const SelectMenuInfo& info) const;
44 
45     void UpdateSelectMenuInfo(std::function<void(SelectMenuInfo& menuInfo)> updateAction) const;
46 
47     void UpdateShowArea(const RectF& area) const;
48 
49     void SetSelectRegionVisible(bool isSelectRegionVisible);
50 
51     void SetHandleReverse(bool reverse);
52 
53     bool IsClosed() const;
54 
55     void Close(bool animation = false) const;
56 
57     void UpdateSelectArea(const RectF& selectArea);
58 
59     void SetIsNewAvoid(bool isNewAvoid);
60 
GetSelectOverlayId()61     int32_t GetSelectOverlayId() const
62     {
63         return selectOverlayId_;
64     }
65 
66     void SetSelectInfo(const std::string& selectInfo) const;
67     void ShowOrHiddenMenu(bool isHidden, bool noAnimation = false);
68     void DisableMenu(bool isDisabled);
69     bool IsMenuShow();
70     bool IsSingleHandleMenuShow();
71     bool IsHandleShow();
72     bool IsSingleHandle();
73     bool IsHandleReverse();
74     SelectOverlayInfo GetSelectOverlayMangerInfo();
75 
76 private:
77     int32_t selectOverlayId_ = 0;
78 
79     ACE_DISALLOW_COPY_AND_MOVE(SelectOverlayProxy);
80 };
81 } // namespace OHOS::Ace::NG
82 
83 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_SELECT_OVERLAY_SELECT_OVERLAY_PROXY_H
84