Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Thickness.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Diagnostics;
5 
6 namespace SiliconStudio.Paradox.UI
7 {
8  /// <summary>
9  /// Describes the thickness of a frame around a cuboid. Six float values describe the Left, Top, Right, Bottom, Front, and Back sides of the cuboid, respectively.
10  /// </summary>
11  [DebuggerDisplay("Left:{Left}, Top:{Top}, Back:{Back}, Right:{Right}, Bottom:{Bottom}, Front:{Front}")]
12  public struct Thickness
13  {
14  /// <summary>
15  /// Initializes a new instance of the Thickness structure that has the specified uniform length on the Left, Right, Top, Bottom side and 0 for the Front and Back side.
16  /// </summary>
17  /// <param name="thickness">The uniform length applied to all four sides of the bounding rectangle.</param>
18  /// <returns>The created thickness class</returns>
19  public static Thickness UniformRectangle(float thickness)
20  {
21  return new Thickness(thickness, thickness, thickness, thickness);
22  }
23 
24  /// <summary>
25  /// Initializes a new instance of the Thickness structure that has the specified uniform length on the Left, Right, Top, Bottom, Front, and Back side.
26  /// </summary>
27  /// <param name="thickness">The uniform length applied to all six sides of the bounding cuboid.</param>
28  /// <returns>The created thickness class</returns>
29  public static Thickness UniformCuboid(float thickness)
30  {
31  return new Thickness(thickness, thickness, thickness, thickness, thickness, thickness);
32  }
33 
34  /// <summary>
35  /// Initializes a new instance of the Thickness structure that has specific lengths applied to each side of the rectangle.
36  /// </summary>
37  /// <param name="bottom">The thickness for the lower side of the rectangle.</param>
38  /// <param name="left">The thickness for the left side of the rectangle.</param>
39  /// <param name="right">The thickness for the right side of the rectangle</param>
40  /// <param name="top">The thickness for the upper side of the rectangle.</param>
41  public Thickness(float left, float top, float right, float bottom)
42  {
43  Bottom = bottom;
44  Left = left;
45  Right = right;
46  Top = top;
47  Front = 0;
48  Back = 0;
49  }
50 
51  /// <summary>
52  /// Reverses the direction of a given Thickness.
53  /// </summary>
54  /// <param name="value">The Thickness to negate.</param>
55  /// <returns>A Thickness with the opposite direction.</returns>
56  public static Thickness operator -(Thickness value)
57  {
58  return new Thickness(-value.Left, -value.Top, -value.Back, -value.Right, -value.Bottom, -value.Front);
59  }
60 
61  /// <summary>
62  /// Addition two Thickness together.
63  /// </summary>
64  /// <param name="value1">The first thickness to add.</param>
65  /// <param name="value2">The second thickness to add.</param>
66  /// <returns>A Thickness with the opposite direction.</returns>
67  public static Thickness operator +(Thickness value1, Thickness value2)
68  {
69  return new Thickness(value1.Left + value2.Left, value1.Top + value2.Top, value1.Back + value2.Back, value1.Right + value2.Right, value1.Bottom + value2.Bottom, value1.Front + value2.Front);
70  }
71 
72  /// <summary>
73  /// Divide a Thickness by a float.
74  /// </summary>
75  /// <param name="value1">The first thickness to add.</param>
76  /// <param name="value2">The float value to divide by.</param>
77  /// <returns>The divided thickness</returns>
78  public static Thickness operator /(Thickness value1, float value2)
79  {
80  return new Thickness(value1.Left / value2, value1.Top / value2, value1.Back / value2, value1.Right / value2, value1.Bottom / value2, value1.Front / value2);
81  }
82 
83  /// <summary>
84  /// Initializes a new instance of the Thickness structure that has specific lengths applied to each side of the cuboid.
85  /// </summary>
86  /// <param name="bottom">The thickness for the lower side of the rectangle.</param>
87  /// <param name="left">The thickness for the left side of the rectangle.</param>
88  /// <param name="right">The thickness for the right side of the rectangle</param>
89  /// <param name="top">The thickness for the upper side of the rectangle.</param>
90  /// <param name="front">The thickness for the front side of the rectangle.</param>
91  /// <param name="back">The thickness for the Back side of the rectangle.</param>
92  public Thickness(float left, float top, float back, float right, float bottom, float front)
93  {
94  Bottom = bottom;
95  Left = left;
96  Right = right;
97  Top = top;
98  Front = front;
99  Back = back;
100  }
101 
102  /// <summary>
103  /// The bottom side of the bounding rectangle.
104  /// </summary>
105  public float Bottom;
106 
107  /// <summary>
108  /// The left side of the bounding rectangle.
109  /// </summary>
110  public float Left;
111 
112  /// <summary>
113  /// The right side of the bounding rectangle.
114  /// </summary>
115  public float Right;
116 
117  /// <summary>
118  /// The upper side of the bounding rectangle.
119  /// </summary>
120  public float Top;
121 
122  /// <summary>
123  /// The front side of the bounding rectangle.
124  /// </summary>
125  public float Front;
126 
127  /// <summary>
128  /// The Back side of the bounding rectangle.
129  /// </summary>
130  public float Back;
131 
132  /// <summary>
133  /// Gets the component at the specified index.
134  /// </summary>
135  /// <param name="index">The index of the component to access. Use 0 for the Left component, 1 for the Top component,
136  /// 2 for the Front component, 3 for the Right component, 4 for the Bottom component, 5 for the Back component.</param>
137  /// <returns>The value of the component at the specified index.</returns>
138  /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="index"/> is out of the range [0, 5].</exception>
139  public float this[int index]
140  {
141  get
142  {
143  switch (index)
144  {
145  case 0: return Left;
146  case 1: return Top;
147  case 2: return Front;
148  case 3: return Right;
149  case 4: return Bottom;
150  case 5: return Back;
151  }
152 
153  throw new ArgumentOutOfRangeException("index", "Indices for Vector2 run from 0 to 1, inclusive.");
154  }
155  }
156  }
157 }
float Right
The right side of the bounding rectangle.
Definition: Thickness.cs:115
Thickness(float left, float top, float back, float right, float bottom, float front)
Initializes a new instance of the Thickness structure that has specific lengths applied to each side ...
Definition: Thickness.cs:92
float Left
The left side of the bounding rectangle.
Definition: Thickness.cs:110
static Thickness UniformCuboid(float thickness)
Initializes a new instance of the Thickness structure that has the specified uniform length on the Le...
Definition: Thickness.cs:29
float Top
The upper side of the bounding rectangle.
Definition: Thickness.cs:120
Describes the thickness of a frame around a cuboid. Six float values describe the Left...
Definition: Thickness.cs:12
float Bottom
The bottom side of the bounding rectangle.
Definition: Thickness.cs:105
float Back
The Back side of the bounding rectangle.
Definition: Thickness.cs:130
float Front
The front side of the bounding rectangle.
Definition: Thickness.cs:125
Thickness(float left, float top, float right, float bottom)
Initializes a new instance of the Thickness structure that has specific lengths applied to each side ...
Definition: Thickness.cs:41
The child element is aligned to the bottom of the parent's layout slot.
The child element is aligned to the top of the parent's layout slot.
static Thickness UniformRectangle(float thickness)
Initializes a new instance of the Thickness structure that has the specified uniform length on the Le...
Definition: Thickness.cs:19