summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-01-08 01:22:14 +0000
committerDave Chapman <dave@dchapman.com>2008-01-08 01:22:14 +0000
commit3646c313679c4bd16c9eec98c2e35c7a7bf5c961 (patch)
treeb6508cc00ae60c70c9499090fb87d97f3370c131 /apps/plugins
parent08e6c6bc2a90e953372e503367c406c469994da2 (diff)
downloadrockbox-3646c313679c4bd16c9eec98c2e35c7a7bf5c961.tar.gz
rockbox-3646c313679c4bd16c9eec98c2e35c7a7bf5c961.zip
Add the viewport functions to the screens API, including a new getfont() function to return the font used by the current viewport. A change to the screens API makes the plugin API incompatible, so we bump version and sort. Also commit the test_viewports plugin (not built by default). This is some more of FS#8385.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16022 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/test_viewports.c309
2 files changed, 310 insertions, 0 deletions
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index 9a6cc93faa..ee28614da0 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -81,6 +81,7 @@ test_disk,apps
81test_fps,apps 81test_fps,apps
82test_sampr,apps 82test_sampr,apps
83test_scanrate,apps 83test_scanrate,apps
84test_viewports,apps
84text_editor,apps 85text_editor,apps
85vbrfix,viewers 86vbrfix,viewers
86video,viewers 87video,viewers
diff --git a/apps/plugins/test_viewports.c b/apps/plugins/test_viewports.c
new file mode 100644
index 0000000000..3cb8afb519
--- /dev/null
+++ b/apps/plugins/test_viewports.c
@@ -0,0 +1,309 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: helloworld.c 12807 2007-03-16 21:56:08Z amiconn $
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "plugin.h"
21
22PLUGIN_HEADER
23
24static struct plugin_api* rb;
25
26#ifdef HAVE_LCD_BITMAP
27
28#ifdef HAVE_LCD_COLOR
29#define BGCOLOR_1 LCD_RGBPACK(255,255,0)
30#define BGCOLOR_2 LCD_RGBPACK(0,255,0)
31#define FGCOLOR_1 LCD_RGBPACK(0,0,255)
32#else if LCD_DEPTH > 1
33#define BGCOLOR_1 LCD_DARKGRAY
34#define BGCOLOR_2 LCD_LIGHTGRAY
35#define FGCOLOR_1 LCD_WHITE
36#endif
37
38static struct viewport vp0 =
39{
40 .x = 0,
41 .y = 0,
42 .width = LCD_WIDTH,
43 .height = 20,
44 .font = FONT_UI,
45 .drawmode = DRMODE_SOLID,
46 .xmargin = 0,
47 .ymargin = 0,
48#if LCD_DEPTH > 1
49 .fg_pattern = LCD_DEFAULT_FG,
50 .bg_pattern = BGCOLOR_1,
51#endif
52#ifdef HAVE_LCD_COLOR
53 .lss_pattern = LCD_DEFAULT_BG,
54 .lse_pattern = LCD_DEFAULT_BG,
55 .lst_pattern = LCD_DEFAULT_BG,
56#endif
57};
58
59static struct viewport vp1 =
60{
61 .x = LCD_WIDTH / 10,
62 .y = 20,
63 .width = LCD_WIDTH / 3,
64 .height = LCD_HEIGHT / 2,
65 .font = FONT_SYSFIXED,
66 .drawmode = DRMODE_SOLID,
67 .xmargin = 0,
68 .ymargin = 0,
69#if LCD_DEPTH > 1
70 .fg_pattern = LCD_DEFAULT_FG,
71 .bg_pattern = LCD_DEFAULT_BG,
72#ifdef HAVE_LCD_COLOR
73 .lss_pattern = LCD_DEFAULT_BG,
74 .lse_pattern = LCD_DEFAULT_BG,
75 .lst_pattern = LCD_DEFAULT_BG,
76#endif
77#endif
78};
79
80static struct viewport vp2 =
81{
82 .x = LCD_WIDTH / 2,
83 .y = 40,
84 .width = LCD_WIDTH / 3,
85 .height = (LCD_HEIGHT / 2),
86 .font = FONT_UI,
87 .drawmode = DRMODE_SOLID,
88 .xmargin = 0,
89 .ymargin = 0,
90#if LCD_DEPTH > 1
91 .fg_pattern = FGCOLOR_1,
92 .bg_pattern = BGCOLOR_2,
93#ifdef HAVE_LCD_COLOR
94 .lss_pattern = LCD_DEFAULT_BG,
95 .lse_pattern = LCD_DEFAULT_BG,
96 .lst_pattern = LCD_DEFAULT_BG,
97#endif
98#endif
99};
100
101
102static struct viewport vp3 =
103{
104 .x = LCD_WIDTH / 4,
105 .y = (5 * LCD_HEIGHT) / 8,
106 .width = LCD_WIDTH / 2,
107 .height = (LCD_HEIGHT / 4),
108 .font = FONT_SYSFIXED,
109 .drawmode = DRMODE_SOLID,
110 .xmargin = 0,
111 .ymargin = 0,
112#if LCD_DEPTH > 1
113 .fg_pattern = LCD_BLACK,
114 .bg_pattern = LCD_WHITE,
115#ifdef HAVE_LCD_COLOR
116 .lss_pattern = LCD_DEFAULT_BG,
117 .lse_pattern = LCD_DEFAULT_BG,
118 .lst_pattern = LCD_DEFAULT_BG,
119#endif
120#endif
121};
122
123
124#ifdef HAVE_REMOTE_LCD
125static struct viewport rvp0 =
126{
127 .x = 0,
128 .y = 10,
129 .width = LCD_REMOTE_WIDTH / 3,
130 .height = LCD_REMOTE_HEIGHT - 10,
131 .font = FONT_SYSFIXED,
132 .drawmode = DRMODE_SOLID,
133 .xmargin = 0,
134 .ymargin = 0,
135#if LCD_REMOTE_DEPTH > 1
136 .fg_pattern = LCD_REMOTE_BLACK,
137 .bg_pattern = LCD_REMOTE_LIGHTGRAY,
138#endif
139};
140
141static struct viewport rvp1 =
142{
143 .x = LCD_REMOTE_WIDTH / 2,
144 .y = 0,
145 .width = LCD_REMOTE_WIDTH / 3,
146 .height = LCD_REMOTE_HEIGHT - 10,
147 .font = FONT_SYSFIXED,
148 .drawmode = DRMODE_SOLID,
149 .xmargin = 0,
150 .ymargin = 0,
151#if LCD_REMOTE_DEPTH > 1
152 .fg_pattern = LCD_REMOTE_DEFAULT_FG,
153 .bg_pattern = LCD_REMOTE_DEFAULT_BG
154#endif
155};
156
157#endif
158
159
160enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
161{
162 (void)parameter;
163 char buf[80];
164 int i,y;
165
166 rb = api;
167
168 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
169 rb->screens[SCREEN_MAIN]->clear_viewport();
170 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title");
171
172 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
173 rb->screens[SCREEN_MAIN]->clear_viewport();
174
175 for (i = 0 ; i < 3; i++)
176 {
177 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
178 rb->screens[SCREEN_MAIN]->puts_scroll(0,i,buf);
179 }
180
181 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
182 rb->screens[SCREEN_MAIN]->clear_viewport();
183 for (i = 1 ; i < 3; i++)
184 {
185 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
186 rb->screens[SCREEN_MAIN]->puts_scroll(1,i,buf);
187 }
188
189 y = -10;
190 for (i = -10; i < vp2.width + 10; i += 5)
191 {
192 rb->screens[SCREEN_MAIN]->drawline(i, y, i, vp2.height - y);
193 }
194
195 rb->screens[SCREEN_MAIN]->set_viewport(&vp3);
196 rb->screens[SCREEN_MAIN]->clear_viewport();
197 for (i = 1 ; i < 2; i++)
198 {
199 rb->snprintf(buf,sizeof(buf),"Bottom text, a scrolling line %d",i);
200 rb->screens[SCREEN_MAIN]->puts_scroll(2,i,buf);
201 }
202 rb->screens[SCREEN_MAIN]->puts_scroll(4,i,"Short line");
203 rb->screens[SCREEN_MAIN]->update();
204
205
206#ifdef HAVE_REMOTE_LCD
207 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp0);
208 rb->screens[SCREEN_REMOTE]->clear_viewport();
209
210 for (i = 0 ; i < 5; i++)
211 {
212 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
213 rb->screens[SCREEN_REMOTE]->puts_scroll(0,i,buf);
214 }
215 rb->screens[SCREEN_REMOTE]->puts(1,i,"Static");
216
217 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp1);
218 rb->screens[SCREEN_REMOTE]->clear_viewport();
219 for (i = 1 ; i < 3; i++)
220 {
221 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
222 rb->screens[SCREEN_REMOTE]->puts_scroll(1,i,buf);
223 }
224
225 y = -10;
226 for (i = -10; i < rvp1.width + 10; i += 5)
227 {
228 rb->screens[SCREEN_REMOTE]->drawline(i, y, i, rvp1.height - y);
229 }
230
231 rb->screens[SCREEN_REMOTE]->update();
232#endif
233
234 rb->button_get(true);
235
236 /* Restore the default viewport */
237 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
238#ifdef HAVE_REMOTE_LCD
239 rb->screens[SCREEN_REMOTE]->set_viewport(NULL);
240#endif
241
242 return PLUGIN_OK;
243}
244
245
246#else
247
248/* Charcell version of plugin */
249
250static struct viewport vp0 =
251{
252 .x = 0,
253 .y = 0,
254 .width = 5,
255 .height = 1,
256 .xmargin = 0,
257 .ymargin = 0,
258};
259
260static struct viewport vp1 =
261{
262 .x = 6,
263 .y = 0,
264 .width = 5,
265 .height = 1,
266 .xmargin = 0,
267 .ymargin = 0,
268};
269
270static struct viewport vp2 =
271{
272 .x = 0,
273 .y = 1,
274 .width = LCD_WIDTH,
275 .height = 1,
276 .xmargin = 0,
277 .ymargin = 0,
278};
279
280
281enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
282{
283 (void)parameter;
284
285 rb = api;
286
287 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
288 rb->screens[SCREEN_MAIN]->clear_viewport();
289 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Rockbox");
290
291 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
292 rb->screens[SCREEN_MAIN]->clear_viewport();
293 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewports");
294
295 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
296 rb->screens[SCREEN_MAIN]->clear_viewport();
297 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Demonstration");
298
299 rb->screens[SCREEN_MAIN]->update();
300
301 rb->button_get(true);
302
303 /* Restore the default viewport */
304 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
305
306 return PLUGIN_OK;
307}
308
309#endif /* !HAVE_LCD_BITMAP */