diff options
author | Ben Basha <benbasha@rockbox.org> | 2006-02-10 13:57:11 +0000 |
---|---|---|
committer | Ben Basha <benbasha@rockbox.org> | 2006-02-10 13:57:11 +0000 |
commit | e0622ab588583d1148af54c0e856ae63339a3491 (patch) | |
tree | 89ee56eb249b4a02399690e35ea3d08d031ffcb9 /apps/gui/scrollbar.c | |
parent | 1e385fdaeb7f21d70c8f2dea180ce75461ac27b9 (diff) | |
download | rockbox-e0622ab588583d1148af54c0e856ae63339a3491.tar.gz rockbox-e0622ab588583d1148af54c0e856ae63339a3491.zip |
add a bitmap progress bar option + add %P|filename.bmp| tag to the WPS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8648 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/scrollbar.c')
-rw-r--r-- | apps/gui/scrollbar.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/apps/gui/scrollbar.c b/apps/gui/scrollbar.c index 73c523f56a..4cf92f4b47 100644 --- a/apps/gui/scrollbar.c +++ b/apps/gui/scrollbar.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifdef HAVE_LCD_BITMAP | 21 | #ifdef HAVE_LCD_BITMAP |
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "limits.h" | 23 | #include "limits.h" |
24 | #include "bmp.h" | ||
24 | 25 | ||
25 | void gui_scrollbar_draw(struct screen * screen, int x, int y, | 26 | void gui_scrollbar_draw(struct screen * screen, int x, int y, |
26 | int width, int height, int items, | 27 | int width, int height, int items, |
@@ -101,4 +102,94 @@ void gui_scrollbar_draw(struct screen * screen, int x, int y, | |||
101 | else | 102 | else |
102 | screen->fillrect(x + start + 1, y + 1, size, height - 2); | 103 | screen->fillrect(x + start + 1, y + 1, size, height - 2); |
103 | } | 104 | } |
105 | |||
106 | void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap bm, int x, int y, | ||
107 | int width, int height, int items, | ||
108 | int min_shown, int max_shown, | ||
109 | enum orientation orientation) | ||
110 | { | ||
111 | int min; | ||
112 | int max; | ||
113 | int inner_len; | ||
114 | int start; | ||
115 | int size; | ||
116 | |||
117 | screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
118 | |||
119 | /* clear pixels in progress bar */ | ||
120 | screen->fillrect(x, y, width, height); | ||
121 | |||
122 | /* min should be min */ | ||
123 | if(min_shown < max_shown) { | ||
124 | min = min_shown; | ||
125 | max = max_shown; | ||
126 | } | ||
127 | else { | ||
128 | min = max_shown; | ||
129 | max = min_shown; | ||
130 | } | ||
131 | |||
132 | /* limit min and max */ | ||
133 | if(min < 0) | ||
134 | min = 0; | ||
135 | if(min > items) | ||
136 | min = items; | ||
137 | |||
138 | if(max < 0) | ||
139 | max = 0; | ||
140 | if(max > items) | ||
141 | max = items; | ||
142 | |||
143 | if (orientation == VERTICAL) | ||
144 | inner_len = height; | ||
145 | else | ||
146 | inner_len = width; | ||
147 | |||
148 | /* avoid overflows */ | ||
149 | while (items > (INT_MAX / inner_len)) { | ||
150 | items >>= 1; | ||
151 | min >>= 1; | ||
152 | max >>= 1; | ||
153 | } | ||
154 | |||
155 | /* calc start and end of the knob */ | ||
156 | if (items > 0 && items > (max - min)) { | ||
157 | size = inner_len * (max - min) / items; | ||
158 | if (size == 0) { /* width of knob is null */ | ||
159 | size = 1; | ||
160 | start = (inner_len - 1) * min / items; | ||
161 | } else { | ||
162 | start = (inner_len - size) * min / (items - (max - min)); | ||
163 | } | ||
164 | } else { /* if null draw full bar */ | ||
165 | size = inner_len; | ||
166 | start = 0; | ||
167 | } | ||
168 | |||
169 | screen->set_drawmode(DRMODE_SOLID); | ||
170 | |||
171 | if(orientation == VERTICAL) { | ||
172 | #if LCD_DEPTH > 1 | ||
173 | if (bm.format == FORMAT_MONO) | ||
174 | #endif | ||
175 | screen->mono_bitmap_part(bm.data, 0, 0, | ||
176 | bm.width, x, y + start, width, size); | ||
177 | #if LCD_DEPTH > 1 | ||
178 | else | ||
179 | screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, | ||
180 | bm.width, x, y + start, width, size); | ||
181 | #endif | ||
182 | } else { | ||
183 | #if LCD_DEPTH > 1 | ||
184 | if (bm.format == FORMAT_MONO) | ||
185 | #endif | ||
186 | screen->mono_bitmap_part(bm.data, 0, 0, | ||
187 | bm.width, x + start, y, size, height); | ||
188 | #if LCD_DEPTH > 1 | ||
189 | else | ||
190 | screen->transparent_bitmap_part((fb_data *)bm.data, 0, 0, | ||
191 | bm.width, x + start, y, size, height); | ||
192 | #endif | ||
193 | } | ||
194 | } | ||
104 | #endif /* HAVE_LCD_BITMAP */ | 195 | #endif /* HAVE_LCD_BITMAP */ |