Fixed compatibility of output.
[AROS.git] / test / layers / layerstest.c
blobd177a85223b73e291c652c7c93de6522fb506d40
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <string.h>
8 #include <exec/types.h>
9 #include <aros/asmcall.h>
10 #include <graphics/rastport.h>
11 #include <graphics/regions.h>
12 #include <graphics/layers.h>
13 #include <graphics/clip.h>
14 #include <intuition/intuition.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
19 #include <proto/layers.h>
21 #define GFX_SYSTEM X11 /* ord HIDD */
23 struct IntuitionBase *IntuitionBase;
24 struct GfxBase *GfxBase;
25 struct Library *LayersBase;
26 struct DosLibrary *DOSBase;
27 struct Screen *screen;
28 struct Window * window;
30 void doall(void);
31 struct Screen * openscreen(void);
32 void closescreen(struct Screen * screen);
34 APTR BltBitMapPtr;
36 int main(int argc, char **argv)
38 if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0)))
40 if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0)))
42 if ((LayersBase = OpenLibrary("layers.library", 0)))
44 if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0)))
46 if ((screen = openscreen()))
48 doall();
49 closescreen(screen);
51 CloseLibrary((struct Library *)DOSBase);
53 CloseLibrary(LayersBase);
55 CloseLibrary((struct Library *)GfxBase);
57 CloseLibrary((struct Library *) IntuitionBase);
59 return 0;
60 } /* main */
63 struct Screen * openscreen(void)
65 struct Screen * screen;
67 screen = OpenScreenTags(NULL,
68 SA_Height, 200,
69 SA_Width, 300,
70 TAG_END);
72 Draw(&screen->RastPort, 100, 100);
74 return screen;
77 void closescreen(struct Screen * screen)
79 CloseScreen(screen);
82 struct Layer *layers[10];
84 void freelayers(void)
86 int i;
87 for (i=0; i < 10; i++)
89 if (NULL != layers[i])
91 DeleteLayer(0, layers[i]);
92 if (layers[i]->SuperBitMap)
93 FreeBitMap(layers[i]->SuperBitMap);
98 int unusedlayer(void)
100 int i;
101 for (i =0; i < 10; i++)
103 if (NULL == layers[i])
104 return i;
106 return -1;
109 void createupfrontlayer(void)
111 int x0,y0,x1,y1;
112 int i;
113 char c,s;
114 LONG flags = 0;
115 struct BitMap * sb = NULL;
116 for (i = 0; i < 10; i++)
118 if (layers[i] == NULL)
119 break;
121 if (i < 10)
123 printf("Backdroplayer [y/N]: ");
124 scanf("%c", &c);
125 printf("SuperBitMap [y/N]: ");
126 scanf("%c", &s);
127 printf("x0: ");
128 scanf("%d", &x0);
129 printf("y0: ");
130 scanf("%d", &y0);
131 printf("x1: ");
132 scanf("%d", &x1);
133 printf("y1: ");
134 scanf("%d", &y1);
136 if (c=='y' || c=='Y')
138 printf("Generating a backdrop layer.\n");
139 flags |= LAYERBACKDROP;
141 if (s=='y' || s=='Y')
143 printf("Generating a superbitmap layer.\n");
144 flags |= LAYERSUPER;
145 sb = AllocBitMap(x1-x0+1,y1-y0+1,1,BMF_CLEAR,NULL);
148 flags |= LAYERSMART;
150 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
151 screen->RastPort.BitMap,
156 flags,
157 sb);
158 if (layers[i])
159 printf("Created layer with ID %d\n",i);
160 else
161 printf("Couldn't create layer. No more memory (?).\n");
163 else
164 printf("No more layers possible!\n");
167 void createbehindlayer(void)
169 int x0,y0,x1,y1;
170 int i;
171 char c, s;
172 LONG flags = 0;
173 struct BitMap * sb = NULL;
174 for (i = 0; i < 10; i++)
176 if (layers[i] == NULL)
177 break;
179 if (i < 10)
181 printf("Backdroplayer [y/N]: ");
182 scanf("%c", &c);
183 printf("SuperBitMap [y/N]: ");
184 scanf("%c", &s);
185 printf("x0: ");
186 scanf("%d", &x0);
187 printf("y0: ");
188 scanf("%d", &y0);
189 printf("x1: ");
190 scanf("%d", &x1);
191 printf("y1: ");
192 scanf("%d", &y1);
194 if (c=='y' || c=='Y')
196 printf("Generating a backdrop layer.\n");
197 flags |= LAYERBACKDROP;
199 if (s=='y' || s=='Y')
201 printf("Generating a superbitmap layer.\n");
202 flags |= LAYERSUPER;
203 sb = AllocBitMap(x1-x0+1,y1-y0+1,1,BMF_CLEAR,NULL);
206 flags |= LAYERSMART;
208 layers[i] = CreateBehindLayer(&screen->LayerInfo,
209 screen->RastPort.BitMap,
214 flags,
215 sb);
216 if (layers[i])
217 printf("Created layer with ID %d\n",i);
218 else
219 printf("Couldn't create layer. No more memory (?).\n");
221 else
222 printf("No more layers possible!\n");
225 void deletelayer(void)
227 int i;
228 printf("Delete layer with id: ");
229 scanf("%d", &i);
230 if (layers[i])
232 DeleteLayer(0, layers[i]);
233 if (layers[i]->SuperBitMap)
234 FreeBitMap(layers[i]->SuperBitMap);
235 printf("Deleted layer with id %d\n",i);
236 layers[i] = NULL;
238 else
240 printf("No layer with id %d\n",i);
244 void upfrontlayer(void)
246 int i;
247 printf("Upfront layer with id: ");
248 scanf("%d", &i);
249 if (layers[i]) {
250 UpfrontLayer(0, layers[i]);
251 printf("Moved layer with id %d upfront\n",i);
253 else
255 printf("No layer with id %d\n",i);
259 void behindlayer(void)
261 int i;
262 printf("Behind layer with id: ");
263 scanf("%d", &i);
264 if (layers[i]) {
265 BehindLayer(0, layers[i]);
266 printf("Moved layer with id %d behind\n",i);
268 else
270 printf("No layer with id %d\n",i);
274 void movelayerinfrontof(void)
276 int i1,i2;
277 printf("Move layer with id: ");
278 scanf("%d", &i1);
279 printf("in front of layer with id: ");
280 scanf("%d", &i2);
281 if (layers[i1] && layers[i2]) {
282 MoveLayerInFrontOf(layers[i1], layers[i2]);
283 printf("Moved layer with id %d in front of layer with id %d\n",i1,i2);
285 else
287 printf("No layer with id %d or id %d\n",i1,i2);
291 void movelayer(void)
293 int i,dx,dy;
294 printf("Move layer with id: ");
295 scanf("%d",&i);
296 printf("delta x: ");
297 scanf("%d",&dx);
298 printf("delta y: ");
299 scanf("%d",&dy);
300 if (layers[i])
302 MoveLayer(0, layers[i], dx, dy);
303 printf("Moved layer with id %d to new position.\n",i);
305 else
307 printf("No layer with id %d\n",i);
311 void movesizelayer(void)
313 int i,dx,dy,dw,dh;
314 printf("Move and size layer with id: ");
315 scanf("%d",&i);
316 printf("delta x: ");
317 scanf("%d",&dx);
318 printf("delta y: ");
319 scanf("%d",&dy);
320 printf("delta width: ");
321 scanf("%d",&dw);
322 printf("delta height: ");
323 scanf("%d",&dh);
324 if (layers[i])
326 MoveSizeLayer(layers[i], dx, dy, dw, dh);
327 printf("Moved and sized layer with id %d.\n",i);
329 else
331 printf("No layer with id %d\n",i);
335 void sizelayer(void)
337 int i,dx,dy;
338 printf("Resize layer with id: ");
339 scanf("%d",&i);
340 printf("delta width: ");
341 scanf("%d",&dx);
342 printf("delta height: ");
343 scanf("%d",&dy);
344 if (layers[i])
346 SizeLayer(0, layers[i], dx, dy);
347 printf("Resized layer with id %d.\n",i);
349 else
351 printf("No layer with id %d\n",i);
355 void scrolllayer(void)
357 int i,dx,dy;
358 printf("Scroll layer with id: ");
359 scanf("%d",&i);
360 if (NULL == layers[i])
362 printf("No layer with id %d\n",i);
365 printf("delta x: ");
366 scanf("%d",&dx);
367 printf("delta y: ");
368 scanf("%d",&dy);
370 if (0 == (layers[i]->Flags & LAYERSUPER))
371 printf("This is a non-superbitmapped layer.\n");
372 else
373 printf("This is a superbitmapped layer.\n");
375 ScrollLayer(0, layers[i], dx, dy);
376 printf("Scrolled layer with id %d.\n",i);
380 void motion(void)
382 int i,dx,dy,iter;
383 printf("Move layer with id: ");
384 scanf("%d",&i);
385 printf("delta x: ");
386 scanf("%d",&dx);
387 printf("delta y: ");
388 scanf("%d",&dy);
389 printf("iterations: ");
390 scanf("%d",&iter);
391 if (layers[i])
393 while (iter > 0 && (TRUE == MoveLayer(0, layers[i],dx,dy)))
394 iter--;
395 printf("Moved layer with id %d to new position.\n",i);
397 else
399 printf("No layer with id %d\n",i);
403 /* Draw a simple frame around a layer */
404 void frame(struct Layer * layer)
406 int c, width = layer->bounds.MaxX-layer->bounds.MinX,i=0;
407 SetAPen(layer->rp, 1);
408 Move(layer->rp, 0,0);
409 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX, 0);
410 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX,
411 layer->bounds.MaxY - layer->bounds.MinY);
412 Draw(layer->rp, 0, layer->bounds.MaxY - layer->bounds.MinY);
413 Draw(layer->rp, 0, 0);
414 Draw(layer->rp, layer->bounds.MaxX - layer->bounds.MinX,
415 layer->bounds.MaxY - layer->bounds.MinY);
417 for (c=0; c <= width; c= c+(width&0x0f)+i )
419 i+=2;
420 Move(layer->rp,c,0);
421 Draw(layer->rp,c,layer->bounds.MaxY - layer->bounds.MinY);
425 void Frame(void)
427 int i;
428 printf("Framing layer with id: ");
429 scanf("%d", &i);
430 if (layers[i])
432 /* Draw a Frame */
433 frame(layers[i]);
435 else
437 printf("No layer with id %d\n",i);
441 void GenerateLayers1(void)
443 int i;
444 i = unusedlayer();
445 if (i==-1) return;
446 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
447 screen->RastPort.BitMap,
450 100,
451 100,
452 LAYERSMART,
453 NULL);
455 frame(layers[i]);
457 i = unusedlayer();
458 if (i==-1) return;
459 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
460 screen->RastPort.BitMap,
463 150,
464 150,
465 LAYERSMART,
466 NULL);
468 frame(layers[i]);
470 i = unusedlayer();
471 if (i==-1) return;
472 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
473 screen->RastPort.BitMap,
476 120,
478 LAYERSMART,
479 NULL);
481 frame(layers[i]);
484 void GenerateLayers2(void)
486 int i;
487 i = unusedlayer();
488 layers[i] = CreateBehindLayer(&screen->LayerInfo,
489 screen->RastPort.BitMap,
492 100,
494 LAYERSMART,
495 NULL);
497 frame(layers[i]);
499 i = unusedlayer();
500 layers[i] = CreateBehindLayer(&screen->LayerInfo,
501 screen->RastPort.BitMap,
504 150,
505 150,
506 LAYERSMART,
507 NULL);
509 frame(layers[i]);
511 i = unusedlayer();
512 layers[i] = CreateBehindLayer(&screen->LayerInfo,
513 screen->RastPort.BitMap,
515 130,
516 140,
517 190,
518 LAYERSMART,
519 NULL);
521 frame(layers[i]);
523 i = unusedlayer();
524 layers[i] = CreateBehindLayer(&screen->LayerInfo,
525 screen->RastPort.BitMap,
526 120,
527 120,
528 150,
529 160,
530 LAYERSMART,
531 NULL);
533 frame(layers[i]);
536 void GenerateLayers3(void)
538 int i;
539 i = unusedlayer();
540 layers[i] = CreateBehindLayer(&screen->LayerInfo,
541 screen->RastPort.BitMap,
542 110,
543 110,
544 200,
545 195,
546 LAYERSMART,
547 NULL);
549 frame(layers[i]);
551 i = unusedlayer();
552 layers[i] = CreateBehindLayer(&screen->LayerInfo,
553 screen->RastPort.BitMap,
554 150,
555 150,
556 190,
557 190,
558 LAYERSMART,
559 NULL);
561 frame(layers[i]);
563 i = unusedlayer();
564 layers[i] = CreateBehindLayer(&screen->LayerInfo,
565 screen->RastPort.BitMap,
567 130,
568 140,
569 190,
570 LAYERSMART,
571 NULL);
572 frame(layers[i]);
574 i = unusedlayer();
575 layers[i] = CreateBehindLayer(&screen->LayerInfo,
576 screen->RastPort.BitMap,
577 120,
578 120,
579 150,
580 160,
581 LAYERSMART,
582 NULL);
584 frame(layers[i]);
587 void GenerateLayers4(void)
589 int i;
590 int c = 0;
591 while (c < 5)
593 i = unusedlayer();
594 if (-1 == i)
595 return;
596 layers[i] = CreateBehindLayer(&screen->LayerInfo,
597 screen->RastPort.BitMap,
598 10+c*10,
599 10+c*10,
600 100+c*10,
601 100+c*10,
602 LAYERSMART,
603 NULL);
604 frame(layers[i]);
605 c++;
609 void DemoA(void)
611 #define DELAYTIME 50
612 int i;
613 printf("Deleting all previously generated layers...\n");
614 for (i = 0; i < 10; i++)
616 if (layers[i])
618 DeleteLayer(0, layers[i]);
619 layers[i] = NULL;
622 i = 0;
624 printf("After each step there will be a short delay.\n");
625 printf("Activate other X-window (Amiga Screen) and always press a key\nto see what is going on\n");
626 printf("Creating layer %i.\n",i);
627 Delay(DELAYTIME);
628 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
629 screen->RastPort.BitMap,
632 100,
633 100,
634 LAYERSMART,
635 NULL);
637 frame(layers[i]);
639 printf("Creating layer %i.\n",++i);
640 Delay(DELAYTIME);
641 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
642 screen->RastPort.BitMap,
646 150,
647 LAYERSMART,
648 NULL);
649 frame(layers[i]);
651 printf("Creating layer %i.\n",++i);
652 Delay(DELAYTIME);
653 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
654 screen->RastPort.BitMap,
657 150,
659 LAYERSMART,
660 NULL);
661 frame(layers[i]);
663 printf("Creating layer %i.\n",++i);
664 Delay(DELAYTIME);
665 layers[i] = CreateUpfrontLayer(&screen->LayerInfo,
666 screen->RastPort.BitMap,
669 180,
670 200,
671 LAYERSMART,
672 NULL);
673 frame(layers[i]);
675 i = 0;
676 printf("Moving layer %i in front of all other layers.\n",i);
677 Delay(DELAYTIME);
678 UpfrontLayer(0, layers[i]);
680 i = 1;
681 printf("Moving layer %i in front of all other layers.\n",i);
682 Delay(DELAYTIME);
683 UpfrontLayer(0, layers[i]);
685 i = 2;
686 printf("Moving layer %i in front of all other layers.\n",i);
687 Delay(DELAYTIME);
688 UpfrontLayer(0, layers[i]);
690 i = 3;
691 printf("Moving layer %i in front of all other layers.\n",i);
692 Delay(DELAYTIME);
693 UpfrontLayer(0, layers[i]);
696 i = 0;
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 = 2;
707 printf("Moving layer %i in front of all other layers.\n",i);
708 Delay(DELAYTIME);
709 UpfrontLayer(0, layers[i]);
711 i = 1;
712 printf("Moving layer %i in front of all other layers.\n",i);
713 Delay(DELAYTIME);
714 UpfrontLayer(0, layers[i]);
716 i = 2;
717 printf("Moving layer %i in front of all other layers.\n",i);
718 Delay(DELAYTIME);
719 UpfrontLayer(0, layers[i]);
721 for (i = 0; i < 10; i++)
722 if (NULL != layers[i])
724 printf("Destroying layer %i.\n",i);
725 Delay(DELAYTIME);
726 DeleteLayer(0, layers[i]);
727 layers[i] = NULL;
730 printf("End of demo .\n");
733 void DemoB(void)
735 #undef DELAYTIME
736 #define DELAYTIME 100
737 int i;
738 printf("Deleting all previously generated layers...\n");
739 for (i = 0; i < 10; i++)
741 if (layers[i])
743 DeleteLayer(0, layers[i]);
744 layers[i] = NULL;
747 i = 0;
749 printf("After each step there will be a short delay.\n");
750 printf("Activate other X-window (Amiga Screen) and always press a key\nto see what is going on\n");
751 printf("Creating behind-layer %i.\n",i);
752 Delay(DELAYTIME);
753 layers[i] = CreateBehindLayer(&screen->LayerInfo,
754 screen->RastPort.BitMap,
757 100,
758 100,
759 LAYERSMART,
760 NULL);
762 frame(layers[i]);
764 printf("Creating behind-layer %i.\n",++i);
765 Delay(DELAYTIME);
766 layers[i] = CreateBehindLayer(&screen->LayerInfo,
767 screen->RastPort.BitMap,
770 120,
771 120,
772 LAYERSMART,
773 NULL);
775 frame(layers[i]);
777 printf("Creating behind-layer %i.\n",++i);
778 Delay(DELAYTIME);
779 layers[i] = CreateBehindLayer(&screen->LayerInfo,
780 screen->RastPort.BitMap,
783 140,
785 LAYERSMART,
786 NULL);
787 frame(layers[i]);
790 printf("Creating behind-layer %i.\n",++i);
791 Delay(DELAYTIME);
792 layers[i] = CreateBehindLayer(&screen->LayerInfo,
793 screen->RastPort.BitMap,
796 150,
798 LAYERSMART,
799 NULL);
801 frame(layers[i]);
803 i = 2;
804 printf("Moving layer %i in front of all other layers.\n",i);
805 Delay(DELAYTIME);
806 UpfrontLayer(0, layers[i]);
808 printf("Moving layer %i in front of layer %i\n",3,0);
809 Delay(DELAYTIME);
810 MoveLayerInFrontOf(layers[3], layers[0]);
812 printf("Moving layer %i in front of layer %i\n",0,3);
813 Delay(DELAYTIME);
814 MoveLayerInFrontOf(layers[0], layers[3]);
816 i = 1;
817 printf("Moving layer %i in front of all other layers.\n",i);
818 Delay(DELAYTIME);
819 UpfrontLayer(0, layers[i]);
821 i = 0;
822 printf("Moving layer %i in front of all other layers.\n",i);
823 Delay(DELAYTIME);
824 UpfrontLayer(0, layers[i]);
826 i = 1;
827 printf("Moving layer %i behind all other layers.\n",i);
828 Delay(DELAYTIME);
829 BehindLayer(0, layers[i]);
831 for (i = 0; i < 10; i++)
832 if (NULL != layers[i])
834 printf("Destroying layer %i.\n",i);
835 Delay(DELAYTIME);
836 DeleteLayer(0, layers[i]);
837 layers[i] = NULL;
840 printf("End of demo .\n");
844 void DemoC()
846 int i;
847 printf("Generating a few layers\n");
848 GenerateLayers2();
849 if (layers[1])
851 printf("Moving layer 1...\n");
852 Delay(30);
853 i = 50;
854 while (i>0 && (TRUE == MoveLayer(0, layers[1], 1,1)))
855 i--;
857 if (layers[2])
859 printf("Moving layer 2...\n");
860 Delay(30);
861 i = 50;
862 while (i>0 && (TRUE == MoveLayer(0, layers[2], 2, -1)))
863 i--;
865 if (layers[3])
867 printf("Moving layer 3...\n");
868 Delay(30);
869 i = 50;
870 while (i>0 && TRUE == MoveLayer(0, layers[3], 1, 3))
871 i--;
873 if (layers[0])
875 printf("Moving layer 0...\n");
876 Delay(30);
877 i = 150;
878 while (i>0 && TRUE == MoveLayer(0, layers[0], 0 ,1))
879 i--;
881 printf("Deleting all visible layers!\n");
882 i = 0;
883 while (i < 10)
885 if (layers[i])
886 DeleteLayer(0, layers[i]);
887 layers[i] = NULL;
888 i++;
893 void DemoD()
895 int i;
896 int c;
897 struct BitMap * sb;
898 printf("Deleting all previously generated layers...\n");
899 for (i = 0; i < 10; i++)
901 if (layers[i])
903 DeleteLayer(0, layers[i]);
904 layers[i] = NULL;
907 i = 0;
909 printf("Creating 4 superbitmap layers\n");
911 sb = AllocBitMap(91,91,1,BMF_CLEAR,NULL);
913 layers[0] = CreateUpfrontLayer(&screen->LayerInfo,
914 screen->RastPort.BitMap,
917 100,
918 100,
919 LAYERSMART|LAYERSUPER,
920 sb);
922 frame(layers[0]);
924 sb = AllocBitMap(71,71,1,BMF_CLEAR,NULL);
925 layers[1] = CreateUpfrontLayer(&screen->LayerInfo,
926 screen->RastPort.BitMap,
929 120,
930 120,
931 LAYERSMART|LAYERSUPER,
932 sb);
934 frame(layers[1]);
936 sb = AllocBitMap(71,61,1,BMF_CLEAR,NULL);
937 layers[2] = CreateUpfrontLayer(&screen->LayerInfo,
938 screen->RastPort.BitMap,
941 140,
943 LAYERSMART|LAYERSUPER,
944 sb);
945 frame(layers[2]);
947 sb = AllocBitMap(131,41,1,BMF_CLEAR,NULL);
948 layers[3] = CreateUpfrontLayer(&screen->LayerInfo,
949 screen->RastPort.BitMap,
952 150,
954 LAYERSMART|LAYERSUPER,
955 sb);
957 frame(layers[3]);
959 printf("Resizing layer 4\n");
960 Delay(30);
961 SizeLayer(0, layers[3], -80, -10);
962 /* this leaves width = 51, height = 31 */
963 printf("Scrolling layer 4\n");
964 Delay(30);
965 c = 0;
966 while (c < 80)
968 c++;
969 Delay(5);
970 ScrollLayer(0, layers[3], 1, 0);
973 c = 0;
974 while (c < 10)
976 c++;
977 Delay(5);
978 ScrollLayer(0, layers[3], 0 ,1);
981 c = 0;
982 while (c < 10)
984 c++;
985 Delay(5);
986 ScrollLayer(0, layers[3], -8 ,-1);
989 printf("Resizing layer 4 to its full size\n");
990 Delay(30);
991 SizeLayer(0, layers[3], 80, 10);
993 printf("Resizing layer 1\n");
994 SizeLayer(0, layers[0], -50, -50);
996 /* this leaves width = 41, height = 41 */
997 printf("Scrolling layer 1\n");
998 Delay(30);
999 c = 0;
1000 while (c < 41)
1002 c++;
1003 Delay(5);
1004 ScrollLayer(0, layers[0], 1, 0);
1007 c = 0;
1008 while (c < 41)
1010 c++;
1011 Delay(5);
1012 ScrollLayer(0, layers[0], 0 ,1);
1015 c = 0;
1016 while (c < 41)
1018 c++;
1019 Delay(5);
1020 ScrollLayer(0, layers[0], -1 ,-1);
1023 printf("Resizing layer 1 to its full size\n");
1024 Delay(30);
1025 SizeLayer(0, layers[0], 50, 50);
1027 printf("Shuffling layers...\n");
1028 UpfrontLayer(0, layers[0]);
1029 Delay(20);
1030 UpfrontLayer(0, layers[1]);
1031 Delay(20);
1032 UpfrontLayer(0, layers[2]);
1033 Delay(20);
1034 UpfrontLayer(0, layers[3]);
1035 Delay(20);
1036 BehindLayer(0, layers[2]);
1037 Delay(20);
1038 BehindLayer(0,layers[1]);
1039 Delay(20);
1040 BehindLayer(0,layers[0]);
1041 printf("Inviting a few smart friends...\n");
1042 GenerateLayers3();
1043 printf("Moving the layers...\n");
1044 c = 0;
1045 while (c < 40)
1047 MoveLayer(0, layers[4], -1, -1);
1048 MoveLayer(0, layers[0], 1,2);
1049 MoveLayer(0, layers[2], 2,1);
1050 MoveLayer(0, layers[5], -2, 0);
1051 c++;
1054 c = 0;
1055 while (c < 30)
1057 MoveLayer(0, layers[4], -1, -1);
1058 MoveLayer(0, layers[5], -1, 0);
1059 MoveLayer(0, layers[3], 3, 2);
1060 MoveSizeLayer(layers[2], 2, -1, -1, -1);
1061 c++;
1064 c = 0;
1065 while (c < 30)
1067 MoveSizeLayer(layers[2], -2, 1, 1 ,1);
1068 MoveSizeLayer(layers[1], 2, 0, -1 ,-1);
1069 MoveLayer(0, layers[5], 2, 1);
1070 c++;
1073 c = 0;
1074 while (c < 30)
1076 MoveSizeLayer(layers[1], -1, -1 ,1 , 1);
1077 c++;
1080 printf("Deleting the layers...\n");
1081 i = 0;
1082 while (i < 8)
1084 while ((layers[i]->bounds.MaxX - layers[i]->bounds.MinX) >= 1 &&
1085 (layers[i]->bounds.MaxY - layers[i]->bounds.MinY) >= 1)
1087 MoveSizeLayer(layers[i], 2, 0, -1, -1);
1089 DeleteLayer(0, layers[i]);
1090 layers[i] = NULL;
1091 i++;
1095 void DumpCliprects(void)
1097 int i;
1098 struct ClipRect * CR;
1099 int c;
1101 printf("Dump ClipRects of which layer? ");
1102 scanf("%i",&i);
1103 if (i < 0 || i > 10 || NULL == layers[i])
1105 printf("No such layer!\n");
1106 return;
1109 printf("Layer at %px is a ",layers[i]);
1110 if (0 != (layers[i]->Flags & LAYERSIMPLE))
1111 printf("simple layer\n");
1112 else if (0 != (layers[i]->Flags & LAYERSUPER))
1113 printf("superbitmap layer\n");
1114 else
1115 printf("smart layer\n");
1117 c = 1;
1118 CR = layers[i]->ClipRect;
1119 while (NULL != CR)
1121 printf("CR #%i\n",c);
1123 printf("Bounds: (%i,%i)-(%i,%i)\n",CR->bounds.MinX,CR->bounds.MinY,CR->bounds.MaxX,CR->bounds.MaxY);
1124 if (NULL != CR->lobs)
1125 printf("This cliprect is hidden by layer %px !\n",CR->lobs);
1126 else
1127 printf("This cliprect is visible!\n");
1128 c++;
1129 CR=CR->Next;
1132 printf("-------------------------------------\n");
1135 void doall(void)
1137 char buf[80];
1138 int i;
1139 for (i = 0; i < 10; i++)
1140 layers[i] = NULL;
1142 for (;;)
1144 printf("> ");
1145 fflush(stdout);
1146 scanf("%s", buf);
1148 if (!strcmp(buf,"quit"))
1150 freelayers();
1151 return;
1153 else if (!strcmp(buf, "help"))
1155 printf("quit help createupfrontlayer [cul] createbehindlayer [cbl] deletelayer [dl]\n");
1156 printf("behindlayerupfrontlayer [ul] movelayerinfrontof [mlio]\n");
1157 printf("movelayer [ml] movesizelayer [msl] sizelayer [sl] scrollayer [scl]\n");
1158 printf("motion [mot] DumpCliprects [dc] \n");
1159 printf("Frame [F] DemoA DemoB DemoC DemoD\n");
1160 printf("Generate a few layers: [gl1,gl2,gl3,gl4]\n");
1162 else if (!strcmp(buf, "createupfrontlayer") || !strcmp(buf, "cul"))
1164 createupfrontlayer();
1166 else if (!strcmp(buf, "createbehindlayer") || !strcmp(buf, "cbl"))
1168 createbehindlayer();
1170 else if (!strcmp(buf, "deletelayer") || !strcmp(buf, "dl"))
1172 deletelayer();
1174 else if (!strcmp(buf, "behindlayer") || !strcmp(buf, "bl"))
1176 behindlayer();
1178 else if (!strcmp(buf, "upfrontlayer") || !strcmp(buf, "ul"))
1180 upfrontlayer();
1182 else if (!strcmp(buf, "movelayerinfrontof") || !strcmp(buf, "mlio"))
1184 movelayerinfrontof();
1186 else if (!strcmp(buf, "movelayer") || !strcmp(buf, "ml"))
1188 movelayer();
1190 else if (!strcmp(buf, "movesizelayer") || !strcmp(buf, "msl"))
1192 movesizelayer();
1194 else if (!strcmp(buf, "sizelayer") || !strcmp(buf, "sl"))
1196 sizelayer();
1198 else if (!strcmp(buf, "scrolllayer") || !strcmp(buf, "scl"))
1200 scrolllayer();
1202 else if (!strcmp(buf, "motion") || !strcmp(buf, "mot"))
1204 motion();
1206 else if (!strcmp(buf, "Frame") || !strcmp(buf, "F"))
1208 Frame();
1210 else if (!strcmp(buf, "DemoA"))
1212 DemoA();
1214 else if (!strcmp(buf, "DemoB"))
1216 DemoB();
1218 else if (!strcmp(buf, "DemoC"))
1220 DemoC();
1222 else if (!strcmp(buf, "DemoD"))
1224 DemoD();
1226 else if (!strcmp(buf, "gl1"))
1228 GenerateLayers1();
1230 else if (!strcmp(buf, "gl2"))
1232 GenerateLayers2();
1234 else if (!strcmp(buf, "gl3"))
1236 GenerateLayers3();
1238 else if (!strcmp(buf, "gl4"))
1240 GenerateLayers4();
1242 else if (!strcmp(buf, "dc"))
1244 DumpCliprects();
1246 else
1247 printf("Unknown command. Try 'help'.\n");