1 /* 2 * Copyright (c) 2023 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 DRAG_DATA_MANAGER_H 17 #define DRAG_DATA_MANAGER_H 18 19 #include <string> 20 21 #include "pixel_map.h" 22 #include "pointer_style.h" 23 #include "singleton.h" 24 25 #include "drag_data.h" 26 27 namespace OHOS { 28 namespace Msdp { 29 namespace DeviceStatus { 30 class DragDataManager final { 31 DECLARE_SINGLETON(DragDataManager); 32 33 public: 34 DISALLOW_MOVE(DragDataManager); 35 36 void Init(const DragData &dragData, const std::string &appCaller = ""); 37 void SetDragStyle(DragCursorStyle style); 38 void SetShadowInfos(const std::vector<ShadowInfo> &shadowInfos); 39 void UpdateShadowInfos(std::shared_ptr<OHOS::Media::PixelMap> pixelMap); 40 DragCursorStyle GetDragStyle() const; 41 void SetDragWindowVisible(bool visible); 42 bool GetDragWindowVisible() const; 43 int32_t GetShadowOffset(ShadowOffset &shadowOffset) const; 44 void SetTargetTid(int32_t tokenId); 45 int32_t GetTargetTid() const; 46 void SetTargetPid(int32_t pid); 47 int32_t GetTargetPid() const; 48 void SetEventId(int32_t eventId); 49 int32_t GetEventId() const; 50 void SetPreviewStyle(const PreviewStyle &previewStyle); 51 PreviewStyle GetPreviewStyle(); 52 void ResetDragData(); 53 DragData GetDragData() const; 54 bool GetCoordinateCorrected(); 55 void SetPixelMapLocation(const std::pair<int32_t, int32_t> &location); 56 void SetTextEditorAreaFlag(bool enable); 57 bool GetTextEditorAreaFlag(); 58 void SetInitialPixelMapLocation(const std::pair<int32_t, int32_t> &location); 59 void SetDragOriginDpi(float dragOriginDpi); 60 void GetSummaryInfo(DragSummaryInfo &dragSummaryInfo); 61 float GetDragOriginDpi() const; 62 std::pair<int32_t, int32_t> GetInitialPixelMapLocation(); 63 64 private: 65 bool visible_ { false }; 66 int32_t targetPid_ { -1 }; 67 PreviewStyle previewStyle_; 68 int32_t targetTid_ { -1 }; 69 int32_t eventId_ { -1 }; 70 std::u16string dragMessage_; 71 DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT }; 72 DragData dragData_; 73 bool textEditorAreaFlag_ { false }; 74 float dragOriginDpi_ { 0.0f }; 75 std::pair<int32_t, int32_t> initialPixelMapLocation_; 76 }; 77 78 #define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance() 79 80 } // namespace DeviceStatus 81 } // namespace Msdp 82 } // namespace OHOS 83 #endif // DRAG_DATA_MANAGER_H