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); 37 void SetDragStyle(DragCursorStyle style); 38 void SetShadowInfos(const std::vector<ShadowInfo> &shadowInfos); 39 DragCursorStyle GetDragStyle() const; 40 void SetDragWindowVisible(bool visible); 41 bool GetDragWindowVisible() const; 42 int32_t GetShadowOffset(ShadowOffset &shadowOffset) const; 43 void SetTargetTid(int32_t tokenId); 44 int32_t GetTargetTid() const; 45 void SetTargetPid(int32_t pid); 46 int32_t GetTargetPid() const; 47 void SetPreviewStyle(const PreviewStyle &previewStyle); 48 PreviewStyle GetPreviewStyle(); 49 void ResetDragData(); 50 DragData GetDragData() const; 51 bool GetCoordinateCorrected(); 52 void SetPixelMapLocation(const std::pair<int32_t, int32_t> &location); 53 void SetTextEditorAreaFlag(bool enable); 54 bool GetTextEditorAreaFlag(); 55 void SetInitialPixelMapLocation(const std::pair<int32_t, int32_t> &location); 56 void SetDragOriginDpi(float dragOriginDpi); 57 float GetDragOriginDpi() const; 58 std::pair<int32_t, int32_t> GetInitialPixelMapLocation(); 59 60 private: 61 bool visible_ { false }; 62 int32_t targetPid_ { -1 }; 63 PreviewStyle previewStyle_; 64 int32_t targetTid_ { -1 }; 65 std::u16string dragMessage_; 66 DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT }; 67 DragData dragData_; 68 bool textEditorAreaFlag_ { false }; 69 float dragOriginDpi_ { 0.0f }; 70 std::pair<int32_t, int32_t> initialPixelMapLocation_; 71 }; 72 73 #define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance() 74 75 } // namespace DeviceStatus 76 } // namespace Msdp 77 } // namespace OHOS 78 #endif // DRAG_DATA_MANAGER_H