mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1056012 - Split ShapedButton into PhoneTabsButton and TabletTabsButton (r=mcomella)
This commit is contained in:
parent
e847d2234b
commit
7bbd1a4367
@ -403,9 +403,11 @@ gbjar.sources += [
|
||||
'toolbar/CanvasDelegate.java',
|
||||
'toolbar/ForwardButton.java',
|
||||
'toolbar/PageActionLayout.java',
|
||||
'toolbar/PhoneTabsButton.java',
|
||||
'toolbar/ShapedButton.java',
|
||||
'toolbar/SiteIdentityPopup.java',
|
||||
'toolbar/TabCounter.java',
|
||||
'toolbar/TabletTabsButton.java',
|
||||
'toolbar/ToolbarDisplayLayout.java',
|
||||
'toolbar/ToolbarEditLayout.java',
|
||||
'toolbar/ToolbarEditText.java',
|
||||
|
@ -3,18 +3,16 @@
|
||||
- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<org.mozilla.gecko.toolbar.ShapedButton android:id="@+id/tabs"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
android:layout_width="84dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
gecko:curveTowards="left"
|
||||
android:background="@drawable/shaped_button"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="38dip"/>
|
||||
<org.mozilla.gecko.toolbar.TabletTabsButton android:id="@+id/tabs"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
android:layout_width="84dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/shaped_button"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="38dip"/>
|
||||
|
||||
<!-- The TextSwitcher should be shifted 28dp on the right, to avoid
|
||||
the curve. On a 56dp space, centering 24dp image will leave
|
||||
|
@ -3,8 +3,7 @@
|
||||
- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ImageButton android:id="@+id/back"
|
||||
style="@style/UrlBar.ImageButton.Unused"/>
|
||||
@ -66,13 +65,12 @@
|
||||
android:src="@drawable/menu_level"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.toolbar.ShapedButton android:id="@+id/tabs"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
android:layout_width="64dip"
|
||||
android:layout_toLeftOf="@id/menu"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
gecko:curveTowards="right"
|
||||
android:background="@drawable/shaped_button"/>
|
||||
<org.mozilla.gecko.toolbar.PhoneTabsButton android:id="@+id/tabs"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
android:layout_width="64dip"
|
||||
android:layout_toLeftOf="@id/menu"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:background="@drawable/shaped_button"/>
|
||||
|
||||
<!-- The TextSwitcher should be shifted 24dp on the left, to avoid
|
||||
the curve. On a 48dp space, centering 24dp image will leave
|
||||
|
@ -92,14 +92,6 @@
|
||||
<attr name="entryKeys" format="string"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BrowserToolbarCurve">
|
||||
<attr name="curveTowards">
|
||||
<flag name="none" value="0x00" />
|
||||
<flag name="left" value="0x01" />
|
||||
<flag name="right" value ="0x02" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TabsTray">
|
||||
<attr name="tabs">
|
||||
<flag name="tabs_normal" value="0x00" />
|
||||
|
@ -17,7 +17,6 @@ import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class BackButton extends ShapedButton {
|
||||
private final Path mPath;
|
||||
private final Path mBorderPath;
|
||||
private final Paint mBorderPaint;
|
||||
private final float mBorderWidth;
|
||||
@ -34,7 +33,6 @@ public class BackButton extends ShapedButton {
|
||||
mBorderPaint.setStyle(Paint.Style.STROKE);
|
||||
|
||||
// Path is masked.
|
||||
mPath = new Path();
|
||||
mBorderPath = new Path();
|
||||
|
||||
setPrivateMode(false);
|
||||
|
29
mobile/android/base/toolbar/PhoneTabsButton.java
Normal file
29
mobile/android/base/toolbar/PhoneTabsButton.java
Normal file
@ -0,0 +1,29 @@
|
||||
/* 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.toolbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.mozilla.gecko.tabs.TabCurve;
|
||||
|
||||
public class PhoneTabsButton extends ShapedButton {
|
||||
public PhoneTabsButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
|
||||
mPath.reset();
|
||||
|
||||
mPath.moveTo(0, 0);
|
||||
TabCurve.drawFromTop(mPath, 0, height, TabCurve.Direction.RIGHT);
|
||||
mPath.lineTo(width, height);
|
||||
mPath.lineTo(width, 0);
|
||||
mPath.lineTo(0, 0);
|
||||
}
|
||||
}
|
@ -24,28 +24,13 @@ public class ShapedButton extends ThemedImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
protected final LightweightTheme mTheme;
|
||||
|
||||
private final Path mPath;
|
||||
private final CurveTowards mSide;
|
||||
|
||||
protected final Path mPath;
|
||||
protected final CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
|
||||
public ShapedButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
||||
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x00);
|
||||
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_IN);
|
||||
@ -53,36 +38,9 @@ public class ShapedButton extends ThemedImageButton
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
|
||||
if (mSide == CurveTowards.NONE)
|
||||
return;
|
||||
|
||||
mPath.reset();
|
||||
|
||||
if (mSide == CurveTowards.RIGHT) {
|
||||
mPath.moveTo(0, 0);
|
||||
TabCurve.drawFromTop(mPath, 0, height, TabCurve.Direction.RIGHT);
|
||||
mPath.lineTo(width, height);
|
||||
mPath.lineTo(width, 0);
|
||||
mPath.lineTo(0, 0);
|
||||
} else if (mSide == CurveTowards.LEFT) {
|
||||
final int curve = (int) (height * 1.125f);
|
||||
|
||||
mPath.moveTo(width, 0);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), 0,
|
||||
(width - (curve * 0.25f)), height,
|
||||
(width - curve), height);
|
||||
mPath.lineTo(0, height);
|
||||
mPath.lineTo(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (mCanvasDelegate != null && mSide != CurveTowards.NONE)
|
||||
if (mCanvasDelegate != null)
|
||||
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
||||
else
|
||||
defaultDraw(canvas);
|
||||
|
30
mobile/android/base/toolbar/TabletTabsButton.java
Normal file
30
mobile/android/base/toolbar/TabletTabsButton.java
Normal file
@ -0,0 +1,30 @@
|
||||
/* 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.toolbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class TabletTabsButton extends ShapedButton {
|
||||
public TabletTabsButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
|
||||
final int curve = (int) (height * 1.125f);
|
||||
|
||||
mPath.reset();
|
||||
|
||||
mPath.moveTo(width, 0);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), 0,
|
||||
(width - (curve * 0.25f)), height,
|
||||
(width - curve), height);
|
||||
mPath.lineTo(0, height);
|
||||
mPath.lineTo(0, 0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user