1 /* 2 * Copyright (c) 2022-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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_GESTURES_GESTURE_GROUP_H 16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_GESTURES_GESTURE_GROUP_H 17 #include <cstdint> 18 #include <functional> 19 #include <string> 20 #include <vector> 21 22 #include "base/geometry/offset.h" 23 #include "base/memory/ace_type.h" 24 #include "base/utils/macros.h" 25 #include "core/components_ng/gestures/gesture_info.h" 26 #include "core/components_ng/gestures/pan_gesture.h" 27 namespace OHOS::Ace::NG { 28 29 #define MAX_BYTES_SIZE (1024*1024*10) 30 class ACE_FORCE_EXPORT GestureGroup : public Gesture { 31 DECLARE_ACE_TYPE(GestureGroup, Gesture); 32 33 public: GestureGroup(GestureMode mode,const std::vector<RefPtr<Gesture>> & gestures)34 GestureGroup(GestureMode mode, const std::vector<RefPtr<Gesture>>& gestures) : mode_(mode), gestures_(gestures) {} GestureGroup(GestureMode mode)35 explicit GestureGroup(GestureMode mode) : mode_(mode) {} 36 ~GestureGroup() override = default; AddGesture(RefPtr<Gesture> gesture)37 void AddGesture(RefPtr<Gesture> gesture) 38 { 39 gestures_.emplace_back(gesture); 40 } 41 int32_t SizeofMe() override; 42 virtual int32_t Serialize(char* buff) override; 43 44 RefPtr<Gesture> MakeGesture(GestureType type); 45 46 virtual int32_t Deserialize(const char* buff) override; 47 48 RefPtr<NGGestureRecognizer> CreateRecognizer() override; 49 50 void RemoveChildrenByTag(const std::string& gestureTag, bool& needRecollect); 51 52 void RemoveGesture(RefPtr<Gesture> gesture); 53 GetGestures()54 const std::vector<RefPtr<Gesture>> &GetGestures() const 55 { 56 return gestures_; 57 } 58 private: 59 GestureMode mode_; 60 std::vector<RefPtr<Gesture>> gestures_; 61 }; 62 } // namespace OHOS::Ace::NG 63 64 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_GESTURES_GESTURE_GROUP_H 65