1 /**
2 Texture-based progress bar. Useful for loading screens and life or stamina bars.
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.textureprogress;
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.range;
24 import godot.texture;
25 import godot.control;
26 import godot.canvasitem;
27 import godot.node;
28 /**
29 Texture-based progress bar. Useful for loading screens and life or stamina bars.
30 
31 TextureProgress works like $(D ProgressBar) but it uses up to 3 textures instead of Godot's $(D Theme) resource. Works horizontally, vertically, and radially.
32 */
33 @GodotBaseClass struct TextureProgress
34 {
35 	enum string _GODOT_internal_name = "TextureProgress";
36 public:
37 @nogc nothrow:
38 	union { godot_object _godot_object; Range _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct _classBinding
43 	{
44 		__gshared:
45 		@GodotName("set_under_texture") GodotMethod!(void, Texture) setUnderTexture;
46 		@GodotName("get_under_texture") GodotMethod!(Texture) getUnderTexture;
47 		@GodotName("set_progress_texture") GodotMethod!(void, Texture) setProgressTexture;
48 		@GodotName("get_progress_texture") GodotMethod!(Texture) getProgressTexture;
49 		@GodotName("set_over_texture") GodotMethod!(void, Texture) setOverTexture;
50 		@GodotName("get_over_texture") GodotMethod!(Texture) getOverTexture;
51 		@GodotName("set_fill_mode") GodotMethod!(void, long) setFillMode;
52 		@GodotName("get_fill_mode") GodotMethod!(long) getFillMode;
53 		@GodotName("set_tint_under") GodotMethod!(void, Color) setTintUnder;
54 		@GodotName("get_tint_under") GodotMethod!(Color) getTintUnder;
55 		@GodotName("set_tint_progress") GodotMethod!(void, Color) setTintProgress;
56 		@GodotName("get_tint_progress") GodotMethod!(Color) getTintProgress;
57 		@GodotName("set_tint_over") GodotMethod!(void, Color) setTintOver;
58 		@GodotName("get_tint_over") GodotMethod!(Color) getTintOver;
59 		@GodotName("set_radial_initial_angle") GodotMethod!(void, double) setRadialInitialAngle;
60 		@GodotName("get_radial_initial_angle") GodotMethod!(double) getRadialInitialAngle;
61 		@GodotName("set_radial_center_offset") GodotMethod!(void, Vector2) setRadialCenterOffset;
62 		@GodotName("get_radial_center_offset") GodotMethod!(Vector2) getRadialCenterOffset;
63 		@GodotName("set_fill_degrees") GodotMethod!(void, double) setFillDegrees;
64 		@GodotName("get_fill_degrees") GodotMethod!(double) getFillDegrees;
65 		@GodotName("set_stretch_margin") GodotMethod!(void, long, long) setStretchMargin;
66 		@GodotName("get_stretch_margin") GodotMethod!(long, long) getStretchMargin;
67 		@GodotName("set_nine_patch_stretch") GodotMethod!(void, bool) setNinePatchStretch;
68 		@GodotName("get_nine_patch_stretch") GodotMethod!(bool) getNinePatchStretch;
69 	}
70 	bool opEquals(in TextureProgress other) const { return _godot_object.ptr is other._godot_object.ptr; }
71 	TextureProgress opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
72 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
73 	mixin baseCasts;
74 	static TextureProgress _new()
75 	{
76 		static godot_class_constructor constructor;
77 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TextureProgress");
78 		if(constructor is null) return typeof(this).init;
79 		return cast(TextureProgress)(constructor());
80 	}
81 	@disable new(size_t s);
82 	/// 
83 	enum FillMode : int
84 	{
85 		/**
86 		The $(D textureProgress) fills from left to right.
87 		*/
88 		fillLeftToRight = 0,
89 		/**
90 		The $(D textureProgress) fills from right to left.
91 		*/
92 		fillRightToLeft = 1,
93 		/**
94 		The $(D textureProgress) fills from top to bototm.
95 		*/
96 		fillTopToBottom = 2,
97 		/**
98 		The $(D textureProgress) fills from bottom to top.
99 		*/
100 		fillBottomToTop = 3,
101 		/**
102 		Turns the node into a radial bar. The $(D textureProgress) fills clockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up.
103 		*/
104 		fillClockwise = 4,
105 		/**
106 		Turns the node into a radial bar. The $(D textureProgress) fills counter-clockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up.
107 		*/
108 		fillCounterClockwise = 5,
109 		/**
110 		The $(D textureProgress) fills from the center, expanding both towards the left and the right.
111 		*/
112 		fillBilinearLeftAndRight = 6,
113 		/**
114 		The $(D textureProgress) fills from the center, expanding both towards the top and the bottom.
115 		*/
116 		fillBilinearTopAndBottom = 7,
117 		/**
118 		Turns the node into a radial bar. The $(D textureProgress) fills radially from the center, expanding both clockwise and counter-clockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up.
119 		*/
120 		fillClockwiseAndCounterClockwise = 8,
121 	}
122 	/// 
123 	enum Constants : int
124 	{
125 		fillLeftToRight = 0,
126 		fillRightToLeft = 1,
127 		fillTopToBottom = 2,
128 		fillBottomToTop = 3,
129 		fillClockwise = 4,
130 		fillCounterClockwise = 5,
131 		fillBilinearLeftAndRight = 6,
132 		fillBilinearTopAndBottom = 7,
133 		fillClockwiseAndCounterClockwise = 8,
134 	}
135 	/**
136 	
137 	*/
138 	void setUnderTexture(Texture tex)
139 	{
140 		checkClassBinding!(typeof(this))();
141 		ptrcall!(void)(_classBinding.setUnderTexture, _godot_object, tex);
142 	}
143 	/**
144 	
145 	*/
146 	Ref!Texture getUnderTexture() const
147 	{
148 		checkClassBinding!(typeof(this))();
149 		return ptrcall!(Texture)(_classBinding.getUnderTexture, _godot_object);
150 	}
151 	/**
152 	
153 	*/
154 	void setProgressTexture(Texture tex)
155 	{
156 		checkClassBinding!(typeof(this))();
157 		ptrcall!(void)(_classBinding.setProgressTexture, _godot_object, tex);
158 	}
159 	/**
160 	
161 	*/
162 	Ref!Texture getProgressTexture() const
163 	{
164 		checkClassBinding!(typeof(this))();
165 		return ptrcall!(Texture)(_classBinding.getProgressTexture, _godot_object);
166 	}
167 	/**
168 	
169 	*/
170 	void setOverTexture(Texture tex)
171 	{
172 		checkClassBinding!(typeof(this))();
173 		ptrcall!(void)(_classBinding.setOverTexture, _godot_object, tex);
174 	}
175 	/**
176 	
177 	*/
178 	Ref!Texture getOverTexture() const
179 	{
180 		checkClassBinding!(typeof(this))();
181 		return ptrcall!(Texture)(_classBinding.getOverTexture, _godot_object);
182 	}
183 	/**
184 	
185 	*/
186 	void setFillMode(in long mode)
187 	{
188 		checkClassBinding!(typeof(this))();
189 		ptrcall!(void)(_classBinding.setFillMode, _godot_object, mode);
190 	}
191 	/**
192 	
193 	*/
194 	long getFillMode()
195 	{
196 		checkClassBinding!(typeof(this))();
197 		return ptrcall!(long)(_classBinding.getFillMode, _godot_object);
198 	}
199 	/**
200 	
201 	*/
202 	void setTintUnder(in Color tint)
203 	{
204 		checkClassBinding!(typeof(this))();
205 		ptrcall!(void)(_classBinding.setTintUnder, _godot_object, tint);
206 	}
207 	/**
208 	
209 	*/
210 	Color getTintUnder() const
211 	{
212 		checkClassBinding!(typeof(this))();
213 		return ptrcall!(Color)(_classBinding.getTintUnder, _godot_object);
214 	}
215 	/**
216 	
217 	*/
218 	void setTintProgress(in Color tint)
219 	{
220 		checkClassBinding!(typeof(this))();
221 		ptrcall!(void)(_classBinding.setTintProgress, _godot_object, tint);
222 	}
223 	/**
224 	
225 	*/
226 	Color getTintProgress() const
227 	{
228 		checkClassBinding!(typeof(this))();
229 		return ptrcall!(Color)(_classBinding.getTintProgress, _godot_object);
230 	}
231 	/**
232 	
233 	*/
234 	void setTintOver(in Color tint)
235 	{
236 		checkClassBinding!(typeof(this))();
237 		ptrcall!(void)(_classBinding.setTintOver, _godot_object, tint);
238 	}
239 	/**
240 	
241 	*/
242 	Color getTintOver() const
243 	{
244 		checkClassBinding!(typeof(this))();
245 		return ptrcall!(Color)(_classBinding.getTintOver, _godot_object);
246 	}
247 	/**
248 	
249 	*/
250 	void setRadialInitialAngle(in double mode)
251 	{
252 		checkClassBinding!(typeof(this))();
253 		ptrcall!(void)(_classBinding.setRadialInitialAngle, _godot_object, mode);
254 	}
255 	/**
256 	
257 	*/
258 	double getRadialInitialAngle()
259 	{
260 		checkClassBinding!(typeof(this))();
261 		return ptrcall!(double)(_classBinding.getRadialInitialAngle, _godot_object);
262 	}
263 	/**
264 	
265 	*/
266 	void setRadialCenterOffset(in Vector2 mode)
267 	{
268 		checkClassBinding!(typeof(this))();
269 		ptrcall!(void)(_classBinding.setRadialCenterOffset, _godot_object, mode);
270 	}
271 	/**
272 	
273 	*/
274 	Vector2 getRadialCenterOffset()
275 	{
276 		checkClassBinding!(typeof(this))();
277 		return ptrcall!(Vector2)(_classBinding.getRadialCenterOffset, _godot_object);
278 	}
279 	/**
280 	
281 	*/
282 	void setFillDegrees(in double mode)
283 	{
284 		checkClassBinding!(typeof(this))();
285 		ptrcall!(void)(_classBinding.setFillDegrees, _godot_object, mode);
286 	}
287 	/**
288 	
289 	*/
290 	double getFillDegrees()
291 	{
292 		checkClassBinding!(typeof(this))();
293 		return ptrcall!(double)(_classBinding.getFillDegrees, _godot_object);
294 	}
295 	/**
296 	
297 	*/
298 	void setStretchMargin(in long margin, in long value)
299 	{
300 		checkClassBinding!(typeof(this))();
301 		ptrcall!(void)(_classBinding.setStretchMargin, _godot_object, margin, value);
302 	}
303 	/**
304 	
305 	*/
306 	long getStretchMargin(in long margin) const
307 	{
308 		checkClassBinding!(typeof(this))();
309 		return ptrcall!(long)(_classBinding.getStretchMargin, _godot_object, margin);
310 	}
311 	/**
312 	
313 	*/
314 	void setNinePatchStretch(in bool stretch)
315 	{
316 		checkClassBinding!(typeof(this))();
317 		ptrcall!(void)(_classBinding.setNinePatchStretch, _godot_object, stretch);
318 	}
319 	/**
320 	
321 	*/
322 	bool getNinePatchStretch() const
323 	{
324 		checkClassBinding!(typeof(this))();
325 		return ptrcall!(bool)(_classBinding.getNinePatchStretch, _godot_object);
326 	}
327 	/**
328 	$(D Texture) that draws under the progress bar. The bar's background.
329 	*/
330 	@property Texture textureUnder()
331 	{
332 		return getUnderTexture();
333 	}
334 	/// ditto
335 	@property void textureUnder(Texture v)
336 	{
337 		setUnderTexture(v);
338 	}
339 	/**
340 	$(D Texture) that draws over the progress bar. Use it to add highlights or an upper-frame that hides part of $(D textureProgress).
341 	*/
342 	@property Texture textureOver()
343 	{
344 		return getOverTexture();
345 	}
346 	/// ditto
347 	@property void textureOver(Texture v)
348 	{
349 		setOverTexture(v);
350 	}
351 	/**
352 	$(D Texture) that clips based on the node's `value` and $(D fillMode). As `value` increased, the texture fills up. It shows entirely when `value` reaches `max_value`. It doesn't show at all if `value` is equal to `min_value`.
353 	The `value` property comes from $(D Range). See $(D Range.value), $(D Range.minValue), $(D Range.maxValue).
354 	*/
355 	@property Texture textureProgress()
356 	{
357 		return getProgressTexture();
358 	}
359 	/// ditto
360 	@property void textureProgress(Texture v)
361 	{
362 		setProgressTexture(v);
363 	}
364 	/**
365 	The fill direction. Uses FILL_* constants.
366 	*/
367 	@property long fillMode()
368 	{
369 		return getFillMode();
370 	}
371 	/// ditto
372 	@property void fillMode(long v)
373 	{
374 		setFillMode(v);
375 	}
376 	/**
377 	Multiplies the color of the bar's `texture_under` texture.
378 	*/
379 	@property Color tintUnder()
380 	{
381 		return getTintUnder();
382 	}
383 	/// ditto
384 	@property void tintUnder(Color v)
385 	{
386 		setTintUnder(v);
387 	}
388 	/**
389 	Multiplies the color of the bar's `texture_over` texture. The effect is similar to $(D CanvasItem.modulate), except it only affects this specific texture instead of the entire node.
390 	*/
391 	@property Color tintOver()
392 	{
393 		return getTintOver();
394 	}
395 	/// ditto
396 	@property void tintOver(Color v)
397 	{
398 		setTintOver(v);
399 	}
400 	/**
401 	Multiplies the color of the bar's `texture_progress` texture.
402 	*/
403 	@property Color tintProgress()
404 	{
405 		return getTintProgress();
406 	}
407 	/// ditto
408 	@property void tintProgress(Color v)
409 	{
410 		setTintProgress(v);
411 	}
412 	/**
413 	Starting angle for the fill of $(D textureProgress) if $(D fillMode) is `FILL_CLOCKWISE` or `FILL_COUNTER_CLOCKWISE`. When the node's `value` is equal to its `min_value`, the texture doesn't show up at all. When the `value` increases, the texture fills and tends towards $(D radialFillDegrees).
414 	*/
415 	@property double radialInitialAngle()
416 	{
417 		return getRadialInitialAngle();
418 	}
419 	/// ditto
420 	@property void radialInitialAngle(double v)
421 	{
422 		setRadialInitialAngle(v);
423 	}
424 	/**
425 	Upper limit for the fill of $(D textureProgress) if $(D fillMode) is `FILL_CLOCKWISE` or `FILL_COUNTER_CLOCKWISE`. When the node's `value` is equal to its `max_value`, the texture fills up to this angle.
426 	See $(D Range.value), $(D Range.maxValue).
427 	*/
428 	@property double radialFillDegrees()
429 	{
430 		return getFillDegrees();
431 	}
432 	/// ditto
433 	@property void radialFillDegrees(double v)
434 	{
435 		setFillDegrees(v);
436 	}
437 	/**
438 	Offsets $(D textureProgress) if $(D fillMode) is `FILL_CLOCKWISE` or `FILL_COUNTER_CLOCKWISE`.
439 	*/
440 	@property Vector2 radialCenterOffset()
441 	{
442 		return getRadialCenterOffset();
443 	}
444 	/// ditto
445 	@property void radialCenterOffset(Vector2 v)
446 	{
447 		setRadialCenterOffset(v);
448 	}
449 	/**
450 	If `true` Godot treats the bar's textures like $(D NinePatchRect). Use `stretch_margin_*`, like $(D stretchMarginBottom), to set up the nine patch's 3x3 grid. Default value: `false`.
451 	*/
452 	@property bool ninePatchStretch()
453 	{
454 		return getNinePatchStretch();
455 	}
456 	/// ditto
457 	@property void ninePatchStretch(bool v)
458 	{
459 		setNinePatchStretch(v);
460 	}
461 	/**
462 	The width of the 9-patch's left column.
463 	*/
464 	@property long stretchMarginLeft()
465 	{
466 		return getStretchMargin(0);
467 	}
468 	/// ditto
469 	@property void stretchMarginLeft(long v)
470 	{
471 		setStretchMargin(0, v);
472 	}
473 	/**
474 	The height of the 9-patch's top row.
475 	*/
476 	@property long stretchMarginTop()
477 	{
478 		return getStretchMargin(1);
479 	}
480 	/// ditto
481 	@property void stretchMarginTop(long v)
482 	{
483 		setStretchMargin(1, v);
484 	}
485 	/**
486 	The width of the 9-patch's right column.
487 	*/
488 	@property long stretchMarginRight()
489 	{
490 		return getStretchMargin(2);
491 	}
492 	/// ditto
493 	@property void stretchMarginRight(long v)
494 	{
495 		setStretchMargin(2, v);
496 	}
497 	/**
498 	The height of the 9-patch's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
499 	*/
500 	@property long stretchMarginBottom()
501 	{
502 		return getStretchMargin(3);
503 	}
504 	/// ditto
505 	@property void stretchMarginBottom(long v)
506 	{
507 		setStretchMargin(3, v);
508 	}
509 }