Bug 785246: Replace the curves in TabsPanel Toolbar for new tab button. [r=mfinkle]
--HG-- extra : rebase_source : 82ad310cfee1870913a4ebabc4a7e2fba85dd0b8
@ -58,6 +58,8 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
||||
return new TabsButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TabsPanel"))
|
||||
return new TabsPanel(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TabsPanelButton"))
|
||||
return new TabsPanelButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TextSelectionHandle"))
|
||||
return new TextSelectionHandle(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "gfx.LayerView"))
|
||||
|
@ -114,6 +114,7 @@ FENNEC_JAVA_FILES = \
|
||||
Tabs.java \
|
||||
TabsButton.java \
|
||||
TabsPanel.java \
|
||||
TabsPanelButton.java \
|
||||
TabsTray.java \
|
||||
TabsAccessor.java \
|
||||
Telemetry.java \
|
||||
@ -648,8 +649,6 @@ RES_DRAWABLE_MDPI_V11 = \
|
||||
res/drawable-mdpi-v11/menu_item_texture.png \
|
||||
res/drawable-mdpi-v11/menu_item_pressed_texture.png \
|
||||
res/drawable-mdpi-v11/menu_item_check.png \
|
||||
res/drawable-mdpi-v11/tab_new_normal.png \
|
||||
res/drawable-mdpi-v11/tab_new_pressed.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_HDPI_V11 = \
|
||||
@ -674,8 +673,6 @@ RES_DRAWABLE_HDPI_V11 = \
|
||||
res/drawable-hdpi-v11/menu_item_texture.png \
|
||||
res/drawable-hdpi-v11/menu_item_pressed_texture.png \
|
||||
res/drawable-hdpi-v11/menu_item_check.png \
|
||||
res/drawable-hdpi-v11/tab_new_normal.png \
|
||||
res/drawable-hdpi-v11/tab_new_pressed.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_XHDPI_V11 = \
|
||||
@ -700,8 +697,6 @@ RES_DRAWABLE_XHDPI_V11 = \
|
||||
res/drawable-xhdpi-v11/menu_item_texture.png \
|
||||
res/drawable-xhdpi-v11/menu_item_pressed_texture.png \
|
||||
res/drawable-xhdpi-v11/menu_item_check.png \
|
||||
res/drawable-xhdpi-v11/tab_new_normal.png \
|
||||
res/drawable-xhdpi-v11/tab_new_pressed.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_LAND_V14 = \
|
||||
@ -717,8 +712,6 @@ RES_DRAWABLE_LAND_MDPI_V14 = \
|
||||
res/drawable-land-mdpi-v14/remote_tabs_off.png \
|
||||
res/drawable-land-mdpi-v14/remote_tabs_on.png \
|
||||
res/drawable-land-mdpi-v14/tab_new.png \
|
||||
res/drawable-land-mdpi-v14/tab_new_normal.png \
|
||||
res/drawable-land-mdpi-v14/tab_new_pressed.png \
|
||||
res/drawable-land-mdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-mdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-mdpi-v14/menu.png \
|
||||
@ -736,8 +729,6 @@ RES_DRAWABLE_LAND_HDPI_V14 = \
|
||||
res/drawable-land-hdpi-v14/remote_tabs_off.png \
|
||||
res/drawable-land-hdpi-v14/remote_tabs_on.png \
|
||||
res/drawable-land-hdpi-v14/tab_new.png \
|
||||
res/drawable-land-hdpi-v14/tab_new_normal.png \
|
||||
res/drawable-land-hdpi-v14/tab_new_pressed.png \
|
||||
res/drawable-land-hdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-hdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-hdpi-v14/menu.png \
|
||||
@ -755,8 +746,6 @@ RES_DRAWABLE_LAND_XHDPI_V14 = \
|
||||
res/drawable-land-xhdpi-v14/remote_tabs_off.png \
|
||||
res/drawable-land-xhdpi-v14/remote_tabs_on.png \
|
||||
res/drawable-land-xhdpi-v14/tab_new.png \
|
||||
res/drawable-land-xhdpi-v14/tab_new_normal.png \
|
||||
res/drawable-land-xhdpi-v14/tab_new_pressed.png \
|
||||
res/drawable-land-xhdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-xhdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-xhdpi-v14/menu.png \
|
||||
@ -781,8 +770,6 @@ RES_DRAWABLE_LARGE_MDPI_V11 = \
|
||||
res/drawable-large-mdpi-v11/remote_tabs_off.png \
|
||||
res/drawable-large-mdpi-v11/remote_tabs_on.png \
|
||||
res/drawable-large-mdpi-v11/tab_new.png \
|
||||
res/drawable-large-mdpi-v11/tab_new_normal.png \
|
||||
res/drawable-large-mdpi-v11/tab_new_pressed.png \
|
||||
res/drawable-large-mdpi-v11/urlbar_stop.png \
|
||||
res/drawable-large-mdpi-v11/reader.png \
|
||||
res/drawable-large-mdpi-v11/site_security_identified.png \
|
||||
@ -806,8 +793,6 @@ RES_DRAWABLE_LARGE_HDPI_V11 = \
|
||||
res/drawable-large-hdpi-v11/remote_tabs_off.png \
|
||||
res/drawable-large-hdpi-v11/remote_tabs_on.png \
|
||||
res/drawable-large-hdpi-v11/tab_new.png \
|
||||
res/drawable-large-hdpi-v11/tab_new_normal.png \
|
||||
res/drawable-large-hdpi-v11/tab_new_pressed.png \
|
||||
res/drawable-large-hdpi-v11/urlbar_stop.png \
|
||||
res/drawable-large-hdpi-v11/reader.png \
|
||||
res/drawable-large-hdpi-v11/site_security_identified.png \
|
||||
@ -831,8 +816,6 @@ RES_DRAWABLE_LARGE_XHDPI_V11 = \
|
||||
res/drawable-large-xhdpi-v11/remote_tabs_on.png \
|
||||
res/drawable-large-xhdpi-v11/remote_tabs_off.png \
|
||||
res/drawable-large-xhdpi-v11/tab_new.png \
|
||||
res/drawable-large-xhdpi-v11/tab_new_normal.png \
|
||||
res/drawable-large-xhdpi-v11/tab_new_pressed.png \
|
||||
res/drawable-large-xhdpi-v11/urlbar_stop.png \
|
||||
res/drawable-large-xhdpi-v11/reader.png \
|
||||
res/drawable-large-xhdpi-v11/site_security_identified.png \
|
||||
|
79
mobile/android/base/TabsPanelButton.java
Normal file
@ -0,0 +1,79 @@
|
||||
/* 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.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 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);
|
||||
}
|
||||
|
||||
@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.LEFT) {
|
||||
mPath.moveTo(0, height);
|
||||
mPath.cubicTo(curve * 0.75f, height,
|
||||
curve * 0.25f, 0,
|
||||
curve, 0);
|
||||
mPath.lineTo(0, 0);
|
||||
mPath.lineTo(0, height);
|
||||
} else if (mSide == CurveTowards.RIGHT) {
|
||||
mPath.moveTo(width, height);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), height,
|
||||
(width - (curve * 0.25f)), 0,
|
||||
(width - curve), 0);
|
||||
mPath.lineTo(width, 0);
|
||||
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);
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 3.9 KiB |
@ -5,7 +5,7 @@
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true" android:drawable="@drawable/tab_new_pressed"/>
|
||||
<item android:drawable="@drawable/tab_new_normal"/>
|
||||
<item android:state_pressed="true" android:drawable="@drawable/highlight"/>
|
||||
<item android:drawable="@drawable/tabs_tray_bg_repeat"/>
|
||||
|
||||
</selector>
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="8dip">
|
||||
android:layout_marginRight="15dip">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
@ -48,15 +48,15 @@
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="70dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="40dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
<org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
|
||||
android:layout_width="63dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="33dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="15dip">
|
||||
android:layout_marginRight="28dip">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
@ -48,15 +48,15 @@
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="98dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="14dip"
|
||||
android:paddingRight="56dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
<org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
|
||||
android:layout_width="85dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="14dip"
|
||||
android:paddingRight="43dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="13dip">
|
||||
android:layout_marginRight="22dip">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
@ -48,15 +48,15 @@
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="84dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="48dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
<org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
|
||||
android:layout_width="75dip"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="39dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/tab_new_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|