diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-05-25 14:21:17 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-05-25 14:21:17 +0000 |
commit | 06ba3cceec94e8bed4ebd4bb52a949a2fbff50df (patch) | |
tree | 16e2eb8505e76aada0535e3ae70a33ea31a69b6b /apps/plugins/test_viewports.lua | |
parent | 88cf5b307a4124789a59a1ca1c7fb38e0213b935 (diff) | |
download | rockbox-06ba3cceec94e8bed4ebd4bb52a949a2fbff50df.tar.gz rockbox-06ba3cceec94e8bed4ebd4bb52a949a2fbff50df.zip |
Lua: port viewports + add test_viewports.lua
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21076 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/test_viewports.lua')
-rw-r--r-- | apps/plugins/test_viewports.lua | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/apps/plugins/test_viewports.lua b/apps/plugins/test_viewports.lua new file mode 100644 index 0000000000..5af1ef4fb9 --- /dev/null +++ b/apps/plugins/test_viewports.lua | |||
@@ -0,0 +1,116 @@ | |||
1 | --[[ | ||
2 | __________ __ ___. | ||
3 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | \/ \/ \/ \/ \/ | ||
8 | $Id$ | ||
9 | |||
10 | Port of test_viewports.c to Lua | ||
11 | |||
12 | Copyright (C) 2009 by Maurus Cuelenaere | ||
13 | |||
14 | This program is free software; you can redistribute it and/or | ||
15 | modify it under the terms of the GNU General Public License | ||
16 | as published by the Free Software Foundation; either version 2 | ||
17 | of the License, or (at your option) any later version. | ||
18 | |||
19 | This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | KIND, either express or implied. | ||
21 | |||
22 | ]]-- | ||
23 | |||
24 | -- TODO: outsource this | ||
25 | rb.DRMODE_SOLID = 3 | ||
26 | rb.LCD_BLACK = rb.lcd_rgbpack(0, 0, 0) | ||
27 | rb.LCD_WHITE = rb.lcd_rgbpack(255, 255, 255) | ||
28 | rb.LCD_DEFAULT_FG = rb.LCD_WHITE | ||
29 | rb.LCD_DEFAULT_BG = rb.LCD_BLACK | ||
30 | |||
31 | BGCOLOR_1 = rb.lcd_rgbpack(255,255,0) | ||
32 | BGCOLOR_2 = rb.lcd_rgbpack(0,255,0) | ||
33 | FGCOLOR_1 = rb.lcd_rgbpack(0,0,255) | ||
34 | |||
35 | local vp0 = | ||
36 | { | ||
37 | x = 0, | ||
38 | y = 0, | ||
39 | width = rb.LCD_WIDTH, | ||
40 | height = 20, | ||
41 | font = rb.FONT_UI, | ||
42 | drawmode = rb.DRMODE_SOLID, | ||
43 | fg_pattern = rb.LCD_DEFAULT_FG, | ||
44 | bg_pattern = BGCOLOR_1 | ||
45 | } | ||
46 | |||
47 | local vp1 = | ||
48 | { | ||
49 | x = rb.LCD_WIDTH / 10, | ||
50 | y = 20, | ||
51 | width = rb.LCD_WIDTH / 3, | ||
52 | height = rb.LCD_HEIGHT / 2, | ||
53 | font = rb.FONT_SYSFIXED, | ||
54 | drawmode = rb.DRMODE_SOLID, | ||
55 | fg_pattern = rb.LCD_DEFAULT_FG, | ||
56 | bg_pattern = rb.LCD_DEFAULT_BG | ||
57 | }; | ||
58 | |||
59 | local vp2 = | ||
60 | { | ||
61 | x = rb.LCD_WIDTH / 2, | ||
62 | y = 40, | ||
63 | width = rb.LCD_WIDTH / 3, | ||
64 | height = (rb.LCD_HEIGHT / 2), | ||
65 | font = rb.FONT_UI, | ||
66 | drawmode = rb.DRMODE_SOLID, | ||
67 | fg_pattern = FGCOLOR_1, | ||
68 | bg_pattern = BGCOLOR_2 | ||
69 | }; | ||
70 | |||
71 | |||
72 | local vp3 = | ||
73 | { | ||
74 | x = rb.LCD_WIDTH / 4, | ||
75 | y = (5 * rb.LCD_HEIGHT) / 8, | ||
76 | width = rb.LCD_WIDTH / 2, | ||
77 | height = (rb.LCD_HEIGHT / 4), | ||
78 | font = rb.FONT_SYSFIXED, | ||
79 | drawmode = rb.DRMODE_SOLID, | ||
80 | fg_pattern = rb.LCD_BLACK, | ||
81 | bg_pattern = rb.LCD_WHITE | ||
82 | }; | ||
83 | |||
84 | rb.set_viewport(vp0) | ||
85 | rb.clear_viewport() | ||
86 | rb.lcd_puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title") | ||
87 | |||
88 | rb.set_viewport(vp1); | ||
89 | rb.clear_viewport(); | ||
90 | |||
91 | for i = 0, 3 do | ||
92 | rb.lcd_puts_scroll(0,i,string.format("Left text, scrolling_line %d",i)); | ||
93 | end | ||
94 | |||
95 | rb.set_viewport(vp2); | ||
96 | rb.clear_viewport(); | ||
97 | for i = 0, 3 do | ||
98 | rb.lcd_puts_scroll(1,i,string.format("Right text, scrolling line %d",i)); | ||
99 | end | ||
100 | |||
101 | local y = -10 | ||
102 | for i = -10, vp2.width + 10, 5 do | ||
103 | rb.lcd_drawline(i, y, i, vp2.height - y); | ||
104 | end | ||
105 | |||
106 | rb.set_viewport(vp3); | ||
107 | rb.clear_viewport(); | ||
108 | for i = 1, 2 do | ||
109 | rb.lcd_puts_scroll(2,i,string.format("Bottom text, a scrolling line %d",i)); | ||
110 | end | ||
111 | rb.lcd_puts_scroll(4,3,"Short line") | ||
112 | rb.lcd_update() | ||
113 | |||
114 | rb.button_get(true) | ||
115 | |||
116 | rb.set_viewport() \ No newline at end of file | ||