summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/widgets.c202
1 files changed, 121 insertions, 81 deletions
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c
index 1c3f0b1a10..dae9e58b32 100644
--- a/apps/recorder/widgets.c
+++ b/apps/recorder/widgets.c
@@ -27,69 +27,45 @@
27void progressbar(int x, int y, int width, int height, int percent, int direction) 27void progressbar(int x, int y, int width, int height, int percent, int direction)
28{ 28{
29 int pos; 29 int pos;
30 int i,j;
31 30
32 /* draw horizontal lines */ 31 /* draw box */
33 for(i=x+1;i<=x+width-2;i++) { 32 lcd_drawrect(x, y, width, height);
34 DRAW_PIXEL(i,y);
35 DRAW_PIXEL(i,(y+height-1));
36 }
37
38 /* draw vertical lines */
39 for(i=1;i<height;i++) {
40 DRAW_PIXEL(x,(y+i));
41 DRAW_PIXEL((x+width-1),(y+i));
42 }
43 33
44 /* clear edge pixels */ 34 /* clear edge pixels */
45 CLEAR_PIXEL(x,y); 35 lcd_clearpixel(x, y);
46 CLEAR_PIXEL((x+width-1),y); 36 lcd_clearpixel((x + width - 1), y);
47 CLEAR_PIXEL(x,(y+height-1)); 37 lcd_clearpixel(x, (y + height - 1));
48 CLEAR_PIXEL((x+width-1),(y+height-1)); 38 lcd_clearpixel((x + width - 1), (y + height - 1));
49 39
50 /* clear pixels in progress bar */ 40 /* clear pixels in progress bar */
51 for(i=1;i<=width-2;i++) { 41 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
52 for(j=1;j<=height-2;j++) {
53 CLEAR_PIXEL((x+i),(y+j));
54 CLEAR_PIXEL((x+i),(y+j));
55 }
56 }
57 42
58 /* draw bar */ 43 /* draw bar */
59 pos=percent; 44 pos = percent;
60 if(pos<0) 45 if(pos < 0)
61 pos=0; 46 pos = 0;
62 if(pos>100) 47 if(pos > 100)
63 pos=100; 48 pos = 100;
64 49
65 switch (direction) 50 switch (direction)
66 { 51 {
67 case Grow_Right: 52 case Grow_Right:
68 pos=(width-2)*pos/100; 53 pos=(width - 2) * pos / 100;
69 for(i=1;i<=pos;i++) 54 lcd_fillrect(x + 1, y + 1, pos, height - 2);
70 for(j=1;j<height-1;j++)
71 DRAW_PIXEL((x+i),(y+j));
72 break; 55 break;
73 case Grow_Left: 56 case Grow_Left:
74 pos=(width-2)*(100-pos)/100; 57 pos=(width - 2) * (100 - pos) / 100;
75 for(i=pos+1;i<=width-2;i++) 58 lcd_fillrect(x + pos, y + 1, width - 1 - pos, height - 2);
76 for(j=1;j<height-1;j++)
77 DRAW_PIXEL((x+i),(y+j));
78 break; 59 break;
79 case Grow_Down: 60 case Grow_Down:
80 pos=(height-2)*pos/100; 61 pos=(height - 2) * pos / 100;
81 for(i=1;i<=pos;i++) 62 lcd_fillrect(x + 1, y + 1, width - 2, pos);
82 for(j=1;j<width-1;j++)
83 DRAW_PIXEL((x+j),(y+i));
84 break; 63 break;
85 case Grow_Up: 64 case Grow_Up:
86 pos=(height-2)*(100-pos)/100; 65 pos=(height - 2) * (100 - pos) / 100;
87 for(i=pos+1;i<=height-2;i++) 66 lcd_fillrect(x + 1, y + pos, width - 2, height - 1 - pos);
88 for(j=1;j<width-1;j++)
89 DRAW_PIXEL((x+j),(y+i));
90 break; 67 break;
91 } 68 }
92
93} 69}
94 70
95 71
@@ -99,63 +75,127 @@ void progressbar(int x, int y, int width, int height, int percent, int direction
99void slidebar(int x, int y, int width, int height, int percent, int direction) 75void slidebar(int x, int y, int width, int height, int percent, int direction)
100{ 76{
101 int pos; 77 int pos;
102 int i,j;
103
104 /* draw horizontal lines */
105 for(i=x+1;i<=x+width-2;i++) {
106 DRAW_PIXEL(i,y);
107 DRAW_PIXEL(i,(y+height-1));
108 }
109 78
110 /* draw vertical lines */ 79 /* draw box */
111 for(i=1;i<height;i++) { 80 lcd_drawrect(x, y, width, height);
112 DRAW_PIXEL(x,(y+i));
113 DRAW_PIXEL((x+width-1),(y+i));
114 }
115 81
116 /* clear edge pixels */ 82 /* clear edge pixels */
117 CLEAR_PIXEL(x,y); 83 lcd_clearpixel(x, y);
118 CLEAR_PIXEL((x+width-1),y); 84 lcd_clearpixel((x + width - 1), y);
119 CLEAR_PIXEL(x,(y+height-1)); 85 lcd_clearpixel(x, (y + height - 1));
120 CLEAR_PIXEL((x+width-1),(y+height-1)); 86 lcd_clearpixel((x + width - 1), (y + height - 1));
121 87
122 /* clear pixels in progress bar */ 88 /* clear pixels in progress bar */
123 for(i=1;i<=width-2;i++) 89 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
124 for(j=1;j<=height-2;j++) {
125 CLEAR_PIXEL((x+i),(y+j));
126 CLEAR_PIXEL((x+i),(y+j));
127 }
128 90
129 /* draw point */ 91 /* draw knob */
130 pos=percent; 92 pos = percent;
131 if(pos<0) 93 if(pos < 0)
132 pos=0; 94 pos = 0;
133 if(pos>100) 95 if(pos > 100)
134 pos=100; 96 pos = 100;
135 97
136 switch (direction) 98 switch (direction)
137 { 99 {
138 case Grow_Right: 100 case Grow_Right:
139 pos=(width-height-1)*pos/100; 101 pos = (width - height) * pos / 100;
140 break; 102 break;
141 case Grow_Left: 103 case Grow_Left:
142 pos=(width-height-1)*(100-pos)/100; 104 pos=(width - height) * (100 - pos) / 100;
143 break; 105 break;
144 case Grow_Down: 106 case Grow_Down:
145 pos=(height-width-1)*pos/100; 107 pos=(height - width) * pos / 100;
146 break; 108 break;
147 case Grow_Up: 109 case Grow_Up:
148 pos=(height-width-1)*(100-pos)/100; 110 pos=(height - width) * (100 - pos) / 100;
149 break; 111 break;
150 } 112 }
151 113
152 if(direction == Grow_Left || direction == Grow_Right) 114 if(direction == Grow_Left || direction == Grow_Right)
153 for(i=1;i<height;i++) 115 lcd_fillrect(x + pos + 1, y + 1, height - 2, height - 2);
154 for(j=1;j<height;j++)
155 DRAW_PIXEL((x+pos+i),(y+j));
156 else 116 else
157 for(i=1;i<width;i++) 117 lcd_fillrect(x + 1, y + pos + 1, width - 2, width - 2);
158 for(j=1;j<width;j++) 118}
159 DRAW_PIXEL((x+i),(y+pos+j)); 119
120
121/*
122 * Print a scroll bar
123 */
124void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation)
125{
126 int min;
127 int max;
128 int start;
129 int size;
130
131 /* draw box */
132 lcd_drawrect(x, y, width, height);
133
134 /* clear edge pixels */
135 lcd_clearpixel(x, y);
136 lcd_clearpixel((x + width - 1), y);
137 lcd_clearpixel(x, (y + height - 1));
138 lcd_clearpixel((x + width - 1), (y + height - 1));
139
140 /* clear pixels in progress bar */
141 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
142
143 /* min should be min */
144 if(min_shown < max_shown) {
145 min = min_shown;
146 max = max_shown;
147 }
148 else {
149 min = max_shown;
150 max = min_shown;
151 }
152
153 /* limit min and max */
154 if(min < 0)
155 min = 0;
156 if(min > items)
157 min = items;
158
159 if(max < 0)
160 max = 0;
161 if(max > items)
162 max = items;
163
164 /* calc start and end of the knob */
165 if(items > 0 && items > (max - min)) {
166 if(orientation == VERTICAL) {
167 size = (height - 2) * (max - min) / items;
168 start = (height - 2 - size) * min / (items - (max - min));
169 }
170 else {
171 size = (width - 2) * (max - min) / items;
172 start = (width - 2 - size) * min / (items - (max - min));
173 }
174 }
175 else { /* if null draw a full bar */
176 start = 0;
177 if(orientation == VERTICAL)
178 size = (height - 2);
179 else
180 size = (width - 2);
181 }
182
183 /* knob has a width */
184 if(size != 0) {
185 if(orientation == VERTICAL)
186 lcd_fillrect(x + 1, y + start + 1, width - 2, size);
187 else
188 lcd_fillrect(x + start + 1, y + 1, size, height - 2);
189 }
190 else { /* width of knob is null */
191 if(orientation == VERTICAL) {
192 start = (height - 2 - 1) * min / items;
193 lcd_fillrect(x + 1, y + start + 1, width - 2, 1);
194 }
195 else {
196 start = (width - 2 - 1) * min / items;
197 lcd_fillrect(x + start + 1, y + 1, 1, height - 2);
198 }
199 }
160} 200}
161#endif 201#endif