Simple GUI Library
insets.cpp
Go to the documentation of this file.
1/**
2 * @author Nikita Mochalov (github.com/tralf-strues)
3 * @file insets.cpp
4 * @date 2021-11-06
5 *
6 * @copyright Copyright (c) 2021
7 */
8
9#include "paint/insets.h"
10
11namespace Sgl
12{
13 const Insets Insets::EMPTY = Insets{0, 0, 0, 0};
14
15 Insets::Insets(int32_t top, int32_t right, int32_t bottom, int32_t left)
16 : top(top), right(right), bottom(bottom), left(left) {}
17
18 Insets::Insets(int32_t topBottom, int32_t rightLeft)
19 : Insets(topBottom, rightLeft, topBottom, rightLeft) {}
20
21 Insets::Insets(int32_t inset)
22 : Insets(inset, inset) {}
23
24 Insets& Insets::operator+=(const Insets& second)
25 {
26 top += second.top;
27 right += second.right;
28 bottom += second.bottom;
29 left += second.left;
30
31 return *this;
32 }
33
34 Insets& Insets::operator-=(const Insets& second)
35 {
36 top -= second.top;
37 right -= second.right;
38 bottom -= second.bottom;
39 left -= second.left;
40
41 return *this;
42 }
43
44 Insets operator+(const Insets& first, const Insets& second)
45 {
46 Insets sum{first};
47 sum += second;
48
49 return sum;
50 }
51
52 Insets operator-(const Insets& first, const Insets& second)
53 {
54 Insets dif{first};
55 dif -= second;
56
57 return dif;
58 }
59}