Fixed use of negative indices when first directory entry has no long name.
[tangerine.git] / test / layerstest.c
blob964b6bc7ca49e8c7e6a92d12335562481889f5ac
1 #include <stdio.h>
2 #include <string.h>
3 #include <exec/types.h>
4 #include <aros/asmcall.h>
5 #include <graphics/rastport.h>
6 #include <graphics/regions.h>
7 #include <graphics/layers.h>
8 #include <graphics/clip.h>
9 #include <intuition/intuition.h>
10 #include <proto/dos.h>
11 #include <proto/exec.h>
12 #include <proto/graphics.h>
13 #include <proto/intuition.h>
14 #include <proto/layers.h>
16 #define GFX_SYSTEM X11 /* ord HIDD */
18 struct IntuitionBase *IntuitionBase;
19 struct GfxBase *GfxBase;
20 struct Library *LayersBase;
21 struct DosLibrary *DOSBase;
22 struct Screen *screen;
23 struct Window * window;
25 void doall(void);
26 struct Screen * openscreen(void);
27 void closescreen(struct Screen * screen);
29 APTR BltBitMapPtr;
31 int main(int argc, char **argv)
33 if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0)))
35 if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0)))
37 if ((LayersBase = OpenLibrary("layers.library", 0)))
39 if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0)))
41 if ((screen = openscreen()))
43 doall();
44 closescreen(screen);
46 CloseLibrary((struct Library *)DOSBase);
48 CloseLibrary(LayersBase);
50 CloseLibrary((struct Library *)GfxBase);
52 CloseLibrary((struct Library *) IntuitionBase);
54 return 0;
55 } /* main */
58 struct Screen * openscreen(void)
60 struct Screen * screen;
62 screen = OpenScreenTags(NULL,
63 SA_Height, 200,
64 SA_Width, 300,
65 TAG_END);
67 Draw(&screen->RastPort, 100, 100);
69 return screen;
72 void closescreen(struct Screen * screen)
74 CloseScreen(screen);
77 struct Layer *layers[10];
79 void freelayers(void)
81 int i;
82 for (i=0; i < 10; i++)
84 if (NULL != layers[i])
86 DeleteLayer(0, layers[i]);
87 if (layers[i]->SuperBitMap)
88 FreeBitMap(layers[i]->SuperBitMap);
93 int unusedlayer(void)
95 int i;
96 for (i =0; i < 10; i++)
98 if (NULL == layers[i])
99 return i;
101 return -1;
104 void createupfrontlayer(void)
106 int x0,y0,x1,y1;
107 int i;
108 char c,s;
109 LONG flags = 0;
110 struct BitMap * sb = NULL;
111 for (i = 0; i < 10; i++)
113 if (layers[i] == NULL)
114 break;
116 if (i < 10)
118 printf("Backdroplayer [y/N]: ");
119 scanf("%c", &c);
120 printf("SuperBitMap [y/N]: ");
121 scanf("%c", &s);
122 printf("x0: ");
123 scanf("%d", &x0);
124 printf("y0: ");
125 scanf("%d", &y0);
126 printf("x1: ");
127 scanf("%d", &x1);
128 printf("y1: ");
129 scanf("%d", &y1);
131 if (c=='y' || c=='Y')
133 printf("Generating a backdrop layer.\n");
134 flags |= LAYERBACKDROP;
136 if (s=='y' || s=='Y')
138 printf("Generating a superbitmap layer.\n");
139 flags |= LAYERSUPER;
140 sb = AllocBitMap(x1-x0+1,y1-y0+1,1,BMF_CLEAR,NULL);
143 flags |= LAYERSMART;
145 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
146 screen->RastPort.BitMap,
151 flags,
152 sb);
153 if (layers[i])
154 printf("Created layer with ID %d\n",i);
155 else
156 printf("Couldn't create layer. No more memory (?).\n");
158 else
159 printf("No more layers possible!\n");
162 void createbehindlayer(void)
164 int x0,y0,x1,y1;
165 int i;
166 char c, s;
167 LONG flags = 0;
168 struct BitMap * sb = NULL;
169 for (i = 0; i < 10; i++)
171 if (layers[i] == NULL)
172 break;
174 if (i < 10)
176 printf("Backdroplayer [y/N]: ");
177 scanf("%c", &c);
178 printf("SuperBitMap [y/N]: ");
179 scanf("%c", &s);
180 printf("x0: ");
181 scanf("%d", &x0);
182 printf("y0: ");
183 scanf("%d", &y0);
184 printf("x1: ");
185 scanf("%d", &x1);
186 printf("y1: ");
187 scanf("%d", &y1);
189 if (c=='y' || c=='Y')
191 printf("Generating a backdrop layer.\n");
192 flags |= LAYERBACKDROP;
194 if (s=='y' || s=='Y')
196 printf("Generating a superbitmap layer.\n");
197 flags |= LAYERSUPER;
198 sb = AllocBitMap(x1-x0+1,y1-y0+1,1,BMF_CLEAR,NULL);
201 flags |= LAYERSMART;
203 layers[i] = CreateBehindLayer(&screen->LayerInfo,
204 screen->RastPort.BitMap,
209 flags,
210 sb);
211 if (layers[i])
212 printf("Created layer with ID %d\n",i);
213 else
214 printf("Couldn't create layer. No more memory (?).\n");
216 else
217 printf("No more layers possible!\n");
220 void deletelayer(void)
222 int i;
223 printf("Delete layer with id: ");
224 scanf("%d", &i);
225 if (layers[i])
227 DeleteLayer(0, layers[i]);
228 if (layers[i]->SuperBitMap)
229 FreeBitMap(layers[i]->SuperBitMap);
230 printf("Deleted layer with id %d\n",i);
231 layers[i] = NULL;
233 else
235 printf("No layer with id %d\n",i);
239 void upfrontlayer(void)
241 int i;
242 printf("Upfront layer with id: ");
243 scanf("%d", &i);
244 if (layers[i]) {
245 UpfrontLayer(0, layers[i]);
246 printf("Moved layer with id %d upfront\n",i);
248 else
250 printf("No layer with id %d\n",i);
254 void behindlayer(void)
256 int i;
257 printf("Behind layer with id: ");
258 scanf("%d", &i);
259 if (layers[i]) {
260 BehindLayer(0, layers[i]);
261 printf("Moved layer with id %d behind\n",i);
263 else
265 printf("No layer with id %d\n",i);
269 void movelayerinfrontof(void)
271 int i1,i2;
272 printf("Move layer with id: ");
273 scanf("%d", &i1);
274 printf("in front of layer with id: ");
275 scanf("%d", &i2);
276 if (layers[i1] && layers[i2]) {
277 MoveLayerInFrontOf(layers[i1], layers[i2]);
278 printf("Moved layer with id %d in front of layer with id %d\n",i1,i2);
280 else
282 printf("No layer with id %d or id %d\n",i1,i2);
286 void movelayer(void)
288 int i,dx,dy;
289 printf("Move layer with id: ");
290 scanf("%d",&i);
291 printf("delta x: ");
292 scanf("%d",&dx);
293 printf("delta y: ");
294 scanf("%d",&dy);
295 if (layers[i])
297 MoveLayer(0, layers[i], dx, dy);
298 printf("Moved layer with id %d to new position.\n",i);
300 else
302 printf("No layer with id %d\n",i);
306 void movesizelayer(void)
308 int i,dx,dy,dw,dh;
309 printf("Move and size layer with id: ");
310 scanf("%d",&i);
311 printf("delta x: ");
312 scanf("%d",&dx);
313 printf("delta y: ");
314 scanf("%d",&dy);
315 printf("delta width: ");
316 scanf("%d",&dw);
317 printf("delta height: ");
318 scanf("%d",&dh);
319 if (layers[i])
321 MoveSizeLayer(layers[i], dx, dy, dw, dh);
322 printf("Moved and sized layer with id %d.\n",i);
324 else
326 printf("No layer with id %d\n",i);
330 void sizelayer(void)
332 int i,dx,dy;
333 printf("Resize layer with id: ");
334 scanf("%d",&i);
335 printf("delta width: ");
336 scanf("%d",&dx);
337 printf("delta height: ");
338 scanf("%d",&dy);
339 if (layers[i])
341 SizeLayer(0, layers[i], dx, dy);
342 printf("Resized layer with id %d.\n",i);
344 else
346 printf("No layer with id %d\n",i);
350 void scrolllayer(void)
352 int i,dx,dy;
353 printf("Scroll layer with id: ");
354 scanf("%d",&i);
355 if (NULL == layers[i])
357 printf("No layer with id %d\n",i);
360 printf("delta x: ");
361 scanf("%d",&dx);
362 printf("delta y: ");
363 scanf("%d",&dy);
365 if (0 == (layers[i]->Flags & LAYERSUPER))
366 printf("This is a non-superbitmapped layer.\n");
367 else
368 printf("This is a superbitmapped layer.\n");
370 ScrollLayer(0, layers[i], dx, dy);
371 printf("Scrolled layer with id %d.\n",i);
375 void motion(void)
377 int i,dx,dy,iter;
378 printf("Move layer with id: ");
379 scanf("%d",&i);
380 printf("delta x: ");
381 scanf("%d",&dx);
382 printf("delta y: ");
383 scanf("%d",&dy);
384 printf("iterations: ");
385 scanf("%d",&iter);
386 if (layers[i])
388 while (iter > 0 && (TRUE == MoveLayer(0, layers[i],dx,dy)))
389 iter--;
390 printf("Moved layer with id %d to new position.\n",i);
392 else
394 printf("No layer with id %d\n",i);
398 /* Draw a simple frame around a layer */
399 void frame(struct Layer * layer)
401 int c, width = layer->bounds.MaxX-layer->bounds.MinX,i=0;
402 SetAPen(layer->rp, 1);
403 Move(layer->rp, 0,0);
404 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX, 0);
405 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX,
406 layer->bounds.MaxY - layer->bounds.MinY);
407 Draw(layer->rp, 0, layer->bounds.MaxY - layer->bounds.MinY);
408 Draw(layer->rp, 0, 0);
409 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX,
410 layer->bounds.MaxY - layer->bounds.MinY);
412 for (c=0; c <= width; c= c+(width&0x0f)+i )
414 i+=2;
415 Move(layer->rp,c,0);
416 Draw(layer->rp,c,layer->bounds.MaxY - layer->bounds.MinY);
420 void Frame(void)
422 int i;
423 printf("Framing layer with id: ");
424 scanf("%d", &i);
425 if (layers[i])
427 /* Draw a Frame */
428 frame(layers[i]);
430 else
432 printf("No layer with id %d\n",i);
436 void GenerateLayers1(void)
438 int i;
439 i = unusedlayer();
440 if (i==-1) return;
441 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
442 screen->RastPort.BitMap,
445 100,
446 100,
447 LAYERSMART,
448 NULL);
450 frame(layers[i]);
452 i = unusedlayer();
453 if (i==-1) return;
454 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
455 screen->RastPort.BitMap,
458 150,
459 150,
460 LAYERSMART,
461 NULL);
463 frame(layers[i]);
465 i = unusedlayer();
466 if (i==-1) return;
467 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
468 screen->RastPort.BitMap,
471 120,
473 LAYERSMART,
474 NULL);
476 frame(layers[i]);
479 void GenerateLayers2(void)
481 int i;
482 i = unusedlayer();
483 layers[i] = CreateBehindLayer(&screen->LayerInfo,
484 screen->RastPort.BitMap,
487 100,
489 LAYERSMART,
490 NULL);
492 frame(layers[i]);
494 i = unusedlayer();
495 layers[i] = CreateBehindLayer(&screen->LayerInfo,
496 screen->RastPort.BitMap,
499 150,
500 150,
501 LAYERSMART,
502 NULL);
504 frame(layers[i]);
506 i = unusedlayer();
507 layers[i] = CreateBehindLayer(&screen->LayerInfo,
508 screen->RastPort.BitMap,
510 130,
511 140,
512 190,
513 LAYERSMART,
514 NULL);
516 frame(layers[i]);
518 i = unusedlayer();
519 layers[i] = CreateBehindLayer(&screen->LayerInfo,
520 screen->RastPort.BitMap,
521 120,
522 120,
523 150,
524 160,
525 LAYERSMART,
526 NULL);
528 frame(layers[i]);
531 void GenerateLayers3(void)
533 int i;
534 i = unusedlayer();
535 layers[i] = CreateBehindLayer(&screen->LayerInfo,
536 screen->RastPort.BitMap,
537 110,
538 110,
539 200,
540 195,
541 LAYERSMART,
542 NULL);
544 frame(layers[i]);
546 i = unusedlayer();
547 layers[i] = CreateBehindLayer(&screen->LayerInfo,
548 screen->RastPort.BitMap,
549 150,
550 150,
551 190,
552 190,
553 LAYERSMART,
554 NULL);
556 frame(layers[i]);
558 i = unusedlayer();
559 layers[i] = CreateBehindLayer(&screen->LayerInfo,
560 screen->RastPort.BitMap,
562 130,
563 140,
564 190,
565 LAYERSMART,
566 NULL);
567 frame(layers[i]);
569 i = unusedlayer();
570 layers[i] = CreateBehindLayer(&screen->LayerInfo,
571 screen->RastPort.BitMap,
572 120,
573 120,
574 150,
575 160,
576 LAYERSMART,
577 NULL);
579 frame(layers[i]);
582 void GenerateLayers4(void)
584 int i;
585 int c = 0;
586 while (c < 5)
588 i = unusedlayer();
589 if (-1 == i)
590 return;
591 layers[i] = CreateBehindLayer(&screen->LayerInfo,
592 screen->RastPort.BitMap,
593 10+c*10,
594 10+c*10,
595 100+c*10,
596 100+c*10,
597 LAYERSMART,
598 NULL);
599 frame(layers[i]);
600 c++;
604 void DemoA(void)
606 #define DELAYTIME 50
607 int i;
608 printf("Deleting all previously generated layers...\n");
609 for (i = 0; i < 10; i++)
611 if (layers[i])
613 DeleteLayer(0, layers[i]);
614 layers[i] = NULL;
617 i = 0;
619 printf("After each step there will be a short delay.\n");
620 printf("Activate other X-window (Amiga Screen) and always press a key\nto see what is going on\n");
621 printf("Creating layer %i.\n",i);
622 Delay(DELAYTIME);
623 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
624 screen->RastPort.BitMap,
627 100,
628 100,
629 LAYERSMART,
630 NULL);
632 frame(layers[i]);
634 printf("Creating layer %i.\n",++i);
635 Delay(DELAYTIME);
636 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
637 screen->RastPort.BitMap,
641 150,
642 LAYERSMART,
643 NULL);
644 frame(layers[i]);
646 printf("Creating layer %i.\n",++i);
647 Delay(DELAYTIME);
648 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
649 screen->RastPort.BitMap,
652 150,
654 LAYERSMART,
655 NULL);
656 frame(layers[i]);
658 printf("Creating layer %i.\n",++i);
659 Delay(DELAYTIME);
660 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
661 screen->RastPort.BitMap,
664 180,
665 200,
666 LAYERSMART,
667 NULL);
668 frame(layers[i]);
670 i = 0;
671 printf("Moving layer %i in front of all other layers.\n",i);
672 Delay(DELAYTIME);
673 UpfrontLayer(0, layers[i]);
675 i = 1;
676 printf("Moving layer %i in front of all other layers.\n",i);
677 Delay(DELAYTIME);
678 UpfrontLayer(0, layers[i]);
680 i = 2;
681 printf("Moving layer %i in front of all other layers.\n",i);
682 Delay(DELAYTIME);
683 UpfrontLayer(0, layers[i]);
685 i = 3;
686 printf("Moving layer %i in front of all other layers.\n",i);
687 Delay(DELAYTIME);
688 UpfrontLayer(0, layers[i]);
691 i = 0;
692 printf("Moving layer %i in front of all other layers.\n",i);
693 Delay(DELAYTIME);
694 UpfrontLayer(0, layers[i]);
696 i = 2;
697 printf("Moving layer %i in front of all other layers.\n",i);
698 Delay(DELAYTIME);
699 UpfrontLayer(0, layers[i]);
701 i = 2;
702 printf("Moving layer %i in front of all other layers.\n",i);
703 Delay(DELAYTIME);
704 UpfrontLayer(0, layers[i]);
706 i = 1;
707 printf("Moving layer %i in front of all other layers.\n",i);
708 Delay(DELAYTIME);
709 UpfrontLayer(0, layers[i]);
711 i = 2;
712 printf("Moving layer %i in front of all other layers.\n",i);
713 Delay(DELAYTIME);
714 UpfrontLayer(0, layers[i]);
716 for (i = 0; i < 10; i++)
717 if (NULL != layers[i])
719 printf("Destroying layer %i.\n",i);
720 Delay(DELAYTIME);
721 DeleteLayer(0, layers[i]);
722 layers[i] = NULL;
725 printf("End of demo .\n");
728 void DemoB(void)
730 #undef DELAYTIME
731 #define DELAYTIME 100
732 int i;
733 printf("Deleting all previously generated layers...\n");
734 for (i = 0; i < 10; i++)
736 if (layers[i])
738 DeleteLayer(0, layers[i]);
739 layers[i] = NULL;
742 i = 0;
744 printf("After each step there will be a short delay.\n");
745 printf("Activate other X-window (Amiga Screen) and always press a key\nto see what is going on\n");
746 printf("Creating behind-layer %i.\n",i);
747 Delay(DELAYTIME);
748 layers[i] = CreateBehindLayer(&screen->LayerInfo,
749 screen->RastPort.BitMap,
752 100,
753 100,
754 LAYERSMART,
755 NULL);
757 frame(layers[i]);
759 printf("Creating behind-layer %i.\n",++i);
760 Delay(DELAYTIME);
761 layers[i] = CreateBehindLayer(&screen->LayerInfo,
762 screen->RastPort.BitMap,
765 120,
766 120,
767 LAYERSMART,
768 NULL);
770 frame(layers[i]);
772 printf("Creating behind-layer %i.\n",++i);
773 Delay(DELAYTIME);
774 layers[i] = CreateBehindLayer(&screen->LayerInfo,
775 screen->RastPort.BitMap,
778 140,
780 LAYERSMART,
781 NULL);
782 frame(layers[i]);
785 printf("Creating behind-layer %i.\n",++i);
786 Delay(DELAYTIME);
787 layers[i] = CreateBehindLayer(&screen->LayerInfo,
788 screen->RastPort.BitMap,
791 150,
793 LAYERSMART,
794 NULL);
796 frame(layers[i]);
798 i = 2;
799 printf("Moving layer %i in front of all other layers.\n",i);
800 Delay(DELAYTIME);
801 UpfrontLayer(0, layers[i]);
803 printf("Moving layer %i in front of layer %i\n",3,0);
804 Delay(DELAYTIME);
805 MoveLayerInFrontOf(layers[3], layers[0]);
807 printf("Moving layer %i in front of layer %i\n",0,3);
808 Delay(DELAYTIME);
809 MoveLayerInFrontOf(layers[0], layers[3]);
811 i = 1;
812 printf("Moving layer %i in front of all other layers.\n",i);
813 Delay(DELAYTIME);
814 UpfrontLayer(0, layers[i]);
816 i = 0;
817 printf("Moving layer %i in front of all other layers.\n",i);
818 Delay(DELAYTIME);
819 UpfrontLayer(0, layers[i]);
821 i = 1;
822 printf("Moving layer %i behind all other layers.\n",i);
823 Delay(DELAYTIME);
824 BehindLayer(0, layers[i]);
826 for (i = 0; i < 10; i++)
827 if (NULL != layers[i])
829 printf("Destroying layer %i.\n",i);
830 Delay(DELAYTIME);
831 DeleteLayer(0, layers[i]);
832 layers[i] = NULL;
835 printf("End of demo .\n");
839 void DemoC()
841 int i;
842 printf("Generating a few layers\n");
843 GenerateLayers2();
844 if (layers[1])
846 printf("Moving layer 1...\n");
847 Delay(30);
848 i = 50;
849 while (i>0 && (TRUE == MoveLayer(0, layers[1], 1,1)))
850 i--;
852 if (layers[2])
854 printf("Moving layer 2...\n");
855 Delay(30);
856 i = 50;
857 while (i>0 && (TRUE == MoveLayer(0, layers[2], 2, -1)))
858 i--;
860 if (layers[3])
862 printf("Moving layer 3...\n");
863 Delay(30);
864 i = 50;
865 while (i>0 && TRUE == MoveLayer(0, layers[3], 1, 3))
866 i--;
868 if (layers[0])
870 printf("Moving layer 0...\n");
871 Delay(30);
872 i = 150;
873 while (i>0 && TRUE == MoveLayer(0, layers[0], 0 ,1))
874 i--;
876 printf("Deleting all visible layers!\n");
877 i = 0;
878 while (i < 10)
880 if (layers[i])
881 DeleteLayer(0, layers[i]);
882 layers[i] = NULL;
883 i++;
888 void DemoD()
890 int i;
891 int c;
892 struct BitMap * sb;
893 printf("Deleting all previously generated layers...\n");
894 for (i = 0; i < 10; i++)
896 if (layers[i])
898 DeleteLayer(0, layers[i]);
899 layers[i] = NULL;
902 i = 0;
904 printf("Creating 4 superbitmap layers\n");
906 sb = AllocBitMap(91,91,1,BMF_CLEAR,NULL);
908 layers[0] = CreateUpfrontLayer(&screen->LayerInfo,
909 screen->RastPort.BitMap,
912 100,
913 100,
914 LAYERSMART|LAYERSUPER,
915 sb);
917 frame(layers[0]);
919 sb = AllocBitMap(71,71,1,BMF_CLEAR,NULL);
920 layers[1] = CreateUpfrontLayer(&screen->LayerInfo,
921 screen->RastPort.BitMap,
924 120,
925 120,
926 LAYERSMART|LAYERSUPER,
927 sb);
929 frame(layers[1]);
931 sb = AllocBitMap(71,61,1,BMF_CLEAR,NULL);
932 layers[2] = CreateUpfrontLayer(&screen->LayerInfo,
933 screen->RastPort.BitMap,
936 140,
938 LAYERSMART|LAYERSUPER,
939 sb);
940 frame(layers[2]);
942 sb = AllocBitMap(131,41,1,BMF_CLEAR,NULL);
943 layers[3] = CreateUpfrontLayer(&screen->LayerInfo,
944 screen->RastPort.BitMap,
947 150,
949 LAYERSMART|LAYERSUPER,
950 sb);
952 frame(layers[3]);
954 printf("Resizing layer 4\n");
955 Delay(30);
956 SizeLayer(0, layers[3], -80, -10);
957 /* this leaves width = 51, height = 31 */
958 printf("Scrolling layer 4\n");
959 Delay(30);
960 c = 0;
961 while (c < 80)
963 c++;
964 Delay(5);
965 ScrollLayer(0, layers[3], 1, 0);
968 c = 0;
969 while (c < 10)
971 c++;
972 Delay(5);
973 ScrollLayer(0, layers[3], 0 ,1);
976 c = 0;
977 while (c < 10)
979 c++;
980 Delay(5);
981 ScrollLayer(0, layers[3], -8 ,-1);
984 printf("Resizing layer 4 to its full size\n");
985 Delay(30);
986 SizeLayer(0, layers[3], 80, 10);
988 printf("Resizing layer 1\n");
989 SizeLayer(0, layers[0], -50, -50);
991 /* this leaves width = 41, height = 41 */
992 printf("Scrolling layer 1\n");
993 Delay(30);
994 c = 0;
995 while (c < 41)
997 c++;
998 Delay(5);
999 ScrollLayer(0, layers[0], 1, 0);
1002 c = 0;
1003 while (c < 41)
1005 c++;
1006 Delay(5);
1007 ScrollLayer(0, layers[0], 0 ,1);
1010 c = 0;
1011 while (c < 41)
1013 c++;
1014 Delay(5);
1015 ScrollLayer(0, layers[0], -1 ,-1);
1018 printf("Resizing layer 1 to its full size\n");
1019 Delay(30);
1020 SizeLayer(0, layers[0], 50, 50);
1022 printf("Shuffling layers...\n");
1023 UpfrontLayer(0, layers[0]);
1024 Delay(20);
1025 UpfrontLayer(0, layers[1]);
1026 Delay(20);
1027 UpfrontLayer(0, layers[2]);
1028 Delay(20);
1029 UpfrontLayer(0, layers[3]);
1030 Delay(20);
1031 BehindLayer(0, layers[2]);
1032 Delay(20);
1033 BehindLayer(0,layers[1]);
1034 Delay(20);
1035 BehindLayer(0,layers[0]);
1036 printf("Inviting a few smart friends...\n");
1037 GenerateLayers3();
1038 printf("Moving the layers...\n");
1039 c = 0;
1040 while (c < 40)
1042 MoveLayer(0, layers[4], -1, -1);
1043 MoveLayer(0, layers[0], 1,2);
1044 MoveLayer(0, layers[2], 2,1);
1045 MoveLayer(0, layers[5], -2, 0);
1046 c++;
1049 c = 0;
1050 while (c < 30)
1052 MoveLayer(0, layers[4], -1, -1);
1053 MoveLayer(0, layers[5], -1, 0);
1054 MoveLayer(0, layers[3], 3, 2);
1055 MoveSizeLayer(layers[2], 2, -1, -1, -1);
1056 c++;
1059 c = 0;
1060 while (c < 30)
1062 MoveSizeLayer(layers[2], -2, 1, 1 ,1);
1063 MoveSizeLayer(layers[1], 2, 0, -1 ,-1);
1064 MoveLayer(0, layers[5], 2, 1);
1065 c++;
1068 c = 0;
1069 while (c < 30)
1071 MoveSizeLayer(layers[1], -1, -1 ,1 , 1);
1072 c++;
1075 printf("Deleting the layers...\n");
1076 i = 0;
1077 while (i < 8)
1079 while ((layers[i]->bounds.MaxX - layers[i]->bounds.MinX) >= 1 &&
1080 (layers[i]->bounds.MaxY - layers[i]->bounds.MinY) >= 1)
1082 MoveSizeLayer(layers[i], 2, 0, -1, -1);
1084 DeleteLayer(0, layers[i]);
1085 layers[i] = NULL;
1086 i++;
1090 void DumpCliprects(void)
1092 int i;
1093 struct ClipRect * CR;
1094 int c;
1096 printf("Dump ClipRects of which layer? ");
1097 scanf("%i",&i);
1098 if (i < 0 || i > 10 || NULL == layers[i])
1100 printf("No such layer!\n");
1101 return;
1104 printf("Layer at %px is a ",layers[i]);
1105 if (0 != (layers[i]->Flags & LAYERSIMPLE))
1106 printf("simple layer\n");
1107 else if (0 != (layers[i]->Flags & LAYERSUPER))
1108 printf("superbitmap layer\n");
1109 else
1110 printf("smart layer\n");
1112 c = 1;
1113 CR = layers[i]->ClipRect;
1114 while (NULL != CR)
1116 printf("CR #%i\n",c);
1118 printf("Bounds: (%i,%i)-(%i,%i)\n",CR->bounds.MinX,CR->bounds.MinY,CR->bounds.MaxX,CR->bounds.MaxY);
1119 if (NULL != CR->lobs)
1120 printf("This cliprect is hidden by layer %px !\n",CR->lobs);
1121 else
1122 printf("This cliprect is visible!\n");
1123 c++;
1124 CR=CR->Next;
1127 printf("-------------------------------------\n");
1130 void doall(void)
1132 char buf[80];
1133 int i;
1134 for (i = 0; i < 10; i++)
1135 layers[i] = NULL;
1137 for (;;)
1139 printf("> ");
1140 fflush(stdout);
1141 scanf("%s", buf);
1143 if (!strcmp(buf,"quit"))
1145 freelayers();
1146 return;
1148 else if (!strcmp(buf, "help"))
1150 printf("quit help createupfrontlayer [cul] createbehindlayer [cbl] deletelayer [dl]\n");
1151 printf("behindlayerupfrontlayer [ul] movelayerinfrontof [mlio]\n");
1152 printf("movelayer [ml] movesizelayer [msl] sizelayer [sl] scrollayer [scl]\n");
1153 printf("motion [mot] DumpCliprects [dc] \n");
1154 printf("Frame [F] DemoA DemoB DemoC DemoD\n");
1155 printf("Generate a few layers: [gl1,gl2,gl3,gl4]\n");
1157 else if (!strcmp(buf, "createupfrontlayer") || !strcmp(buf, "cul"))
1159 createupfrontlayer();
1161 else if (!strcmp(buf, "createbehindlayer") || !strcmp(buf, "cbl"))
1163 createbehindlayer();
1165 else if (!strcmp(buf, "deletelayer") || !strcmp(buf, "dl"))
1167 deletelayer();
1169 else if (!strcmp(buf, "behindlayer") || !strcmp(buf, "bl"))
1171 behindlayer();
1173 else if (!strcmp(buf, "upfrontlayer") || !strcmp(buf, "ul"))
1175 upfrontlayer();
1177 else if (!strcmp(buf, "movelayerinfrontof") || !strcmp(buf, "mlio"))
1179 movelayerinfrontof();
1181 else if (!strcmp(buf, "movelayer") || !strcmp(buf, "ml"))
1183 movelayer();
1185 else if (!strcmp(buf, "movesizelayer") || !strcmp(buf, "msl"))
1187 movesizelayer();
1189 else if (!strcmp(buf, "sizelayer") || !strcmp(buf, "sl"))
1191 sizelayer();
1193 else if (!strcmp(buf, "scrolllayer") || !strcmp(buf, "scl"))
1195 scrolllayer();
1197 else if (!strcmp(buf, "motion") || !strcmp(buf, "mot"))
1199 motion();
1201 else if (!strcmp(buf, "Frame") || !strcmp(buf, "F"))
1203 Frame();
1205 else if (!strcmp(buf, "DemoA"))
1207 DemoA();
1209 else if (!strcmp(buf, "DemoB"))
1211 DemoB();
1213 else if (!strcmp(buf, "DemoC"))
1215 DemoC();
1217 else if (!strcmp(buf, "DemoD"))
1219 DemoD();
1221 else if (!strcmp(buf, "gl1"))
1223 GenerateLayers1();
1225 else if (!strcmp(buf, "gl2"))
1227 GenerateLayers2();
1229 else if (!strcmp(buf, "gl3"))
1231 GenerateLayers3();
1233 else if (!strcmp(buf, "gl4"))
1235 GenerateLayers4();
1237 else if (!strcmp(buf, "dc"))
1239 DumpCliprects();
1241 else
1242 printf("Unknown command. Try 'help'.\n");