diff options
author | Tor Norbye <tnorbye@google.com> | 2012-10-10 12:57:27 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-10-12 10:09:34 -0700 |
commit | 5ab3464ae51f3169a48c0a70480df2d1af5d9d3a (patch) | |
tree | b0deb5540c74c74f30125b4846ea728917ff579f /rule_api | |
parent | 2ff4725103ee97f4d18604d182c5a67e659aa689 (diff) | |
download | sdk-5ab3464ae51f3169a48c0a70480df2d1af5d9d3a.zip sdk-5ab3464ae51f3169a48c0a70480df2d1af5d9d3a.tar.gz sdk-5ab3464ae51f3169a48c0a70480df2d1af5d9d3a.tar.bz2 |
Improvements to the multi-configuration layout
This adds a new layout algorithm which tries to do a more optimal fit
if all the configuration previews can fit on the current screen
without scrolling. (However, it still doesn't scale up these previews
to fit all available space, that's coming in a later CL).
It also delays rendering previews and performing layout until the
layout is actually painted, and improves the error rendering a bit.
It's also more deliberate in how preview renderings are scheduled,
performing them in visual order etc.
There's a new brief animation when you switch to a preview.
Finally, there are some preview zoom controls now.
Change-Id: Iea503a3fd57dfcaea7656e47b946bfcfea3eecb1
Diffstat (limited to 'rule_api')
-rw-r--r-- | rule_api/src/com/android/ide/common/api/Rect.java | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/rule_api/src/com/android/ide/common/api/Rect.java b/rule_api/src/com/android/ide/common/api/Rect.java index 0fb791b..88c04a6 100644 --- a/rule_api/src/com/android/ide/common/api/Rect.java +++ b/rule_api/src/com/android/ide/common/api/Rect.java @@ -16,9 +16,9 @@ package com.android.ide.common.api; -import com.google.common.annotations.Beta; import com.android.annotations.NonNull; import com.android.annotations.Nullable; +import com.google.common.annotations.Beta; /** @@ -81,11 +81,39 @@ public class Rect { /** Returns true if the rectangle contains the x,y coordinates, borders included. */ public boolean contains(int x, int y) { - return isValid() && - x >= this.x && - y >= this.y && - x < (this.x + this.w) && - y < (this.y + this.h); + return isValid() + && x >= this.x + && y >= this.y + && x < (this.x + this.w) + && y < (this.y + this.h); + } + + /** + * Returns true if this rectangle intersects the given rectangle. + * Two rectangles intersect if they overlap. + * @param other the other rectangle to test + * @return true if the two rectangles overlap + */ + public boolean intersects(@Nullable Rect other) { + if (other == null) { + return false; + } + if (x2() <= other.x + || other.x2() <= x + || y2() <= other.y + || other.y2() <= y) { + return false; + } + + return true; + } + + /** Returns true if the rectangle fully contains the given rectangle */ + public boolean contains(@Nullable Rect rect) { + return rect != null && x <= rect.x + && y <= rect.y + && x2() >= rect.x2() + && y2() >= rect.y2(); } /** Returns true if the rectangle contains the x,y coordinates, borders included. */ |