1 /**
2 Canvas drawing layer.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.canvaslayer;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.node;
25 /**
26 Canvas drawing layer.
27 
28 $(D CanvasItem) nodes that are direct or indirect children of a $(D CanvasLayer) will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a $(D CanvasLayer) with index -1 will be drawn below, and one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below).
29 */
30 @GodotBaseClass struct CanvasLayer
31 {
32 	package(godot) enum string _GODOT_internal_name = "CanvasLayer";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Node _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("get_canvas") GodotMethod!(RID) getCanvas;
43 		@GodotName("get_custom_viewport") GodotMethod!(Node) getCustomViewport;
44 		@GodotName("get_follow_viewport_scale") GodotMethod!(double) getFollowViewportScale;
45 		@GodotName("get_layer") GodotMethod!(long) getLayer;
46 		@GodotName("get_offset") GodotMethod!(Vector2) getOffset;
47 		@GodotName("get_rotation") GodotMethod!(double) getRotation;
48 		@GodotName("get_rotation_degrees") GodotMethod!(double) getRotationDegrees;
49 		@GodotName("get_scale") GodotMethod!(Vector2) getScale;
50 		@GodotName("get_transform") GodotMethod!(Transform2D) getTransform;
51 		@GodotName("is_following_viewport") GodotMethod!(bool) isFollowingViewport;
52 		@GodotName("set_custom_viewport") GodotMethod!(void, Node) setCustomViewport;
53 		@GodotName("set_follow_viewport") GodotMethod!(void, bool) setFollowViewport;
54 		@GodotName("set_follow_viewport_scale") GodotMethod!(void, double) setFollowViewportScale;
55 		@GodotName("set_layer") GodotMethod!(void, long) setLayer;
56 		@GodotName("set_offset") GodotMethod!(void, Vector2) setOffset;
57 		@GodotName("set_rotation") GodotMethod!(void, double) setRotation;
58 		@GodotName("set_rotation_degrees") GodotMethod!(void, double) setRotationDegrees;
59 		@GodotName("set_scale") GodotMethod!(void, Vector2) setScale;
60 		@GodotName("set_transform") GodotMethod!(void, Transform2D) setTransform;
61 	}
62 	/// 
63 	pragma(inline, true) bool opEquals(in CanvasLayer other) const
64 	{ return _godot_object.ptr is other._godot_object.ptr; }
65 	/// 
66 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
67 	{ _godot_object.ptr = n; return null; }
68 	/// 
69 	pragma(inline, true) bool opEquals(typeof(null) n) const
70 	{ return _godot_object.ptr is n; }
71 	/// 
72 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
73 	mixin baseCasts;
74 	/// Construct a new instance of CanvasLayer.
75 	/// Note: use `memnew!CanvasLayer` instead.
76 	static CanvasLayer _new()
77 	{
78 		static godot_class_constructor constructor;
79 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CanvasLayer");
80 		if(constructor is null) return typeof(this).init;
81 		return cast(CanvasLayer)(constructor());
82 	}
83 	@disable new(size_t s);
84 	/**
85 	Returns the RID of the canvas used by this layer.
86 	*/
87 	RID getCanvas() const
88 	{
89 		checkClassBinding!(typeof(this))();
90 		return ptrcall!(RID)(GDNativeClassBinding.getCanvas, _godot_object);
91 	}
92 	/**
93 	
94 	*/
95 	Node getCustomViewport() const
96 	{
97 		checkClassBinding!(typeof(this))();
98 		return ptrcall!(Node)(GDNativeClassBinding.getCustomViewport, _godot_object);
99 	}
100 	/**
101 	
102 	*/
103 	double getFollowViewportScale() const
104 	{
105 		checkClassBinding!(typeof(this))();
106 		return ptrcall!(double)(GDNativeClassBinding.getFollowViewportScale, _godot_object);
107 	}
108 	/**
109 	
110 	*/
111 	long getLayer() const
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(long)(GDNativeClassBinding.getLayer, _godot_object);
115 	}
116 	/**
117 	
118 	*/
119 	Vector2 getOffset() const
120 	{
121 		checkClassBinding!(typeof(this))();
122 		return ptrcall!(Vector2)(GDNativeClassBinding.getOffset, _godot_object);
123 	}
124 	/**
125 	
126 	*/
127 	double getRotation() const
128 	{
129 		checkClassBinding!(typeof(this))();
130 		return ptrcall!(double)(GDNativeClassBinding.getRotation, _godot_object);
131 	}
132 	/**
133 	
134 	*/
135 	double getRotationDegrees() const
136 	{
137 		checkClassBinding!(typeof(this))();
138 		return ptrcall!(double)(GDNativeClassBinding.getRotationDegrees, _godot_object);
139 	}
140 	/**
141 	
142 	*/
143 	Vector2 getScale() const
144 	{
145 		checkClassBinding!(typeof(this))();
146 		return ptrcall!(Vector2)(GDNativeClassBinding.getScale, _godot_object);
147 	}
148 	/**
149 	
150 	*/
151 	Transform2D getTransform() const
152 	{
153 		checkClassBinding!(typeof(this))();
154 		return ptrcall!(Transform2D)(GDNativeClassBinding.getTransform, _godot_object);
155 	}
156 	/**
157 	
158 	*/
159 	bool isFollowingViewport() const
160 	{
161 		checkClassBinding!(typeof(this))();
162 		return ptrcall!(bool)(GDNativeClassBinding.isFollowingViewport, _godot_object);
163 	}
164 	/**
165 	
166 	*/
167 	void setCustomViewport(Node viewport)
168 	{
169 		checkClassBinding!(typeof(this))();
170 		ptrcall!(void)(GDNativeClassBinding.setCustomViewport, _godot_object, viewport);
171 	}
172 	/**
173 	
174 	*/
175 	void setFollowViewport(in bool enable)
176 	{
177 		checkClassBinding!(typeof(this))();
178 		ptrcall!(void)(GDNativeClassBinding.setFollowViewport, _godot_object, enable);
179 	}
180 	/**
181 	
182 	*/
183 	void setFollowViewportScale(in double scale)
184 	{
185 		checkClassBinding!(typeof(this))();
186 		ptrcall!(void)(GDNativeClassBinding.setFollowViewportScale, _godot_object, scale);
187 	}
188 	/**
189 	
190 	*/
191 	void setLayer(in long layer)
192 	{
193 		checkClassBinding!(typeof(this))();
194 		ptrcall!(void)(GDNativeClassBinding.setLayer, _godot_object, layer);
195 	}
196 	/**
197 	
198 	*/
199 	void setOffset(in Vector2 offset)
200 	{
201 		checkClassBinding!(typeof(this))();
202 		ptrcall!(void)(GDNativeClassBinding.setOffset, _godot_object, offset);
203 	}
204 	/**
205 	
206 	*/
207 	void setRotation(in double radians)
208 	{
209 		checkClassBinding!(typeof(this))();
210 		ptrcall!(void)(GDNativeClassBinding.setRotation, _godot_object, radians);
211 	}
212 	/**
213 	
214 	*/
215 	void setRotationDegrees(in double degrees)
216 	{
217 		checkClassBinding!(typeof(this))();
218 		ptrcall!(void)(GDNativeClassBinding.setRotationDegrees, _godot_object, degrees);
219 	}
220 	/**
221 	
222 	*/
223 	void setScale(in Vector2 scale)
224 	{
225 		checkClassBinding!(typeof(this))();
226 		ptrcall!(void)(GDNativeClassBinding.setScale, _godot_object, scale);
227 	}
228 	/**
229 	
230 	*/
231 	void setTransform(in Transform2D transform)
232 	{
233 		checkClassBinding!(typeof(this))();
234 		ptrcall!(void)(GDNativeClassBinding.setTransform, _godot_object, transform);
235 	}
236 	/**
237 	The custom $(D Viewport) node assigned to the $(D CanvasLayer). If `null`, uses the default viewport instead.
238 	*/
239 	@property Node customViewport()
240 	{
241 		return getCustomViewport();
242 	}
243 	/// ditto
244 	@property void customViewport(Node v)
245 	{
246 		setCustomViewport(v);
247 	}
248 	/**
249 	Sets the layer to follow the viewport in order to simulate a pseudo 3D effect.
250 	*/
251 	@property bool followViewportEnable()
252 	{
253 		return isFollowingViewport();
254 	}
255 	/// ditto
256 	@property void followViewportEnable(bool v)
257 	{
258 		setFollowViewport(v);
259 	}
260 	/**
261 	Scales the layer when using $(D followViewportEnable). Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales.
262 	*/
263 	@property double followViewportScale()
264 	{
265 		return getFollowViewportScale();
266 	}
267 	/// ditto
268 	@property void followViewportScale(double v)
269 	{
270 		setFollowViewportScale(v);
271 	}
272 	/**
273 	Layer index for draw order. Lower values are drawn first.
274 	*/
275 	@property long layer()
276 	{
277 		return getLayer();
278 	}
279 	/// ditto
280 	@property void layer(long v)
281 	{
282 		setLayer(v);
283 	}
284 	/**
285 	The layer's base offset.
286 	*/
287 	@property Vector2 offset()
288 	{
289 		return getOffset();
290 	}
291 	/// ditto
292 	@property void offset(Vector2 v)
293 	{
294 		setOffset(v);
295 	}
296 	/**
297 	The layer's rotation in radians.
298 	*/
299 	@property double rotation()
300 	{
301 		return getRotation();
302 	}
303 	/// ditto
304 	@property void rotation(double v)
305 	{
306 		setRotation(v);
307 	}
308 	/**
309 	The layer's rotation in degrees.
310 	*/
311 	@property double rotationDegrees()
312 	{
313 		return getRotationDegrees();
314 	}
315 	/// ditto
316 	@property void rotationDegrees(double v)
317 	{
318 		setRotationDegrees(v);
319 	}
320 	/**
321 	The layer's scale.
322 	*/
323 	@property Vector2 scale()
324 	{
325 		return getScale();
326 	}
327 	/// ditto
328 	@property void scale(Vector2 v)
329 	{
330 		setScale(v);
331 	}
332 	/**
333 	The layer's transform.
334 	*/
335 	@property Transform2D transform()
336 	{
337 		return getTransform();
338 	}
339 	/// ditto
340 	@property void transform(Transform2D v)
341 	{
342 		setTransform(v);
343 	}
344 }