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_PATTERNS_SELECT_OVERLAY_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_PROPERTY_H 18 19 #include <cstdint> 20 #include <functional> 21 22 #include "base/geometry/ng/offset_t.h" 23 #include "base/geometry/ng/rect_t.h" 24 #include "core/components_ng/event/gesture_event_hub.h" 25 26 namespace OHOS::Ace::NG { 27 28 struct SelectHandleInfo { 29 bool isShow = true; 30 RectF paintRect; 31 32 bool operator==(const SelectHandleInfo& info) const 33 { 34 return (isShow == info.isShow) && (paintRect == info.paintRect); 35 } 36 37 bool operator!=(const SelectHandleInfo& info) const 38 { 39 return !(*this == info); 40 } 41 42 static Dimension GetDefaultLineWidth(); 43 }; 44 45 struct SelectMenuInfo { 46 bool menuDisable = false; 47 bool menuIsShow = false; 48 bool showCopy = true; 49 bool showPaste = true; 50 bool showCopyAll = true; 51 bool showCut = true; 52 IsIconChangedSelectMenuInfo53 bool IsIconChanged(const SelectMenuInfo& info) const 54 { 55 return !((showCopy == info.showCopy) && (showPaste == info.showPaste) && (showCopyAll == info.showCopyAll) && 56 (showCut == info.showCut)); 57 } 58 }; 59 60 struct SelectMenuCallback { 61 std::function<void()> onCopy; 62 std::function<void()> onPaste; 63 std::function<void()> onSelectAll; 64 std::function<void()> onCut; 65 }; 66 67 struct SelectOverlayInfo { 68 bool isUsingMouse = false; 69 bool isSingleHandle = false; 70 // when handleReverse is true, The first one is on the right side of the second. 71 bool handleReverse = false; 72 // Used to determine the range of judgment that is parallel to the first and second handles. 73 float singleLineHeight = 10.0f; 74 SelectHandleInfo firstHandle; 75 SelectHandleInfo secondHandle; 76 HitTestMode hitTestMode = HitTestMode::HTMTRANSPARENT_SELF; 77 78 // show area 79 bool useFullScreen = true; 80 RectF showArea; 81 82 OffsetF rightClickOffset; 83 84 // handle touch event 85 std::function<void(const TouchEventInfo&)> onTouchDown; 86 std::function<void(const TouchEventInfo&)> onTouchUp; 87 std::function<void(const TouchEventInfo&)> onTouchMove; 88 89 // handle move callback. 90 std::function<void(bool isFirst)> onHandleMoveStart; 91 std::function<void(const RectF&, bool isFirst)> onHandleMove; 92 std::function<void(const RectF&, bool isFirst)> onHandleMoveDone; 93 std::function<void(bool)> onHandleReverse; 94 95 // menu info. 96 SelectMenuInfo menuInfo; 97 SelectMenuCallback menuCallback; 98 99 // force hide callback, which may be called when other textOverlay shows. 100 std::function<void()> onClose; 101 }; 102 103 } // namespace OHOS::Ace::NG 104 105 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_PROPERTY_H 106