openshot-audio  0.1.2
juce_BorderSize.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_BORDERSIZE_H_INCLUDED
26 #define JUCE_BORDERSIZE_H_INCLUDED
27 
28 
29 //==============================================================================
38 template <typename ValueType>
40 {
41 public:
42  //==============================================================================
47  : top(), left(), bottom(), right()
48  {
49  }
50 
53  : top (other.top), left (other.left), bottom (other.bottom), right (other.right)
54  {
55  }
56 
58  BorderSize (ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) noexcept
59  : top (topGap), left (leftGap), bottom (bottomGap), right (rightGap)
60  {
61  }
62 
64  explicit BorderSize (ValueType allGaps) noexcept
65  : top (allGaps), left (allGaps), bottom (allGaps), right (allGaps)
66  {
67  }
68 
69  //==============================================================================
71  ValueType getTop() const noexcept { return top; }
72 
74  ValueType getLeft() const noexcept { return left; }
75 
77  ValueType getBottom() const noexcept { return bottom; }
78 
80  ValueType getRight() const noexcept { return right; }
81 
83  ValueType getTopAndBottom() const noexcept { return top + bottom; }
84 
86  ValueType getLeftAndRight() const noexcept { return left + right; }
87 
89  bool isEmpty() const noexcept { return left + right + top + bottom == ValueType(); }
90 
91  //==============================================================================
93  void setTop (ValueType newTopGap) noexcept { top = newTopGap; }
94 
96  void setLeft (ValueType newLeftGap) noexcept { left = newLeftGap; }
97 
99  void setBottom (ValueType newBottomGap) noexcept { bottom = newBottomGap; }
100 
102  void setRight (ValueType newRightGap) noexcept { right = newRightGap; }
103 
104  //==============================================================================
107  {
108  return Rectangle<ValueType> (original.getX() + left,
109  original.getY() + top,
110  original.getWidth() - (left + right),
111  original.getHeight() - (top + bottom));
112  }
113 
116  {
117  rectangle = subtractedFrom (rectangle);
118  }
119 
122  {
123  return Rectangle<ValueType> (original.getX() - left,
124  original.getY() - top,
125  original.getWidth() + (left + right),
126  original.getHeight() + (top + bottom));
127  }
128 
129 
131  void addTo (Rectangle<ValueType>& rectangle) const noexcept
132  {
133  rectangle = addedTo (rectangle);
134  }
135 
136  //==============================================================================
137  bool operator== (const BorderSize& other) const noexcept
138  {
139  return top == other.top && left == other.left && bottom == other.bottom && right == other.right;
140  }
141 
142  bool operator!= (const BorderSize& other) const noexcept
143  {
144  return ! operator== (other);
145  }
146 
147 private:
148  //==============================================================================
149  ValueType top, left, bottom, right;
150 };
151 
152 
153 #endif // JUCE_BORDERSIZE_H_INCLUDED
ValueType getLeftAndRight() const noexcept
Definition: juce_BorderSize.h:86
bool operator==(const BorderSize &other) const noexcept
Definition: juce_BorderSize.h:137
void setBottom(ValueType newBottomGap) noexcept
Definition: juce_BorderSize.h:99
#define noexcept
Definition: juce_CompilerSupport.h:141
bool operator!=(const BorderSize &other) const noexcept
Definition: juce_BorderSize.h:142
ValueType getRight() const noexcept
Definition: juce_BorderSize.h:80
BorderSize() noexcept
Definition: juce_BorderSize.h:46
Rectangle< ValueType > addedTo(const Rectangle< ValueType > &original) const noexcept
Definition: juce_BorderSize.h:121
ValueType getTopAndBottom() const noexcept
Definition: juce_BorderSize.h:83
void setLeft(ValueType newLeftGap) noexcept
Definition: juce_BorderSize.h:96
void setRight(ValueType newRightGap) noexcept
Definition: juce_BorderSize.h:102
void addTo(Rectangle< ValueType > &rectangle) const noexcept
Definition: juce_BorderSize.h:131
Definition: juce_Rectangle.h:36
ValueType getLeft() const noexcept
Definition: juce_BorderSize.h:74
BorderSize(ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) noexcept
Definition: juce_BorderSize.h:58
bool isEmpty() const noexcept
Definition: juce_BorderSize.h:89
Definition: juce_BorderSize.h:39
ValueType getTop() const noexcept
Definition: juce_BorderSize.h:71
void subtractFrom(Rectangle< ValueType > &rectangle) const noexcept
Definition: juce_BorderSize.h:115
void setTop(ValueType newTopGap) noexcept
Definition: juce_BorderSize.h:93
BorderSize(ValueType allGaps) noexcept
Definition: juce_BorderSize.h:64
ValueType getBottom() const noexcept
Definition: juce_BorderSize.h:77
BorderSize(const BorderSize &other) noexcept
Definition: juce_BorderSize.h:52
Rectangle< ValueType > subtractedFrom(const Rectangle< ValueType > &original) const noexcept
Definition: juce_BorderSize.h:106