2012-09-05 14:53:54 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Path;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
Backout 533faa3c50ed, 718abc1bd4ad, af2d5272c06b, ad5554e1345d, c9ef1b41b829, d3a825311d11, 0a51bcb3eb9e, a01a327e8ec4, 973b0ed30b8b, 39851bbcfaa1 & a92d2d2a3b0e (bug 805162), d4884aab5ce6, 06fcbaf40cb4, daccc3fe7c70, 881eb2a2906e, 76232441ae06, 01ae34fa1b3f & 5f405fc4e323 (bug 783092), a03d8d4db1c2, 49beb3801192, 174634554a97, 0bd27e755a83, 19e8f151ca67, a6604e038bc0, ed3b8237e76e & 082cf8d72554 (bug 785945) for bustage or conflicting with backout of said bustage on a CLOSED TREE
2012-10-31 17:16:35 -07:00
|
|
|
public class ShapedButton extends ImageButton
|
|
|
|
implements CanvasDelegate.DrawManager {
|
2012-09-05 14:53:54 -07:00
|
|
|
protected Path mPath;
|
|
|
|
protected CurveTowards mSide;
|
|
|
|
protected CanvasDelegate mCanvasDelegate;
|
|
|
|
|
|
|
|
protected enum CurveTowards { NONE, LEFT, RIGHT };
|
|
|
|
|
|
|
|
public ShapedButton(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
|
|
|
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
|
|
|
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02);
|
|
|
|
a.recycle();
|
|
|
|
|
|
|
|
if (curveTowards == 0x00)
|
|
|
|
mSide = CurveTowards.NONE;
|
|
|
|
else if (curveTowards == 0x01)
|
|
|
|
mSide = CurveTowards.LEFT;
|
|
|
|
else
|
|
|
|
mSide = CurveTowards.RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void draw(Canvas canvas) {
|
|
|
|
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void defaultDraw(Canvas canvas) {
|
|
|
|
super.draw(canvas);
|
|
|
|
}
|
|
|
|
}
|