1 /* 2 * Copyright (c) 2021 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_GESTURES_PARALLEL_RECOGNIZER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_GESTURES_PARALLEL_RECOGNIZER_H 18 19 #include <functional> 20 21 #include "core/gestures/gesture_info.h" 22 #include "core/gestures/multi_fingers_recognizer.h" 23 24 namespace OHOS::Ace { 25 26 // ParallelRecognizer identifies events in parallel recognizers. 27 // For long press and double click, see: LongPressRecognizer and DoubleClickRecognizer. 28 class ACE_EXPORT ParallelRecognizer : public MultiFingersRecognizer { 29 DECLARE_ACE_TYPE(ParallelRecognizer, MultiFingersRecognizer); 30 31 public: ParallelRecognizer(const std::vector<RefPtr<GestureRecognizer>> & recognizers)32 explicit ParallelRecognizer(const std::vector<RefPtr<GestureRecognizer>>& recognizers) 33 { 34 for (auto& recognizer : recognizers) { 35 recognizer->SetGestureGroup(AceType::WeakClaim(this)); 36 } 37 recognizers_ = recognizers; 38 } 39 ~ParallelRecognizer() override = default; 40 void OnAccepted(size_t touchId) override; 41 void OnRejected(size_t touchId) override; 42 void OnPending(size_t touchId) override; 43 bool HandleEvent(const TouchEvent& point) override; 44 45 private: HandleTouchDownEvent(const TouchEvent & event)46 void HandleTouchDownEvent(const TouchEvent& event) override {}; HandleTouchUpEvent(const TouchEvent & event)47 void HandleTouchUpEvent(const TouchEvent& event) override {}; HandleTouchMoveEvent(const TouchEvent & event)48 void HandleTouchMoveEvent(const TouchEvent& event) override {}; HandleTouchCancelEvent(const TouchEvent & event)49 void HandleTouchCancelEvent(const TouchEvent& event) override {}; 50 void BatchAdjudicate(const std::set<size_t>& touchIds, const RefPtr<GestureRecognizer>& recognizer, 51 GestureDisposal disposal) override; 52 void AddToReferee(size_t touchId, const RefPtr<GestureRecognizer>& recognizer) override; 53 bool ReconcileFrom(const RefPtr<GestureRecognizer>& recognizer) override; 54 void Reset(); DelFromReferee(size_t touchId,const RefPtr<GestureRecognizer> & recognizer)55 void DelFromReferee(size_t touchId, const RefPtr<GestureRecognizer>& recognizer) override {} 56 bool IsRecognizeEnd(const RefPtr<GestureRecognizer>& recognizer); 57 58 std::vector<RefPtr<GestureRecognizer>> recognizers_; 59 }; 60 61 } // namespace OHOS::Ace 62 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_GESTURES_PARALLEL_RECOGNIZER_H 64 65