summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/view/PieMenu.java
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-03-08 14:12:06 -0800
committerMichael Kolb <kolby@google.com>2011-03-09 09:37:22 -0800
commit1acef69ffc079d1bc029ff7eb1f5043f7efd7f36 (patch)
tree9e8daece975b283d9866d2c1915cbd86446bb16b /src/com/android/browser/view/PieMenu.java
parent66996bfa98bcf98f2ea944ddd27439f554f8f0b9 (diff)
downloadpackages_apps_Browser-1acef69ffc079d1bc029ff7eb1f5043f7efd7f36.zip
packages_apps_Browser-1acef69ffc079d1bc029ff7eb1f5043f7efd7f36.tar.gz
packages_apps_Browser-1acef69ffc079d1bc029ff7eb1f5043f7efd7f36.tar.bz2
add menu options to qc
Bug 4071315 Use the standard menu items to popuplate a menu from within quick controls Change-Id: I80d483ab2ce054e9b70ff4c6b0d6e0d9be783dc4
Diffstat (limited to 'src/com/android/browser/view/PieMenu.java')
-rw-r--r--src/com/android/browser/view/PieMenu.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/com/android/browser/view/PieMenu.java b/src/com/android/browser/view/PieMenu.java
index 98c0f59..22ebd18 100644
--- a/src/com/android/browser/view/PieMenu.java
+++ b/src/com/android/browser/view/PieMenu.java
@@ -46,6 +46,19 @@ public class PieMenu extends FrameLayout {
public boolean onOpen();
}
+ /**
+ * A view like object that lives off of the pie menu
+ */
+ public interface PieView {
+
+ public void layout(int anchorX, int anchorY, boolean onleft);
+
+ public void draw(Canvas c);
+
+ public boolean onTouchEvent(MotionEvent evt);
+
+ }
+
private Point mCenter;
private int mRadius;
private int mRadiusInc;
@@ -57,6 +70,7 @@ public class PieMenu extends FrameLayout {
private List<PieItem> mItems;
private int mLevels;
private int[] mCounts;
+ private PieView mPieView = null;
private Drawable mBackground;
@@ -143,6 +157,7 @@ public class PieMenu extends FrameLayout {
}
if (!show) {
mCurrentItem = null;
+ mPieView = null;
}
invalidate();
}
@@ -159,6 +174,7 @@ public class PieMenu extends FrameLayout {
private void layoutPie() {
int inner = mRadius;
int outer = mRadius + mRadiusInc;
+ int radius = mRadius;
for (int i = 0; i < mLevels; i++) {
int level = i + 1;
float sweep = (float) Math.PI / (mCounts[level] + 1);
@@ -205,6 +221,9 @@ public class PieMenu extends FrameLayout {
for (PieItem item : mItems) {
drawItem(canvas, item);
}
+ if (mPieView != null) {
+ mPieView.draw(canvas);
+ }
}
}
@@ -236,10 +255,14 @@ public class PieMenu extends FrameLayout {
}
} else if (MotionEvent.ACTION_UP == action) {
if (mOpen) {
+ boolean handled = false;
+ if (mPieView != null) {
+ handled = mPieView.onTouchEvent(evt);
+ }
PieItem item = mCurrentItem;
deselect();
show(false);
- if (item != null) {
+ if (!handled && (item != null)) {
item.getView().performClick();
}
return true;
@@ -254,6 +277,13 @@ public class PieMenu extends FrameLayout {
boolean handled = false;
PointF polar = getPolar(x, y);
int maxr = mRadius + mLevels * mRadiusInc + 50;
+ if (mPieView != null) {
+ handled = mPieView.onTouchEvent(evt);
+ }
+ if (handled) {
+ invalidate();
+ return false;
+ }
if (polar.y > maxr) {
deselect();
show(false);
@@ -266,6 +296,13 @@ public class PieMenu extends FrameLayout {
PieItem item = findItem(polar);
if (mCurrentItem != item) {
onEnter(item);
+ if ((item != null) && item.isPieView()) {
+ int cx = item.getView().getLeft() + (onTheLeft()
+ ? item.getView().getWidth() : 0);
+ int cy = item.getView().getTop();
+ mPieView = item.getPieView();
+ layoutPieView(mPieView, cx, cy);
+ }
invalidate();
}
}
@@ -273,6 +310,10 @@ public class PieMenu extends FrameLayout {
return false;
}
+ private void layoutPieView(PieView pv, int x, int y) {
+ pv.layout(x, y, onTheLeft());
+ }
+
/**
* enter a slice for a view
* updates model only
@@ -287,6 +328,7 @@ public class PieMenu extends FrameLayout {
// clear up stack
playSoundEffect(SoundEffectConstants.CLICK);
item.setSelected(true);
+ mPieView = null;
}
mCurrentItem = item;
}
@@ -296,6 +338,7 @@ public class PieMenu extends FrameLayout {
mCurrentItem.setSelected(false);
}
mCurrentItem = null;
+ mPieView = null;
}
private PointF getPolar(float x, float y) {