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.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.node; 24 import godot.viewport; 25 /** 26 Canvas drawing layer. 27 28 $(D CanvasItem) nodes that are direct or indirect children of a `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 `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 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 _classBinding 40 { 41 __gshared: 42 @GodotName("set_layer") GodotMethod!(void, long) setLayer; 43 @GodotName("get_layer") GodotMethod!(long) getLayer; 44 @GodotName("set_transform") GodotMethod!(void, Transform2D) setTransform; 45 @GodotName("get_transform") GodotMethod!(Transform2D) getTransform; 46 @GodotName("set_offset") GodotMethod!(void, Vector2) setOffset; 47 @GodotName("get_offset") GodotMethod!(Vector2) getOffset; 48 @GodotName("set_rotation") GodotMethod!(void, double) setRotation; 49 @GodotName("get_rotation") GodotMethod!(double) getRotation; 50 @GodotName("set_rotation_degrees") GodotMethod!(void, double) setRotationDegrees; 51 @GodotName("get_rotation_degrees") GodotMethod!(double) getRotationDegrees; 52 @GodotName("set_scale") GodotMethod!(void, Vector2) setScale; 53 @GodotName("get_scale") GodotMethod!(Vector2) getScale; 54 @GodotName("set_custom_viewport") GodotMethod!(void, GodotObject) setCustomViewport; 55 @GodotName("get_custom_viewport") GodotMethod!(Node) getCustomViewport; 56 @GodotName("get_canvas") GodotMethod!(RID) getCanvas; 57 } 58 bool opEquals(in CanvasLayer other) const { return _godot_object.ptr is other._godot_object.ptr; } 59 CanvasLayer opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 60 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 61 mixin baseCasts; 62 static CanvasLayer _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CanvasLayer"); 66 if(constructor is null) return typeof(this).init; 67 return cast(CanvasLayer)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 72 */ 73 void setLayer(in long layer) 74 { 75 checkClassBinding!(typeof(this))(); 76 ptrcall!(void)(_classBinding.setLayer, _godot_object, layer); 77 } 78 /** 79 80 */ 81 long getLayer() const 82 { 83 checkClassBinding!(typeof(this))(); 84 return ptrcall!(long)(_classBinding.getLayer, _godot_object); 85 } 86 /** 87 88 */ 89 void setTransform(in Transform2D transform) 90 { 91 checkClassBinding!(typeof(this))(); 92 ptrcall!(void)(_classBinding.setTransform, _godot_object, transform); 93 } 94 /** 95 96 */ 97 Transform2D getTransform() const 98 { 99 checkClassBinding!(typeof(this))(); 100 return ptrcall!(Transform2D)(_classBinding.getTransform, _godot_object); 101 } 102 /** 103 104 */ 105 void setOffset(in Vector2 offset) 106 { 107 checkClassBinding!(typeof(this))(); 108 ptrcall!(void)(_classBinding.setOffset, _godot_object, offset); 109 } 110 /** 111 112 */ 113 Vector2 getOffset() const 114 { 115 checkClassBinding!(typeof(this))(); 116 return ptrcall!(Vector2)(_classBinding.getOffset, _godot_object); 117 } 118 /** 119 120 */ 121 void setRotation(in double radians) 122 { 123 checkClassBinding!(typeof(this))(); 124 ptrcall!(void)(_classBinding.setRotation, _godot_object, radians); 125 } 126 /** 127 128 */ 129 double getRotation() const 130 { 131 checkClassBinding!(typeof(this))(); 132 return ptrcall!(double)(_classBinding.getRotation, _godot_object); 133 } 134 /** 135 136 */ 137 void setRotationDegrees(in double degrees) 138 { 139 checkClassBinding!(typeof(this))(); 140 ptrcall!(void)(_classBinding.setRotationDegrees, _godot_object, degrees); 141 } 142 /** 143 144 */ 145 double getRotationDegrees() const 146 { 147 checkClassBinding!(typeof(this))(); 148 return ptrcall!(double)(_classBinding.getRotationDegrees, _godot_object); 149 } 150 /** 151 152 */ 153 void setScale(in Vector2 scale) 154 { 155 checkClassBinding!(typeof(this))(); 156 ptrcall!(void)(_classBinding.setScale, _godot_object, scale); 157 } 158 /** 159 160 */ 161 Vector2 getScale() const 162 { 163 checkClassBinding!(typeof(this))(); 164 return ptrcall!(Vector2)(_classBinding.getScale, _godot_object); 165 } 166 /** 167 168 */ 169 void setCustomViewport(GodotObject viewport) 170 { 171 checkClassBinding!(typeof(this))(); 172 ptrcall!(void)(_classBinding.setCustomViewport, _godot_object, viewport); 173 } 174 /** 175 176 */ 177 Node getCustomViewport() const 178 { 179 checkClassBinding!(typeof(this))(); 180 return ptrcall!(Node)(_classBinding.getCustomViewport, _godot_object); 181 } 182 /** 183 Returns the RID of the canvas used by this layer. 184 */ 185 RID getCanvas() const 186 { 187 checkClassBinding!(typeof(this))(); 188 return ptrcall!(RID)(_classBinding.getCanvas, _godot_object); 189 } 190 /** 191 Layer index for draw order. Lower values are drawn first. Default value: `1`. 192 */ 193 @property long layer() 194 { 195 return getLayer(); 196 } 197 /// ditto 198 @property void layer(long v) 199 { 200 setLayer(v); 201 } 202 /** 203 The layer's base offset. 204 */ 205 @property Vector2 offset() 206 { 207 return getOffset(); 208 } 209 /// ditto 210 @property void offset(Vector2 v) 211 { 212 setOffset(v); 213 } 214 /** 215 The layer's rotation in degrees. 216 */ 217 @property double rotationDegrees() 218 { 219 return getRotationDegrees(); 220 } 221 /// ditto 222 @property void rotationDegrees(double v) 223 { 224 setRotationDegrees(v); 225 } 226 /** 227 The layer's rotation in radians. 228 */ 229 @property double rotation() 230 { 231 return getRotation(); 232 } 233 /// ditto 234 @property void rotation(double v) 235 { 236 setRotation(v); 237 } 238 /** 239 The layer's scale. 240 */ 241 @property Vector2 scale() 242 { 243 return getScale(); 244 } 245 /// ditto 246 @property void scale(Vector2 v) 247 { 248 setScale(v); 249 } 250 /** 251 The layer's transform. 252 */ 253 @property Transform2D transform() 254 { 255 return getTransform(); 256 } 257 /// ditto 258 @property void transform(Transform2D v) 259 { 260 setTransform(v); 261 } 262 /** 263 The custom $(D Viewport) node assigned to the `CanvasLayer`. If null, uses the default viewport instead. 264 */ 265 @property Node customViewport() 266 { 267 return getCustomViewport(); 268 } 269 /// ditto 270 @property void customViewport(GodotObject v) 271 { 272 setCustomViewport(v); 273 } 274 }