grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / layers / sortlayercr.c
blobae284391885e8c840c3974b6f74f023e5b0a0ea4
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/clip.h>
7 #include <graphics/gfx.h>
8 #include <exec/exec.h>
9 #include <proto/layers.h>
10 #include <proto/exec.h>
12 #include <stdio.h>
14 struct Library *LayersBase;
15 struct Layer dummy_lay;
17 struct ClipRect dummy_cr[100];
19 void setcr(WORD which, WORD x1, WORD y1, WORD x2, WORD y2)
21 dummy_cr[which].bounds.MinX = x1;
22 dummy_cr[which].bounds.MinY = y1;
23 dummy_cr[which].bounds.MaxX = x2;
24 dummy_cr[which].bounds.MaxY = y2;
25 dummy_cr[which].Flags = which;
27 if (which > 0) dummy_cr[which - 1].Next = &dummy_cr[which];
30 void makecrs(void)
32 /* 0000000000011111111122
33 0123456789012345678901
35 00 +---+---+------------+
36 01 | 0 | | |
37 02 +---+ | 2 |
38 03 | | 1 +---+--------+
39 04 | 3 | | 4 | |
40 05 +---+ +---+ |
41 06 | 6 | | | 5 |
42 07 +---+---+ 8 +--------+
43 08 | 7 | | 9 |
44 09 +-------+---+--------+
47 setcr(0, 0, 0, 39, 19);
48 setcr(1, 40, 0, 79, 69);
49 setcr(2, 80, 0, 209, 29);
50 setcr(3, 0, 20, 39, 49);
51 setcr(4, 80, 30, 119, 49);
52 setcr(5, 120, 30, 209, 69);
53 setcr(6, 0, 50, 39, 69);
54 setcr(7, 0, 70, 79, 89);
55 setcr(8, 80, 50, 119, 89);
56 setcr(9, 120, 70, 209, 89);
58 dummy_lay.ClipRect = dummy_cr;
61 void doit(char *msg, WORD dx, WORD dy)
63 struct ClipRect *cr;
65 SortLayerCR(&dummy_lay, dx, dy);
67 printf("\n%s\n----------------------------\n", msg);
68 cr = dummy_lay.ClipRect;
69 while(cr)
71 printf("%ld ", (long)cr->Flags);
72 cr = cr->Next;
74 printf("\n");
78 void action(void)
80 doit("UP", 0, -1);
81 doit("DOWN", 0, 1);
82 doit("LEFT", -1, 0);
83 doit("RIGHT", 1, 0);
84 doit("UP LEFT", -1, -1);
85 doit("UP RIGHT", 1, -1);
86 doit("DOWN LEFT", -1, 1);
87 doit("DOWN RIGHT", 1, 1);
91 int main(void)
93 LayersBase = OpenLibrary("layers.library", 0);
94 if (LayersBase)
96 makecrs();
97 action();
99 CloseLibrary(LayersBase);
102 return 0;