4 * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
10 * \author Bernardo Innocenti <bernie@develer.com>
12 * \brief Windowing system test.
17 *#* Revision 1.1 2006/01/23 23:14:29 bernie
18 *#* Implement simple, but impressive windowing system.
22 #include <emul/emul.h>
23 #include <drv/lcd_gfx.h>
27 static void magic(struct Bitmap *bitmap, coord_t x, coord_t y)
29 static const coord_t coords[] = { 120, 34, 90, 90, 30, 90, 0, 34, 60, 0, 90, 90, 0, 34, 120, 34, 30, 90, 60, 0 };
32 gfx_moveTo(bitmap, coords[countof(coords)-2]/2 + x, coords[countof(coords)-1]/3 + y);
33 for (i = 0; i < countof(coords); i += 2)
34 gfx_lineTo(bitmap, coords[i]/2 + x, coords[i+1]/3 + y);
37 int main(int argc, char *argv[])
39 emul_init(&argc, argv);
42 const coord_t small_left = 45, small_top = 30, small_width = 50, small_height = 30;
43 const coord_t large_left = -10, large_top = 10, large_width = 85, large_height = 41;
45 Window root_win, small_win, large_win;
46 Bitmap small_bm, large_bm;
47 uint8_t small_raster[RASTER_SIZE(small_width, small_height)];
48 uint8_t large_raster[RASTER_SIZE(large_width, large_height)];
50 win_create(&root_win, &lcd_bitmap);
52 gfx_bitmapInit(&large_bm, large_raster, large_width, large_height);
53 win_create(&large_win, &large_bm);
54 win_open(&large_win, &root_win);
55 win_move(&large_win, large_left, large_top);
57 gfx_bitmapInit(&small_bm, small_raster, small_width, small_height);
58 win_create(&small_win, &small_bm);
59 win_open(&small_win, &root_win);
60 win_move(&small_win, small_left, small_top);
63 coord_t x = 0, y = LCD_WIDTH / 2;
64 coord_t xdir = +1, ydir = -1;
65 coord_t xdir_large = +1;
66 coord_t ydir_small = +1;
67 int raise_counter = 0;
73 /* Background animation */
76 /* gfx_setClipRect(bm, 0, 0, bm->width, bm->height);
77 gfx_rectDraw(bm, 10, 10, bm->width-10, bm->height-10);
78 gfx_setClipRect(bm, 11, 11, bm->width-11, bm->height-11);
82 if (x >= bm->width) xdir = -1;
83 if (x <= -50) xdir = +1;
84 if (y >= bm->height) ydir = -1;
85 if (y <= -50) ydir = +1;
87 /* Large window animation */
88 bm = large_win.bitmap;
90 for (i = 0; i < bm->height / 2; i += 2)
91 gfx_rectDraw(bm, 0 + i, 0 + i, bm->width - i, bm->height - i);
94 /* Small window animation */
95 bm = small_win.bitmap;
97 gfx_rectDraw(bm, 0, 0, bm->width, bm->height);
98 gfx_line(bm, 0, 0, bm->width, bm->height);
99 gfx_line(bm, bm->width, 0, 0, bm->height);
101 /* Move windows around */
102 win_move(&large_win, large_win.geom.xmin + xdir_large, large_top);
103 if (large_win.geom.xmin < -20) xdir_large = +1;
104 if (large_win.geom.xmin > RECT_WIDTH(&root_win.geom) - 5) xdir_large = -1;
106 win_move(&small_win, small_left, small_win.geom.ymin + ydir_small);
107 if (small_win.geom.ymin < -20) ydir_small = +1;
108 if (small_win.geom.ymin > RECT_HEIGHT(&root_win.geom) - 5) ydir_small = -1;
111 if (raise_counter % 997 == 0)
112 win_raise(&small_win);
113 else if (raise_counter % 731 == 0)
114 win_raise(&large_win);
116 win_compose(&root_win);
117 lcd_blit_bitmap(root_win.bitmap);