mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
248 lines
8.1 KiB
Java
248 lines
8.1 KiB
Java
package androidx.appcompat.graphics.drawable;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.ColorFilter;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import androidx.appcompat.R;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DrawerArrowDrawable extends Drawable {
|
|
public static final int ARROW_DIRECTION_END = 3;
|
|
public static final int ARROW_DIRECTION_LEFT = 0;
|
|
public static final int ARROW_DIRECTION_RIGHT = 1;
|
|
public static final int ARROW_DIRECTION_START = 2;
|
|
private static final float ARROW_HEAD_ANGLE = (float) Math.toRadians(45.0d);
|
|
private float mArrowHeadLength;
|
|
private float mArrowShaftLength;
|
|
private float mBarGap;
|
|
private float mBarLength;
|
|
private int mDirection;
|
|
private float mMaxCutForBarSize;
|
|
private final Paint mPaint;
|
|
private final Path mPath;
|
|
private float mProgress;
|
|
private final int mSize;
|
|
private boolean mSpin;
|
|
private boolean mVerticalMirror;
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
/* loaded from: classes.dex */
|
|
public @interface ArrowDirection {
|
|
}
|
|
|
|
private static float lerp(float f, float f2, float f3) {
|
|
return f + ((f2 - f) * f3);
|
|
}
|
|
|
|
public float getArrowHeadLength() {
|
|
return this.mArrowHeadLength;
|
|
}
|
|
|
|
public float getArrowShaftLength() {
|
|
return this.mArrowShaftLength;
|
|
}
|
|
|
|
public float getBarLength() {
|
|
return this.mBarLength;
|
|
}
|
|
|
|
public int getDirection() {
|
|
return this.mDirection;
|
|
}
|
|
|
|
public float getGapSize() {
|
|
return this.mBarGap;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public int getIntrinsicHeight() {
|
|
return this.mSize;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public int getIntrinsicWidth() {
|
|
return this.mSize;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public int getOpacity() {
|
|
return -3;
|
|
}
|
|
|
|
public final Paint getPaint() {
|
|
return this.mPaint;
|
|
}
|
|
|
|
public float getProgress() {
|
|
return this.mProgress;
|
|
}
|
|
|
|
public boolean isSpinEnabled() {
|
|
return this.mSpin;
|
|
}
|
|
|
|
public DrawerArrowDrawable(Context context) {
|
|
Paint paint = new Paint();
|
|
this.mPaint = paint;
|
|
this.mPath = new Path();
|
|
this.mVerticalMirror = false;
|
|
this.mDirection = 2;
|
|
paint.setStyle(Paint.Style.STROKE);
|
|
paint.setStrokeJoin(Paint.Join.MITER);
|
|
paint.setStrokeCap(Paint.Cap.BUTT);
|
|
paint.setAntiAlias(true);
|
|
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(null, R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle, R.style.Base_Widget_AppCompat_DrawerArrowToggle);
|
|
setColor(obtainStyledAttributes.getColor(R.styleable.DrawerArrowToggle_color, 0));
|
|
setBarThickness(obtainStyledAttributes.getDimension(R.styleable.DrawerArrowToggle_thickness, 0.0f));
|
|
setSpinEnabled(obtainStyledAttributes.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true));
|
|
setGapSize(Math.round(obtainStyledAttributes.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0.0f)));
|
|
this.mSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
|
|
this.mBarLength = Math.round(obtainStyledAttributes.getDimension(R.styleable.DrawerArrowToggle_barLength, 0.0f));
|
|
this.mArrowHeadLength = Math.round(obtainStyledAttributes.getDimension(R.styleable.DrawerArrowToggle_arrowHeadLength, 0.0f));
|
|
this.mArrowShaftLength = obtainStyledAttributes.getDimension(R.styleable.DrawerArrowToggle_arrowShaftLength, 0.0f);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
|
|
public void setArrowHeadLength(float f) {
|
|
if (this.mArrowHeadLength != f) {
|
|
this.mArrowHeadLength = f;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setArrowShaftLength(float f) {
|
|
if (this.mArrowShaftLength != f) {
|
|
this.mArrowShaftLength = f;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setBarLength(float f) {
|
|
if (this.mBarLength != f) {
|
|
this.mBarLength = f;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setColor(int i) {
|
|
if (i != this.mPaint.getColor()) {
|
|
this.mPaint.setColor(i);
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public int getColor() {
|
|
return this.mPaint.getColor();
|
|
}
|
|
|
|
public void setBarThickness(float f) {
|
|
if (this.mPaint.getStrokeWidth() != f) {
|
|
this.mPaint.setStrokeWidth(f);
|
|
this.mMaxCutForBarSize = (float) ((f / 2.0f) * Math.cos(ARROW_HEAD_ANGLE));
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public float getBarThickness() {
|
|
return this.mPaint.getStrokeWidth();
|
|
}
|
|
|
|
public void setGapSize(float f) {
|
|
if (f != this.mBarGap) {
|
|
this.mBarGap = f;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setDirection(int i) {
|
|
if (i != this.mDirection) {
|
|
this.mDirection = i;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setSpinEnabled(boolean z) {
|
|
if (this.mSpin != z) {
|
|
this.mSpin = z;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
public void setVerticalMirror(boolean z) {
|
|
if (this.mVerticalMirror != z) {
|
|
this.mVerticalMirror = z;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void draw(Canvas canvas) {
|
|
Rect bounds = getBounds();
|
|
int i = this.mDirection;
|
|
boolean z = false;
|
|
if (i != 0 && (i == 1 || (i == 3 ? DrawableCompat.getLayoutDirection(this) == 0 : DrawableCompat.getLayoutDirection(this) == 1))) {
|
|
z = true;
|
|
}
|
|
float f = this.mArrowHeadLength;
|
|
float lerp = lerp(this.mBarLength, (float) Math.sqrt(f * f * 2.0f), this.mProgress);
|
|
float lerp2 = lerp(this.mBarLength, this.mArrowShaftLength, this.mProgress);
|
|
float round = Math.round(lerp(0.0f, this.mMaxCutForBarSize, this.mProgress));
|
|
float lerp3 = lerp(0.0f, ARROW_HEAD_ANGLE, this.mProgress);
|
|
float lerp4 = lerp(z ? 0.0f : -180.0f, z ? 180.0f : 0.0f, this.mProgress);
|
|
double d = lerp;
|
|
double d2 = lerp3;
|
|
boolean z2 = z;
|
|
float round2 = (float) Math.round(Math.cos(d2) * d);
|
|
float round3 = (float) Math.round(d * Math.sin(d2));
|
|
this.mPath.rewind();
|
|
float lerp5 = lerp(this.mBarGap + this.mPaint.getStrokeWidth(), -this.mMaxCutForBarSize, this.mProgress);
|
|
float f2 = (-lerp2) / 2.0f;
|
|
this.mPath.moveTo(f2 + round, 0.0f);
|
|
this.mPath.rLineTo(lerp2 - (round * 2.0f), 0.0f);
|
|
this.mPath.moveTo(f2, lerp5);
|
|
this.mPath.rLineTo(round2, round3);
|
|
this.mPath.moveTo(f2, -lerp5);
|
|
this.mPath.rLineTo(round2, -round3);
|
|
this.mPath.close();
|
|
canvas.save();
|
|
float strokeWidth = this.mPaint.getStrokeWidth();
|
|
float height = bounds.height() - (3.0f * strokeWidth);
|
|
canvas.translate(bounds.centerX(), ((((int) (height - (2.0f * r5))) / 4) * 2) + (strokeWidth * 1.5f) + this.mBarGap);
|
|
if (this.mSpin) {
|
|
canvas.rotate(lerp4 * (this.mVerticalMirror ^ z2 ? -1 : 1));
|
|
} else if (z2) {
|
|
canvas.rotate(180.0f);
|
|
}
|
|
canvas.drawPath(this.mPath, this.mPaint);
|
|
canvas.restore();
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void setAlpha(int i) {
|
|
if (i != this.mPaint.getAlpha()) {
|
|
this.mPaint.setAlpha(i);
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void setColorFilter(ColorFilter colorFilter) {
|
|
this.mPaint.setColorFilter(colorFilter);
|
|
invalidateSelf();
|
|
}
|
|
|
|
public void setProgress(float f) {
|
|
if (this.mProgress != f) {
|
|
this.mProgress = f;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
}
|