• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_OCCUPIED_AREA_CHANGE_INFO_H
17 #define OHOS_OCCUPIED_AREA_CHANGE_INFO_H
18 
19 #include "wm_common.h"
20 
21 namespace OHOS::Rosen {
22 class OccupiedAreaChangeInfo : public Parcelable {
23 public:
24 
25     OccupiedAreaChangeInfo() = default;
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect)26     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect) : type_(type), rect_(rect) {};
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect,uint32_t safeHeight)27     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect, uint32_t safeHeight)
28         : type_(type), rect_(rect), safeHeight_(safeHeight) {};
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect,double textFieldPositionY,double textFieldHeight)29     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect,
30                             double textFieldPositionY, double textFieldHeight)
31         : type_(type), rect_(rect), textFieldPositionY_(textFieldPositionY), textFieldHeight_(textFieldHeight) {};
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect,uint32_t safeHeight,double textFieldPositionY,double textFieldHeight)32     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect, uint32_t safeHeight,
33                            double textFieldPositionY, double textFieldHeight)
34         : type_(type), rect_(rect), safeHeight_(safeHeight),
35           textFieldPositionY_(textFieldPositionY), textFieldHeight_(textFieldHeight) {};
36     ~OccupiedAreaChangeInfo() = default;
37 
Marshalling(Parcel & parcel)38     virtual bool Marshalling(Parcel& parcel) const
39     {
40         return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) &&
41             parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
42             parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
43             parcel.WriteUint32(safeHeight_) &&
44             parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_);
45     }
46 
Unmarshalling(Parcel & parcel)47     static OccupiedAreaChangeInfo* Unmarshalling(Parcel& parcel)
48     {
49         OccupiedAreaChangeInfo* occupiedAreaChangeInfo = new OccupiedAreaChangeInfo();
50         bool res = parcel.ReadInt32(occupiedAreaChangeInfo->rect_.posX_) &&
51             parcel.ReadInt32(occupiedAreaChangeInfo->rect_.posY_) &&
52             parcel.ReadUint32(occupiedAreaChangeInfo->rect_.width_) &&
53             parcel.ReadUint32(occupiedAreaChangeInfo->rect_.height_);
54         if (!res) {
55             delete occupiedAreaChangeInfo;
56             return nullptr;
57         }
58         occupiedAreaChangeInfo->type_ = static_cast<OccupiedAreaType>(parcel.ReadUint32());
59         occupiedAreaChangeInfo->safeHeight_ = parcel.ReadUint32();
60         occupiedAreaChangeInfo->textFieldPositionY_ = parcel.ReadDouble();
61         occupiedAreaChangeInfo->textFieldHeight_ = parcel.ReadDouble();
62         return occupiedAreaChangeInfo;
63     }
64 
65     OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
66     Rect rect_ = { 0, 0, 0, 0 };
67     uint32_t safeHeight_ = 0;
68     double textFieldPositionY_ = 0.0;
69     double textFieldHeight_ = 0.0;
70 };
71 } // namespace OHOS::Rosen
72 #endif // OHOS_OCCUPIED_AREA_CHANGE_INFO_H