mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 785246: Make custom button inherit ShapedButton. [r=mfinkle]
--HG-- extra : rebase_source : 3cb4344c42d323b7c42af2d7529726781ba23e00
This commit is contained in:
parent
d6ecfa29f2
commit
916da33f22
@ -107,6 +107,7 @@ FENNEC_JAVA_FILES = \
|
||||
RemoteTabs.java \
|
||||
RobocopAPI.java \
|
||||
SetupScreen.java \
|
||||
ShapedButton.java \
|
||||
SiteIdentityPopup.java \
|
||||
SuggestClient.java \
|
||||
SurfaceBits.java \
|
||||
|
@ -5,35 +5,16 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
public class MenuButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Path mPath;
|
||||
CurveTowards mSide;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
public class MenuButton extends ShapedButton {
|
||||
|
||||
public MenuButton(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;
|
||||
|
||||
// Path is clipped.
|
||||
mPath = new Path();
|
||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
||||
@ -66,14 +47,4 @@ public class MenuButton extends ImageButton
|
||||
mPath.lineTo(width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
46
mobile/android/base/ShapedButton.java
Normal file
46
mobile/android/base/ShapedButton.java
Normal file
@ -0,0 +1,46 @@
|
||||
/* 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;
|
||||
|
||||
public class ShapedButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
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);
|
||||
}
|
||||
}
|
@ -14,42 +14,24 @@ import android.graphics.Path;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
public class TabsButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Paint mPaint;
|
||||
public class TabsButton extends ShapedButton {
|
||||
private Paint mPaint;
|
||||
|
||||
Path mPath;
|
||||
Path mBackgroundPath;
|
||||
Path mLeftCurve;
|
||||
Path mRightCurve;
|
||||
private Path mBackgroundPath;
|
||||
private Path mLeftCurve;
|
||||
private Path mRightCurve;
|
||||
|
||||
boolean mCropped;
|
||||
int mFullWidth;
|
||||
CurveTowards mSide;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
private boolean mCropped;
|
||||
private int mFullWidth;
|
||||
|
||||
public TabsButton(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();
|
||||
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.TabsButton);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabsButton);
|
||||
mCropped = a.getBoolean(R.styleable.TabsButton_cropped, false);
|
||||
a.recycle();
|
||||
|
||||
if (curveTowards == 0x00)
|
||||
mSide = CurveTowards.NONE;
|
||||
else if (curveTowards == 0x01)
|
||||
mSide = CurveTowards.LEFT;
|
||||
else
|
||||
mSide = CurveTowards.RIGHT;
|
||||
|
||||
// Paint to draw the background.
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
@ -169,9 +151,4 @@ public class TabsButton extends ImageButton
|
||||
if (mCropped && background.getLevel() != 2)
|
||||
canvas.drawPath(mBackgroundPath, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
@ -5,35 +5,16 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
public class TabsPanelButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Path mPath;
|
||||
CurveTowards mSide;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
public class TabsPanelButton extends ShapedButton {
|
||||
|
||||
public TabsPanelButton(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;
|
||||
|
||||
// Path is clipped.
|
||||
mPath = new Path();
|
||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
||||
@ -66,14 +47,4 @@ public class TabsPanelButton extends ImageButton
|
||||
mPath.lineTo(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user