blob: 3c3f46383755bc7707a61a46d80bf21589c134fa [file] [log] [blame]
Alex Sakhartchouk27f50522010-08-18 15:46:43 -07001// Copyright (C) 2009 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma version(1)
16
17#pragma rs java_package_name(com.android.samples)
18
19#include "rs_graphics.rsh"
20
21float gDY;
22
23rs_font gItalic;
24
25typedef struct ListAllocs_s {
26 rs_allocation text;
27} ListAllocs;
28
29ListAllocs *gList;
30
31#pragma rs export_var(gDY, gItalic, gList)
32
33void init() {
34 gDY = 0.0f;
35}
36
37int textPos = 0;
38
39int root(int launchID) {
40
41 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
42 rsgClearDepth(1.0f);
43
44 textPos -= (int)gDY*2;
45 gDY *= 0.95;
46
47 rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
48 rsgBindFont(gItalic);
49 color(0.2, 0.2, 0.2, 0);
50
51 rs_allocation listAlloc = rsGetAllocation(gList);
52 int allocSize = rsAllocationGetDimX(listAlloc);
53
54 int width = rsgGetWidth();
55 int height = rsgGetHeight();
56
57 int itemHeight = 80;
58 int currentYPos = itemHeight + textPos;
59
60 for(int i = 0; i < allocSize; i ++) {
61 if(currentYPos - itemHeight > height) {
62 break;
63 }
64
65 if(currentYPos > 0) {
66 rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
67 rsgDrawText(gList[i].text, 30, currentYPos - 32);
68 }
69 currentYPos += itemHeight;
70 }
71
72 return 10;
73}