xref: /haiku/src/tests/servers/app/newerClipping/ViewLayer.h (revision 2ae568931fcac7deb9f1e6ff4e47213fbfe4029b)
1 
2 #ifndef	VIEW_LAYER_H
3 #define VIEW_LAYER_H
4 
5 #include <GraphicsDefs.h>
6 #include <Region.h>
7 #include <String.h>
8 
9 class BList;
10 class DrawingEngine;
11 class WindowLayer;
12 
13 class ViewLayer {
14  public:
15 							ViewLayer(BRect frame,
16 									  const char* name,
17 									  uint32 reizeMode,
18 									  uint32 flags,
19 									  rgb_color viewColor);
20 
21 	virtual					~ViewLayer();
22 
23 	inline	BRect			Frame() const
24 								{ return fFrame; }
25 			BRect			Bounds() const;
26 
27 	inline	rgb_color		ViewColor() const
28 								{ return fViewColor; }
29 
30 			void			AttachedToWindow(WindowLayer* window,
31 											 bool topLayer = false);
32 			void			DetachedFromWindow();
33 
34 			// tree stuff
35 			void			AddChild(ViewLayer* layer);
36 			bool			RemoveChild(ViewLayer* layer);
37 
38 	inline	ViewLayer*		Parent() const
39 								{ return fParent; }
40 
41 			ViewLayer*		FirstChild() const;
42 			ViewLayer*		PreviousChild() const;
43 			ViewLayer*		NextChild() const;
44 			ViewLayer*		LastChild() const;
45 
46 			ViewLayer*		TopLayer();
47 
48 			uint32			CountChildren(bool deep = false) const;
49 			void			CollectTokensForChildren(BList* tokenMap) const;
50 
51 			// coordinate conversion
52 			void			ConvertToParent(BPoint* point) const;
53 			void			ConvertToParent(BRect* rect) const;
54 			void			ConvertToParent(BRegion* region) const;
55 
56 			void			ConvertFromParent(BPoint* point) const;
57 			void			ConvertFromParent(BRect* rect) const;
58 			void			ConvertFromParent(BRegion* region) const;
59 
60 			void			ConvertToTop(BPoint* point) const;
61 			void			ConvertToTop(BRect* rect) const;
62 			void			ConvertToTop(BRegion* region) const;
63 
64 			// settings
65 			void			SetName(const char* string);
66 	inline	const char*		Name() const
67 								{ return fName.String(); }
68 
69 			void			MoveBy(			int32 dx, int32 dy,
70 											BRegion* dirtyRegion);
71 
72 			void			ResizeBy(		int32 dx, int32 dy,
73 											BRegion* dirtyRegion);
74 
75 			void			ScrollBy(		int32 dx, int32 dy,
76 											BRegion* dirtyRegion);
77 
78 			void			ParentResized(	int32 dx, int32 dy,
79 											BRegion* dirtyRegion);
80 
81 			// for background clearing
82 			void			Draw(			DrawingEngine* drawingEngine,
83 											BRegion* effectiveClipping,
84 											BRegion* windowContentClipping,
85 											bool deep = false);
86 
87 			// to simulate drawing triggered from client side
88 			void			ClientDraw(		DrawingEngine* drawingEngine,
89 											BRegion* effectiveClipping);
90 
91 			bool			IsHidden() const;
92 			void			Hide();
93 			void			Show();
94 
95 			// clipping
96 			void			RebuildClipping(bool deep);
97 			BRegion&		ScreenClipping(BRegion* windowContentClipping,
98 										   bool force = false) const;
99 
100 			// debugging
101 			void			PrintToStream() const;
102 
103 			void			InvalidateScreenClipping(bool deep);
104 
105 private:
106 			void			_MoveScreenClipping(int32 x, int32 y,
107 												bool deep);
108 
109 			BString			fName;
110 			// area within parent coordinate space
111 			BRect			fFrame;
112 			// scrolling offset
113 			BPoint			fScrollingOffset;
114 
115 			rgb_color		fViewColor;
116 
117 			uint32			fResizeMode;
118 			uint32			fFlags;
119 			bool			fHidden;
120 
121 			WindowLayer*	fWindow;
122 			ViewLayer*		fParent;
123 			bool			fIsTopLayer;
124 
125 			ViewLayer*		fFirstChild;
126 			ViewLayer*		fPreviousSibling;
127 			ViewLayer*		fNextSibling;
128 			ViewLayer*		fLastChild;
129 
130 			// used for traversing the childs
131 	mutable	ViewLayer*		fCurrentChild;
132 
133 			// clipping
134 			BRegion			fLocalClipping;
135 
136 	mutable	BRegion			fScreenClipping;
137 	mutable	bool			fScreenClippingValid;
138 
139 };
140 
141 #endif // LAYER_H
142