Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.launcher2; |
| 18 | |
| 19 | import java.io.Writer; |
| 20 | import java.util.ArrayList; |
| 21 | import java.util.concurrent.Semaphore; |
| 22 | import java.lang.Float; |
| 23 | |
| 24 | import android.renderscript.RSSurfaceView; |
| 25 | import android.renderscript.RenderScript; |
| 26 | |
| 27 | import android.renderscript.RenderScript; |
| 28 | import android.renderscript.ProgramVertex; |
| 29 | import android.renderscript.Element; |
| 30 | import android.renderscript.Allocation; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 31 | import android.renderscript.Type; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 32 | import android.renderscript.Script; |
| 33 | import android.renderscript.ScriptC; |
| 34 | import android.renderscript.ProgramFragment; |
| 35 | import android.renderscript.ProgramStore; |
| 36 | import android.renderscript.Sampler; |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 37 | import android.renderscript.SimpleMesh; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 38 | |
| 39 | import android.content.Context; |
| 40 | import android.content.res.Resources; |
Joe Onorato | 7c312c1 | 2009-08-13 21:36:53 -0700 | [diff] [blame] | 41 | import android.database.DataSetObserver; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 42 | import android.graphics.Bitmap; |
| 43 | import android.graphics.BitmapFactory; |
| 44 | import android.graphics.Canvas; |
| 45 | import android.graphics.Paint; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 46 | import android.graphics.drawable.BitmapDrawable; |
| 47 | import android.graphics.drawable.Drawable; |
| 48 | import android.os.Handler; |
| 49 | import android.os.Message; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 50 | import android.os.SystemClock; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 51 | import android.util.AttributeSet; |
| 52 | import android.util.Log; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 53 | import android.view.KeyEvent; |
| 54 | import android.view.MotionEvent; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 55 | import android.view.Surface; |
| 56 | import android.view.SurfaceHolder; |
| 57 | import android.view.SurfaceView; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 58 | import android.view.View; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 59 | import android.view.VelocityTracker; |
| 60 | import android.view.ViewConfiguration; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 61 | import android.graphics.PixelFormat; |
| 62 | |
| 63 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 64 | public class AllAppsView extends RSSurfaceView |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 65 | implements View.OnClickListener, View.OnLongClickListener, DragSource { |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 66 | private static final String TAG = "Launcher.AllAppsView"; |
| 67 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 68 | /** Bit for mLocks for when there are icons being loaded. */ |
| 69 | private static final int LOCK_ICONS_PENDING = 1; |
| 70 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 71 | private static final int TRACKING_FLING = 0; |
| 72 | private static final int TRACKING_HOME = 1; |
| 73 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 74 | private Launcher mLauncher; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 75 | private DragController mDragController; |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 76 | |
| 77 | /** When this is 0, modifications are allowed, when it's not, they're not. |
| 78 | * TODO: What about scrolling? */ |
| 79 | private int mLocks = LOCK_ICONS_PENDING; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 80 | |
Joe Onorato | f7b0e01 | 2009-10-01 14:09:15 -0700 | [diff] [blame] | 81 | private int mSlopX; |
| 82 | private int mMaxFlingVelocity; |
| 83 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 84 | private Defines mDefines = new Defines(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 85 | private RenderScript mRS; |
| 86 | private RolloRS mRollo; |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 87 | private ArrayList<ApplicationInfo> mAllAppsList; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 88 | |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 89 | private int mPageCount; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 90 | private boolean mStartedScrolling; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 91 | private VelocityTracker mVelocity; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 92 | private int mTouchTracking; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 93 | private int mLastMotionX; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 94 | private int mMotionDownRawX; |
| 95 | private int mMotionDownRawY; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 96 | private int mHomeButtonTop; |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 97 | private long mTouchTime; |
Joe Onorato | 360d035 | 2009-09-28 14:37:53 -0400 | [diff] [blame] | 98 | private boolean mZoomSwipeInProgress; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 99 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 100 | static class Defines { |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 101 | public static final int ALLOC_PARAMS = 0; |
| 102 | public static final int ALLOC_STATE = 1; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 103 | public static final int ALLOC_READBACK = 2; |
| 104 | public static final int ALLOC_ICON_IDS = 3; |
| 105 | public static final int ALLOC_LABEL_IDS = 4; |
| 106 | public static final int ALLOC_X_BORDERS = 5; |
| 107 | public static final int ALLOC_Y_BORDERS = 6; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 108 | |
| 109 | public static final int COLUMNS_PER_PAGE = 4; |
| 110 | public static final int ROWS_PER_PAGE = 4; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 111 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 112 | public static final float RADIUS = 4.0f; |
| 113 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 114 | public static final int ICON_WIDTH_PX = 64; |
| 115 | public static final int ICON_TEXTURE_WIDTH_PX = 128; |
| 116 | |
| 117 | public static final int ICON_HEIGHT_PX = 64; |
| 118 | public static final int ICON_TEXTURE_HEIGHT_PX = 128; |
| 119 | public static final float ICON_TOP_OFFSET = 0.2f; |
| 120 | |
| 121 | public static final float CAMERA_Z = -2; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 122 | |
| 123 | public int SCREEN_WIDTH_PX; |
| 124 | public int SCREEN_HEIGHT_PX; |
| 125 | |
| 126 | public float FAR_ICON_SIZE; |
| 127 | |
| 128 | public void recompute(int w, int h) { |
| 129 | SCREEN_WIDTH_PX = 480; |
| 130 | SCREEN_HEIGHT_PX = 800; |
| 131 | FAR_ICON_SIZE = farSize(2 * ICON_WIDTH_PX / (float)w); |
| 132 | } |
| 133 | |
| 134 | private static float farSize(float sizeAt0) { |
| 135 | return sizeAt0 * (Defines.RADIUS - Defines.CAMERA_Z) / -Defines.CAMERA_Z; |
| 136 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 137 | } |
Joe Onorato | 7c312c1 | 2009-08-13 21:36:53 -0700 | [diff] [blame] | 138 | |
| 139 | public AllAppsView(Context context, AttributeSet attrs) { |
| 140 | super(context, attrs); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 141 | setFocusable(true); |
| 142 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
Joe Onorato | f7b0e01 | 2009-10-01 14:09:15 -0700 | [diff] [blame] | 143 | final ViewConfiguration config = ViewConfiguration.get(context); |
| 144 | mSlopX = config.getScaledTouchSlop(); |
| 145 | mMaxFlingVelocity = config.getScaledMaximumFlingVelocity(); |
| 146 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 147 | setOnClickListener(this); |
| 148 | setOnLongClickListener(this); |
Dianne Hackborn | e52a1b5 | 2009-09-30 22:36:20 -0700 | [diff] [blame] | 149 | setZOrderOnTop(true); |
Jason Sams | fd22dac | 2009-09-20 17:24:16 -0700 | [diff] [blame] | 150 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Joe Onorato | 7c312c1 | 2009-08-13 21:36:53 -0700 | [diff] [blame] | 153 | public AllAppsView(Context context, AttributeSet attrs, int defStyle) { |
| 154 | this(context, attrs); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 157 | public void setLauncher(Launcher launcher) { |
| 158 | mLauncher = launcher; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 161 | @Override |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 162 | public void surfaceDestroyed(SurfaceHolder holder) { |
| 163 | super.surfaceDestroyed(holder); |
| 164 | |
| 165 | destroyRenderScript(); |
| 166 | mRS = null; |
| 167 | mRollo = null; |
| 168 | } |
| 169 | |
| 170 | @Override |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 171 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { |
| 172 | super.surfaceChanged(holder, format, w, h); |
| 173 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 174 | long startTime = SystemClock.uptimeMillis(); |
| 175 | |
Jason Sams | 05de32a | 2009-09-27 14:01:40 -0700 | [diff] [blame] | 176 | mRS = createRenderScript(true); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 177 | mRollo = new RolloRS(); |
| 178 | mRollo.init(getResources(), w, h); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 179 | if (mAllAppsList != null) { |
| 180 | mRollo.setApps(mAllAppsList); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 181 | Log.d(TAG, "surfaceChanged... calling mRollo.setApps"); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 182 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 183 | |
| 184 | Resources res = getContext().getResources(); |
| 185 | int barHeight = (int)res.getDimension(R.dimen.button_bar_height); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 186 | mHomeButtonTop = h - barHeight; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 187 | |
| 188 | long endTime = SystemClock.uptimeMillis(); |
| 189 | Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | @Override |
| 193 | public boolean onKeyDown(int keyCode, KeyEvent event) |
| 194 | { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 195 | // this method doesn't work when 'extends View' include 'extends ScrollView'. |
| 196 | return super.onKeyDown(keyCode, event); |
| 197 | } |
| 198 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 199 | @Override |
| 200 | public boolean onTouchEvent(MotionEvent ev) |
| 201 | { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 202 | if (!isVisible()) { |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 203 | return true; |
Joe Onorato | e3406a2 | 2009-09-03 14:36:25 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 206 | if (mLocks != 0) { |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 207 | return true; |
| 208 | } |
| 209 | |
| 210 | super.onTouchEvent(ev); |
| 211 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 212 | int x = (int)ev.getX(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 213 | int y = (int)ev.getY(); |
| 214 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 215 | int deltaX; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 216 | int action = ev.getAction(); |
| 217 | switch (action) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 218 | case MotionEvent.ACTION_DOWN: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 219 | if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) { |
| 220 | mTouchTracking = TRACKING_HOME; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 221 | } else { |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 222 | mTouchTracking = TRACKING_FLING; |
| 223 | |
| 224 | mMotionDownRawX = (int)ev.getRawX(); |
| 225 | mMotionDownRawY = (int)ev.getRawY(); |
| 226 | mLastMotionX = x; |
| 227 | mRollo.mReadback.read(); |
| 228 | |
| 229 | mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX; |
| 230 | mRollo.mState.newTouchDown = 1; |
| 231 | |
| 232 | if (!mRollo.checkClickOK()) { |
| 233 | mRollo.clearSelectedIcon(); |
| 234 | } else { |
| 235 | mRollo.selectIcon(x, y, mRollo.mReadback.posX); |
| 236 | } |
| 237 | mRollo.mState.save(); |
| 238 | mRollo.mInvokeMove.execute(); |
| 239 | mVelocity = VelocityTracker.obtain(); |
| 240 | mVelocity.addMovement(ev); |
| 241 | mStartedScrolling = false; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 242 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 243 | break; |
| 244 | case MotionEvent.ACTION_MOVE: |
| 245 | case MotionEvent.ACTION_OUTSIDE: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 246 | if (mTouchTracking == TRACKING_HOME) { |
| 247 | // TODO: highlight? |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 248 | } else { |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 249 | int slopX = Math.abs(x - mLastMotionX); |
| 250 | if (!mStartedScrolling && slopX < mSlopX) { |
| 251 | // don't update mLastMotionX so slopX is right and when we do start scrolling |
| 252 | // below, we get the right delta. |
| 253 | } else { |
| 254 | mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX; |
| 255 | mRollo.mState.newTouchDown = 1; |
| 256 | mRollo.mInvokeMove.execute(); |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 257 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 258 | mStartedScrolling = true; |
| 259 | mRollo.clearSelectedIcon(); |
| 260 | deltaX = x - mLastMotionX; |
| 261 | mVelocity.addMovement(ev); |
| 262 | mRollo.mState.save(); |
| 263 | mLastMotionX = x; |
| 264 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 265 | } |
| 266 | break; |
| 267 | case MotionEvent.ACTION_UP: |
| 268 | case MotionEvent.ACTION_CANCEL: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 269 | if (mTouchTracking == TRACKING_HOME) { |
| 270 | if (action == MotionEvent.ACTION_UP) { |
| 271 | if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) { |
| 272 | mLauncher.closeAllApps(true); |
| 273 | } |
| 274 | } |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 275 | } else { |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 276 | mRollo.mState.newTouchDown = 0; |
| 277 | mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX; |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 278 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 279 | if (!mZoomSwipeInProgress) { |
| 280 | mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity); |
| 281 | mRollo.mState.flingVelocityX |
| 282 | = mVelocity.getXVelocity() / mDefines.SCREEN_WIDTH_PX; |
| 283 | mRollo.clearSelectedIcon(); |
| 284 | mRollo.mState.save(); |
| 285 | mRollo.mInvokeFling.execute(); |
| 286 | } else { |
| 287 | mRollo.mState.save(); |
| 288 | mRollo.mInvokeMove.execute(); |
| 289 | } |
| 290 | |
| 291 | mLastMotionX = -10000; |
Joe Onorato | 539ed9d | 2009-10-02 10:22:14 -0700 | [diff] [blame] | 292 | if (mVelocity != null) { |
| 293 | mVelocity.recycle(); |
| 294 | mVelocity = null; |
| 295 | } |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 296 | break; |
| 297 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 298 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 299 | |
| 300 | return true; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 303 | public void onClick(View v) { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 304 | if (mLocks != 0 || !isVisible()) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 305 | return; |
| 306 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 307 | int index = mRollo.mState.selectedIconIndex; |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 308 | if (mRollo.checkClickOK() && index >= 0 && index < mAllAppsList.size()) { |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 309 | ApplicationInfo app = mAllAppsList.get(index); |
| 310 | mLauncher.startActivitySafely(app.intent); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | public boolean onLongClick(View v) { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 315 | if (mLocks != 0 || !isVisible()) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 316 | return true; |
| 317 | } |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 318 | int index = mRollo.mState.selectedIconIndex; |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 319 | Log.d(TAG, "long click! velocity=" + mRollo.mReadback.velocity + " index=" + index); |
| 320 | if (mRollo.checkClickOK() && index >= 0 && index < mAllAppsList.size()) { |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 321 | ApplicationInfo app = mAllAppsList.get(index); |
| 322 | |
| 323 | // We don't really have an accurate location to use. This will do. |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 324 | int screenX = mMotionDownRawX - (mDefines.ICON_WIDTH_PX / 2); |
| 325 | int screenY = mMotionDownRawY - mDefines.ICON_HEIGHT_PX; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 326 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 327 | int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2; |
| 328 | int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 329 | mDragController.startDrag(app.iconBitmap, screenX, screenY, |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 330 | left, top, mDefines.ICON_WIDTH_PX, mDefines.ICON_HEIGHT_PX, |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 331 | this, app, DragController.DRAG_ACTION_COPY); |
Joe Onorato | e3406a2 | 2009-09-03 14:36:25 -0700 | [diff] [blame] | 332 | |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 333 | mLauncher.closeAllApps(true); |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 334 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 335 | return true; |
| 336 | } |
| 337 | |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 338 | public void setDragController(DragController dragger) { |
| 339 | mDragController = dragger; |
| 340 | } |
| 341 | |
| 342 | public void onDropCompleted(View target, boolean success) { |
| 343 | } |
| 344 | |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame^] | 345 | /** |
| 346 | * Zoom to the specifed amount. |
| 347 | * |
| 348 | * @param amount [0..1] 0 is hidden, 1 is open |
| 349 | * @param animate Whether to animate. |
| 350 | */ |
| 351 | public void zoom(float amount, boolean animate) { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 352 | if (mRollo == null) { |
| 353 | return; |
| 354 | } |
| 355 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 356 | cancelLongPress(); |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 357 | mRollo.clearSelectedIcon(); |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 358 | if (amount > 0.001f) { |
Joe Onorato | c5acd42 | 2009-10-01 14:21:24 -0700 | [diff] [blame] | 359 | // set in readback, so we're correct even before the next frame |
| 360 | mRollo.mReadback.zoom = mRollo.mState.zoomTarget = amount; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 361 | if (!animate) { |
Joe Onorato | c5acd42 | 2009-10-01 14:21:24 -0700 | [diff] [blame] | 362 | mRollo.mState.zoom = amount; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 363 | mRollo.mReadback.save(); |
| 364 | } |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 365 | } else { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 366 | mRollo.mState.zoomTarget = 0; |
| 367 | if (!animate) { |
| 368 | mRollo.mReadback.zoom = mRollo.mState.zoom = 0; |
| 369 | mRollo.mReadback.save(); |
| 370 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 371 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 372 | mRollo.mState.save(); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 373 | if (!animate) { |
| 374 | mRollo.mInvokeSetZoom.execute(); |
| 375 | } else { |
| 376 | mRollo.mInvokeSetZoomTarget.execute(); |
| 377 | } |
Joe Onorato | 8e099e2 | 2009-09-25 17:30:47 -0700 | [diff] [blame] | 378 | mReadZoom.removeMessages(1); |
| 379 | mReadZoom.sendEmptyMessageDelayed(1, 1000); |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 380 | } |
| 381 | |
Joe Onorato | 8e099e2 | 2009-09-25 17:30:47 -0700 | [diff] [blame] | 382 | Handler mReadZoom = new Handler() { |
| 383 | public void handleMessage(Message msg) { |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 384 | if(mRollo != null && mRollo.mReadback != null) { |
| 385 | // FIXME: These checks may indicate other problems. |
| 386 | mRollo.mReadback.read(); |
| 387 | } |
Joe Onorato | 8e099e2 | 2009-09-25 17:30:47 -0700 | [diff] [blame] | 388 | } |
| 389 | }; |
| 390 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 391 | public boolean isVisible() { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 392 | if (mRollo == null) { |
| 393 | return false; |
| 394 | } |
Joe Onorato | 8e099e2 | 2009-09-25 17:30:47 -0700 | [diff] [blame] | 395 | //mRollo.mReadback.read(); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 396 | return mRollo.mReadback.zoom > 0.001f; |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 397 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 398 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 399 | @Override |
| 400 | public boolean onTrackballEvent(MotionEvent ev) |
| 401 | { |
| 402 | float x = ev.getX(); |
| 403 | float y = ev.getY(); |
| 404 | //Float tx = new Float(x); |
| 405 | //Float ty = new Float(y); |
| 406 | //Log.e("rs", "tbe " + tx.toString() + ", " + ty.toString()); |
| 407 | |
| 408 | |
| 409 | return true; |
| 410 | } |
| 411 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 412 | public void setApps(ArrayList<ApplicationInfo> list) { |
| 413 | mAllAppsList = list; |
| 414 | if (mRollo != null) { |
| 415 | mRollo.setApps(list); |
| 416 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 417 | mPageCount = countPages(list.size()); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 418 | Log.d(TAG, "setApps mRollo=" + mRollo + " list=" + list); |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 419 | mLocks &= ~LOCK_ICONS_PENDING; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | private void invokeIcon(int index) { |
| 423 | Log.d(TAG, "launch it!!!! index=" + index); |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | private static int countPages(int iconCount) { |
| 427 | int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE; |
| 428 | int pages = iconCount / iconsPerPage; |
| 429 | if (pages*iconsPerPage != iconCount) { |
| 430 | pages++; |
| 431 | } |
| 432 | return pages; |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 433 | } |
| 434 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 435 | public class RolloRS { |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 436 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 437 | // Allocations ====== |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 438 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 439 | private int mWidth; |
| 440 | private int mHeight; |
| 441 | |
| 442 | private Resources mRes; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 443 | private Script mScript; |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 444 | |
| 445 | private Script.Invokable mInvokeMove; |
| 446 | private Script.Invokable mInvokeFling; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 447 | private Script.Invokable mInvokeSetZoomTarget; |
| 448 | private Script.Invokable mInvokeSetZoom; |
Joe Onorato | 360d035 | 2009-09-28 14:37:53 -0400 | [diff] [blame] | 449 | private Script.Invokable mInvokeTouchUp; |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 450 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 451 | private ProgramStore mPSIcons; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 452 | private ProgramStore mPSText; |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 453 | private ProgramFragment mPFColor; |
| 454 | private ProgramFragment mPFTexLinear; |
| 455 | private ProgramFragment mPFTexNearest; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 456 | private ProgramVertex mPV; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 457 | private ProgramVertex mPVOrtho; |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 458 | private SimpleMesh mMesh; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 459 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 460 | private Allocation mHomeButton; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 461 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 462 | private Allocation[] mIcons; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 463 | private int[] mIconIds; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 464 | private Allocation mAllocIconID; |
| 465 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 466 | private Allocation[] mLabels; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 467 | private int[] mLabelIds; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 468 | private Allocation mAllocLabelID; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 469 | private Allocation mSelectedIcon; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 470 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 471 | private int[] mTouchYBorders; |
| 472 | private Allocation mAllocTouchYBorders; |
| 473 | private int[] mTouchXBorders; |
| 474 | private Allocation mAllocTouchXBorders; |
| 475 | |
| 476 | private Bitmap mSelectionBitmap; |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 477 | private Canvas mSelectionCanvas; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 478 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 479 | Params mParams; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 480 | State mState; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 481 | Readback mReadback; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 482 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 483 | class BaseAlloc { |
| 484 | Allocation mAlloc; |
| 485 | Type mType; |
| 486 | |
| 487 | void save() { |
| 488 | mAlloc.data(this); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 489 | } |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 492 | private boolean checkClickOK() { |
| 493 | //android.util.Log.e("rs", "check click " + Float.toString(mReadback.velocity) + ", " + Float.toString(mReadback.posX)); |
| 494 | return (Math.abs(mReadback.velocity) < 0.1f) && |
| 495 | (Math.abs(mReadback.posX - Math.round(mReadback.posX)) < 0.1f); |
| 496 | } |
| 497 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 498 | class Params extends BaseAlloc { |
| 499 | Params() { |
| 500 | mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass"); |
| 501 | mAlloc = Allocation.createTyped(mRS, mType); |
| 502 | save(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 503 | } |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 504 | public int bubbleWidth; |
| 505 | public int bubbleHeight; |
| 506 | public int bubbleBitmapWidth; |
| 507 | public int bubbleBitmapHeight; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 508 | |
| 509 | public int homeButtonId; |
| 510 | public int homeButtonWidth; |
| 511 | public int homeButtonHeight; |
| 512 | public int homeButtonTextureWidth; |
| 513 | public int homeButtonTextureHeight; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | class State extends BaseAlloc { |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 517 | public float newPositionX; |
| 518 | public int newTouchDown; |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 519 | public float flingVelocityX; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 520 | public int iconCount; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 521 | public int selectedIconIndex = -1; |
| 522 | public int selectedIconTexture; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 523 | public float zoomTarget; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 524 | public float zoom; |
| 525 | |
| 526 | State() { |
| 527 | mType = Type.createFromClass(mRS, State.class, 1, "StateClass"); |
| 528 | mAlloc = Allocation.createTyped(mRS, mType); |
| 529 | save(); |
| 530 | } |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 533 | class Readback extends BaseAlloc { |
| 534 | public float posX; |
| 535 | public float velocity; |
| 536 | public float zoom; |
| 537 | |
| 538 | Readback() { |
| 539 | mType = Type.createFromClass(mRS, Readback.class, 1, "ReadbackClass"); |
| 540 | mAlloc = Allocation.createTyped(mRS, mType); |
| 541 | save(); |
| 542 | } |
| 543 | |
| 544 | void read() { |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 545 | if(mAlloc != null) { |
| 546 | mAlloc.read(this); |
| 547 | } |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 548 | } |
| 549 | } |
| 550 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 551 | public RolloRS() { |
| 552 | } |
| 553 | |
| 554 | public void init(Resources res, int width, int height) { |
| 555 | mRes = res; |
| 556 | mWidth = width; |
| 557 | mHeight = height; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 558 | mDefines.recompute(width, height); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 559 | initProgramVertex(); |
| 560 | initProgramFragment(); |
| 561 | initProgramStore(); |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 562 | initMesh(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 563 | initGl(); |
| 564 | initData(); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 565 | initTouchState(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 566 | initRs(); |
| 567 | } |
| 568 | |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 569 | public void initMesh() { |
| 570 | SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 3, |
| 571 | SimpleMesh.TriangleMeshBuilder.TEXTURE_0 | SimpleMesh.TriangleMeshBuilder.COLOR); |
| 572 | |
| 573 | for (int ct=0; ct < 450; ct++) { |
| 574 | float x = 0; |
| 575 | float z = 0; |
| 576 | float l = 1.f; |
| 577 | |
| 578 | if (ct < 190) { |
| 579 | z = 0.1f + 0.05f * (190 - ct); |
| 580 | x = -1; |
| 581 | l = 0.125f + (0.125f / 190.f) * ct; |
| 582 | } else if (ct >= 190 && ct < 200) { |
| 583 | float a = (3.14f * 0.5f) * (0.1f * (ct - 200)); |
| 584 | float s = (float)Math.sin(a); |
| 585 | float c = (float)Math.cos(a); |
| 586 | x = -0.9f + s * 0.1f; |
| 587 | z = 0.1f - c * 0.1f; |
| 588 | l = 0.25f + 0.075f * (ct - 190); |
| 589 | } else if (ct >= 200 && ct < 250) { |
| 590 | z = 0.f; |
| 591 | x = -0.9f + (1.8f * (ct - 200) / 50.f); |
| 592 | } else if (ct >= 250 && ct < 260) { |
| 593 | float a = (3.14f * 0.5f) * (0.1f * (ct - 250)); |
| 594 | float s = (float)Math.sin(a); |
| 595 | float c = (float)Math.cos(a); |
| 596 | x = 0.9f + s * 0.1f; |
| 597 | z = 0.1f - c * 0.1f; |
| 598 | l = 0.25f + 0.075f * (260 - ct); |
| 599 | } else if (ct >= 260) { |
| 600 | z = 0.1f + 0.05f * (ct - 260); |
| 601 | x = 1; |
| 602 | l = 0.125f + (0.125f / 190.f) * (450 - ct); |
| 603 | } |
| 604 | //Log.e("rs", "ct " + Integer.toString(ct) + " x = " + Float.toString(x) + ", z = " + Float.toString(z)); |
| 605 | //Log.e("rs", "ct " + Integer.toString(ct) + " l = " + Float.toString(l)); |
| 606 | float s = ct * 0.1f; |
| 607 | tm.setColor(l, l, l, 0.99f); |
| 608 | tm.setTexture(s, 1); |
| 609 | tm.addVertex(x, -0.5f, z); |
| 610 | tm.setTexture(s, 0); |
| 611 | tm.addVertex(x, 0.5f, z); |
| 612 | } |
| 613 | for (int ct=0; ct < (450*2 - 2); ct+= 2) { |
| 614 | tm.addTriangle(ct, ct+1, ct+2); |
| 615 | tm.addTriangle(ct+1, ct+3, ct+2); |
| 616 | } |
| 617 | mMesh = tm.create(); |
| 618 | mMesh.setName("SMMesh"); |
| 619 | |
| 620 | } |
| 621 | |
| 622 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 623 | private void initProgramVertex() { |
| 624 | ProgramVertex.MatrixAllocation pva = new ProgramVertex.MatrixAllocation(mRS); |
| 625 | pva.setupProjectionNormalized(mWidth, mHeight); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 626 | |
| 627 | ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 628 | pvb.setTextureMatrixEnable(true); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 629 | mPV = pvb.create(); |
| 630 | mPV.setName("PV"); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 631 | mPV.bindAllocation(pva); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 632 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 633 | pva = new ProgramVertex.MatrixAllocation(mRS); |
| 634 | pva.setupOrthoWindow(mWidth, mHeight); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 635 | pvb.setTextureMatrixEnable(true); |
| 636 | mPVOrtho = pvb.create(); |
| 637 | mPVOrtho.setName("PVOrtho"); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 638 | mPVOrtho.bindAllocation(pva); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 639 | |
| 640 | mRS.contextBindProgramVertex(mPV); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 641 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 642 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 643 | private void initProgramFragment() { |
| 644 | Sampler.Builder sb = new Sampler.Builder(mRS); |
| 645 | sb.setMin(Sampler.Value.LINEAR); |
| 646 | sb.setMag(Sampler.Value.LINEAR); |
| 647 | sb.setWrapS(Sampler.Value.CLAMP); |
| 648 | sb.setWrapT(Sampler.Value.CLAMP); |
| 649 | Sampler linear = sb.create(); |
| 650 | |
| 651 | sb.setMin(Sampler.Value.NEAREST); |
| 652 | sb.setMag(Sampler.Value.NEAREST); |
| 653 | Sampler nearest = sb.create(); |
| 654 | |
| 655 | ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null); |
| 656 | mPFColor = bf.create(); |
| 657 | mPFColor.setName("PFColor"); |
| 658 | |
| 659 | bf.setTexEnable(true, 0); |
| 660 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
| 661 | mPFTexLinear = bf.create(); |
| 662 | mPFTexLinear.setName("PFTexLinear"); |
| 663 | mPFTexLinear.bindSampler(linear, 0); |
| 664 | |
| 665 | mPFTexNearest = bf.create(); |
| 666 | mPFTexNearest.setName("PFTexNearest"); |
| 667 | mPFTexNearest.bindSampler(nearest, 0); |
| 668 | } |
| 669 | |
| 670 | private void initProgramStore() { |
| 671 | ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null); |
| 672 | bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 673 | bs.setDitherEnable(true); |
| 674 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 675 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 676 | mPSIcons = bs.create(); |
| 677 | mPSIcons.setName("PSIcons"); |
| 678 | |
| 679 | //bs.setDitherEnable(false); |
| 680 | //mPSText = bs.create(); |
| 681 | //mPSText.setName("PSText"); |
| 682 | } |
| 683 | |
| 684 | private void initGl() { |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 685 | mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 686 | mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32(mRS), |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 687 | mTouchXBorders.length); |
| 688 | mAllocTouchXBorders.data(mTouchXBorders); |
| 689 | |
| 690 | mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 691 | mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32(mRS), |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 692 | mTouchYBorders.length); |
| 693 | mAllocTouchYBorders.data(mTouchYBorders); |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 694 | } |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 695 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 696 | private void initData() { |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 697 | mParams = new Params(); |
| 698 | mState = new State(); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 699 | mReadback = new Readback(); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 700 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 701 | final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 702 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 703 | mParams.bubbleWidth = bubble.getBubbleWidth(); |
| 704 | mParams.bubbleHeight = bubble.getMaxBubbleHeight(); |
| 705 | mParams.bubbleBitmapWidth = bubble.getBitmapWidth(); |
| 706 | mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 707 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 708 | mHomeButton = Allocation.createFromBitmapResource(mRS, mRes, |
| 709 | R.drawable.home_button, Element.RGBA_8888(mRS), false); |
| 710 | mHomeButton.uploadToTexture(0); |
| 711 | mParams.homeButtonId = mHomeButton.getID(); |
| 712 | mParams.homeButtonWidth = 76; |
| 713 | mParams.homeButtonHeight = 68; |
| 714 | mParams.homeButtonTextureWidth = 128; |
| 715 | mParams.homeButtonTextureHeight = 128; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 716 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 717 | mParams.save(); |
| 718 | mState.save(); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 719 | mReadback.save(); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 720 | |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 721 | mSelectionBitmap = Bitmap.createBitmap(Defines.ICON_TEXTURE_WIDTH_PX, |
| 722 | Defines.ICON_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888); |
| 723 | mSelectionCanvas = new Canvas(mSelectionBitmap); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 724 | |
| 725 | Log.d(TAG, "initData calling mRollo.setApps"); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 726 | setApps(null); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 729 | private void initRs() { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 730 | ScriptC.Builder sb = new ScriptC.Builder(mRS); |
| 731 | sb.setScript(mRes, R.raw.rollo); |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 732 | //sb.setScript(mRes, R.raw.rollo2); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 733 | sb.setRoot(true); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 734 | sb.addDefines(mDefines); |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 735 | sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS); |
| 736 | sb.setType(mState.mType, "state", Defines.ALLOC_STATE); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 737 | sb.setType(mReadback.mType, "readback", Defines.ALLOC_READBACK); |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 738 | mInvokeMove = sb.addInvokable("move"); |
| 739 | mInvokeFling = sb.addInvokable("fling"); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 740 | mInvokeSetZoomTarget = sb.addInvokable("setZoomTarget"); |
| 741 | mInvokeSetZoom = sb.addInvokable("setZoom"); |
Joe Onorato | 360d035 | 2009-09-28 14:37:53 -0400 | [diff] [blame] | 742 | mInvokeTouchUp = sb.addInvokable("touchUp"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 743 | mScript = sb.create(); |
| 744 | mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 745 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 746 | mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS); |
| 747 | mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE); |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 748 | mScript.bindAllocation(mReadback.mAlloc, Defines.ALLOC_READBACK); |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 749 | mScript.bindAllocation(mAllocIconID, Defines.ALLOC_ICON_IDS); |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 750 | mScript.bindAllocation(mAllocLabelID, Defines.ALLOC_LABEL_IDS); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 751 | mScript.bindAllocation(mAllocTouchXBorders, Defines.ALLOC_X_BORDERS); |
| 752 | mScript.bindAllocation(mAllocTouchYBorders, Defines.ALLOC_Y_BORDERS); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 753 | |
| 754 | mRS.contextBindRootScript(mScript); |
| 755 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 756 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 757 | private void setApps(ArrayList<ApplicationInfo> list) { |
| 758 | final int count = list != null ? list.size() : 0; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 759 | int allocCount = count; |
| 760 | if(allocCount < 1) { |
| 761 | allocCount = 1; |
| 762 | } |
| 763 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 764 | mIcons = new Allocation[count]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 765 | mIconIds = new int[allocCount]; |
| 766 | mAllocIconID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 767 | |
| 768 | mLabels = new Allocation[count]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 769 | mLabelIds = new int[allocCount]; |
| 770 | mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 771 | |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 772 | Element ie8888 = Element.RGBA_8888(mRS); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 773 | |
| 774 | Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
| 775 | |
| 776 | for (int i=0; i<count; i++) { |
| 777 | final ApplicationInfo item = list.get(i); |
| 778 | |
| 779 | mIcons[i] = Allocation.createFromBitmap(mRS, item.iconBitmap, |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 780 | Element.RGBA_8888(mRS), false); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 781 | mLabels[i] = Allocation.createFromBitmap(mRS, item.titleBitmap, |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 782 | Element.RGBA_8888(mRS), false); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 783 | |
| 784 | mIcons[i].uploadToTexture(0); |
| 785 | mLabels[i].uploadToTexture(0); |
| 786 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 787 | mIconIds[i] = mIcons[i].getID(); |
| 788 | mLabelIds[i] = mLabels[i].getID(); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 789 | } |
| 790 | |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 791 | mAllocIconID.data(mIconIds); |
| 792 | mAllocLabelID.data(mLabelIds); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 793 | |
| 794 | mState.iconCount = count; |
| 795 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 796 | if (mScript != null) { // wtf |
| 797 | mScript.bindAllocation(mAllocIconID, Defines.ALLOC_ICON_IDS); |
| 798 | mScript.bindAllocation(mAllocLabelID, Defines.ALLOC_LABEL_IDS); |
| 799 | } |
| 800 | |
| 801 | mState.save(); |
| 802 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 803 | |
| 804 | void initTouchState() { |
| 805 | int width = getWidth(); |
| 806 | int height = getHeight(); |
| 807 | |
| 808 | int iconsSize; |
| 809 | if (width < height) { |
| 810 | iconsSize = width; |
| 811 | } else { |
| 812 | iconsSize = height; |
| 813 | } |
| 814 | int cellHeight = iconsSize / Defines.ROWS_PER_PAGE; |
| 815 | int cellWidth = iconsSize / Defines.COLUMNS_PER_PAGE; |
| 816 | |
Joe Onorato | 56848b0 | 2009-09-25 13:59:59 -0700 | [diff] [blame] | 817 | int centerY = (height / 2) - (int)(cellHeight * 0.2f); |
| 818 | mTouchYBorders[0] = centerY - (int)(2.8f * cellHeight); |
| 819 | mTouchYBorders[1] = centerY - (int)(1.25f * cellHeight); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 820 | mTouchYBorders[2] = centerY; |
Joe Onorato | 56848b0 | 2009-09-25 13:59:59 -0700 | [diff] [blame] | 821 | mTouchYBorders[3] = centerY + (int)(1.25f * cellHeight);; |
| 822 | mTouchYBorders[4] = centerY + (int)(2.6f * cellHeight); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 823 | |
| 824 | mAllocTouchYBorders.data(mTouchYBorders); |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 825 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 826 | int centerX = (width / 2); |
| 827 | mTouchXBorders[0] = centerX - (2 * cellWidth); |
Joe Onorato | 56848b0 | 2009-09-25 13:59:59 -0700 | [diff] [blame] | 828 | mTouchXBorders[1] = centerX - (int)(0.85f * cellWidth); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 829 | mTouchXBorders[2] = centerX; |
Joe Onorato | 56848b0 | 2009-09-25 13:59:59 -0700 | [diff] [blame] | 830 | mTouchXBorders[3] = centerX + (int)(0.85f * cellWidth); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 831 | mTouchXBorders[4] = centerX + (2 * cellWidth); |
| 832 | |
| 833 | mAllocTouchXBorders.data(mTouchXBorders); |
| 834 | } |
| 835 | |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 836 | int chooseTappedIcon(int x, int y, float page) { |
| 837 | int currentPage = (int)page; |
| 838 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 839 | int col = -1; |
| 840 | int row = -1; |
| 841 | |
| 842 | for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) { |
| 843 | if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) { |
| 844 | col = i; |
| 845 | break; |
| 846 | } |
| 847 | } |
| 848 | for (int i=0; i<Defines.ROWS_PER_PAGE; i++) { |
| 849 | if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) { |
| 850 | row = i; |
| 851 | break; |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | if (row < 0 || col < 0) { |
| 856 | return -1; |
| 857 | } |
| 858 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 859 | return (currentPage * Defines.ROWS_PER_PAGE * Defines.COLUMNS_PER_PAGE) |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 860 | + (row * Defines.ROWS_PER_PAGE) + col; |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * You need to call save() on mState on your own after calling this. |
| 865 | */ |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 866 | void selectIcon(int x, int y, float pos) { |
| 867 | int index = chooseTappedIcon(x, y, pos); |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 868 | selectIcon(index); |
| 869 | } |
| 870 | |
| 871 | void selectIcon(int index) { |
| 872 | Log.d(TAG, "selectIcon index=" + index); |
| 873 | int iconCount = mAllAppsList.size(); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 874 | if (index < 0 || index >= iconCount) { |
| 875 | mState.selectedIconIndex = -1; |
| 876 | return; |
| 877 | } else { |
| 878 | mState.selectedIconIndex = index; |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 879 | |
| 880 | Bitmap selectionBitmap = mSelectionBitmap; |
| 881 | |
| 882 | Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas, |
| 883 | selectionBitmap.getWidth(), selectionBitmap.getHeight(), |
| 884 | mAllAppsList.get(index).iconBitmap); |
| 885 | |
| 886 | mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap, |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 887 | Element.RGBA_8888(mRS), false); |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 888 | mSelectedIcon.uploadToTexture(0); |
| 889 | mState.selectedIconTexture = mSelectedIcon.getID(); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 890 | } |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * You need to call save() on mState on your own after calling this. |
| 895 | */ |
| 896 | void clearSelectedIcon() { |
Joe Onorato | 2ca51dc | 2009-09-16 11:44:14 -0400 | [diff] [blame] | 897 | mState.selectedIconIndex = -1; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 898 | } |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 899 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | |