fixing red:
[Rockbox.git] / apps / plugins / test_viewports.c
blob3cb8afb5194dc9bb4628a874154d990d04b849fa
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: helloworld.c 12807 2007-03-16 21:56:08Z amiconn $
10 * Copyright (C) 2007 Dave Chapman
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "plugin.h"
22 PLUGIN_HEADER
24 static struct plugin_api* rb;
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 #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
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 .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
59 static struct viewport vp1 =
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
80 static struct viewport vp2 =
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
102 static struct viewport vp3 =
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
124 #ifdef HAVE_REMOTE_LCD
125 static struct viewport rvp0 =
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
141 static struct viewport rvp1 =
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
157 #endif
160 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
162 (void)parameter;
163 char buf[80];
164 int i,y;
166 rb = api;
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");
172 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
173 rb->screens[SCREEN_MAIN]->clear_viewport();
175 for (i = 0 ; i < 3; i++)
177 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
178 rb->screens[SCREEN_MAIN]->puts_scroll(0,i,buf);
181 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
182 rb->screens[SCREEN_MAIN]->clear_viewport();
183 for (i = 1 ; i < 3; i++)
185 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
186 rb->screens[SCREEN_MAIN]->puts_scroll(1,i,buf);
189 y = -10;
190 for (i = -10; i < vp2.width + 10; i += 5)
192 rb->screens[SCREEN_MAIN]->drawline(i, y, i, vp2.height - y);
195 rb->screens[SCREEN_MAIN]->set_viewport(&vp3);
196 rb->screens[SCREEN_MAIN]->clear_viewport();
197 for (i = 1 ; i < 2; i++)
199 rb->snprintf(buf,sizeof(buf),"Bottom text, a scrolling line %d",i);
200 rb->screens[SCREEN_MAIN]->puts_scroll(2,i,buf);
202 rb->screens[SCREEN_MAIN]->puts_scroll(4,i,"Short line");
203 rb->screens[SCREEN_MAIN]->update();
206 #ifdef HAVE_REMOTE_LCD
207 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp0);
208 rb->screens[SCREEN_REMOTE]->clear_viewport();
210 for (i = 0 ; i < 5; i++)
212 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
213 rb->screens[SCREEN_REMOTE]->puts_scroll(0,i,buf);
215 rb->screens[SCREEN_REMOTE]->puts(1,i,"Static");
217 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp1);
218 rb->screens[SCREEN_REMOTE]->clear_viewport();
219 for (i = 1 ; i < 3; i++)
221 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
222 rb->screens[SCREEN_REMOTE]->puts_scroll(1,i,buf);
225 y = -10;
226 for (i = -10; i < rvp1.width + 10; i += 5)
228 rb->screens[SCREEN_REMOTE]->drawline(i, y, i, rvp1.height - y);
231 rb->screens[SCREEN_REMOTE]->update();
232 #endif
234 rb->button_get(true);
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
242 return PLUGIN_OK;
246 #else
248 /* Charcell version of plugin */
250 static struct viewport vp0 =
252 .x = 0,
253 .y = 0,
254 .width = 5,
255 .height = 1,
256 .xmargin = 0,
257 .ymargin = 0,
260 static struct viewport vp1 =
262 .x = 6,
263 .y = 0,
264 .width = 5,
265 .height = 1,
266 .xmargin = 0,
267 .ymargin = 0,
270 static struct viewport vp2 =
272 .x = 0,
273 .y = 1,
274 .width = LCD_WIDTH,
275 .height = 1,
276 .xmargin = 0,
277 .ymargin = 0,
281 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
283 (void)parameter;
285 rb = api;
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");
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");
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");
299 rb->screens[SCREEN_MAIN]->update();
301 rb->button_get(true);
303 /* Restore the default viewport */
304 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
306 return PLUGIN_OK;
309 #endif /* !HAVE_LCD_BITMAP */