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_COMPONENTS_GRID_LAYOUT_RENDER_GRID_LAYOUT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_GRID_LAYOUT_RENDER_GRID_LAYOUT_H 18 19 #include <atomic> 20 #include <functional> 21 #include <map> 22 #include <mutex> 23 #include <vector> 24 25 #include "core/animation/animation.h" 26 #include "core/animation/animator.h" 27 #include "core/animation/scroll_motion.h" 28 #include "core/animation/spring_motion.h" 29 #include "core/components/common/layout/constants.h" 30 #include "core/components/common/properties/scroll_bar.h" 31 #include "core/components/grid_layout/grid_layout_component.h" 32 #include "core/components/grid_layout/render_grid_layout_item.h" 33 #include "core/components/positioned/positioned_component.h" 34 #include "core/components/stack/stack_element.h" 35 #include "core/gestures/drag_recognizer.h" 36 #include "core/gestures/gesture_info.h" 37 #include "core/gestures/raw_recognizer.h" 38 #include "core/pipeline/base/render_node.h" 39 40 namespace OHOS::Ace { 41 namespace { 42 43 constexpr int32_t DEFAULT_FINGERS = 1; 44 constexpr int32_t DEFAULT_DURATION = 150; 45 constexpr int32_t DEFAULT_DISTANCE = 0; 46 47 constexpr int32_t DRAG_LEAVE = -1; 48 constexpr int32_t DRAG_ENTER = 1; 49 constexpr int32_t NONE = 0; 50 constexpr double ITEM_ANIMATION_DURATION = 300.0; 51 constexpr double ITEM_ANIMATION_DURATION_NO = 40.0; 52 53 constexpr double GRID_SPRING_MASS = 1.0; 54 constexpr double GRID_SPRING_STIFF = 228.0; 55 constexpr double GRID_SPRING_DAMP = 30.0; 56 constexpr double GRID_SPRING_DAMP_INC = 0; 57 constexpr double GRID_SPRING_SLIDE_LIMIT = 20.0; 58 59 }; // namespace 60 61 enum class GridLayoutAnimationAct { 62 ANIMATION_NONE = 0, 63 ANIMATION_DRAG_MOVE, 64 ANIMATION_DRAG_DROP, 65 ANIMATION_RESTORE_SCENCE, 66 }; 67 68 enum class GridSpringGravitationDirect { 69 SPRING_NONE = 0, 70 SPRING_TO_LEFT, 71 SPRING_TO_RIGHT, 72 SPRING_TO_UP, 73 SPRING_TO_DOWN, 74 }; 75 76 enum class GridSlideDirect { 77 SLIDE_NODE = 0, 78 SLIDE_HORIZON, 79 SLIDE_VERTICAL, 80 }; 81 82 enum class GridSlideStatus { 83 SLIDE_NONE = 0, 84 SLIDE_START, 85 SLIDE_SLIDING, 86 SLIDE_SPRING_START, 87 }; 88 89 class GridItemIndexPosition { 90 public: GridItemIndexPosition(int32_t rowIndex,int32_t colIndex)91 GridItemIndexPosition(int32_t rowIndex, int32_t colIndex) : rowIndex_(rowIndex), colIndex_(colIndex) {} 92 ~GridItemIndexPosition() = default; GridItemIndexPosition(const GridItemIndexPosition & r)93 GridItemIndexPosition(const GridItemIndexPosition& r) 94 { 95 rowIndex_ = r.rowIndex_; 96 colIndex_ = r.colIndex_; 97 } 98 GridItemIndexPosition operator=(const GridItemIndexPosition& r) 99 { 100 if (this != &r) { 101 rowIndex_ = r.rowIndex_; 102 colIndex_ = r.colIndex_; 103 } 104 return *this; 105 } 106 bool operator==(const GridItemIndexPosition& data) 107 { 108 return (data.rowIndex_ == rowIndex_) && (data.colIndex_ == colIndex_); 109 } 110 bool operator!=(const GridItemIndexPosition& data) 111 { 112 return !(*this == data); 113 } 114 115 int32_t rowIndex_; 116 int32_t colIndex_; 117 }; 118 119 using OnItemDragFunc = std::function<void(const Dimension&, const Dimension&)>; 120 using OnAnimationCallJSFunc = std::function<void()>; 121 using OnCallJSDropFunc = std::function<void()>; 122 123 class RenderGridLayout : public RenderNode { 124 DECLARE_ACE_TYPE(RenderGridLayout, RenderNode); 125 126 public: 127 static RefPtr<RenderNode> Create(); 128 129 void Update(const RefPtr<Component>& component) override; 130 131 void PerformLayout() override; 132 bool IsUseOnly() override; 133 134 void OnTouchTestHit( 135 const Offset& coordinateOffset, const TouchRestrict& touchRestrict, TouchTestResult& result) override; 136 137 // Adjust focus index when grid_item request focus itself. 138 void UpdateFocusInfo(int32_t focusIndex); 139 140 // Support to grid element response focus event. 141 int32_t RequestNextFocus(bool vertical, bool reverse); 142 GetColumnsTemplate()143 const std::string& GetColumnsTemplate() const 144 { 145 return colsArgs_; 146 } 147 GetRowTemplate()148 const std::string& GetRowTemplate() const 149 { 150 return rowsArgs_; 151 } 152 GetColumnsGap()153 double GetColumnsGap() const 154 { 155 return colGap_; 156 } 157 GetRowGaps()158 double GetRowGaps() const 159 { 160 return rowGap_; 161 } 162 GetColumns()163 Dimension GetColumns() const 164 { 165 return userColGap_; 166 } 167 GetRows()168 Dimension GetRows() const 169 { 170 return userRowGap_; 171 } 172 GetScrollBarWidth()173 const std::string& GetScrollBarWidth() const 174 { 175 return scrollBarWidth_; 176 } 177 GetScrollBarColor()178 const std::string& GetScrollBarColor() const 179 { 180 return scrollBarColor_; 181 } 182 GetScrollBar()183 DisplayMode GetScrollBar() const 184 { 185 return displayMode_; 186 } 187 GetUpdatePositionId()188 const OnItemDragFunc& GetUpdatePositionId() const 189 { 190 return updatePosition_; 191 } 192 SetUpdatePositionId(const OnItemDragFunc & updatePosition)193 void SetUpdatePositionId(const OnItemDragFunc& updatePosition) 194 { 195 updatePosition_ = updatePosition; 196 } 197 GetEditMode()198 bool GetEditMode() const 199 { 200 return editMode_; 201 } 202 GetMaxCount()203 int32_t GetMaxCount() const 204 { 205 return mainCountMax_; 206 } 207 GetMinCount()208 int32_t GetMinCount() const 209 { 210 return mainCountMin_; 211 } 212 GetCellLength()213 int32_t GetCellLength() const 214 { 215 return cellLength_; 216 } 217 GetSupportAnimation()218 bool GetSupportAnimation() const 219 { 220 return supportAnimation_; 221 } 222 GetMultiSelectable()223 bool GetMultiSelectable() const 224 { 225 return isMultiSelectable_; 226 } 227 228 protected: 229 virtual LayoutParam MakeInnerLayoutParam(int32_t row, int32_t col, int32_t rowSpan, int32_t colSpan) const; 230 231 void SetItemIndex(const RefPtr<RenderNode>& child, int32_t index); 232 233 int32_t GetItemRowIndex(const RefPtr<RenderNode>& child) const; 234 235 int32_t GetItemColumnIndex(const RefPtr<RenderNode>& child) const; 236 237 int32_t GetItemSpan(const RefPtr<RenderNode>& child, bool isRow) const; 238 239 virtual void GetNextGrid(int32_t& curRow, int32_t& curCol) const; 240 241 virtual void GetPreviousGird(int32_t& curRow, int32_t& curCol) const; 242 243 virtual bool CheckGridPlaced(int32_t index, int32_t row, int32_t col, int32_t& rowSpan, int32_t& colSpan); 244 245 int32_t GetIndexByGrid(int32_t row, int32_t column) const; 246 247 // Sets child position, the mainAxis does not contain the offset. 248 virtual void SetChildPosition( 249 const RefPtr<RenderNode>& child, int32_t row, int32_t col, int32_t rowSpan, int32_t colSpan); 250 251 void DisableChild(const RefPtr<RenderNode>& child, int32_t index); 252 253 void ConvertRepeatArgs(std::string& args); 254 255 // Handle direction key move 256 int32_t focusMove(KeyDirection direction); 257 258 Size GetTargetLayoutSize(int32_t row, int32_t col); 259 260 std::string PreParseRows(); 261 262 std::string PreParseCols(); 263 264 virtual void InitialGridProp(); 265 266 void UpdateAccessibilityAttr(); 267 268 std::vector<double> ParseArgs(const std::string& agrs, double size, double gap); 269 270 std::vector<double> ParseAutoFill(const std::vector<std::string>& strs, double size, double gap); 271 SetPreTargetRenderGrid(const RefPtr<RenderGridLayout> & preTargetRenderGrid)272 void SetPreTargetRenderGrid(const RefPtr<RenderGridLayout>& preTargetRenderGrid) 273 { 274 preTargetRenderGrid_ = preTargetRenderGrid; 275 } 276 GetPreTargetRenderGrid()277 const RefPtr<RenderGridLayout> GetPreTargetRenderGrid() const 278 { 279 return preTargetRenderGrid_.Upgrade(); 280 } 281 SetMainTargetRenderGrid(const RefPtr<RenderGridLayout> & mainTargetRenderGrid)282 void SetMainTargetRenderGrid(const RefPtr<RenderGridLayout>& mainTargetRenderGrid) 283 { 284 mainTargetRenderGrid_ = mainTargetRenderGrid; 285 } 286 GetMainTargetRenderGrid()287 const RefPtr<RenderGridLayout> GetMainTargetRenderGrid() const 288 { 289 return mainTargetRenderGrid_.Upgrade(); 290 } 291 SetLongPressPoint(const Point & lastLongPressPoint)292 void SetLongPressPoint(const Point& lastLongPressPoint) 293 { 294 lastLongPressPoint_ = lastLongPressPoint; 295 } 296 GetLongPressPoint()297 const Point GetLongPressPoint() const 298 { 299 return lastLongPressPoint_; 300 } 301 302 void ClearPartDragInfo(); 303 void ClearAllDragInfo(); 304 void CalIsVertical(); 305 void RegisterLongPressedForItems(); 306 void CreateDragDropRecognizer(); 307 void ActionStart(const ItemDragInfo& info, RefPtr<Component> customComponent); 308 void PanOnActionUpdate(const GestureEvent& info); 309 void PanOnActionEnd(const GestureEvent& info); 310 void OnDragEnter(const ItemDragInfo& info); 311 void OnDragLeave(const ItemDragInfo& info); 312 void OnDragMove(const ItemDragInfo& info); 313 bool OnDrop(const ItemDragInfo& info); 314 void ImpDragStart(const ItemDragInfo& info); 315 bool ImpDropInGrid(const ItemDragInfo& info); 316 317 void ImpDragMove(const ItemDragInfo& info); 318 void ImpDragLeaveMainGrid(const ItemDragInfo& info); 319 void ImpDragLeaveSubGrid(const ItemDragInfo& info); 320 void ImpDragEnterMainGrid(const ItemDragInfo& info); 321 void ImpDragEnterSubGrid(const ItemDragInfo& info); 322 void ImpDragEnterMainGridUpdate(); 323 void OnCallSubDragEnter(const ItemDragInfo& info); 324 void OnCallSubDragLeave(const ItemDragInfo& info); 325 326 // Check whether the item is currently allowed to be inserted 327 bool CouldBeInserted(); 328 bool NeedBeLarger(); 329 bool NeedBeSmaller(); 330 void BackGridMatrix(); 331 void RestoreScene(const ItemDragInfo& info); 332 333 int32_t CountItemInGrid(); 334 int32_t CountItemInRow(const std::map<int32_t, std::map<int32_t, int32_t>>::iterator& rowGrid); 335 void ResetItemPosition(); 336 void InitialDynamicGridProp(int32_t dragLeaveOrEnter = NONE); 337 void PerformLayoutForEditGrid(); 338 void PerformLayoutForStaticGrid(); 339 bool CalDragCell(const ItemDragInfo& info); 340 bool CalDragRowIndex(double dragRelativelyY, int32_t& dragRowIndex); 341 bool CalDragColumIndex(double dragRelativelyX, int32_t& dragColIndex); 342 void MoveItems(); 343 344 // These functions cannot be called independently, they must be called by MoveItems() 345 void MoveWhenNoInsertCell(); 346 void MoveWhenNoInsertCellAndNoItemInDragCell(); 347 void MoveWhenNoInsertCellButWithItemInDragCell(); 348 void MoveWhenNoInsertCellButWithItemInDragCellAndDragEnter(); 349 void MoveWhenNoInsertCellButWithItemInDragCellAndDragStart(); 350 void MoveWhenWithInsertCell(); 351 352 void MoveWhenWithInsertCellAndNoItemInDragCell(); 353 void MoveWhenWithInsertCellButWithItemInDragCell(); 354 void MoveWhenWithInsertCellButWithItemInDragCellDragBeforeInsert(); 355 void MoveWhenWithInsertCellButWithItemInDragCellDragAfterInsert(); 356 357 void FakeRemoveDragItem(); 358 void FakeRemoveDragItemUpdate(); 359 // it should be cells which has item in 360 bool MoveItemsForward(int32_t fromRow, int32_t fromColum, int32_t toRow, int32_t toColum); 361 362 // it should be cells which has item in 363 bool MoveItemsBackward(int32_t fromRow, int32_t fromColum, int32_t toRow, int32_t toColum); 364 void UpdateMatrixByIndexStrong(int32_t index, int32_t row, int32_t colum); 365 void UpdateCurInsertPos(int32_t curInsertRow, int32_t curInsertColum); 366 int32_t CalIndexForItemByRowAndColum(int32_t row, int32_t colum); 367 368 // If the first is equal the second, return true, else return false. 369 bool SortCellIndex(int32_t rowFirst, int32_t columFirst, int32_t rowSecond, int32_t columSecond, bool& firstIsPre); 370 371 // if there is no empty in the cell return false, else return true. 372 bool CalTheFirstEmptyCell(int32_t& rowIndex, int32_t& columIndex, bool ignoreInsert); 373 374 void SetGridLayoutParam(); 375 void CalculateVerticalSize(std::vector<double>& cols, std::vector<double>& rows, int32_t dragLeaveOrEnter); 376 void CalculateHorizontalSize(std::vector<double>& cols, std::vector<double>& rows, int32_t dragLeaveOrEnter); 377 void UpdateCollectionInfo(std::vector<double> cols, std::vector<double> rows); 378 void ClearSpringSlideData(); 379 void CreateSlideRecognizer(); 380 void HandleSlideStart(const TouchEventInfo& info); 381 void HandleSlideUpdate(const TouchEventInfo& info); 382 void HandleSlideEnd(const TouchEventInfo& info); 383 bool CheckLongPress(); 384 bool MayStartToSlide(const TouchEventInfo& info); 385 void UpdateSlideStatus(GridSlideStatus status); 386 GridSlideStatus GetSlideStatus(); 387 Point GetPointFromTouchInfo(const TouchEventInfo& info); 388 void MoveRelativeDistance(double& dx, double& dy); 389 void CreateSpringController(); 390 Point GetSpringStartPoint(); 391 Point GetSpringEndPoint(); 392 void StartSpringAnimation(const Point& startPoint, const Point& endPoint); 393 void FinishedSpringAnimation(); 394 void UpdateSprintAnimationPosition(double offset); 395 void BackupSpringItemsData(); 396 void GetMotionPosition(const Point& startPoint, const Point& endPoint, double& start, double& end); 397 void CalcSlideDirect(const Point& curPos); 398 void CalcSpringGravitationDirect(); 399 400 void TriggerMoveEventForJS(const ItemDragInfo& info); 401 void TriggerDropEventForJS(const ItemDragInfo& info, int32_t insertIndex, bool successed); 402 void InitAnimationController(const WeakPtr<PipelineContext>& context); 403 bool AddNodeAnimationToController(int32_t itemIndex, int32_t row, int32_t col, int32_t rowSpan, int32_t colSpan); 404 void AddNodeAnimationToControllerForDrop( 405 const RefPtr<RenderNode>& item, const Point& startPoint, const Point& endPoint); 406 void PrepareAnimationController(const std::string& key); 407 void StartAnimationController(GridLayoutAnimationAct animationAct, const OnAnimationCallJSFunc& func); 408 void StopAnimationController(); 409 Point CalcChildPosition( 410 const RefPtr<RenderNode>& child, int32_t row, int32_t col, int32_t rowSpan, int32_t colSpan); 411 Point CalcDragChildStartPosition(const ItemDragInfo& info); 412 Point CalcDragChildEndPosition(int32_t rowIndex, int32_t colIndex); 413 void FinishedAnimationController(const std::string& key); 414 void RegisterAnimationFinishedFunc(const std::string& key, std::function<void()> func); 415 void CalcRestoreScenePosition(const ItemDragInfo& info); 416 void ParseRestoreScenePosition( 417 const std::map<int32_t, std::map<int32_t, int32_t>>& data, std::map<int32_t, GridItemIndexPosition>& info); GetDragPosRowIndex()418 int32_t GetDragPosRowIndex() 419 { 420 return dragPosRowIndex_; 421 } GetDragPosColumnIndex()422 int32_t GetDragPosColumnIndex() 423 { 424 return dragPosColumnIndex_; 425 } 426 void StartFlexController(const Point& endPoint, bool includeSubGrid = false); 427 void FinishedFlexController(); 428 void FinishedFlexControllerForSubGrid(); 429 void CloseFlexComponent(); 430 void UpdateFlexComponenPosition(const Point& pos); 431 void RegisterDropJSEvent(const ItemDragInfo& info, int32_t insertIndex, bool successed); 432 void RegisterDropJSFunc(const OnCallJSDropFunc& func); 433 void CallDropJSFunc(); 434 bool CheckAnimation(); 435 436 bool isVertical_ = false; 437 bool updateFlag_ = false; 438 FlexDirection direction_ = FlexDirection::ROW; 439 FlexAlign crossAxisAlign_ = FlexAlign::CENTER; 440 441 int32_t focusRow_ = -1; 442 int32_t focusCol_ = -1; 443 int32_t focusIndex_ = 0; 444 445 double colSize_ = 0.0; 446 double rowSize_ = 0.0; 447 double gridWidth_ = -1.0; 448 double gridHeight_ = -1.0; 449 int32_t colCount_ = 0; 450 int32_t rowCount_ = 0; 451 Dimension userColGap_ = 0.0_px; 452 Dimension userRowGap_ = 0.0_px; 453 double colGap_ = 0.0; 454 double rowGap_ = 0.0; 455 std::string colsArgs_; 456 std::string rowsArgs_; 457 std::string scrollBarWidth_; 458 std::string scrollBarColor_; 459 DisplayMode displayMode_ = DisplayMode::OFF; 460 bool rightToLeft_ = false; 461 bool needResetItemPosition_ = false; 462 // Map structure: [rowIndex - (columnIndex, index)] 463 std::map<int32_t, std::map<int32_t, int32_t>> gridMatrix_; 464 // Map structure: [rowIndex - columnIndex - (width, height)] 465 std::map<int32_t, std::map<int32_t, Size>> gridCells_; 466 467 RefPtr<GestureRecognizer> dragDropGesture_; 468 WeakPtr<RenderGridLayout> preTargetRenderGrid_ = nullptr; 469 WeakPtr<RenderGridLayout> mainTargetRenderGrid_ = nullptr; 470 471 // The list of renderNodes of items in the grid 472 std::vector<RefPtr<RenderNode>> itemsInGrid_; 473 474 // back for gridMatrix_ 475 std::map<int32_t, std::map<int32_t, int32_t>> gridMatrixBack_; 476 477 // The maximum number of items that the grid can hold 478 int32_t itemCountMax_ = -1; 479 480 // The grid length in the main axis direction 481 int32_t cellLength_ = 0; 482 483 // The maximum number of rows (columns) that can be accommodated in a variable direction. 484 // (only for dynamic limited grid) 485 int32_t mainCountMax_ = -1; 486 487 // The minimum number of rows (columns) that must be accommodated in the variable direction. 488 // (only for dynamic limited grid) 489 int32_t mainCountMin_ = -1; 490 491 // The maximum number of items that the grid can hold. 492 // (Only the dynamic grid needs to be used to determine whether the main sequence needs to be increased.) 493 int32_t curItemCountMax_ = -1; 494 495 // The rowIndex of the grid currently to be inserted 496 int32_t curInsertRowIndex_ = -1; 497 498 // The columnIndex of the grid currently to be inserted 499 int32_t curInsertColumnIndex_ = -1; 500 501 // The rowIndex of the grid where the Drag coordinates are located 502 int32_t dragPosRowIndex_ = -1; 503 504 // The columnIndex of the grid where the Drag coordinates are located 505 int32_t dragPosColumnIndex_ = -1; 506 507 // The index of the item currently being dragged. 508 int32_t dragingItemIndex_ = -1; 509 510 // Whether to send changes to the grid where the drag coordinate is located 511 bool dragPosChanged_ = false; 512 513 bool isDynamicGrid_ = false; 514 515 bool editMode_ = false; 516 517 bool itemLongPressed_ = false; 518 519 bool itemDragEntered_ = false; 520 521 bool itemDragStarted_ = false; 522 523 bool isDragChangeLayout_ = false; 524 525 bool needRestoreScene_ = false; 526 527 bool isInMainGrid_ = false; 528 529 bool isMainGrid_ = false; 530 531 bool reEnter_ = false; 532 533 WeakPtr<RenderNode> dragingItemRenderNode_; 534 WeakPtr<RenderGridLayout> subGrid_; 535 WeakPtr<RenderGridLayout> mainGrid_; 536 RefPtr<GridLayoutComponent> component_; 537 538 OnGridDragEnterFunc OnGridDragEnterFunc_; 539 OnGridDragMoveFunc onGridDragMoveFunc_; 540 OnGridDragLeaveFunc onGridDragLeaveFunc_; 541 OnGridDragStartFunc onGridDragStartFunc_; 542 OnGridDropFunc onGridDropFunc_; 543 544 OnItemDragFunc updatePosition_; 545 Point lastGlobalPoint_; 546 Point lastLongPressPoint_; 547 Point startGlobalPoint_; 548 bool isExistComponent_ = false; 549 std::atomic<bool> isDragging_; 550 551 GridLayoutAnimationAct animationAct_ = GridLayoutAnimationAct::ANIMATION_NONE; 552 RefPtr<Animator> animationController_; 553 RefPtr<Animator> flexController_; 554 bool supportAnimation_ = true; 555 std::atomic<bool> needRunAnimation_; 556 std::map<std::string, std::function<void()>> animationFinishedFuncList_; 557 std::mutex animationLock_; 558 OnAnimationCallJSFunc jsMoveFunc_ = nullptr; 559 OnAnimationCallJSFunc jsDropFunc_ = nullptr; 560 OnAnimationCallJSFunc restoreScenceFunc_ = nullptr; 561 std::map<int32_t, Point> gridItemPosition_; 562 std::list<RefPtr<RenderNode>> animationItemList_; 563 std::atomic<bool> runFlexAnimation_; 564 std::atomic<bool> triggerJSDrop_; 565 std::vector<OnCallJSDropFunc> dropJSFuncList_; 566 std::mutex dropJSFuncListLock_; 567 568 RefPtr<RawRecognizer> slideRecognizer_; 569 GridSpringGravitationDirect gravitationDirect_ = GridSpringGravitationDirect::SPRING_NONE; 570 GridSlideDirect slideDirect_ = GridSlideDirect::SLIDE_NODE; 571 std::atomic<GridSlideStatus> slideStatus_; 572 Point slideStartPoint_; 573 Point slidePriPoint_; 574 Point slideCurPoint_; 575 Point slideDistance_; 576 RefPtr<Animator> springController_; 577 RefPtr<SpringMotion> springMotion_; 578 std::vector<Offset> springStartPosition_; 579 580 Offset mouseStartOffset_; 581 Offset mouseEndOffset_; 582 bool HandleMouseEvent(const MouseEvent& event) override; 583 bool isMultiSelectable_ = false; 584 void ClearMultiSelect(); 585 586 void MultiSelectWithoutKeyboard(const Rect& selectedZone); 587 void HandleMouseEventWithoutKeyboard(const MouseEvent& event); 588 589 void MultiSelectWhenCtrlDown(const Rect& selectedZone); 590 void HandleMouseEventWhenCtrlDown(const MouseEvent& event); 591 void CollectSelectedItems(); 592 std::set<RefPtr<RenderGridLayoutItem>> selectedItemsWithCtrl_; 593 594 void MultiSelectWhenShiftDown(const Rect& selectedZone); 595 RefPtr<RenderGridLayoutItem> GetPressItemWhenShiftDown(const Rect& selectedZone); 596 void HandleMouseEventWhenShiftDown(const MouseEvent& event); 597 void MultiSelectAllInRange(const RefPtr<RenderGridLayoutItem>& firstItem, 598 const RefPtr<RenderGridLayoutItem>& secondItem); 599 RefPtr<RenderGridLayoutItem> firstItemWithShift_; 600 RefPtr<RenderGridLayoutItem> secondItemWithShift_; 601 602 void MultiSelectAllWhenCtrlA(); 603 }; 604 605 } // namespace OHOS::Ace 606 607 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_GRID_LAYOUT_RENDER_GRID_LAYOUT_H 608