1 /** 2 Packs multiple small textures in a single, bigger one. Helps to optimize video memory costs and render calls. 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.atlastexture; 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.texture; 24 import godot.resource; 25 import godot.reference; 26 /** 27 Packs multiple small textures in a single, bigger one. Helps to optimize video memory costs and render calls. 28 29 $(D Texture) resource aimed at managing big textures files that pack multiple smaller textures. Consists of a $(D Texture), a margin that defines the border width, 30 and a region that defines the actual area of the AtlasTexture. 31 */ 32 @GodotBaseClass struct AtlasTexture 33 { 34 enum string _GODOT_internal_name = "AtlasTexture"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Texture _GODOT_base; } 38 alias _GODOT_base this; 39 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 40 package(godot) __gshared bool _classBindingInitialized = false; 41 package(godot) static struct _classBinding 42 { 43 __gshared: 44 @GodotName("set_atlas") GodotMethod!(void, Texture) setAtlas; 45 @GodotName("get_atlas") GodotMethod!(Texture) getAtlas; 46 @GodotName("set_region") GodotMethod!(void, Rect2) setRegion; 47 @GodotName("get_region") GodotMethod!(Rect2) getRegion; 48 @GodotName("set_margin") GodotMethod!(void, Rect2) setMargin; 49 @GodotName("get_margin") GodotMethod!(Rect2) getMargin; 50 @GodotName("set_filter_clip") GodotMethod!(void, bool) setFilterClip; 51 @GodotName("has_filter_clip") GodotMethod!(bool) hasFilterClip; 52 } 53 bool opEquals(in AtlasTexture other) const { return _godot_object.ptr is other._godot_object.ptr; } 54 AtlasTexture opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 55 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 56 mixin baseCasts; 57 static AtlasTexture _new() 58 { 59 static godot_class_constructor constructor; 60 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AtlasTexture"); 61 if(constructor is null) return typeof(this).init; 62 return cast(AtlasTexture)(constructor()); 63 } 64 @disable new(size_t s); 65 /** 66 67 */ 68 void setAtlas(Texture atlas) 69 { 70 checkClassBinding!(typeof(this))(); 71 ptrcall!(void)(_classBinding.setAtlas, _godot_object, atlas); 72 } 73 /** 74 75 */ 76 Ref!Texture getAtlas() const 77 { 78 checkClassBinding!(typeof(this))(); 79 return ptrcall!(Texture)(_classBinding.getAtlas, _godot_object); 80 } 81 /** 82 83 */ 84 void setRegion(in Rect2 region) 85 { 86 checkClassBinding!(typeof(this))(); 87 ptrcall!(void)(_classBinding.setRegion, _godot_object, region); 88 } 89 /** 90 91 */ 92 Rect2 getRegion() const 93 { 94 checkClassBinding!(typeof(this))(); 95 return ptrcall!(Rect2)(_classBinding.getRegion, _godot_object); 96 } 97 /** 98 99 */ 100 void setMargin(in Rect2 margin) 101 { 102 checkClassBinding!(typeof(this))(); 103 ptrcall!(void)(_classBinding.setMargin, _godot_object, margin); 104 } 105 /** 106 107 */ 108 Rect2 getMargin() const 109 { 110 checkClassBinding!(typeof(this))(); 111 return ptrcall!(Rect2)(_classBinding.getMargin, _godot_object); 112 } 113 /** 114 115 */ 116 void setFilterClip(in bool enable) 117 { 118 checkClassBinding!(typeof(this))(); 119 ptrcall!(void)(_classBinding.setFilterClip, _godot_object, enable); 120 } 121 /** 122 123 */ 124 bool hasFilterClip() const 125 { 126 checkClassBinding!(typeof(this))(); 127 return ptrcall!(bool)(_classBinding.hasFilterClip, _godot_object); 128 } 129 /** 130 The texture that contains the atlas. Can be any $(D Texture) subtype. 131 */ 132 @property Texture atlas() 133 { 134 return getAtlas(); 135 } 136 /// ditto 137 @property void atlas(Texture v) 138 { 139 setAtlas(v); 140 } 141 /** 142 The AtlasTexture's used region. 143 */ 144 @property Rect2 region() 145 { 146 return getRegion(); 147 } 148 /// ditto 149 @property void region(Rect2 v) 150 { 151 setRegion(v); 152 } 153 /** 154 The margin around the region. The $(D Rect2)'s 'size' parameter ('w' and 'h' in the editor) resizes the texture so it fits within the margin. 155 */ 156 @property Rect2 margin() 157 { 158 return getMargin(); 159 } 160 /// ditto 161 @property void margin(Rect2 v) 162 { 163 setMargin(v); 164 } 165 /** 166 If `true` clips the area outside of the region to avoid bleeding of the surrounding texture pixels. 167 */ 168 @property bool filterClip() 169 { 170 return hasFilterClip(); 171 } 172 /// ditto 173 @property void filterClip(bool v) 174 { 175 setFilterClip(v); 176 } 177 }