blob: acee82bf0177420b6040e3b224a66088ce59cc01 [file] [log] [blame]
Jason Sams0f505e52009-10-13 17:18:35 -07001#pragma version(1)
Jason Sams14f67ed2010-05-11 14:02:43 -07002
Shih-wei Liaoc8149652010-06-14 11:46:11 -07003#pragma rs java_package_name(com.android.launcher2)
4
Shih-wei Liaoafb81d42010-07-19 16:20:03 -07005#include "rs_graphics.rsh"
Jason Sams0f505e52009-10-13 17:18:35 -07006
7#define PI 3.14159f
8
Jason Sams14f67ed2010-05-11 14:02:43 -07009// Constants from Java
10int COLUMNS_PER_PAGE_PORTRAIT;
11int ROWS_PER_PAGE_PORTRAIT;
12int COLUMNS_PER_PAGE_LANDSCAPE;
13int ROWS_PER_PAGE_LANDSCAPE;
14
Jason Sams14f67ed2010-05-11 14:02:43 -070015int gIconCount;
Jason Sams1aa4ff02010-06-15 14:59:57 -070016int gSelectedIconIndex = -1;
Jason Sams14f67ed2010-05-11 14:02:43 -070017rs_allocation gSelectedIconTexture;
Jason Sams14f67ed2010-05-11 14:02:43 -070018rs_allocation gHomeButton;
Jason Sams14f67ed2010-05-11 14:02:43 -070019
20rs_program_fragment gPFTexNearest;
21rs_program_fragment gPFTexMip;
22rs_program_fragment gPFTexMipAlpha;
23rs_program_vertex gPVCurve;
24rs_program_store gPS;
25rs_mesh gSMCell;
26
27rs_allocation *gIconIDs;
28rs_allocation *gLabelIDs;
29
Jason Sams1aa4ff02010-06-15 14:59:57 -070030typedef struct VpConsts {
Alex Sakhartchouk95252b42010-09-13 20:44:01 -070031 rs_matrix4x4 Proj;
Jason Sams14f67ed2010-05-11 14:02:43 -070032 float4 Position;
33 float4 ScaleOffset;
34 float2 BendPos;
35 float2 ImgSize;
36} VpConsts_t;
37VpConsts_t *vpConstants;
38
39
Jason Sams60a55bb2010-06-18 15:11:19 -070040#pragma rs export_var(COLUMNS_PER_PAGE_PORTRAIT, ROWS_PER_PAGE_PORTRAIT, COLUMNS_PER_PAGE_LANDSCAPE, ROWS_PER_PAGE_LANDSCAPE, gIconCount, gSelectedIconIndex, gSelectedIconTexture, gHomeButton, gTargetPos, gPFTexNearest, gPFTexMip, gPFTexMipAlpha, gPVCurve, gPS, gSMCell, gIconIDs, gLabelIDs, vpConstants)
41#pragma rs export_func(move, moveTo, setZoom, fling)
Jason Sams14f67ed2010-05-11 14:02:43 -070042
Jason Sams0f505e52009-10-13 17:18:35 -070043
44// Attraction to center values from page edge to page center.
Jason Samsad1bdf02010-05-14 17:54:50 -070045static float g_AttractionTable[9] = {20.f, 20.f, 20.f, 10.f, -10.f, -20.f, -20.f, -20.f, -20.f};
46static float g_FrictionTable[9] = {10.f, 10.f, 11.f, 15.f, 15.f, 11.f, 10.f, 10.f, 10.f};
47static float g_PhysicsTableSize = 7;
Jason Sams0f505e52009-10-13 17:18:35 -070048
Jason Sams60a55bb2010-06-18 15:11:19 -070049static float gZoomTarget;
50static float gTargetPos;
Jason Samsad1bdf02010-05-14 17:54:50 -070051static float g_PosPage = 0.f;
52static float g_PosVelocity = 0.f;
53static float g_LastPositionX = 0.f;
Jason Sams60a55bb2010-06-18 15:11:19 -070054static bool g_LastTouchDown = false;
Jason Sams14f67ed2010-05-11 14:02:43 -070055static float g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -070056static int g_PosMax;
Jason Samsad1bdf02010-05-14 17:54:50 -070057static float g_Zoom = 0.f;
58static float g_Animation = 1.f;
Jason Sams14f67ed2010-05-11 14:02:43 -070059static float g_OldPosPage;
60static float g_OldPosVelocity;
61static float g_OldZoom;
Jason Samsad1bdf02010-05-14 17:54:50 -070062static float g_MoveToTotalTime = 0.2f;
63static float g_MoveToTime = 0.f;
64static float g_MoveToOldPos = 0.f;
Jason Samsc1c521e2009-10-19 14:45:45 -070065
Jason Sams14f67ed2010-05-11 14:02:43 -070066static int g_Cols;
67static int g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -070068
Alex Sakhartchouk95252b42010-09-13 20:44:01 -070069rs_allocation g_VPConstAlloc;
70
Jason Sams0f505e52009-10-13 17:18:35 -070071// Drawing constants, should be parameters ======
72#define VIEW_ANGLE 1.28700222f
73
Jason Sams0f505e52009-10-13 17:18:35 -070074
Jason Sams14f67ed2010-05-11 14:02:43 -070075static void updateReadback() {
Jason Samsad1bdf02010-05-14 17:54:50 -070076 if ((g_OldPosPage != g_PosPage) ||
77 (g_OldPosVelocity != g_PosVelocity) ||
78 (g_OldZoom != g_Zoom)) {
Jason Sams0f505e52009-10-13 17:18:35 -070079
80 g_OldPosPage = g_PosPage;
81 g_OldPosVelocity = g_PosVelocity;
82 g_OldZoom = g_Zoom;
83
84 int i[3];
85 i[0] = g_PosPage * (1 << 16);
86 i[1] = g_PosVelocity * (1 << 16);
87 i[2] = g_OldZoom * (1 << 16);
Jason Sams500d36e2010-07-28 11:15:33 -070088 rsSendToClientBlocking(1, &i[0], sizeof(i));
Jason Samsad1bdf02010-05-14 17:54:50 -070089 }
Jason Sams0f505e52009-10-13 17:18:35 -070090}
91
Jason Sams0f505e52009-10-13 17:18:35 -070092void init() {
Jason Sams41b61c82009-10-15 15:40:54 -070093}
Jason Sams0f505e52009-10-13 17:18:35 -070094
Jason Sams60a55bb2010-06-18 15:11:19 -070095void move(float newPos) {
Jason Sams0f505e52009-10-13 17:18:35 -070096 if (g_LastTouchDown) {
Jason Sams60a55bb2010-06-18 15:11:19 -070097 float dx = -(newPos - g_LastPositionX);
Jason Sams0f505e52009-10-13 17:18:35 -070098 g_PosVelocity = 0;
Jason Sams6ec11bc2010-01-19 17:56:52 -080099 g_PosPage += dx * 5.2f;
Jason Sams0f505e52009-10-13 17:18:35 -0700100
Jason Samsc8514792009-10-29 14:27:29 -0700101 float pmin = -0.49f;
102 float pmax = g_PosMax + 0.49f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700103 g_PosPage = clamp(g_PosPage, pmin, pmax);
Jason Sams0f505e52009-10-13 17:18:35 -0700104 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700105 g_LastTouchDown = true;
106 g_LastPositionX = newPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700107 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700108}
109
Jason Sams60a55bb2010-06-18 15:11:19 -0700110void moveTo(float targetPos) {
111 gTargetPos = targetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700112 g_MoveToTime = g_MoveToTotalTime;
113 g_PosVelocity = 0;
114 g_MoveToOldPos = g_PosPage;
115}
116
Jason Sams60a55bb2010-06-18 15:11:19 -0700117void setZoom(float z, /*bool*/ int animate) {
118 gZoomTarget = z;
119 if (gZoomTarget < 0.001f) {
120 gZoomTarget = 0;
121 }
122 if (!animate) {
123 g_Zoom = gZoomTarget;
124 }
Joe Onorato3a8820b2009-11-10 15:06:42 -0800125 updateReadback();
126}
127
Jason Sams60a55bb2010-06-18 15:11:19 -0700128void fling(float newPos, float vel) {
129 move(newPos);
130
131 g_LastTouchDown = false;
132 g_PosVelocity = -vel * 4;
Jason Sams14f67ed2010-05-11 14:02:43 -0700133 float av = fabs(g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700134 float minVel = 3.5f;
135
Jason Sams13a75d52010-05-19 16:38:04 -0700136 minVel *= 1.f - (fabs(rsFrac(g_PosPage + 0.5f) - 0.5f) * 0.45f);
Jason Sams0f505e52009-10-13 17:18:35 -0700137
138 if (av < minVel && av > 0.2f) {
139 if (g_PosVelocity > 0) {
140 g_PosVelocity = minVel;
141 } else {
142 g_PosVelocity = -minVel;
143 }
144 }
145
146 if (g_PosPage <= 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700147 g_PosVelocity = max(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700148 }
149 if (g_PosPage > g_PosMax) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700150 g_PosVelocity = min(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700151 }
152}
153
Jason Sams14f67ed2010-05-11 14:02:43 -0700154// Interpolates values in the range 0..1 to a curve that eases in
155// and out.
156static float getInterpolation(float input) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700157 return (cos((input + 1) * PI) * 0.5f) + 0.5f;
Jason Sams0f505e52009-10-13 17:18:35 -0700158}
159
Mike Cleron7d5d7462009-10-20 14:06:00 -0700160
Jason Sams14f67ed2010-05-11 14:02:43 -0700161static void updatePos() {
Jason Sams0f505e52009-10-13 17:18:35 -0700162 if (g_LastTouchDown) {
163 return;
164 }
165
Jason Sams13a75d52010-05-19 16:38:04 -0700166 float tablePosNorm = rsFrac(g_PosPage + 0.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700167 float tablePosF = tablePosNorm * g_PhysicsTableSize;
168 int tablePosI = tablePosF;
169 float tablePosFrac = tablePosF - tablePosI;
Jason Sams14f67ed2010-05-11 14:02:43 -0700170 float accel = mix(g_AttractionTable[tablePosI],
Jason Sams0f505e52009-10-13 17:18:35 -0700171 g_AttractionTable[tablePosI + 1],
172 tablePosFrac) * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700173 float friction = mix(g_FrictionTable[tablePosI],
Jason Sams2e19c052009-10-20 18:19:55 -0700174 g_FrictionTable[tablePosI + 1],
175 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700176
Jason Samsc1c521e2009-10-19 14:45:45 -0700177 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700178 // New position is old posiition + (total distance) * (interpolated time)
Jason Sams14f67ed2010-05-11 14:02:43 -0700179 g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700180 g_MoveToTime -= g_DT;
181 if (g_MoveToTime <= 0) {
182 g_MoveToTime = 0;
Jason Sams14f67ed2010-05-11 14:02:43 -0700183 g_PosPage = gTargetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700184 }
185 return;
186 }
187
Jason Sams0f505e52009-10-13 17:18:35 -0700188 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams14f67ed2010-05-11 14:02:43 -0700189 if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700190 g_PosVelocity += accel;
191 }
Jason Sams13a75d52010-05-19 16:38:04 -0700192 //RS_DEBUG(g_PosPage);
193 //RS_DEBUG(g_PosVelocity);
194 //RS_DEBUG(friction);
195 //RS_DEBUG(accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700196
Jason Samsc8514792009-10-29 14:27:29 -0700197 // Normal physics
198 if (g_PosVelocity > 0) {
199 g_PosVelocity -= friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700200 g_PosVelocity = max(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700201 } else {
202 g_PosVelocity += friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700203 g_PosVelocity = min(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700204 }
205
Jason Sams14f67ed2010-05-11 14:02:43 -0700206 if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700207 // Special get back to center and overcome friction physics.
208 float t = tablePosNorm - 0.5f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700209 if (fabs(t) < (friction * g_DT)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700210 // really close, just snap
Jason Sams14f67ed2010-05-11 14:02:43 -0700211 g_PosPage = round(g_PosPage);
Jason Sams0f505e52009-10-13 17:18:35 -0700212 g_PosVelocity = 0;
213 } else {
214 if (t > 0) {
215 g_PosVelocity = -friction;
216 } else {
217 g_PosVelocity = friction;
218 }
219 }
Jason Sams0f505e52009-10-13 17:18:35 -0700220 }
Jason Sams0f505e52009-10-13 17:18:35 -0700221
222 // Check for out of boundry conditions.
223 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700224 float damp = 1.0f + (g_PosPage * 4);
225 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700226 g_PosVelocity *= damp;
227 }
228 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700229 float damp = 1.0f - ((g_PosPage - g_PosMax) * 4);
230 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700231 g_PosVelocity *= damp;
232 }
Jason Samsc8514792009-10-29 14:27:29 -0700233
234 g_PosPage += g_PosVelocity * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700235 g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f);
Jason Sams0f505e52009-10-13 17:18:35 -0700236}
237
Jason Sams14f67ed2010-05-11 14:02:43 -0700238static void
Jason Sams0f505e52009-10-13 17:18:35 -0700239draw_home_button()
240{
Jason Sams13a75d52010-05-19 16:38:04 -0700241 rsgBindTexture(gPFTexNearest, 0, gHomeButton);
Jason Sams0f505e52009-10-13 17:18:35 -0700242
Jason Sams13a75d52010-05-19 16:38:04 -0700243 float w = rsgGetWidth();
244 float h = rsgGetHeight();
245 float tw = rsAllocationGetDimX(gHomeButton);
246 float th = rsAllocationGetDimY(gHomeButton);
Jason Sams76512482010-02-04 16:31:35 -0800247
248 float x;
249 float y;
Jason Sams13a75d52010-05-19 16:38:04 -0700250 if (w > h) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700251 x = w - (tw * (1 - g_Animation)) + 20;
252 y = (h - th) * 0.5f;
Jason Sams76512482010-02-04 16:31:35 -0800253 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700254 x = (w - tw) / 2;
255 y = -g_Animation * th;
Jason Sams76512482010-02-04 16:31:35 -0800256 y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
257 }
258
Jason Sams13a75d52010-05-19 16:38:04 -0700259 rsgDrawSpriteScreenspace(x, y, 0, tw, th);
Jason Sams0f505e52009-10-13 17:18:35 -0700260}
261
Jason Sams14f67ed2010-05-11 14:02:43 -0700262static void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700263{
Jason Sams13a75d52010-05-19 16:38:04 -0700264 float h = rsgGetHeight();
265 float w = rsgGetWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700266
267 int intRowOffset = rowOffset;
268 float rowFrac = rowOffset - intRowOffset;
Jason Sams13a75d52010-05-19 16:38:04 -0700269 float colWidth = 120.f;//w / 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700270 float rowHeight = colWidth + 25.f;
Jason Samsb4ecab22010-01-19 16:43:26 -0800271 float yoff = 0.5f * h + 1.5f * rowHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700272
273 int row, col;
Jason Sams76512482010-02-04 16:31:35 -0800274 int colCount = 4;
275 if (w > h) {
276 colCount = 6;
277 rowHeight -= 12.f;
278 yoff = 0.47f * h + 1.0f * rowHeight;
279 }
280
281 int iconNum = (intRowOffset - 5) * colCount;
282
Jason Sams13a75d52010-05-19 16:38:04 -0700283 rsgBindProgramVertex(gPVCurve);
Jason Samsb4ecab22010-01-19 16:43:26 -0800284
Jason Sams76512482010-02-04 16:31:35 -0800285 vpConstants->Position.z = p;
Jason Samsb4ecab22010-01-19 16:43:26 -0800286
287 for (row = -5; row < 15; row++) {
Jason Sams0f505e52009-10-13 17:18:35 -0700288 float y = yoff - ((-rowFrac + row) * rowHeight);
289
Jason Sams76512482010-02-04 16:31:35 -0800290 for (col=0; col < colCount; col++) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700291 if (iconNum >= gIconCount) {
Jason Sams0f505e52009-10-13 17:18:35 -0700292 return;
293 }
294
295 if (iconNum >= 0) {
Jason Samsb4ecab22010-01-19 16:43:26 -0800296 float x = colWidth * col + (colWidth / 2);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800297 vpConstants->Position.x = x + 0.2f;
Jason Sams1a94ee32010-01-20 13:34:30 -0800298
Jason Samsf0d03e42010-08-13 12:18:01 -0700299 if (gSelectedIconIndex == iconNum && !p && rsIsObject(gSelectedIconTexture)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700300 rsgBindProgramFragment(gPFTexNearest);
301 rsgBindTexture(gPFTexNearest, 0, gSelectedIconTexture);
302 vpConstants->ImgSize.x = rsAllocationGetDimX(gSelectedIconTexture);
303 vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
304 vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
305 - rsAllocationGetDimY(gIconIDs[iconNum])) * 0.5f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700306 rsAllocationMarkDirty(g_VPConstAlloc);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700307 rsgDrawMesh(gSMCell);
Jason Sams37f262d2010-01-20 11:19:51 -0800308 }
309
Jason Sams13a75d52010-05-19 16:38:04 -0700310 rsgBindProgramFragment(gPFTexMip);
311 vpConstants->ImgSize.x = rsAllocationGetDimX(gIconIDs[iconNum]);
312 vpConstants->ImgSize.y = rsAllocationGetDimY(gIconIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800313 vpConstants->Position.y = y - 0.2f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700314 rsAllocationMarkDirty(g_VPConstAlloc);
Jason Sams13a75d52010-05-19 16:38:04 -0700315 rsgBindTexture(gPFTexMip, 0, gIconIDs[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700316 rsgDrawMesh(gSMCell);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700317
Jason Sams13a75d52010-05-19 16:38:04 -0700318 rsgBindProgramFragment(gPFTexMipAlpha);
319 vpConstants->ImgSize.x = rsAllocationGetDimX(gLabelIDs[iconNum]);
320 vpConstants->ImgSize.y = rsAllocationGetDimY(gLabelIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800321 vpConstants->Position.y = y - 64.f - 0.2f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700322 rsAllocationMarkDirty(g_VPConstAlloc);
Jason Sams13a75d52010-05-19 16:38:04 -0700323 rsgBindTexture(gPFTexMipAlpha, 0, gLabelIDs[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700324 rsgDrawMesh(gSMCell);
Jason Sams0f505e52009-10-13 17:18:35 -0700325 }
326 iconNum++;
327 }
328 }
329}
330
Jason Sams0f505e52009-10-13 17:18:35 -0700331
Jason Sams14f67ed2010-05-11 14:02:43 -0700332int root()
Jason Sams0f505e52009-10-13 17:18:35 -0700333{
334 // Compute dt in seconds.
Jason Samsb52dfa02009-10-14 20:16:14 -0700335 // physics may break if DT is large.
Jason Sams500d36e2010-07-28 11:15:33 -0700336 g_DT = min(rsGetDt(), 0.1f);
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700337 g_VPConstAlloc = rsGetAllocation(vpConstants);
Jason Sams0f505e52009-10-13 17:18:35 -0700338
Jason Sams14f67ed2010-05-11 14:02:43 -0700339 if (g_Zoom != gZoomTarget) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800340 float dz = g_DT * 1.7f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700341 if (gZoomTarget < 0.5f) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800342 dz = -dz;
Jason Sams0f505e52009-10-13 17:18:35 -0700343 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700344 if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) {
345 g_Zoom = gZoomTarget;
Jason Sams0f505e52009-10-13 17:18:35 -0700346 } else {
347 g_Zoom += dz;
348 }
349 updateReadback();
350 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700351 g_Animation = pow(1.f - g_Zoom, 3.f);
Jason Sams0f505e52009-10-13 17:18:35 -0700352
353 // Set clear value to dim the background based on the zoom position.
Jason Samsad1bdf02010-05-14 17:54:50 -0700354 if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700355 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Jason Sams0f505e52009-10-13 17:18:35 -0700356 // When we're zoomed out and not tracking motion events, reset the pos to 0.
357 if (!g_LastTouchDown) {
358 g_PosPage = 0;
359 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700360 return 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700361 } else {
Jason Sams13a75d52010-05-19 16:38:04 -0700362 rsgClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700363 }
364
Jason Sams13a75d52010-05-19 16:38:04 -0700365 rsgBindProgramStore(gPS);
366
Jason Sams0f505e52009-10-13 17:18:35 -0700367 // icons & labels
Jason Sams13a75d52010-05-19 16:38:04 -0700368 if (rsgGetWidth() > rsgGetHeight()) {
Jason Samsad1bdf02010-05-14 17:54:50 -0700369 g_Cols = COLUMNS_PER_PAGE_LANDSCAPE;
370 g_Rows = ROWS_PER_PAGE_LANDSCAPE;
Joe Onorato20e7a562010-03-18 17:12:52 -0700371 } else {
Jason Samsad1bdf02010-05-14 17:54:50 -0700372 g_Cols = COLUMNS_PER_PAGE_PORTRAIT;
373 g_Rows = ROWS_PER_PAGE_PORTRAIT;
Jason Samscc903492010-03-12 12:46:04 -0800374 }
Jason Samsad1bdf02010-05-14 17:54:50 -0700375
Jason Sams14f67ed2010-05-11 14:02:43 -0700376 g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -0700377 if (g_PosMax < 0) g_PosMax = 0;
378
Jason Samscc903492010-03-12 12:46:04 -0800379 updatePos();
Jason Sams0f505e52009-10-13 17:18:35 -0700380 updateReadback();
381
Jason Sams0f505e52009-10-13 17:18:35 -0700382 // Draw the icons ========================================
Jason Sams6471c8b2010-01-20 14:15:22 -0800383 drawFrontGrid(g_PosPage, g_Animation);
Jason Samsc8514792009-10-29 14:27:29 -0700384
Jason Sams13a75d52010-05-19 16:38:04 -0700385 rsgBindProgramFragment(gPFTexNearest);
Jason Samsb52dfa02009-10-14 20:16:14 -0700386 draw_home_button();
Jason Sams60a55bb2010-06-18 15:11:19 -0700387 return (g_PosVelocity != 0) || rsFrac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700388}
389
Jason Sams14f67ed2010-05-11 14:02:43 -0700390