[NUI] Integreation from dalihub (#988)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Layouting / LayoutSize.cs
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// [Draft] This class represents a layout size (width and height), non mutable.
25     /// </summary>
26     internal struct LayoutSize
27     {
28         /// <summary>
29         /// [Draft] Constructor from width and height
30         /// </summary>
31         /// <param name="width">Int to initialize with.</param>
32         /// <param name="height">Int to initialize with.</param>
33         public LayoutSize(int width, int height)
34         {
35             Width = width;
36             Height = height;
37         }
38
39         /// <summary>
40         /// Computes a hash code for this LayoutSize for use in hash based collections.
41         /// </summary>
42         /// <returns>A non unique hash code .</returns>
43         public override int GetHashCode()
44         {
45             return Width ^ Height;
46         }
47
48         /// <summary>
49         /// Whether the values of two LayoutSize objects are equals
50         /// </summary>
51         /// <param name="obj">Object to be compared against.</param>
52         /// <returns>true if obj is equal to this LayoutSize.</returns>
53         public override bool Equals(object obj)
54         {
55             if (obj is LayoutSize)
56             {
57                 LayoutSize layoutSize = (LayoutSize)obj;
58                 return ((layoutSize.Width == Width) && (layoutSize.Height == Height));
59             }
60             return false;
61         }
62
63         /// <summary>
64         /// Compares whether the two LayoutSize instances are equal.
65         /// </summary>
66         /// <param name="lhs">A LayoutSize instance.</param>
67         /// <param name="rhs">A LayoutSize instance.</param>
68         /// <returns>true if the two LayoutSize instances have equal values.</returns>
69         public static bool operator ==(LayoutSize lhs, LayoutSize rhs)
70         {
71             return ((lhs.Width == rhs.Width) && (lhs.Height == rhs.Height));
72         }
73
74
75         /// <summary>
76         /// Compares whether the two LayoutSize instances are same or not.
77         /// </summary>
78         /// <param name="lhs">A LayoutSize instance.</param>
79         /// <param name="rhs">A LayoutSize instance.</param>
80         /// <returns>true if the two LayoutSize instances have do not have equal values.</returns>
81         public static bool operator !=(LayoutSize lhs, LayoutSize rhs)
82         {
83             return ((lhs.Width != rhs.Width) || (lhs.Height != rhs.Height));
84         }
85
86         /// <summary>
87         /// [Draft] Get the width value of this layout
88         /// </summary>
89         public int Width{ get; private set; }
90
91         /// <summary>
92         /// [Draft] Get the height value of this layout
93         /// </summary>
94         public int Height{ get; private set; }
95
96     }
97 }