summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hak <adiamas@rockbox.org>2003-08-10 08:58:54 +0000
committerRobert Hak <adiamas@rockbox.org>2003-08-10 08:58:54 +0000
commit7a38db572ef1d6435d52d66bc169baf6fde3b040 (patch)
tree231f30585dbe17b81c53511346b843fe7b384456
parent8afb858804c3dbaadf70f84a32f3d9e30b3e7a11 (diff)
downloadrockbox-7a38db572ef1d6435d52d66bc169baf6fde3b040.tar.gz
rockbox-7a38db572ef1d6435d52d66bc169baf6fde3b040.zip
a minor bit of code policing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3928 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/recorder/widgets.c93
1 files changed, 33 insertions, 60 deletions
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c
index 9ee7dbc66a..99257495cf 100644
--- a/apps/recorder/widgets.c
+++ b/apps/recorder/widgets.c
@@ -21,26 +21,21 @@
21#include "widgets.h" 21#include "widgets.h"
22 22
23#ifdef HAVE_LCD_BITMAP 23#ifdef HAVE_LCD_BITMAP
24/*
25 * Print a progress bar
26 */
27void progressbar(int x, int y, int width, int height, int percent, int direction)
28{
29 int pos;
30
31 /* check position and dimensions */
32 if(x < 0)
33 return;
34 24
35 if(y < 0) 25/* Valid dimensions return true, invalid false */
36 return; 26bool valid_dimensions(int x, int y, int width, int height)
37 27{
38 if(x + width > LCD_WIDTH) 28 if((x < 0) || (x + width > LCD_WIDTH) ||
39 return; 29 (y < 0) || (y + height > LCD_HEIGHT))
30 {
31 return false;
32 }
40 33
41 if(y + height > LCD_HEIGHT) 34 return true;
42 return; 35}
43 36
37void init_bar(int x, int y, int width, int height)
38{
44 /* draw box */ 39 /* draw box */
45 lcd_drawrect(x, y, width, height); 40 lcd_drawrect(x, y, width, height);
46 41
@@ -52,6 +47,21 @@ void progressbar(int x, int y, int width, int height, int percent, int direction
52 47
53 /* clear pixels in progress bar */ 48 /* clear pixels in progress bar */
54 lcd_clearrect(x + 1, y + 1, width - 2, height - 2); 49 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
50}
51
52/*
53 * Print a progress bar
54 */
55void progressbar(int x, int y, int width, int height, int percent,
56 int direction)
57{
58 int pos;
59
60 /* check position and dimensions */
61 if (!valid_dimensions(x, y, width, height))
62 return;
63
64 init_bar(x, y, width, height);
55 65
56 /* draw bar */ 66 /* draw bar */
57 pos = percent; 67 pos = percent;
@@ -90,29 +100,10 @@ void slidebar(int x, int y, int width, int height, int percent, int direction)
90 int pos; 100 int pos;
91 101
92 /* check position and dimensions */ 102 /* check position and dimensions */
93 if(x < 0) 103 if (!valid_dimensions(x, y, width, height))
94 return;
95
96 if(y < 0)
97 return;
98
99 if(x + width > LCD_WIDTH)
100 return;
101
102 if(y + height > LCD_HEIGHT)
103 return; 104 return;
104 105
105 /* draw box */ 106 init_bar(x, y, width, height);
106 lcd_drawrect(x, y, width, height);
107
108 /* clear edge pixels */
109 lcd_clearpixel(x, y);
110 lcd_clearpixel((x + width - 1), y);
111 lcd_clearpixel(x, (y + height - 1));
112 lcd_clearpixel((x + width - 1), (y + height - 1));
113
114 /* clear pixels in progress bar */
115 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
116 107
117 /* draw knob */ 108 /* draw knob */
118 pos = percent; 109 pos = percent;
@@ -147,7 +138,8 @@ void slidebar(int x, int y, int width, int height, int percent, int direction)
147/* 138/*
148 * Print a scroll bar 139 * Print a scroll bar
149 */ 140 */
150void scrollbar(int x, int y, int width, int height, int items, int min_shown, int max_shown, int orientation) 141void scrollbar(int x, int y, int width, int height, int items, int min_shown,
142 int max_shown, int orientation)
151{ 143{
152 int min; 144 int min;
153 int max; 145 int max;
@@ -155,29 +147,10 @@ void scrollbar(int x, int y, int width, int height, int items, int min_shown, in
155 int size; 147 int size;
156 148
157 /* check position and dimensions */ 149 /* check position and dimensions */
158 if(x < 0) 150 if (!valid_dimensions(x, y, width, height))
159 return;
160
161 if(y < 0)
162 return; 151 return;
163 152
164 if(x + width > LCD_WIDTH) 153 init_bar(x, y, width, height);
165 return;
166
167 if(y + height > LCD_HEIGHT)
168 return;
169
170 /* draw box */
171 lcd_drawrect(x, y, width, height);
172
173 /* clear edge pixels */
174 lcd_clearpixel(x, y);
175 lcd_clearpixel((x + width - 1), y);
176 lcd_clearpixel(x, (y + height - 1));
177 lcd_clearpixel((x + width - 1), (y + height - 1));
178
179 /* clear pixels in progress bar */
180 lcd_clearrect(x + 1, y + 1, width - 2, height - 2);
181 154
182 /* min should be min */ 155 /* min should be min */
183 if(min_shown < max_shown) { 156 if(min_shown < max_shown) {