1 /**
2 Crops out one part of a texture, such as a texture from a texture atlas.
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.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.texture;
25 /**
26 Crops out one part of a texture, such as a texture from a texture atlas.
27 
28 $(D Texture) resource that crops out one part of the $(D atlas) texture, defined by $(D region). The main use case is cropping out textures from a texture atlas, which is a big texture file that packs multiple smaller textures. Consists of a $(D Texture) for the $(D atlas), a $(D region) that defines the area of $(D atlas) to use, and a $(D margin) that defines the border width.
29 $(D AtlasTexture) cannot be used in an $(D AnimatedTexture), cannot be tiled in nodes such as $(D TextureRect), and does not work properly if used inside of other $(D AtlasTexture) resources. Multiple $(D AtlasTexture) resources can be used to crop multiple textures from the atlas. Using a texture atlas helps to optimize video memory costs and render calls compared to using multiple small files.
30 $(B Note:) AtlasTextures don't support repetition. The $(D constant Texture.FLAG_REPEAT) and $(D constant Texture.FLAG_MIRRORED_REPEAT) flags are ignored when using an AtlasTexture.
31 */
32 @GodotBaseClass struct AtlasTexture
33 {
34 	package(godot) 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 GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("get_atlas") GodotMethod!(Texture) getAtlas;
45 		@GodotName("get_margin") GodotMethod!(Rect2) getMargin;
46 		@GodotName("get_region") GodotMethod!(Rect2) getRegion;
47 		@GodotName("has_filter_clip") GodotMethod!(bool) hasFilterClip;
48 		@GodotName("set_atlas") GodotMethod!(void, Texture) setAtlas;
49 		@GodotName("set_filter_clip") GodotMethod!(void, bool) setFilterClip;
50 		@GodotName("set_margin") GodotMethod!(void, Rect2) setMargin;
51 		@GodotName("set_region") GodotMethod!(void, Rect2) setRegion;
52 	}
53 	/// 
54 	pragma(inline, true) bool opEquals(in AtlasTexture other) const
55 	{ return _godot_object.ptr is other._godot_object.ptr; }
56 	/// 
57 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
58 	{ _godot_object.ptr = n; return null; }
59 	/// 
60 	pragma(inline, true) bool opEquals(typeof(null) n) const
61 	{ return _godot_object.ptr is n; }
62 	/// 
63 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
64 	mixin baseCasts;
65 	/// Construct a new instance of AtlasTexture.
66 	/// Note: use `memnew!AtlasTexture` instead.
67 	static AtlasTexture _new()
68 	{
69 		static godot_class_constructor constructor;
70 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AtlasTexture");
71 		if(constructor is null) return typeof(this).init;
72 		return cast(AtlasTexture)(constructor());
73 	}
74 	@disable new(size_t s);
75 	/**
76 	
77 	*/
78 	Ref!Texture getAtlas() const
79 	{
80 		checkClassBinding!(typeof(this))();
81 		return ptrcall!(Texture)(GDNativeClassBinding.getAtlas, _godot_object);
82 	}
83 	/**
84 	
85 	*/
86 	Rect2 getMargin() const
87 	{
88 		checkClassBinding!(typeof(this))();
89 		return ptrcall!(Rect2)(GDNativeClassBinding.getMargin, _godot_object);
90 	}
91 	/**
92 	
93 	*/
94 	Rect2 getRegion() const
95 	{
96 		checkClassBinding!(typeof(this))();
97 		return ptrcall!(Rect2)(GDNativeClassBinding.getRegion, _godot_object);
98 	}
99 	/**
100 	
101 	*/
102 	bool hasFilterClip() const
103 	{
104 		checkClassBinding!(typeof(this))();
105 		return ptrcall!(bool)(GDNativeClassBinding.hasFilterClip, _godot_object);
106 	}
107 	/**
108 	
109 	*/
110 	void setAtlas(Texture atlas)
111 	{
112 		checkClassBinding!(typeof(this))();
113 		ptrcall!(void)(GDNativeClassBinding.setAtlas, _godot_object, atlas);
114 	}
115 	/**
116 	
117 	*/
118 	void setFilterClip(in bool enable)
119 	{
120 		checkClassBinding!(typeof(this))();
121 		ptrcall!(void)(GDNativeClassBinding.setFilterClip, _godot_object, enable);
122 	}
123 	/**
124 	
125 	*/
126 	void setMargin(in Rect2 margin)
127 	{
128 		checkClassBinding!(typeof(this))();
129 		ptrcall!(void)(GDNativeClassBinding.setMargin, _godot_object, margin);
130 	}
131 	/**
132 	
133 	*/
134 	void setRegion(in Rect2 region)
135 	{
136 		checkClassBinding!(typeof(this))();
137 		ptrcall!(void)(GDNativeClassBinding.setRegion, _godot_object, region);
138 	}
139 	/**
140 	The texture that contains the atlas. Can be any $(D Texture) subtype.
141 	*/
142 	@property Texture atlas()
143 	{
144 		return getAtlas();
145 	}
146 	/// ditto
147 	@property void atlas(Texture v)
148 	{
149 		setAtlas(v);
150 	}
151 	/**
152 	If `true`, clips the area outside of the region to avoid bleeding of the surrounding texture pixels.
153 	*/
154 	@property bool filterClip()
155 	{
156 		return hasFilterClip();
157 	}
158 	/// ditto
159 	@property void filterClip(bool v)
160 	{
161 		setFilterClip(v);
162 	}
163 	/**
164 	The margin around the region. The $(D Rect2)'s $(D Rect2.size) parameter ("w" and "h" in the editor) resizes the texture so it fits within the margin.
165 	*/
166 	@property Rect2 margin()
167 	{
168 		return getMargin();
169 	}
170 	/// ditto
171 	@property void margin(Rect2 v)
172 	{
173 		setMargin(v);
174 	}
175 	/**
176 	The AtlasTexture's used region.
177 	*/
178 	@property Rect2 region()
179 	{
180 		return getRegion();
181 	}
182 	/// ditto
183 	@property void region(Rect2 v)
184 	{
185 		setRegion(v);
186 	}
187 }