• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BASE_GEOMETRY_DIMENSION_RECT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_DIMENSION_RECT_H
18 
19 #include <cmath>
20 #include <limits>
21 
22 #include "base/geometry/dimension.h"
23 #include "base/geometry/dimension_offset.h"
24 #include "base/geometry/dimension_size.h"
25 
26 namespace OHOS::Ace {
27 
28 class DimensionRect {
29 public:
30     DimensionRect() = default;
31     ~DimensionRect() = default;
32 
DimensionRect(const Dimension & width,const Dimension & height,const DimensionOffset & offset)33     DimensionRect(const Dimension& width, const Dimension& height, const DimensionOffset& offset)
34         : width_(width), height_(height), offset_(offset)
35     {}
36 
DimensionRect(const Dimension & width,const Dimension & height)37     DimensionRect(const Dimension& width, const Dimension& height) : width_(width), height_(height) {}
38 
GetWidth()39     const Dimension& GetWidth() const
40     {
41         return width_;
42     }
43 
GetHeight()44     const Dimension& GetHeight() const
45     {
46         return height_;
47     }
48 
GetOffset()49     const DimensionOffset& GetOffset() const
50     {
51         return offset_;
52     }
53 
SetOffset(const DimensionOffset & offset)54     void SetOffset(const DimensionOffset& offset)
55     {
56         offset_ = offset;
57     }
58 
SetSize(const DimensionSize & size)59     void SetSize(const DimensionSize& size)
60     {
61         width_ = size.Width();
62         height_ = size.Height();
63     }
64 
65 
SetWidth(const Dimension & width)66     void SetWidth(const Dimension& width)
67     {
68         width_ = width;
69     }
70 
SetHeight(const Dimension & height)71     void SetHeight(const Dimension& height)
72     {
73         height_ = height;
74     }
75 
76 
Reset()77     void Reset()
78     {
79         width_ = 0.0_vp;
80         height_ = 0.0_vp;
81         offset_ = DimensionOffset();
82     }
83 
84 private:
85     Dimension width_ = 0.0_vp;
86     Dimension height_ = 0.0_vp;
87     DimensionOffset offset_;
88 };
89 
90 } // namespace OHOS::Ace
91 
92 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_DIMENSION_RECT_H
93