1 /* 2 * Copyright 2007-2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus, superstippi@gmx.de 7 */ 8 #ifndef SPIDER_SAVER_H 9 #define SPIDER_SAVER_H 10 11 12 #include <Locker.h> 13 #include <ScreenSaver.h> 14 #include <View.h> 15 16 17 enum { 18 RED = 1, 19 GREEN = 2, 20 BLUE = 3, 21 YELLOW = 4, 22 PURPLE = 5, 23 CYAN = 6, 24 GRAY = 7, 25 }; 26 27 28 #define MIN_POLY_POINTS 3 29 #define MAX_POLY_POINTS 10 30 #define MIN_QUEUE_DEPTH 40 31 #define MAX_QUEUE_DEPTH 160 32 #define MAX_QUEUE_NUMBER 40 33 34 35 36 class BSlider; 37 class BMenuField; 38 class Polygon; 39 class PolygonQueue; 40 class SpiderView; 41 42 43 class SpiderSaver : public BScreenSaver { 44 public: 45 SpiderSaver(BMessage *message, 46 image_id image); 47 virtual ~SpiderSaver(); 48 49 // BScreenSaver 50 virtual void StartConfig(BView *view); 51 virtual status_t StartSaver(BView *view, bool preview); 52 virtual void StopSaver(); 53 virtual void Draw(BView* view, int32 frame); 54 virtual status_t SaveState(BMessage* into) const; 55 56 // SpiderSaver 57 void SetQueueNumber(uint32 number); 58 void SetQueueDepth(uint32 maxDepth); 59 void SetPolyPoints(uint32 maxPoints); 60 void SetColor(uint32 color); 61 62 private: 63 void _Init(BRect bounds); 64 void _Cleanup(); 65 void _AllocBackBitmap(float width, float height); 66 void _FreeBackBitmap(); 67 void _DrawInto(BView *view); 68 void _DrawPolygon(Polygon* polygon, BView *view); 69 70 BBitmap* fBackBitmap; 71 BView* fBackView; 72 73 PolygonQueue** fQueues; 74 uint32 fQueueNumber; 75 uint32 fMaxPolyPoints; 76 uint32 fMaxQueueDepth; 77 uint32 fColor; 78 79 bool fPreview; 80 BRect fBounds; 81 82 BLocker fLocker; 83 }; 84 85 86 #endif // SPIDER_SAVER_H 87