mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-13 23:17:57 +00:00
be52597f79
--HG-- extra : rebase_source : 3cb4344c42d323b7c42af2d7529726781ba23e00
51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
/* 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.graphics.Canvas;
|
|
import android.graphics.Path;
|
|
import android.graphics.PorterDuff.Mode;
|
|
import android.util.AttributeSet;
|
|
|
|
public class MenuButton extends ShapedButton {
|
|
|
|
public MenuButton(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
|
|
// Path is clipped.
|
|
mPath = new Path();
|
|
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
|
}
|
|
|
|
@Override
|
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
int width = getMeasuredWidth();
|
|
int height = getMeasuredHeight();
|
|
float curve = height * 1.125f;
|
|
|
|
mPath.reset();
|
|
|
|
// Clipping happens on opposite side for menu.
|
|
if (mSide == CurveTowards.RIGHT) {
|
|
mPath.moveTo(0, 0);
|
|
mPath.cubicTo(curve * 0.75f, 0,
|
|
curve * 0.25f, height,
|
|
curve, height);
|
|
mPath.lineTo(0, height);
|
|
mPath.lineTo(0, 0);
|
|
} else if (mSide == CurveTowards.LEFT) {
|
|
mPath.moveTo(width, 0);
|
|
mPath.cubicTo((width - (curve * 0.75f)), 0,
|
|
(width - (curve * 0.25f)), height,
|
|
(width - curve), height);
|
|
mPath.lineTo(width, height);
|
|
mPath.lineTo(width, 0);
|
|
}
|
|
}
|
|
}
|