summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UniWebView/Script/UniWebViewEdgeInsets.cs
blob: 88cb8755858da2c266cc788f1a3b98dcb996ebfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//    UniWebViewEdgeInsets.cs
//  Created by Wang Wei(@onevcat) on 2013-10-20.
//

[System.Serializable]
/// <summary>
/// This class defined the edge inset of a UniWebView
/// </summary>
public class UniWebViewEdgeInsets {

    public int top, left, bottom, right;

    /// <summary>
    /// Initializes a new instance of the <see cref="UniWebViewEdgeInsets"/> class.
    /// </summary>
    /// <param name="aTop">Top inset by point.</param>
    /// <param name="aLeft">Left inset by point.</param>
    /// <param name="aBottom">Bottominset by point.</param>
    /// <param name="aRight">Rightinset by point.</param>
    public UniWebViewEdgeInsets(int aTop, int aLeft, int aBottom, int aRight) {
        top = aTop;
        left = aLeft;
        bottom = aBottom;
        right = aRight;
    }

    public static bool operator ==(UniWebViewEdgeInsets inset1, UniWebViewEdgeInsets inset2) 
    {
        return inset1.Equals(inset2);
    }

    public static bool operator !=(UniWebViewEdgeInsets inset1, UniWebViewEdgeInsets inset2) 
    {
        return !inset1.Equals(inset2);
    }

    public override int GetHashCode()
    {
        var calculation = top + left + bottom + right;
        return calculation.GetHashCode();
    }

    public override bool Equals (object obj)
    {
        if (obj == null || GetType() != obj.GetType()) {
            return false;
        }
        UniWebViewEdgeInsets anInset = (UniWebViewEdgeInsets)obj;
        return  (top     == anInset.top) && 
                (left   == anInset.left) && 
                (bottom == anInset.bottom) && 
                (right  == anInset.right);
    }
}