TGUI  0.8-dev
Outline.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_OUTLINE_HPP
27 #define TGUI_OUTLINE_HPP
28 
29 #include <TGUI/Config.hpp>
30 
32 
33 namespace tgui
34 {
36 
37  class TGUI_API Outline
38  {
39  public:
40 
47  Outline(float size = 0) :
48  left (size),
49  top (size),
50  right (size),
51  bottom(size)
52  {
53  }
54 
55 
63  Outline(float width, float height) :
64  left (width),
65  top (height),
66  right (width),
67  bottom(height)
68  {
69  }
70 
71 
81  Outline(float leftBorderWidth, float topBorderHeight, float rightBorderWidth, float bottomBorderHeight) :
82  left (leftBorderWidth),
83  top (topBorderHeight),
84  right (rightBorderWidth),
85  bottom(bottomBorderHeight)
86  {
87  }
88 
89 
98  bool operator==(const Outline& outline) const
99  {
100  return (left == outline.left) && (top == outline.top) && (right == outline.right) && (bottom == outline.bottom);
101  }
102 
103 
112  bool operator!=(const Outline& outline) const
113  {
114  return !(*this == outline);
115  }
116 
117 
119 
121  float left;
122 
124  float top;
125 
127  float right;
128 
130  float bottom;
131  };
132 
133 
137  inline Outline operator+(const Outline& left, const Outline& right)
138  {
139  return {left.left + right.left, left.top + right.top, left.right + right.right, left.bottom + right.bottom};
140  }
141 
142 
146  inline Outline operator-(const Outline& left, const Outline& right)
147  {
148  return {left.left - right.left, left.top - right.top, left.right - right.right, left.bottom - right.bottom};
149  }
150 
152 
153  using Borders = Outline;
154  using Padding = Outline;
155 
157 }
158 
160 
161 #endif // TGUI_OUTLINE_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Outline(float width, float height)
Constructor that initializes the outline.
Definition: Outline.hpp:63
Outline(float leftBorderWidth, float topBorderHeight, float rightBorderWidth, float bottomBorderHeight)
Constructor that initializes the outline.
Definition: Outline.hpp:81
float bottom
Height of the bottom outline.
Definition: Outline.hpp:130
float left
Width of the left outline.
Definition: Outline.hpp:121
TGUI_API Layout operator-(Layout left, Layout right)
operator for the Layout class
TGUI_API Layout operator+(Layout left, Layout right)
operator for the Layout class
float top
Height of the top outline.
Definition: Outline.hpp:124
bool operator==(const Outline &outline) const
Compares two outlines.
Definition: Outline.hpp:98
Definition: Outline.hpp:37
bool operator!=(const Outline &outline) const
Compares two outlines.
Definition: Outline.hpp:112
Outline(float size=0)
Default constructor.
Definition: Outline.hpp:47
float right
Width of the right outline.
Definition: Outline.hpp:127