diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
commit | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /libs/ui/Rect.cpp | |
parent | 076357b8567458d4b6dfdcf839ef751634cd2bfb (diff) | |
download | frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.zip frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.gz frameworks_base-d83a98f4ce9cfa908f5c54bbd70f03eec07e7553.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'libs/ui/Rect.cpp')
-rw-r--r-- | libs/ui/Rect.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp deleted file mode 100644 index 99e68bb..0000000 --- a/libs/ui/Rect.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Rect.cpp - * Android - * - * Created on 10/14/05. - * Copyright 2005 The Android Open Source Project - * - */ - -#include <ui/Rect.h> - -namespace android { - -inline int min(int a, int b) { - return (a<b) ? a : b; -} - -inline int max(int a, int b) { - return (a>b) ? a : b; -} - -void Rect::makeInvalid() { - left = 0; - top = 0; - right = -1; - bottom = -1; -} - -bool Rect::operator < (const Rect& rhs) const -{ - if (top<rhs.top) { - return true; - } else if (top == rhs.top) { - if (left < rhs.left) { - return true; - } else if (left == rhs.left) { - if (bottom<rhs.bottom) { - return true; - } else if (bottom == rhs.bottom) { - if (right<rhs.right) { - return true; - } - } - } - } - return false; -} - -Rect& Rect::offsetTo(int x, int y) -{ - right -= left - x; - bottom -= top - y; - left = x; - top = y; - return *this; -} - -Rect& Rect::offsetBy(int x, int y) -{ - left += x; - top += y; - right+= x; - bottom+=y; - return *this; -} - -Rect Rect::operator + (const Point& rhs) const -{ - return Rect(left+rhs.x, top+rhs.y, right+rhs.x, bottom+rhs.y); -} - -Rect Rect::operator - (const Point& rhs) const -{ - return Rect(left-rhs.x, top-rhs.y, right-rhs.x, bottom-rhs.y); -} - -bool Rect::intersect(const Rect& with, Rect* result) const -{ - result->left = max(left, with.left); - result->top = max(top, with.top); - result->right = min(right, with.right); - result->bottom = min(bottom, with.bottom); - return !(result->isEmpty()); -} - -}; // namespace android |