1 /* 2 * Copyright (c) 2021-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_GESTURES_GESTURE_INFO_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_GESTURES_GESTURE_INFO_H 18 19 #include <functional> 20 #include <map> 21 #include <list> 22 #include <string> 23 #include <unordered_map> 24 #include <vector> 25 26 #include "base/geometry/offset.h" 27 #include "base/geometry/point.h" 28 #include "base/image/pixel_map.h" 29 #include "base/memory/ace_type.h" 30 #include "base/utils/event_callback.h" 31 #include "base/utils/macros.h" 32 #include "base/utils/type_definition.h" 33 #include "core/event/ace_events.h" 34 #include "core/gestures/velocity.h" 35 #include "core/gestures/velocity_tracker.h" 36 37 #ifdef ENABLE_DRAG_FRAMEWORK 38 #include "core/common/udmf/unified_data.h" 39 #include "base/geometry/rect.h" 40 #endif 41 42 namespace OHOS::Ace { 43 44 constexpr int32_t DEFAULT_PAN_FINGER = 1; 45 constexpr Dimension DEFAULT_PAN_DISTANCE = 5.0_vp; 46 constexpr double DRAG_PAN_DISTANCE_MOUSE = 1.0; 47 constexpr double DRAG_LONG_PRESS_THRESHOLD = 3.0; 48 constexpr Dimension DEFAULT_SLIDE_DISTANCE = DEFAULT_PAN_DISTANCE; 49 constexpr int32_t DEFAULT_SLIDE_FINGER = DEFAULT_PAN_FINGER; 50 constexpr double DEFAULT_SLIDE_SPEED = 300.0; 51 constexpr int32_t DEFAULT_LONG_PRESS_DURATION = 100; 52 53 class GestureRecognizer; 54 class PipelineBase; 55 56 struct TransformConfig { 57 double scaleX = 1.0; 58 double scaleY = 1.0; 59 double centerX = 0.0; 60 double centerY = 0.0; 61 double offsetX = 0.0; 62 double offsetY = 0.0; 63 double translateX = 0.0; 64 double translateY = 0.0; 65 double degree = 0.0; 66 int id = -1; 67 bool operator==(TransformConfig tc) 68 { 69 return scaleX = tc.scaleX && scaleY == tc.scaleY && centerX == tc.centerX && centerY == tc.centerY && 70 offsetX == tc.offsetX && offsetY == tc.offsetY && translateX == tc.translateX && 71 translateY == tc.translateY && degree == tc.degree; 72 } 73 }; 74 75 struct AncestorNodeInfo { 76 int parentId = 0; 77 }; 78 79 enum class GesturePriority { 80 Begin = -1, 81 Low = 0, 82 High, 83 Parallel, 84 End, 85 }; 86 87 enum class GestureMask { 88 Begin = -1, 89 Normal = 0, 90 IgnoreInternal, 91 End, 92 }; 93 94 enum class GestureMode { 95 Begin = -1, 96 Sequence = 0, 97 Parallel, 98 Exclusive, 99 End, 100 }; 101 102 enum class Direction { 103 BEGIN = -1, 104 ALL = 0, 105 HORIZONTAL, 106 VERTICAL, 107 END, 108 }; 109 110 enum class DragEventAction { 111 DRAG_EVENT_START = 0, 112 DRAG_EVENT_MOVE, 113 DRAG_EVENT_END, 114 DRAG_EVENT_OUT, 115 }; 116 117 enum class InputEventType { 118 TOUCH_SCREEN = 0, 119 TOUCH_PAD, 120 MOUSE_BUTTON, 121 AXIS, 122 KEYBOARD, 123 }; 124 125 struct PanDirection final { 126 static constexpr uint32_t NONE = 0; 127 static constexpr uint32_t LEFT = 1; 128 static constexpr uint32_t RIGHT = 2; 129 static constexpr uint32_t HORIZONTAL = 3; 130 static constexpr uint32_t UP = 4; 131 static constexpr uint32_t DOWN = 8; 132 static constexpr uint32_t VERTICAL = 12; 133 static constexpr uint32_t ALL = 15; 134 135 uint32_t type = ALL; 136 }; 137 138 using OnPanFingersFunc = EventCallback<void(int32_t fingers)>; 139 using PanFingersFuncType = OnPanFingersFunc::FunctionType; 140 using OnPanDirectionFunc = EventCallback<void(const PanDirection& direction)>; 141 using PanDirectionFuncType = OnPanDirectionFunc::FunctionType; 142 using OnPanDistanceFunc = EventCallback<void(double distance)>; 143 using PanDistanceFuncType = OnPanDistanceFunc::FunctionType; 144 145 class PanGestureOption : public AceType { 146 DECLARE_ACE_TYPE(PanGestureOption, AceType); 147 148 public: 149 PanGestureOption() = default; 150 ~PanGestureOption() override = default; 151 SetDirection(PanDirection direction)152 void SetDirection(PanDirection direction) 153 { 154 direction_ = direction; 155 for (const auto& callback : onPanDirectionIds_) { 156 (callback.second.GetCallback())(direction); 157 } 158 } 159 GetDirection()160 const PanDirection& GetDirection() const 161 { 162 return direction_; 163 } 164 SetDistance(double distance)165 void SetDistance(double distance) 166 { 167 distance_ = distance; 168 for (const auto& callback : onPanDistanceIds_) { 169 (callback.second.GetCallback())(distance); 170 } 171 } 172 GetDistance()173 double GetDistance() const 174 { 175 return distance_; 176 } 177 SetFingers(int32_t fingers)178 void SetFingers(int32_t fingers) 179 { 180 fingers_ = fingers; 181 for (const auto& callback : onPanFingersIds_) { 182 (callback.second.GetCallback())(fingers); 183 } 184 } 185 GetFingers()186 int32_t GetFingers() const 187 { 188 return fingers_; 189 } 190 GetOnPanFingersIds()191 std::unordered_map<typename OnPanFingersFunc::IdType, OnPanFingersFunc>& GetOnPanFingersIds() 192 { 193 return onPanFingersIds_; 194 } 195 SetOnPanFingersId(const OnPanFingersFunc & onPanFingersId)196 void SetOnPanFingersId(const OnPanFingersFunc& onPanFingersId) 197 { 198 onPanFingersIds_.emplace(onPanFingersId.GetId(), onPanFingersId); 199 } 200 GetOnPanDirectionIds()201 std::unordered_map<typename OnPanDirectionFunc::IdType, OnPanDirectionFunc>& GetOnPanDirectionIds() 202 { 203 return onPanDirectionIds_; 204 } 205 SetOnPanDirectionId(const OnPanDirectionFunc & onPanDirectionId)206 void SetOnPanDirectionId(const OnPanDirectionFunc& onPanDirectionId) 207 { 208 onPanDirectionIds_.emplace(onPanDirectionId.GetId(), onPanDirectionId); 209 } 210 GetOnPanDistanceIds()211 std::unordered_map<typename OnPanDistanceFunc::IdType, OnPanDistanceFunc>& GetOnPanDistanceIds() 212 { 213 return onPanDistanceIds_; 214 } 215 SetOnPanDistanceId(const OnPanDistanceFunc & onPanDistanceId)216 void SetOnPanDistanceId(const OnPanDistanceFunc& onPanDistanceId) 217 { 218 onPanDistanceIds_.emplace(onPanDistanceId.GetId(), onPanDistanceId); 219 } 220 221 private: 222 PanDirection direction_; 223 double distance_ = DEFAULT_PAN_DISTANCE.ConvertToPx(); 224 int32_t fingers_ = 1; 225 std::unordered_map<typename OnPanFingersFunc::IdType, OnPanFingersFunc> onPanFingersIds_; 226 std::unordered_map<typename OnPanDirectionFunc::IdType, OnPanDirectionFunc> onPanDirectionIds_; 227 std::unordered_map<typename OnPanDistanceFunc::IdType, OnPanDistanceFunc> onPanDistanceIds_; 228 }; 229 230 struct SwipeDirection final { 231 static constexpr uint32_t NONE = 0; 232 static constexpr uint32_t HORIZONTAL = 1; 233 static constexpr uint32_t VERTICAL = 2; 234 static constexpr uint32_t ALL = 3; 235 236 uint32_t type = ALL; 237 }; 238 using OnSwipeFingersFunc = EventCallback<void(int32_t fingers)>; 239 using SwipeFingersFuncType = OnSwipeFingersFunc::FunctionType; 240 using OnSwipeDirectionFunc = EventCallback<void(const SwipeDirection& direction)>; 241 using SwipeDirectionFuncType = OnSwipeDirectionFunc::FunctionType; 242 using OnSwipeSpeedFunc = EventCallback<void(double speed)>; 243 using SwipeSpeedFuncType = OnSwipeSpeedFunc::FunctionType; 244 245 class PasteData : public AceType { 246 DECLARE_ACE_TYPE(PasteData, AceType); 247 248 public: 249 PasteData() = default; 250 ~PasteData() override = default; 251 SetPlainText(const std::string & plainText)252 void SetPlainText(const std::string& plainText) 253 { 254 plainText_ = plainText; 255 } 256 GetPlainText()257 const std::string& GetPlainText() const 258 { 259 return plainText_; 260 } 261 262 private: 263 std::string plainText_; 264 }; 265 266 #ifdef ENABLE_DRAG_FRAMEWORK 267 enum class DragRet { 268 DRAG_SUCCESS = 0, 269 DRAG_FAIL, 270 DRAG_CANCEL, 271 ENABLE_DROP, 272 DISABLE_DROP, 273 }; 274 enum class DragBehavior { 275 COPY = 0, 276 MOVE = 1, 277 }; 278 #endif 279 280 class ACE_FORCE_EXPORT DragEvent : public AceType { 281 DECLARE_ACE_TYPE(DragEvent, AceType) 282 283 public: 284 DragEvent() = default; 285 ~DragEvent() override = default; 286 SetPasteData(const RefPtr<PasteData> & pasteData)287 void SetPasteData(const RefPtr<PasteData>& pasteData) 288 { 289 pasteData_ = pasteData; 290 } 291 GetPasteData()292 RefPtr<PasteData> GetPasteData() const 293 { 294 return pasteData_; 295 } 296 GetScreenX()297 double GetScreenX() const 298 { 299 return screenX_; 300 } 301 GetScreenY()302 double GetScreenY() const 303 { 304 return screenY_; 305 } 306 SetScreenX(double x)307 void SetScreenX(double x) 308 { 309 screenX_ = x; 310 } 311 SetScreenY(double y)312 void SetScreenY(double y) 313 { 314 screenY_ = y; 315 } 316 GetX()317 double GetX() const 318 { 319 return x_; 320 } 321 GetY()322 double GetY() const 323 { 324 return y_; 325 } 326 SetX(double x)327 void SetX(double x) 328 { 329 x_ = x; 330 } 331 SetY(double y)332 void SetY(double y) 333 { 334 y_ = y; 335 } 336 SetDescription(const std::string & description)337 void SetDescription(const std::string& description) 338 { 339 description_ = description; 340 } 341 GetDescription()342 const std::string& GetDescription() const 343 { 344 return description_; 345 } 346 SetPixmap(const RefPtr<PixelMap> & pixelMap)347 void SetPixmap(const RefPtr<PixelMap>& pixelMap) 348 { 349 pixelMap_ = pixelMap; 350 } 351 GetPixmap()352 RefPtr<PixelMap> GetPixmap() const 353 { 354 return pixelMap_; 355 } 356 357 #ifdef ENABLE_DRAG_FRAMEWORK 358 void SetData(const RefPtr<UnifiedData>& unifiedData); 359 360 RefPtr<UnifiedData>& GetData(); 361 362 void SetSummary(std::map<std::string, int64_t>& summary); 363 364 std::map<std::string, int64_t>& GetSummary(); 365 366 void SetResult(DragRet dragRet); 367 368 DragRet GetResult(); 369 370 void SetPreviewRect(Rect previewRect); 371 372 Rect GetPreviewRect(); 373 374 void UseCustomAnimation(bool useCustomAnimation); 375 376 bool IsUseCustomAnimation(); 377 378 void SetUdKey(const std::string udKey); 379 380 std::string GetUdKey(); 381 382 void SetDragInfo(const RefPtr<UnifiedData>& dragInfo); 383 384 RefPtr<UnifiedData>& GetDragInfo(); 385 386 void SetCopy(bool copy); 387 388 bool IsCopy(); 389 390 void SetIsGetDataSuccess(bool isGetDataSuccess); 391 392 bool IsGetDataSuccess(); 393 #endif 394 SetVelocity(const Velocity & velocity)395 void SetVelocity(const Velocity& velocity) 396 { 397 velocity_ = velocity; 398 } 399 GetVelocity()400 const Velocity& GetVelocity() const 401 { 402 return velocity_; 403 } 404 405 private: 406 RefPtr<PasteData> pasteData_; 407 double screenX_ = 0.0; 408 double screenY_ = 0.0; 409 double x_ = 0.0; 410 double y_ = 0.0; 411 std::string description_; 412 RefPtr<PixelMap> pixelMap_; 413 #ifdef ENABLE_DRAG_FRAMEWORK 414 RefPtr<UnifiedData> unifiedData_; 415 std::map<std::string, int64_t> summary_; 416 std::string udKey_ = ""; 417 DragRet dragRet_; 418 Rect previewRect_; 419 bool useCustomAnimation_ = false; 420 bool isGetDataSuccess_ = false; 421 RefPtr<UnifiedData> dragInfo_; 422 bool copy_ = true; 423 #endif 424 Velocity velocity_; 425 }; 426 427 struct FingerInfo { 428 int32_t fingerId_ = -1; 429 // global position at which the touch point contacts the screen. 430 Offset globalLocation_; 431 // Different from global location, The local location refers to the location of the contact point relative to the 432 // current node which has the recognizer. 433 Offset localLocation_; 434 SourceType sourceType_ = SourceType::NONE; 435 SourceTool sourceTool_ = SourceTool::UNKNOWN; 436 }; 437 438 class ItemDragInfo : public BaseEventInfo { 439 DECLARE_RELATIONSHIP_OF_CLASSES(ItemDragInfo, BaseEventInfo); 440 441 public: ItemDragInfo()442 ItemDragInfo() : BaseEventInfo("itemDrag") {} 443 ~ItemDragInfo() override = default; 444 GetX()445 double GetX() const 446 { 447 return x_; 448 } 449 GetY()450 double GetY() const 451 { 452 return y_; 453 } 454 SetX(double x)455 void SetX(double x) 456 { 457 x_ = x; 458 } 459 SetY(double y)460 void SetY(double y) 461 { 462 y_ = y; 463 } 464 465 private: 466 double x_ = 0.0; 467 double y_ = 0.0; 468 }; 469 470 class GestureEvent : public BaseEventInfo { 471 DECLARE_RELATIONSHIP_OF_CLASSES(GestureEvent, BaseEventInfo); 472 473 public: GestureEvent()474 GestureEvent() : BaseEventInfo("gesture") {} 475 ~GestureEvent() override = default; 476 SetRepeat(bool repeat)477 void SetRepeat(bool repeat) 478 { 479 repeat_ = repeat; 480 } 481 GetRepeat()482 bool GetRepeat() const 483 { 484 return repeat_; 485 } 486 SetOffsetX(double offsetX)487 void SetOffsetX(double offsetX) 488 { 489 offsetX_ = offsetX; 490 } 491 GetOffsetX()492 double GetOffsetX() const 493 { 494 return offsetX_; 495 } 496 SetOffsetY(double offsetY)497 void SetOffsetY(double offsetY) 498 { 499 offsetY_ = offsetY; 500 } 501 GetOffsetY()502 double GetOffsetY() const 503 { 504 return offsetY_; 505 } 506 SetScale(double scale)507 void SetScale(double scale) 508 { 509 scale_ = scale; 510 } 511 GetScale()512 double GetScale() const 513 { 514 return scale_; 515 } 516 SetAngle(double angle)517 void SetAngle(double angle) 518 { 519 angle_ = angle; 520 } 521 GetAngle()522 double GetAngle() const 523 { 524 return angle_; 525 } 526 SetGlobalPoint(const Point & globalPoint)527 GestureEvent& SetGlobalPoint(const Point& globalPoint) 528 { 529 globalPoint_ = globalPoint; 530 globalLocation_.SetX(globalPoint.GetX()); 531 globalLocation_.SetY(globalPoint.GetY()); 532 return *this; 533 } 534 GetGlobalPoint()535 const Point& GetGlobalPoint() const 536 { 537 return globalPoint_; 538 } 539 SetScreenLocation(const Offset & screenLocation)540 GestureEvent& SetScreenLocation(const Offset& screenLocation) 541 { 542 screenLocation_ = screenLocation; 543 return *this; 544 } 545 GetScreenLocation()546 const Offset& GetScreenLocation() const 547 { 548 return screenLocation_; 549 } 550 SetGlobalLocation(const Offset & globalLocation)551 GestureEvent& SetGlobalLocation(const Offset& globalLocation) 552 { 553 globalLocation_ = globalLocation; 554 globalPoint_.SetX(globalLocation.GetX()); 555 globalPoint_.SetY(globalLocation.GetY()); 556 return *this; 557 } SetLocalLocation(const Offset & localLocation)558 GestureEvent& SetLocalLocation(const Offset& localLocation) 559 { 560 localLocation_ = localLocation; 561 return *this; 562 } 563 GetLocalLocation()564 const Offset& GetLocalLocation() const 565 { 566 return localLocation_; 567 } GetGlobalLocation()568 const Offset& GetGlobalLocation() const 569 { 570 return globalLocation_; 571 } 572 GetPinchCenter()573 const Offset& GetPinchCenter() const 574 { 575 return pinchCenter_; 576 } 577 SetPinchCenter(const Offset & pinchCenter)578 GestureEvent& SetPinchCenter(const Offset& pinchCenter) 579 { 580 pinchCenter_ = pinchCenter; 581 return *this; 582 } 583 GetFingerList()584 const std::list<FingerInfo>& GetFingerList() const 585 { 586 return fingerList_; 587 } 588 SetFingerList(const std::list<FingerInfo> & fingerList)589 void SetFingerList(const std::list<FingerInfo>& fingerList) 590 { 591 fingerList_ = fingerList; 592 } 593 SetSpeed(double speed)594 void SetSpeed(double speed) 595 { 596 speed_ = speed; 597 } 598 GetSpeed()599 double GetSpeed() const 600 { 601 return speed_; 602 } 603 SetMainSpeed(double mainSpeed)604 void SetMainSpeed(double mainSpeed) 605 { 606 mainSpeed_ = mainSpeed; 607 } 608 GetMainSpeed()609 double GetMainSpeed() const 610 { 611 return mainSpeed_; 612 } 613 SetVelocity(const Velocity & velocity)614 void SetVelocity(const Velocity& velocity) 615 { 616 velocity_ = velocity; 617 } 618 GetVelocity()619 const Velocity& GetVelocity() const 620 { 621 return velocity_; 622 } 623 SetMainVelocity(double mainVelocity)624 void SetMainVelocity(double mainVelocity) 625 { 626 mainVelocity_ = mainVelocity; 627 } 628 GetMainVelocity()629 double GetMainVelocity() const 630 { 631 return mainVelocity_; 632 } 633 SetPressed(bool pressed)634 void SetPressed(bool pressed) 635 { 636 pressed_ = pressed; 637 } 638 GetPressed()639 bool GetPressed() const 640 { 641 return pressed_; 642 } 643 SetDelta(const Offset & delta)644 void SetDelta(const Offset& delta) 645 { 646 delta_ = delta; 647 } 648 GetDelta()649 const Offset& GetDelta() const 650 { 651 return delta_; 652 } 653 SetMainDelta(double mainDelta)654 void SetMainDelta(double mainDelta) 655 { 656 mainDelta_ = mainDelta; 657 } 658 GetMainDelta()659 double GetMainDelta() const 660 { 661 return mainDelta_; 662 } 663 SetInputEventType(InputEventType type)664 void SetInputEventType(InputEventType type) 665 { 666 inputEventType_ = type; 667 } 668 GetInputEventType()669 InputEventType GetInputEventType() const 670 { 671 return inputEventType_; 672 } 673 #ifdef ENABLE_DRAG_FRAMEWORK SetPointerId(int32_t pointerId)674 void SetPointerId(int32_t pointerId) 675 { 676 pointerId_ = pointerId; 677 } 678 GetPointerId()679 int32_t GetPointerId() const 680 { 681 return pointerId_; 682 } 683 #endif // ENABLE_DRAG_FRAMEWORK 684 #ifdef SECURITY_COMPONENT_ENABLE SetDisplayX(double displayX)685 void SetDisplayX(double displayX) 686 { 687 displayX_ = displayX; 688 } 689 GetDisplayX()690 double GetDisplayX() const 691 { 692 return displayX_; 693 } 694 SetDisplayY(double displayY)695 void SetDisplayY(double displayY) 696 { 697 displayY_ = displayY; 698 } 699 GetDisplayY()700 double GetDisplayY() const 701 { 702 return displayY_; 703 } 704 SetSecCompHandleEvent(const std::shared_ptr<JsonValue> & event)705 void SetSecCompHandleEvent(const std::shared_ptr<JsonValue>& event) 706 { 707 secCompHandleEvent_ = event; 708 } 709 GetSecCompHandleEvent()710 std::shared_ptr<JsonValue> GetSecCompHandleEvent() const 711 { 712 return secCompHandleEvent_; 713 } 714 SetEnhanceData(std::vector<uint8_t> enhanceData)715 void SetEnhanceData(std::vector<uint8_t> enhanceData) 716 { 717 enhanceData_ = enhanceData; 718 } 719 GetEnhanceData()720 std::vector<uint8_t> GetEnhanceData() const 721 { 722 return enhanceData_; 723 } 724 #endif 725 private: 726 bool repeat_ = false; 727 bool pressed_ = false; 728 double offsetX_ = 0.0; 729 double offsetY_ = 0.0; 730 double scale_ = 1.0; 731 double angle_ = 0.0; 732 Velocity velocity_; 733 double mainVelocity_ = 0.0; 734 double speed_ = 0.0; 735 double mainSpeed_ = 0.0; 736 double mainDelta_ = 0.0; 737 #ifdef ENABLE_DRAG_FRAMEWORK 738 int32_t pointerId_ = 0; 739 #endif // ENABLE_DRAG_FRAMEWORK 740 #ifdef SECURITY_COMPONENT_ENABLE 741 double displayX_ = 0.0; 742 double displayY_ = 0.0; 743 std::vector<uint8_t> enhanceData_; 744 std::shared_ptr<JsonValue> secCompHandleEvent_; 745 #endif 746 Point globalPoint_; 747 // global position at which the touch point contacts the screen. 748 Offset globalLocation_; 749 // Different from global location, The local location refers to the location of the contact point relative to the 750 // current node which has the recognizer. 751 Offset localLocation_; 752 Offset screenLocation_; 753 Offset pinchCenter_; 754 Offset delta_; 755 std::list<FingerInfo> fingerList_; 756 InputEventType inputEventType_ = InputEventType::TOUCH_SCREEN; 757 }; 758 759 using GestureEventFunc = std::function<void(GestureEvent& info)>; 760 using GestureEventNoParameter = std::function<void()>; 761 762 class ACE_EXPORT Gesture : public virtual AceType { 763 DECLARE_ACE_TYPE(Gesture, AceType); 764 765 public: 766 Gesture() = default; Gesture(int32_t fingers)767 explicit Gesture(int32_t fingers) : fingers_(fingers) {} 768 ~Gesture() override = default; 769 SetOnActionId(const GestureEventFunc & onActionId)770 void SetOnActionId(const GestureEventFunc& onActionId) 771 { 772 onActionId_ = std::make_unique<GestureEventFunc>(onActionId); 773 } SetOnActionStartId(const GestureEventFunc & onActionStartId)774 void SetOnActionStartId(const GestureEventFunc& onActionStartId) 775 { 776 onActionStartId_ = std::make_unique<GestureEventFunc>(onActionStartId); 777 } SetOnActionUpdateId(const GestureEventFunc & onActionUpdateId)778 void SetOnActionUpdateId(const GestureEventFunc& onActionUpdateId) 779 { 780 onActionUpdateId_ = std::make_unique<GestureEventFunc>(onActionUpdateId); 781 } SetOnActionEndId(const GestureEventFunc & onActionEndId)782 void SetOnActionEndId(const GestureEventFunc& onActionEndId) 783 { 784 onActionEndId_ = std::make_unique<GestureEventFunc>(onActionEndId); 785 } SetOnActionCancelId(const GestureEventNoParameter & onActionCancelId)786 void SetOnActionCancelId(const GestureEventNoParameter& onActionCancelId) 787 { 788 onActionCancelId_ = std::make_unique<GestureEventNoParameter>(onActionCancelId); 789 } SetPriority(GesturePriority priority)790 void SetPriority(GesturePriority priority) 791 { 792 priority_ = priority; 793 } SetGestureMask(GestureMask gestureMask)794 void SetGestureMask(GestureMask gestureMask) 795 { 796 gestureMask_ = gestureMask; 797 } 798 GetPriority()799 GesturePriority GetPriority() const 800 { 801 return priority_; 802 } 803 GetGestureMask()804 GestureMask GetGestureMask() const 805 { 806 return gestureMask_; 807 } 808 809 virtual RefPtr<GestureRecognizer> CreateRecognizer(WeakPtr<PipelineBase> context) = 0; 810 811 protected: 812 int32_t fingers_ = 1; 813 GesturePriority priority_ = GesturePriority::Low; 814 GestureMask gestureMask_ = GestureMask::Normal; 815 std::unique_ptr<GestureEventFunc> onActionId_; 816 std::unique_ptr<GestureEventFunc> onActionStartId_; 817 std::unique_ptr<GestureEventFunc> onActionUpdateId_; 818 std::unique_ptr<GestureEventFunc> onActionEndId_; 819 std::unique_ptr<GestureEventNoParameter> onActionCancelId_; 820 }; 821 822 class ClickInfo : public TouchLocationInfo { 823 DECLARE_RELATIONSHIP_OF_CLASSES(ClickInfo, TouchLocationInfo); 824 825 public: ClickInfo(int32_t fingerId)826 explicit ClickInfo(int32_t fingerId) : TouchLocationInfo("onClick", fingerId) {} 827 ~ClickInfo() override = default; 828 }; 829 using ClickCallback = std::function<void(const ClickInfo&)>; 830 831 } // namespace OHOS::Ace 832 833 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_GESTURES_GESTURE_INFO_H 834