diff options
Diffstat (limited to 'linden/indra/llmath/llrect.h')
-rw-r--r-- | linden/indra/llmath/llrect.h | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/linden/indra/llmath/llrect.h b/linden/indra/llmath/llrect.h index 76b5a27..9aadf9f 100644 --- a/linden/indra/llmath/llrect.h +++ b/linden/indra/llmath/llrect.h | |||
@@ -152,68 +152,74 @@ public: | |||
152 | mBottom <= rect->mTop && rect->mBottom <= mTop ; | 152 | mBottom <= rect->mTop && rect->mBottom <= mTop ; |
153 | } | 153 | } |
154 | 154 | ||
155 | void set(Type left, Type top, Type right, Type bottom) | 155 | LLRectBase& set(Type left, Type top, Type right, Type bottom) |
156 | { | 156 | { |
157 | mLeft = left; | 157 | mLeft = left; |
158 | mTop = top; | 158 | mTop = top; |
159 | mRight = right; | 159 | mRight = right; |
160 | mBottom = bottom; | 160 | mBottom = bottom; |
161 | return *this; | ||
161 | } | 162 | } |
162 | 163 | ||
163 | // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect | 164 | // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect |
164 | void setOriginAndSize( Type left, Type bottom, Type width, Type height) | 165 | LLRectBase& setOriginAndSize( Type left, Type bottom, Type width, Type height) |
165 | { | 166 | { |
166 | mLeft = left; | 167 | mLeft = left; |
167 | mTop = bottom + height; | 168 | mTop = bottom + height; |
168 | mRight = left + width; | 169 | mRight = left + width; |
169 | mBottom = bottom; | 170 | mBottom = bottom; |
171 | return *this; | ||
170 | } | 172 | } |
171 | 173 | ||
172 | // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect | 174 | // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect |
173 | void setLeftTopAndSize( Type left, Type top, Type width, Type height) | 175 | LLRectBase& setLeftTopAndSize( Type left, Type top, Type width, Type height) |
174 | { | 176 | { |
175 | mLeft = left; | 177 | mLeft = left; |
176 | mTop = top; | 178 | mTop = top; |
177 | mRight = left + width; | 179 | mRight = left + width; |
178 | mBottom = top - height; | 180 | mBottom = top - height; |
181 | return *this; | ||
179 | } | 182 | } |
180 | 183 | ||
181 | void setCenterAndSize(Type x, Type y, Type width, Type height) | 184 | LLRectBase& setCenterAndSize(Type x, Type y, Type width, Type height) |
182 | { | 185 | { |
183 | mLeft = x - width/2; | 186 | mLeft = x - width/2; |
184 | mTop = y + height/2; | 187 | mTop = y + height/2; |
185 | mRight = x + width/2; | 188 | mRight = x + width/2; |
186 | mBottom = y - height/2; | 189 | mBottom = y - height/2; |
190 | return *this; | ||
187 | } | 191 | } |
188 | 192 | ||
189 | 193 | ||
190 | void translate(Type horiz, Type vertical) | 194 | LLRectBase& translate(Type horiz, Type vertical) |
191 | { | 195 | { |
192 | mLeft += horiz; | 196 | mLeft += horiz; |
193 | mRight += horiz; | 197 | mRight += horiz; |
194 | mTop += vertical; | 198 | mTop += vertical; |
195 | mBottom += vertical; | 199 | mBottom += vertical; |
200 | return *this; | ||
196 | } | 201 | } |
197 | 202 | ||
198 | void stretch( Type dx, Type dy) | 203 | LLRectBase& stretch( Type dx, Type dy) |
199 | { | 204 | { |
200 | mLeft -= dx; | 205 | mLeft -= dx; |
201 | mRight += dx; | 206 | mRight += dx; |
202 | mTop += dy; | 207 | mTop += dy; |
203 | mBottom -= dy; | 208 | mBottom -= dy; |
204 | makeValid(); | 209 | return makeValid(); |
205 | } | 210 | } |
206 | 211 | ||
207 | void stretch( Type delta ) | 212 | LLRectBase& stretch( Type delta ) |
208 | { | 213 | { |
209 | stretch(delta, delta); | 214 | stretch(delta, delta); |
210 | 215 | return *this; | |
211 | } | 216 | } |
212 | 217 | ||
213 | void makeValid() | 218 | LLRectBase& makeValid() |
214 | { | 219 | { |
215 | mLeft = llmin(mLeft, mRight); | 220 | mLeft = llmin(mLeft, mRight); |
216 | mBottom = llmin(mBottom, mTop); | 221 | mBottom = llmin(mBottom, mTop); |
222 | return *this; | ||
217 | } | 223 | } |
218 | 224 | ||
219 | bool isNull() const | 225 | bool isNull() const |
@@ -221,15 +227,16 @@ public: | |||
221 | return mLeft == mRight || mBottom == mTop; | 227 | return mLeft == mRight || mBottom == mTop; |
222 | } | 228 | } |
223 | 229 | ||
224 | void unionWith(const LLRectBase &other) | 230 | LLRectBase& unionWith(const LLRectBase &other) |
225 | { | 231 | { |
226 | mLeft = llmin(mLeft, other.mLeft); | 232 | mLeft = llmin(mLeft, other.mLeft); |
227 | mRight = llmax(mRight, other.mRight); | 233 | mRight = llmax(mRight, other.mRight); |
228 | mBottom = llmin(mBottom, other.mBottom); | 234 | mBottom = llmin(mBottom, other.mBottom); |
229 | mTop = llmax(mTop, other.mTop); | 235 | mTop = llmax(mTop, other.mTop); |
236 | return *this; | ||
230 | } | 237 | } |
231 | 238 | ||
232 | void intersectWith(const LLRectBase &other) | 239 | LLRectBase& intersectWith(const LLRectBase &other) |
233 | { | 240 | { |
234 | mLeft = llmax(mLeft, other.mLeft); | 241 | mLeft = llmax(mLeft, other.mLeft); |
235 | mRight = llmin(mRight, other.mRight); | 242 | mRight = llmin(mRight, other.mRight); |
@@ -243,6 +250,7 @@ public: | |||
243 | { | 250 | { |
244 | mBottom = mTop; | 251 | mBottom = mTop; |
245 | } | 252 | } |
253 | return *this; | ||
246 | } | 254 | } |
247 | 255 | ||
248 | friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect) | 256 | friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect) |