OSDN Git Service

roll MR3 stretchy changes into master
authorMike Reed <reed@google.com>
Fri, 29 Jan 2010 16:31:39 +0000 (11:31 -0500)
committerMike Reed <reed@google.com>
Fri, 29 Jan 2010 17:54:25 +0000 (12:54 -0500)
res/drawable/pattern_carbon_fiber_dark.png [new file with mode: 0644]
src/com/android/browser/MeshTracker.java
src/com/android/browser/TabControl.java

diff --git a/res/drawable/pattern_carbon_fiber_dark.png b/res/drawable/pattern_carbon_fiber_dark.png
new file mode 100644 (file)
index 0000000..07af4b6
Binary files /dev/null and b/res/drawable/pattern_carbon_fiber_dark.png differ
index ec730e3..c4b6332 100644 (file)
@@ -1,4 +1,18 @@
-
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package com.android.browser;
 
@@ -64,8 +78,11 @@ import android.webkit.WebView;
 
         // first experimental behavior
         private void doit1(float dx, float dy) {
-            int index;
+            final float scale = 0.75f;  // temper how far we actually move
+            dx *= scale;
+            dy *= scale;
 
+            int index;
             if (dx < 0) {
                 index = 10;
             } else {
@@ -84,8 +101,12 @@ import android.webkit.WebView;
         }
 
         private void doit2(float dx, float dy) {
-            int index;
+            final float scale = 0.35f;  // temper how far we actually move
+            dx *= scale;
+            dy *= scale;
+            final float cornerScale = 0.25f;
 
+            int index;
             if (dx < 0) {
                 index = 4;
             } else {
@@ -93,6 +114,11 @@ import android.webkit.WebView;
             }
             mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx;
             mCubics[index*2 + 2] = mOrig[index*2 + 2] + dx;
+            // corners
+            index -= 1;
+            mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx * cornerScale;
+            index = (index + 3) % 12; // next corner
+            mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx * cornerScale;
 
             if (dy < 0) {
                 index = 7;
@@ -101,6 +127,11 @@ import android.webkit.WebView;
             }
             mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy;
             mCubics[index*2 + 3] = mOrig[index*2 + 3] + dy;
+            // corners
+            index -= 1;
+            mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy * cornerScale;
+            index = (index + 3) % 12; // next corner
+            mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy * cornerScale;
         }
 
         public void setStretch(float dx, float dy) {
@@ -125,11 +156,16 @@ import android.webkit.WebView;
     private Mesh mMesh;
     private Bitmap mBitmap;
     private int mWhich;
+    private Paint mBGPaint;
 
     public MeshTracker(int which) {
         mWhich = which;
     }
 
+    public void setBGPaint(Paint paint) {
+        mBGPaint = paint;
+    }
+
     @Override public void onStartDrag(float x, float y) {
         mMesh = new Mesh(mWhich, 16, 16);
     }
@@ -149,10 +185,13 @@ import android.webkit.WebView;
     }
 
     @Override public void onDraw(Canvas canvas) {
-        canvas.drawColor(0xFF000000);
-        Paint paint = new Paint();
-        paint.setAlpha(0x80);
-        canvas.drawBitmap(mBitmap, 0, 0, paint);
+        if (mWhich == 2) {
+            if (mBGPaint != null) {
+                canvas.drawPaint(mBGPaint);
+            } else {
+                canvas.drawColor(0xFF000000);
+            }
+        }
         mMesh.draw(canvas);
     }
 }
index 5e64a4b..1790098 100644 (file)
 
 package com.android.browser;
 
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
+import android.graphics.Paint;
+import android.graphics.Shader;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
@@ -539,7 +544,16 @@ class TabControl {
         s.addObserver(w.getSettings()).update(s, null);
 
         // pick a default
-        w.setDragTracker(new MeshTracker(1));
+        if (true) {
+            MeshTracker mt = new MeshTracker(2);
+            Paint paint = new Paint();
+            Bitmap bm = BitmapFactory.decodeResource(mActivity.getResources(),
+                                         R.drawable.pattern_carbon_fiber_dark);
+            paint.setShader(new BitmapShader(bm, Shader.TileMode.REPEAT,
+                                             Shader.TileMode.REPEAT));
+            mt.setBGPaint(paint);
+            w.setDragTracker(mt);
+        }
         return w;
     }