TGUI  0.7.4
Borders.hpp
1 //
3 // TGUI - Texus's 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_BORDERS_HPP
27 #define TGUI_BORDERS_HPP
28 
29 #include <TGUI/Config.hpp>
30 
32 
33 namespace tgui
34 {
36 
37  class TGUI_API Borders
38  {
39  public:
40 
44  Borders(float size = 0) :
45  left (size),
46  top (size),
47  right (size),
48  bottom(size)
49  {
50  }
51 
52 
62  Borders(float leftBorderWidth, float topBorderHeight, float rightBorderWidth, float bottomBorderHeight) :
63  left (leftBorderWidth),
64  top (topBorderHeight),
65  right (rightBorderWidth),
66  bottom(bottomBorderHeight)
67  {
68  }
69 
70 
78  Borders(float width, float height) :
79  left (width),
80  top (height),
81  right (width),
82  bottom(height)
83  {
84  }
85 
86 
95  bool operator==(const Borders& borders) const
96  {
97  return (left == borders.left) && (top == borders.top) && (right == borders.right) && (bottom == borders.bottom);
98  }
99 
100 
109  bool operator!=(const Borders& borders) const
110  {
111  return !(*this == borders);
112  }
113 
114 
116 
118  float left;
119 
121  float top;
122 
124  float right;
125 
127  float bottom;
128  };
129 
130  using Padding = Borders;
131 
132 
136  class TGUI_API WidgetBorders
137  {
138  public:
139 
140  virtual ~WidgetBorders() {};
141 
142 
149  virtual void setBorders(const Borders& borders)
150  {
151  m_borders = borders;
152  }
153 
154 
164  void setBorders(float leftBorder, float topBorder, float rightBorder, float bottomBorder)
165  {
166  setBorders({leftBorder, topBorder, rightBorder, bottomBorder});
167  }
168 
169 
177  void setBorders(float width, float height)
178  {
179  setBorders({width, height});
180  }
181 
182 
192  virtual Borders getBorders() const
193  {
194  return m_borders;
195  }
196 
197 
199  protected:
200 
201  Borders m_borders;
202 
204  };
205 
206 
210  class TGUI_API WidgetPadding
211  {
212  public:
213 
214  virtual ~WidgetPadding() {};
215 
216 
223  virtual void setPadding(const Padding& padding)
224  {
225  m_padding = padding;
226  }
227 
228 
238  void setPadding(float leftPadding, float topPadding, float rightPadding, float bottomPadding)
239  {
240  setPadding({leftPadding, topPadding, rightPadding, bottomPadding});
241  }
242 
243 
251  void setPadding(float width, float height)
252  {
253  setPadding({width, height});
254  }
255 
256 
266  virtual Padding getPadding() const
267  {
268  return m_padding;
269  }
270 
271 
273  protected:
274 
275  Padding m_padding;
276 
277 
279  };
280 
282 }
283 
285 
286 #endif // TGUI_BORDERS_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
virtual void setBorders(const Borders &borders)
Changes the size of the borders.
Definition: Borders.hpp:149
virtual void setPadding(const Padding &padding)
Changes the size of the padding.
Definition: Borders.hpp:223
float bottom
Height of the bottom border.
Definition: Borders.hpp:127
void setPadding(float leftPadding, float topPadding, float rightPadding, float bottomPadding)
Changes the size of the padding.
Definition: Borders.hpp:238
float left
Width of the left border.
Definition: Borders.hpp:118
void setPadding(float width, float height)
Changes the size of the padding.
Definition: Borders.hpp:251
bool operator==(const Borders &borders) const
Compare two borders.
Definition: Borders.hpp:95
virtual Padding getPadding() const
Returns the size of the padding.
Definition: Borders.hpp:266
void setBorders(float width, float height)
Changes the size of the borders.
Definition: Borders.hpp:177
Parent class for every widget that has padding.
Definition: Borders.hpp:210
bool operator!=(const Borders &borders) const
Compare two borders.
Definition: Borders.hpp:109
Borders(float leftBorderWidth, float topBorderHeight, float rightBorderWidth, float bottomBorderHeight)
Constructor that initializes the borders.
Definition: Borders.hpp:62
Parent class for every widget that has borders.
Definition: Borders.hpp:136
float top
Height of the top border.
Definition: Borders.hpp:121
Definition: Borders.hpp:37
float right
Width of the right border.
Definition: Borders.hpp:124
Borders(float width, float height)
Constructor that initializes the borders.
Definition: Borders.hpp:78
void setBorders(float leftBorder, float topBorder, float rightBorder, float bottomBorder)
Changes the size of the borders.
Definition: Borders.hpp:164
virtual Borders getBorders() const
Returns the size of the borders as a tgui::Borders.
Definition: Borders.hpp:192
Borders(float size=0)
Default constructor.
Definition: Borders.hpp:44