1 /**
2 Displays plain text in a line or wrapped inside a rectangle. For formatted text, use $(D RichTextLabel).
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.label;
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.control;
24 import godot.canvasitem;
25 import godot.node;
26 /**
27 Displays plain text in a line or wrapped inside a rectangle. For formatted text, use $(D RichTextLabel).
28 
29 Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment, and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics or other formatting. For that, use $(D RichTextLabel) instead.
30 Note that contrarily to most other $(D Control)s, Label's $(D Control.mouseFilter) defaults to MOUSE_FILTER_IGNORE (i.e. it doesn't react to mouse input events).
31 */
32 @GodotBaseClass struct Label
33 {
34 	enum string _GODOT_internal_name = "Label";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Control _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_align") GodotMethod!(void, long) setAlign;
45 		@GodotName("get_align") GodotMethod!(Label.Align) getAlign;
46 		@GodotName("set_valign") GodotMethod!(void, long) setValign;
47 		@GodotName("get_valign") GodotMethod!(Label.VAlign) getValign;
48 		@GodotName("set_text") GodotMethod!(void, String) setText;
49 		@GodotName("get_text") GodotMethod!(String) getText;
50 		@GodotName("set_autowrap") GodotMethod!(void, bool) setAutowrap;
51 		@GodotName("has_autowrap") GodotMethod!(bool) hasAutowrap;
52 		@GodotName("set_clip_text") GodotMethod!(void, bool) setClipText;
53 		@GodotName("is_clipping_text") GodotMethod!(bool) isClippingText;
54 		@GodotName("set_uppercase") GodotMethod!(void, bool) setUppercase;
55 		@GodotName("is_uppercase") GodotMethod!(bool) isUppercase;
56 		@GodotName("get_line_height") GodotMethod!(long) getLineHeight;
57 		@GodotName("get_line_count") GodotMethod!(long) getLineCount;
58 		@GodotName("get_visible_line_count") GodotMethod!(long) getVisibleLineCount;
59 		@GodotName("get_total_character_count") GodotMethod!(long) getTotalCharacterCount;
60 		@GodotName("set_visible_characters") GodotMethod!(void, long) setVisibleCharacters;
61 		@GodotName("get_visible_characters") GodotMethod!(long) getVisibleCharacters;
62 		@GodotName("set_percent_visible") GodotMethod!(void, double) setPercentVisible;
63 		@GodotName("get_percent_visible") GodotMethod!(double) getPercentVisible;
64 		@GodotName("set_lines_skipped") GodotMethod!(void, long) setLinesSkipped;
65 		@GodotName("get_lines_skipped") GodotMethod!(long) getLinesSkipped;
66 		@GodotName("set_max_lines_visible") GodotMethod!(void, long) setMaxLinesVisible;
67 		@GodotName("get_max_lines_visible") GodotMethod!(long) getMaxLinesVisible;
68 	}
69 	bool opEquals(in Label other) const { return _godot_object.ptr is other._godot_object.ptr; }
70 	Label opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
71 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
72 	mixin baseCasts;
73 	static Label _new()
74 	{
75 		static godot_class_constructor constructor;
76 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Label");
77 		if(constructor is null) return typeof(this).init;
78 		return cast(Label)(constructor());
79 	}
80 	@disable new(size_t s);
81 	/// 
82 	enum Align : int
83 	{
84 		/**
85 		Align rows to the left (default).
86 		*/
87 		alignLeft = 0,
88 		/**
89 		Align rows centered.
90 		*/
91 		alignCenter = 1,
92 		/**
93 		Align rows to the right (default).
94 		*/
95 		alignRight = 2,
96 		/**
97 		Expand row whitespaces to fit the width.
98 		*/
99 		alignFill = 3,
100 	}
101 	/// 
102 	enum VAlign : int
103 	{
104 		/**
105 		Align the whole text to the top.
106 		*/
107 		valignTop = 0,
108 		/**
109 		Align the whole text to the center.
110 		*/
111 		valignCenter = 1,
112 		/**
113 		Align the whole text to the bottom.
114 		*/
115 		valignBottom = 2,
116 		/**
117 		Align the whole text by spreading the rows.
118 		*/
119 		valignFill = 3,
120 	}
121 	/// 
122 	enum Constants : int
123 	{
124 		alignLeft = 0,
125 		valignTop = 0,
126 		alignCenter = 1,
127 		valignCenter = 1,
128 		alignRight = 2,
129 		valignBottom = 2,
130 		valignFill = 3,
131 		alignFill = 3,
132 	}
133 	/**
134 	
135 	*/
136 	void setAlign(in long _align)
137 	{
138 		checkClassBinding!(typeof(this))();
139 		ptrcall!(void)(_classBinding.setAlign, _godot_object, _align);
140 	}
141 	/**
142 	
143 	*/
144 	Label.Align getAlign() const
145 	{
146 		checkClassBinding!(typeof(this))();
147 		return ptrcall!(Label.Align)(_classBinding.getAlign, _godot_object);
148 	}
149 	/**
150 	
151 	*/
152 	void setValign(in long valign)
153 	{
154 		checkClassBinding!(typeof(this))();
155 		ptrcall!(void)(_classBinding.setValign, _godot_object, valign);
156 	}
157 	/**
158 	
159 	*/
160 	Label.VAlign getValign() const
161 	{
162 		checkClassBinding!(typeof(this))();
163 		return ptrcall!(Label.VAlign)(_classBinding.getValign, _godot_object);
164 	}
165 	/**
166 	
167 	*/
168 	void setText(StringArg0)(in StringArg0 text)
169 	{
170 		checkClassBinding!(typeof(this))();
171 		ptrcall!(void)(_classBinding.setText, _godot_object, text);
172 	}
173 	/**
174 	
175 	*/
176 	String getText() const
177 	{
178 		checkClassBinding!(typeof(this))();
179 		return ptrcall!(String)(_classBinding.getText, _godot_object);
180 	}
181 	/**
182 	
183 	*/
184 	void setAutowrap(in bool enable)
185 	{
186 		checkClassBinding!(typeof(this))();
187 		ptrcall!(void)(_classBinding.setAutowrap, _godot_object, enable);
188 	}
189 	/**
190 	
191 	*/
192 	bool hasAutowrap() const
193 	{
194 		checkClassBinding!(typeof(this))();
195 		return ptrcall!(bool)(_classBinding.hasAutowrap, _godot_object);
196 	}
197 	/**
198 	
199 	*/
200 	void setClipText(in bool enable)
201 	{
202 		checkClassBinding!(typeof(this))();
203 		ptrcall!(void)(_classBinding.setClipText, _godot_object, enable);
204 	}
205 	/**
206 	
207 	*/
208 	bool isClippingText() const
209 	{
210 		checkClassBinding!(typeof(this))();
211 		return ptrcall!(bool)(_classBinding.isClippingText, _godot_object);
212 	}
213 	/**
214 	
215 	*/
216 	void setUppercase(in bool enable)
217 	{
218 		checkClassBinding!(typeof(this))();
219 		ptrcall!(void)(_classBinding.setUppercase, _godot_object, enable);
220 	}
221 	/**
222 	
223 	*/
224 	bool isUppercase() const
225 	{
226 		checkClassBinding!(typeof(this))();
227 		return ptrcall!(bool)(_classBinding.isUppercase, _godot_object);
228 	}
229 	/**
230 	Returns the font size in pixels.
231 	*/
232 	long getLineHeight() const
233 	{
234 		checkClassBinding!(typeof(this))();
235 		return ptrcall!(long)(_classBinding.getLineHeight, _godot_object);
236 	}
237 	/**
238 	Returns the amount of lines of text the Label has.
239 	*/
240 	long getLineCount() const
241 	{
242 		checkClassBinding!(typeof(this))();
243 		return ptrcall!(long)(_classBinding.getLineCount, _godot_object);
244 	}
245 	/**
246 	Returns the number of lines shown. Useful if the `Label` 's height cannot currently display all lines.
247 	*/
248 	long getVisibleLineCount() const
249 	{
250 		checkClassBinding!(typeof(this))();
251 		return ptrcall!(long)(_classBinding.getVisibleLineCount, _godot_object);
252 	}
253 	/**
254 	Returns the total length of the text.
255 	*/
256 	long getTotalCharacterCount() const
257 	{
258 		checkClassBinding!(typeof(this))();
259 		return ptrcall!(long)(_classBinding.getTotalCharacterCount, _godot_object);
260 	}
261 	/**
262 	
263 	*/
264 	void setVisibleCharacters(in long amount)
265 	{
266 		checkClassBinding!(typeof(this))();
267 		ptrcall!(void)(_classBinding.setVisibleCharacters, _godot_object, amount);
268 	}
269 	/**
270 	
271 	*/
272 	long getVisibleCharacters() const
273 	{
274 		checkClassBinding!(typeof(this))();
275 		return ptrcall!(long)(_classBinding.getVisibleCharacters, _godot_object);
276 	}
277 	/**
278 	
279 	*/
280 	void setPercentVisible(in double percent_visible)
281 	{
282 		checkClassBinding!(typeof(this))();
283 		ptrcall!(void)(_classBinding.setPercentVisible, _godot_object, percent_visible);
284 	}
285 	/**
286 	
287 	*/
288 	double getPercentVisible() const
289 	{
290 		checkClassBinding!(typeof(this))();
291 		return ptrcall!(double)(_classBinding.getPercentVisible, _godot_object);
292 	}
293 	/**
294 	
295 	*/
296 	void setLinesSkipped(in long lines_skipped)
297 	{
298 		checkClassBinding!(typeof(this))();
299 		ptrcall!(void)(_classBinding.setLinesSkipped, _godot_object, lines_skipped);
300 	}
301 	/**
302 	
303 	*/
304 	long getLinesSkipped() const
305 	{
306 		checkClassBinding!(typeof(this))();
307 		return ptrcall!(long)(_classBinding.getLinesSkipped, _godot_object);
308 	}
309 	/**
310 	
311 	*/
312 	void setMaxLinesVisible(in long lines_visible)
313 	{
314 		checkClassBinding!(typeof(this))();
315 		ptrcall!(void)(_classBinding.setMaxLinesVisible, _godot_object, lines_visible);
316 	}
317 	/**
318 	
319 	*/
320 	long getMaxLinesVisible() const
321 	{
322 		checkClassBinding!(typeof(this))();
323 		return ptrcall!(long)(_classBinding.getMaxLinesVisible, _godot_object);
324 	}
325 	/**
326 	The text to display on screen.
327 	*/
328 	@property String text()
329 	{
330 		return getText();
331 	}
332 	/// ditto
333 	@property void text(String v)
334 	{
335 		setText(v);
336 	}
337 	/**
338 	Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the `ALIGN_*` constants.
339 	*/
340 	@property Label.Align _align()
341 	{
342 		return getAlign();
343 	}
344 	/// ditto
345 	@property void _align(long v)
346 	{
347 		setAlign(v);
348 	}
349 	/**
350 	Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the `VALIGN_*` constants.
351 	*/
352 	@property Label.VAlign valign()
353 	{
354 		return getValign();
355 	}
356 	/// ditto
357 	@property void valign(long v)
358 	{
359 		setValign(v);
360 	}
361 	/**
362 	If `true`, wraps the text inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. Default: false.
363 	*/
364 	@property bool autowrap()
365 	{
366 		return hasAutowrap();
367 	}
368 	/// ditto
369 	@property void autowrap(bool v)
370 	{
371 		setAutowrap(v);
372 	}
373 	/**
374 	If `true`, the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.
375 	*/
376 	@property bool clipText()
377 	{
378 		return isClippingText();
379 	}
380 	/// ditto
381 	@property void clipText(bool v)
382 	{
383 		setClipText(v);
384 	}
385 	/**
386 	If `true`, all the text displays as UPPERCASE.
387 	*/
388 	@property bool uppercase()
389 	{
390 		return isUppercase();
391 	}
392 	/// ditto
393 	@property void uppercase(bool v)
394 	{
395 		setUppercase(v);
396 	}
397 	/**
398 	Restricts the number of characters to display. Set to -1 to disable.
399 	*/
400 	@property long visibleCharacters()
401 	{
402 		return getVisibleCharacters();
403 	}
404 	/// ditto
405 	@property void visibleCharacters(long v)
406 	{
407 		setVisibleCharacters(v);
408 	}
409 	/**
410 	Limits the count of visible characters. If you set `percent_visible` to 50, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
411 	*/
412 	@property double percentVisible()
413 	{
414 		return getPercentVisible();
415 	}
416 	/// ditto
417 	@property void percentVisible(double v)
418 	{
419 		setPercentVisible(v);
420 	}
421 	/**
422 	The node ignores the first `lines_skipped` lines before it starts to display text.
423 	*/
424 	@property long linesSkipped()
425 	{
426 		return getLinesSkipped();
427 	}
428 	/// ditto
429 	@property void linesSkipped(long v)
430 	{
431 		setLinesSkipped(v);
432 	}
433 	/**
434 	Limits the lines of text the node shows on screen.
435 	*/
436 	@property long maxLinesVisible()
437 	{
438 		return getMaxLinesVisible();
439 	}
440 	/// ditto
441 	@property void maxLinesVisible(long v)
442 	{
443 		setMaxLinesVisible(v);
444 	}
445 }