Fix manual button tables for disktidy, mpegplayer, text editor and
[maemo-rb.git] / apps / plugins / test_viewports.c
blob08c23a91c8e0e39af67211c91d93dc58d8d082bc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "plugin.h"
24 PLUGIN_HEADER
26 #ifdef HAVE_LCD_BITMAP
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 #elif LCD_DEPTH > 1
33 #define BGCOLOR_1 LCD_DARKGRAY
34 #define BGCOLOR_2 LCD_LIGHTGRAY
35 #define FGCOLOR_1 LCD_WHITE
36 #endif
38 static struct viewport vp0 =
40 .x = 0,
41 .y = 0,
42 .width = LCD_WIDTH,
43 .height = 20,
44 .font = FONT_UI,
45 .drawmode = DRMODE_SOLID,
46 #if LCD_DEPTH > 1
47 .fg_pattern = LCD_DEFAULT_FG,
48 .bg_pattern = BGCOLOR_1,
49 #endif
50 #ifdef HAVE_LCD_COLOR
51 .lss_pattern = LCD_DEFAULT_BG,
52 .lse_pattern = LCD_DEFAULT_BG,
53 .lst_pattern = LCD_DEFAULT_BG,
54 #endif
57 static struct viewport vp1 =
59 .x = LCD_WIDTH / 10,
60 .y = 20,
61 .width = LCD_WIDTH / 3,
62 .height = LCD_HEIGHT / 2,
63 .font = FONT_SYSFIXED,
64 .drawmode = DRMODE_SOLID,
65 #if LCD_DEPTH > 1
66 .fg_pattern = LCD_DEFAULT_FG,
67 .bg_pattern = LCD_DEFAULT_BG,
68 #ifdef HAVE_LCD_COLOR
69 .lss_pattern = LCD_DEFAULT_BG,
70 .lse_pattern = LCD_DEFAULT_BG,
71 .lst_pattern = LCD_DEFAULT_BG,
72 #endif
73 #endif
76 static struct viewport vp2 =
78 .x = LCD_WIDTH / 2,
79 .y = 40,
80 .width = LCD_WIDTH / 3,
81 .height = (LCD_HEIGHT / 2),
82 .font = FONT_UI,
83 .drawmode = DRMODE_SOLID,
84 #if LCD_DEPTH > 1
85 .fg_pattern = FGCOLOR_1,
86 .bg_pattern = BGCOLOR_2,
87 #ifdef HAVE_LCD_COLOR
88 .lss_pattern = LCD_DEFAULT_BG,
89 .lse_pattern = LCD_DEFAULT_BG,
90 .lst_pattern = LCD_DEFAULT_BG,
91 #endif
92 #endif
96 static struct viewport vp3 =
98 .x = LCD_WIDTH / 4,
99 .y = (5 * LCD_HEIGHT) / 8,
100 .width = LCD_WIDTH / 2,
101 .height = (LCD_HEIGHT / 4),
102 .font = FONT_SYSFIXED,
103 .drawmode = DRMODE_SOLID,
104 #if LCD_DEPTH > 1
105 .fg_pattern = LCD_BLACK,
106 .bg_pattern = LCD_WHITE,
107 #ifdef HAVE_LCD_COLOR
108 .lss_pattern = LCD_DEFAULT_BG,
109 .lse_pattern = LCD_DEFAULT_BG,
110 .lst_pattern = LCD_DEFAULT_BG,
111 #endif
112 #endif
116 #ifdef HAVE_REMOTE_LCD
117 static struct viewport rvp0 =
119 .x = 0,
120 .y = 10,
121 .width = LCD_REMOTE_WIDTH / 3,
122 .height = LCD_REMOTE_HEIGHT - 10,
123 .font = FONT_SYSFIXED,
124 .drawmode = DRMODE_SOLID,
125 #if LCD_REMOTE_DEPTH > 1
126 .fg_pattern = LCD_REMOTE_BLACK,
127 .bg_pattern = LCD_REMOTE_LIGHTGRAY,
128 #endif
131 static struct viewport rvp1 =
133 .x = LCD_REMOTE_WIDTH / 2,
134 .y = 0,
135 .width = LCD_REMOTE_WIDTH / 3,
136 .height = LCD_REMOTE_HEIGHT - 10,
137 .font = FONT_SYSFIXED,
138 .drawmode = DRMODE_SOLID,
139 #if LCD_REMOTE_DEPTH > 1
140 .fg_pattern = LCD_REMOTE_DEFAULT_FG,
141 .bg_pattern = LCD_REMOTE_DEFAULT_BG
142 #endif
145 #endif
148 enum plugin_status plugin_start(const void* parameter)
150 (void)parameter;
151 char buf[80];
152 int i,y;
154 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
155 rb->screens[SCREEN_MAIN]->clear_viewport();
156 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title");
158 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
159 rb->screens[SCREEN_MAIN]->clear_viewport();
161 for (i = 0 ; i < 3; i++)
163 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
164 rb->screens[SCREEN_MAIN]->puts_scroll(0,i,buf);
167 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
168 rb->screens[SCREEN_MAIN]->clear_viewport();
169 for (i = 1 ; i < 3; i++)
171 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
172 rb->screens[SCREEN_MAIN]->puts_scroll(1,i,buf);
175 y = -10;
176 for (i = -10; i < vp2.width + 10; i += 5)
178 rb->screens[SCREEN_MAIN]->drawline(i, y, i, vp2.height - y);
181 rb->screens[SCREEN_MAIN]->set_viewport(&vp3);
182 rb->screens[SCREEN_MAIN]->clear_viewport();
183 for (i = 1 ; i < 2; i++)
185 rb->snprintf(buf,sizeof(buf),"Bottom text, a scrolling line %d",i);
186 rb->screens[SCREEN_MAIN]->puts_scroll(2,i,buf);
188 rb->screens[SCREEN_MAIN]->puts_scroll(4,i,"Short line");
189 rb->screens[SCREEN_MAIN]->update();
192 #ifdef HAVE_REMOTE_LCD
193 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp0);
194 rb->screens[SCREEN_REMOTE]->clear_viewport();
196 for (i = 0 ; i < 5; i++)
198 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
199 rb->screens[SCREEN_REMOTE]->puts_scroll(0,i,buf);
201 rb->screens[SCREEN_REMOTE]->puts(1,i,"Static");
203 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp1);
204 rb->screens[SCREEN_REMOTE]->clear_viewport();
205 for (i = 1 ; i < 3; i++)
207 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
208 rb->screens[SCREEN_REMOTE]->puts_scroll(1,i,buf);
211 y = -10;
212 for (i = -10; i < rvp1.width + 10; i += 5)
214 rb->screens[SCREEN_REMOTE]->drawline(i, y, i, rvp1.height - y);
217 rb->screens[SCREEN_REMOTE]->update();
218 #endif
220 rb->button_get(true);
222 /* Restore the default viewport */
223 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
224 #ifdef HAVE_REMOTE_LCD
225 rb->screens[SCREEN_REMOTE]->set_viewport(NULL);
226 #endif
228 return PLUGIN_OK;
232 #else
234 /* Charcell version of plugin */
236 static struct viewport vp0 =
238 .x = 0,
239 .y = 0,
240 .width = 5,
241 .height = 1,
244 static struct viewport vp1 =
246 .x = 6,
247 .y = 0,
248 .width = 5,
249 .height = 1,
252 static struct viewport vp2 =
254 .x = 0,
255 .y = 1,
256 .width = LCD_WIDTH,
257 .height = 1,
261 enum plugin_status plugin_start(const void* parameter)
263 (void)parameter;
265 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
266 rb->screens[SCREEN_MAIN]->clear_viewport();
267 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Rockbox");
269 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
270 rb->screens[SCREEN_MAIN]->clear_viewport();
271 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewports");
273 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
274 rb->screens[SCREEN_MAIN]->clear_viewport();
275 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Demonstration");
277 rb->screens[SCREEN_MAIN]->update();
279 rb->button_get(true);
281 /* Restore the default viewport */
282 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
284 return PLUGIN_OK;
287 #endif /* !HAVE_LCD_BITMAP */