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 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_SELECT_CONTENT_OVERLAY_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_SELECT_CONTENT_OVERLAY_PATTERN_H
18 
19 #include "core/components_ng/pattern/select_overlay/select_overlay_pattern.h"
20 #include "core/components_ng/pattern/select_overlay/select_overlay_property.h"
21 
22 namespace OHOS::Ace::NG {
23 
24 class ACE_EXPORT SelectContentOverlayPattern : public SelectOverlayPattern {
25     DECLARE_ACE_TYPE(SelectContentOverlayPattern, SelectOverlayPattern);
26 
27 public:
SelectContentOverlayPattern(std::shared_ptr<SelectOverlayInfo> info,SelectOverlayMode mode)28     explicit SelectContentOverlayPattern(std::shared_ptr<SelectOverlayInfo> info, SelectOverlayMode mode)
29         : SelectOverlayPattern(info, mode)
30     {}
31     ~SelectContentOverlayPattern() override = default;
32 
33     void UpdateMenuIsShow(bool menuIsShow, bool noAnimation = false);
34     void UpdateMenuInfo(const SelectMenuInfo& info);
35     void UpdateIsShowHandleLine(bool isShowHandleLine);
36     void UpdateIsSingleHandle(bool isSingleHandle);
37     void RestartHiddenHandleTask(bool isDelay);
38     void CancelHiddenHandleTask();
39     SelectMenuInfo GetSelectMenuInfo();
40     void UpdateViewPort(const std::optional<RectF>& viewPort);
41     void UpdateSelectArea(const RectF& selectArea) override;
42     void SetHandleCircleIsShow(bool isFirst, bool isShow);
43     void SetIsHandleLineShow(bool isShow);
44 
45 protected:
46     void CheckHandleReverse() override;
47     void UpdateHandleHotZone() override;
48 
49 private:
50     bool UpdateHandleHotZoneWithPoint();
51     void UpdateHandleHotRegion(RectF& hotRegion, const OffsetF& offset);
52     DimensionRect ConvertToHotRect(const RectF& rect);
53     bool IsHandleInSameLine(const RectF& first, const RectF& second);
54     OffsetF GetHandleHotZoneOffset(bool isFirst, float raidus, bool handleOnTop);
55 
56 private:
57     ACE_DISALLOW_COPY_AND_MOVE(SelectContentOverlayPattern);
58 };
59 } // namespace OHOS::Ace::NG
60 
61 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_SELECT_CONTENT_OVERLAY_PATTERN_H
62