1 /**
2 Customizable $(D StyleBox) with a given set of parameters (no texture required).
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.styleboxflat;
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.stylebox;
25 import godot.resource;
26 import godot.reference;
27 /**
28 Customizable $(D StyleBox) with a given set of parameters (no texture required).
29 
30 This $(D StyleBox) can be used to achieve all kinds of looks without the need of a texture. The following properties are customizable:
31 - Color
32 - Border width (individual width for each border)
33 - Rounded corners (individual radius for each corner)
34 - Shadow (with blur and offset)
35 Setting corner radius to high values is allowed. As soon as corners overlap, the stylebox will switch to a relative system. Example:
36 
37 
38 height = 30
39 corner_radius_top_left = 50
40 corner_radius_bottom_left = 100
41 
42 
43 The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will $(B never) be more than the height. Result:
44 
45 
46 corner_radius_top_left: 10
47 corner_radius_bottom_left: 20
48 
49 
50 */
51 @GodotBaseClass struct StyleBoxFlat
52 {
53 	package(godot) enum string _GODOT_internal_name = "StyleBoxFlat";
54 public:
55 @nogc nothrow:
56 	union { /** */ godot_object _godot_object; /** */ StyleBox _GODOT_base; }
57 	alias _GODOT_base this;
58 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
59 	package(godot) __gshared bool _classBindingInitialized = false;
60 	package(godot) static struct GDNativeClassBinding
61 	{
62 		__gshared:
63 		@GodotName("get_aa_size") GodotMethod!(long) getAaSize;
64 		@GodotName("get_bg_color") GodotMethod!(Color) getBgColor;
65 		@GodotName("get_border_blend") GodotMethod!(bool) getBorderBlend;
66 		@GodotName("get_border_color") GodotMethod!(Color) getBorderColor;
67 		@GodotName("get_border_width") GodotMethod!(long, long) getBorderWidth;
68 		@GodotName("get_border_width_min") GodotMethod!(long) getBorderWidthMin;
69 		@GodotName("get_corner_detail") GodotMethod!(long) getCornerDetail;
70 		@GodotName("get_corner_radius") GodotMethod!(long, long) getCornerRadius;
71 		@GodotName("get_expand_margin") GodotMethod!(double, long) getExpandMargin;
72 		@GodotName("get_shadow_color") GodotMethod!(Color) getShadowColor;
73 		@GodotName("get_shadow_offset") GodotMethod!(Vector2) getShadowOffset;
74 		@GodotName("get_shadow_size") GodotMethod!(long) getShadowSize;
75 		@GodotName("is_anti_aliased") GodotMethod!(bool) isAntiAliased;
76 		@GodotName("is_draw_center_enabled") GodotMethod!(bool) isDrawCenterEnabled;
77 		@GodotName("set_aa_size") GodotMethod!(void, long) setAaSize;
78 		@GodotName("set_anti_aliased") GodotMethod!(void, bool) setAntiAliased;
79 		@GodotName("set_bg_color") GodotMethod!(void, Color) setBgColor;
80 		@GodotName("set_border_blend") GodotMethod!(void, bool) setBorderBlend;
81 		@GodotName("set_border_color") GodotMethod!(void, Color) setBorderColor;
82 		@GodotName("set_border_width") GodotMethod!(void, long, long) setBorderWidth;
83 		@GodotName("set_border_width_all") GodotMethod!(void, long) setBorderWidthAll;
84 		@GodotName("set_corner_detail") GodotMethod!(void, long) setCornerDetail;
85 		@GodotName("set_corner_radius") GodotMethod!(void, long, long) setCornerRadius;
86 		@GodotName("set_corner_radius_all") GodotMethod!(void, long) setCornerRadiusAll;
87 		@GodotName("set_corner_radius_individual") GodotMethod!(void, long, long, long, long) setCornerRadiusIndividual;
88 		@GodotName("set_draw_center") GodotMethod!(void, bool) setDrawCenter;
89 		@GodotName("set_expand_margin") GodotMethod!(void, long, double) setExpandMargin;
90 		@GodotName("set_expand_margin_all") GodotMethod!(void, double) setExpandMarginAll;
91 		@GodotName("set_expand_margin_individual") GodotMethod!(void, double, double, double, double) setExpandMarginIndividual;
92 		@GodotName("set_shadow_color") GodotMethod!(void, Color) setShadowColor;
93 		@GodotName("set_shadow_offset") GodotMethod!(void, Vector2) setShadowOffset;
94 		@GodotName("set_shadow_size") GodotMethod!(void, long) setShadowSize;
95 	}
96 	/// 
97 	pragma(inline, true) bool opEquals(in StyleBoxFlat other) const
98 	{ return _godot_object.ptr is other._godot_object.ptr; }
99 	/// 
100 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
101 	{ _godot_object.ptr = n; return null; }
102 	/// 
103 	pragma(inline, true) bool opEquals(typeof(null) n) const
104 	{ return _godot_object.ptr is n; }
105 	/// 
106 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
107 	mixin baseCasts;
108 	/// Construct a new instance of StyleBoxFlat.
109 	/// Note: use `memnew!StyleBoxFlat` instead.
110 	static StyleBoxFlat _new()
111 	{
112 		static godot_class_constructor constructor;
113 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("StyleBoxFlat");
114 		if(constructor is null) return typeof(this).init;
115 		return cast(StyleBoxFlat)(constructor());
116 	}
117 	@disable new(size_t s);
118 	/**
119 	
120 	*/
121 	long getAaSize() const
122 	{
123 		checkClassBinding!(typeof(this))();
124 		return ptrcall!(long)(GDNativeClassBinding.getAaSize, _godot_object);
125 	}
126 	/**
127 	
128 	*/
129 	Color getBgColor() const
130 	{
131 		checkClassBinding!(typeof(this))();
132 		return ptrcall!(Color)(GDNativeClassBinding.getBgColor, _godot_object);
133 	}
134 	/**
135 	
136 	*/
137 	bool getBorderBlend() const
138 	{
139 		checkClassBinding!(typeof(this))();
140 		return ptrcall!(bool)(GDNativeClassBinding.getBorderBlend, _godot_object);
141 	}
142 	/**
143 	
144 	*/
145 	Color getBorderColor() const
146 	{
147 		checkClassBinding!(typeof(this))();
148 		return ptrcall!(Color)(GDNativeClassBinding.getBorderColor, _godot_object);
149 	}
150 	/**
151 	Returns the given `margin`'s border width. See $(D margin) for possible values.
152 	*/
153 	long getBorderWidth(in long margin) const
154 	{
155 		checkClassBinding!(typeof(this))();
156 		return ptrcall!(long)(GDNativeClassBinding.getBorderWidth, _godot_object, margin);
157 	}
158 	/**
159 	Returns the smallest border width out of all four borders.
160 	*/
161 	long getBorderWidthMin() const
162 	{
163 		checkClassBinding!(typeof(this))();
164 		return ptrcall!(long)(GDNativeClassBinding.getBorderWidthMin, _godot_object);
165 	}
166 	/**
167 	
168 	*/
169 	long getCornerDetail() const
170 	{
171 		checkClassBinding!(typeof(this))();
172 		return ptrcall!(long)(GDNativeClassBinding.getCornerDetail, _godot_object);
173 	}
174 	/**
175 	Returns the given `corner`'s radius. See $(D corner) for possible values.
176 	*/
177 	long getCornerRadius(in long corner) const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(long)(GDNativeClassBinding.getCornerRadius, _godot_object, corner);
181 	}
182 	/**
183 	Returns the size of the given `margin`'s expand margin. See $(D margin) for possible values.
184 	*/
185 	double getExpandMargin(in long margin) const
186 	{
187 		checkClassBinding!(typeof(this))();
188 		return ptrcall!(double)(GDNativeClassBinding.getExpandMargin, _godot_object, margin);
189 	}
190 	/**
191 	
192 	*/
193 	Color getShadowColor() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(Color)(GDNativeClassBinding.getShadowColor, _godot_object);
197 	}
198 	/**
199 	
200 	*/
201 	Vector2 getShadowOffset() const
202 	{
203 		checkClassBinding!(typeof(this))();
204 		return ptrcall!(Vector2)(GDNativeClassBinding.getShadowOffset, _godot_object);
205 	}
206 	/**
207 	
208 	*/
209 	long getShadowSize() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(long)(GDNativeClassBinding.getShadowSize, _godot_object);
213 	}
214 	/**
215 	
216 	*/
217 	bool isAntiAliased() const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(bool)(GDNativeClassBinding.isAntiAliased, _godot_object);
221 	}
222 	/**
223 	
224 	*/
225 	bool isDrawCenterEnabled() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(bool)(GDNativeClassBinding.isDrawCenterEnabled, _godot_object);
229 	}
230 	/**
231 	
232 	*/
233 	void setAaSize(in long size)
234 	{
235 		checkClassBinding!(typeof(this))();
236 		ptrcall!(void)(GDNativeClassBinding.setAaSize, _godot_object, size);
237 	}
238 	/**
239 	
240 	*/
241 	void setAntiAliased(in bool anti_aliased)
242 	{
243 		checkClassBinding!(typeof(this))();
244 		ptrcall!(void)(GDNativeClassBinding.setAntiAliased, _godot_object, anti_aliased);
245 	}
246 	/**
247 	
248 	*/
249 	void setBgColor(in Color color)
250 	{
251 		checkClassBinding!(typeof(this))();
252 		ptrcall!(void)(GDNativeClassBinding.setBgColor, _godot_object, color);
253 	}
254 	/**
255 	
256 	*/
257 	void setBorderBlend(in bool blend)
258 	{
259 		checkClassBinding!(typeof(this))();
260 		ptrcall!(void)(GDNativeClassBinding.setBorderBlend, _godot_object, blend);
261 	}
262 	/**
263 	
264 	*/
265 	void setBorderColor(in Color color)
266 	{
267 		checkClassBinding!(typeof(this))();
268 		ptrcall!(void)(GDNativeClassBinding.setBorderColor, _godot_object, color);
269 	}
270 	/**
271 	Sets the border width to `width` pixels for the given `margin`. See $(D margin) for possible values.
272 	*/
273 	void setBorderWidth(in long margin, in long width)
274 	{
275 		checkClassBinding!(typeof(this))();
276 		ptrcall!(void)(GDNativeClassBinding.setBorderWidth, _godot_object, margin, width);
277 	}
278 	/**
279 	Sets the border width to `width` pixels for all margins.
280 	*/
281 	void setBorderWidthAll(in long width)
282 	{
283 		checkClassBinding!(typeof(this))();
284 		ptrcall!(void)(GDNativeClassBinding.setBorderWidthAll, _godot_object, width);
285 	}
286 	/**
287 	
288 	*/
289 	void setCornerDetail(in long detail)
290 	{
291 		checkClassBinding!(typeof(this))();
292 		ptrcall!(void)(GDNativeClassBinding.setCornerDetail, _godot_object, detail);
293 	}
294 	/**
295 	Sets the corner radius to `radius` pixels for the given `corner`. See $(D corner) for possible values.
296 	*/
297 	void setCornerRadius(in long corner, in long radius)
298 	{
299 		checkClassBinding!(typeof(this))();
300 		ptrcall!(void)(GDNativeClassBinding.setCornerRadius, _godot_object, corner, radius);
301 	}
302 	/**
303 	Sets the corner radius to `radius` pixels for all corners.
304 	*/
305 	void setCornerRadiusAll(in long radius)
306 	{
307 		checkClassBinding!(typeof(this))();
308 		ptrcall!(void)(GDNativeClassBinding.setCornerRadiusAll, _godot_object, radius);
309 	}
310 	/**
311 	Sets the corner radius for each corner to `radius_top_left`, `radius_top_right`, `radius_bottom_right`, and `radius_bottom_left` pixels.
312 	*/
313 	void setCornerRadiusIndividual(in long radius_top_left, in long radius_top_right, in long radius_bottom_right, in long radius_bottom_left)
314 	{
315 		checkClassBinding!(typeof(this))();
316 		ptrcall!(void)(GDNativeClassBinding.setCornerRadiusIndividual, _godot_object, radius_top_left, radius_top_right, radius_bottom_right, radius_bottom_left);
317 	}
318 	/**
319 	
320 	*/
321 	void setDrawCenter(in bool draw_center)
322 	{
323 		checkClassBinding!(typeof(this))();
324 		ptrcall!(void)(GDNativeClassBinding.setDrawCenter, _godot_object, draw_center);
325 	}
326 	/**
327 	Sets the expand margin to `size` pixels for the given `margin`. See $(D margin) for possible values.
328 	*/
329 	void setExpandMargin(in long margin, in double size)
330 	{
331 		checkClassBinding!(typeof(this))();
332 		ptrcall!(void)(GDNativeClassBinding.setExpandMargin, _godot_object, margin, size);
333 	}
334 	/**
335 	Sets the expand margin to `size` pixels for all margins.
336 	*/
337 	void setExpandMarginAll(in double size)
338 	{
339 		checkClassBinding!(typeof(this))();
340 		ptrcall!(void)(GDNativeClassBinding.setExpandMarginAll, _godot_object, size);
341 	}
342 	/**
343 	Sets the expand margin for each margin to `size_left`, `size_top`, `size_right`, and `size_bottom` pixels.
344 	*/
345 	void setExpandMarginIndividual(in double size_left, in double size_top, in double size_right, in double size_bottom)
346 	{
347 		checkClassBinding!(typeof(this))();
348 		ptrcall!(void)(GDNativeClassBinding.setExpandMarginIndividual, _godot_object, size_left, size_top, size_right, size_bottom);
349 	}
350 	/**
351 	
352 	*/
353 	void setShadowColor(in Color color)
354 	{
355 		checkClassBinding!(typeof(this))();
356 		ptrcall!(void)(GDNativeClassBinding.setShadowColor, _godot_object, color);
357 	}
358 	/**
359 	
360 	*/
361 	void setShadowOffset(in Vector2 offset)
362 	{
363 		checkClassBinding!(typeof(this))();
364 		ptrcall!(void)(GDNativeClassBinding.setShadowOffset, _godot_object, offset);
365 	}
366 	/**
367 	
368 	*/
369 	void setShadowSize(in long size)
370 	{
371 		checkClassBinding!(typeof(this))();
372 		ptrcall!(void)(GDNativeClassBinding.setShadowSize, _godot_object, size);
373 	}
374 	/**
375 	Antialiasing draws a small ring around the edges, which fades to transparency. As a result, edges look much smoother. This is only noticeable when using rounded corners.
376 	*/
377 	@property bool antiAliasing()
378 	{
379 		return isAntiAliased();
380 	}
381 	/// ditto
382 	@property void antiAliasing(bool v)
383 	{
384 		setAntiAliased(v);
385 	}
386 	/**
387 	This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect.
388 	*/
389 	@property long antiAliasingSize()
390 	{
391 		return getAaSize();
392 	}
393 	/// ditto
394 	@property void antiAliasingSize(long v)
395 	{
396 		setAaSize(v);
397 	}
398 	/**
399 	The background color of the stylebox.
400 	*/
401 	@property Color bgColor()
402 	{
403 		return getBgColor();
404 	}
405 	/// ditto
406 	@property void bgColor(Color v)
407 	{
408 		setBgColor(v);
409 	}
410 	/**
411 	If `true`, the border will fade into the background color.
412 	*/
413 	@property bool borderBlend()
414 	{
415 		return getBorderBlend();
416 	}
417 	/// ditto
418 	@property void borderBlend(bool v)
419 	{
420 		setBorderBlend(v);
421 	}
422 	/**
423 	Sets the color of the border.
424 	*/
425 	@property Color borderColor()
426 	{
427 		return getBorderColor();
428 	}
429 	/// ditto
430 	@property void borderColor(Color v)
431 	{
432 		setBorderColor(v);
433 	}
434 	/**
435 	Border width for the bottom border.
436 	*/
437 	@property long borderWidthBottom()
438 	{
439 		return getBorderWidth(3);
440 	}
441 	/// ditto
442 	@property void borderWidthBottom(long v)
443 	{
444 		setBorderWidth(3, v);
445 	}
446 	/**
447 	Border width for the left border.
448 	*/
449 	@property long borderWidthLeft()
450 	{
451 		return getBorderWidth(0);
452 	}
453 	/// ditto
454 	@property void borderWidthLeft(long v)
455 	{
456 		setBorderWidth(0, v);
457 	}
458 	/**
459 	Border width for the right border.
460 	*/
461 	@property long borderWidthRight()
462 	{
463 		return getBorderWidth(2);
464 	}
465 	/// ditto
466 	@property void borderWidthRight(long v)
467 	{
468 		setBorderWidth(2, v);
469 	}
470 	/**
471 	Border width for the top border.
472 	*/
473 	@property long borderWidthTop()
474 	{
475 		return getBorderWidth(1);
476 	}
477 	/// ditto
478 	@property void borderWidthTop(long v)
479 	{
480 		setBorderWidth(1, v);
481 	}
482 	/**
483 	This sets the number of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius ($(D setCornerRadiusAll)) into account.
484 	For corner radii less than 10, `4` or `5` should be enough. For corner radii less than 30, values between `8` and `12` should be enough.
485 	A corner detail of `1` will result in chamfered corners instead of rounded corners, which is useful for some artistic effects.
486 	*/
487 	@property long cornerDetail()
488 	{
489 		return getCornerDetail();
490 	}
491 	/// ditto
492 	@property void cornerDetail(long v)
493 	{
494 		setCornerDetail(v);
495 	}
496 	/**
497 	The bottom-left corner's radius. If `0`, the corner is not rounded.
498 	*/
499 	@property long cornerRadiusBottomLeft()
500 	{
501 		return getCornerRadius(3);
502 	}
503 	/// ditto
504 	@property void cornerRadiusBottomLeft(long v)
505 	{
506 		setCornerRadius(3, v);
507 	}
508 	/**
509 	The bottom-right corner's radius. If `0`, the corner is not rounded.
510 	*/
511 	@property long cornerRadiusBottomRight()
512 	{
513 		return getCornerRadius(2);
514 	}
515 	/// ditto
516 	@property void cornerRadiusBottomRight(long v)
517 	{
518 		setCornerRadius(2, v);
519 	}
520 	/**
521 	The top-left corner's radius. If `0`, the corner is not rounded.
522 	*/
523 	@property long cornerRadiusTopLeft()
524 	{
525 		return getCornerRadius(0);
526 	}
527 	/// ditto
528 	@property void cornerRadiusTopLeft(long v)
529 	{
530 		setCornerRadius(0, v);
531 	}
532 	/**
533 	The top-right corner's radius. If `0`, the corner is not rounded.
534 	*/
535 	@property long cornerRadiusTopRight()
536 	{
537 		return getCornerRadius(1);
538 	}
539 	/// ditto
540 	@property void cornerRadiusTopRight(long v)
541 	{
542 		setCornerRadius(1, v);
543 	}
544 	/**
545 	Toggles drawing of the inner part of the stylebox.
546 	*/
547 	@property bool drawCenter()
548 	{
549 		return isDrawCenterEnabled();
550 	}
551 	/// ditto
552 	@property void drawCenter(bool v)
553 	{
554 		setDrawCenter(v);
555 	}
556 	/**
557 	Expands the stylebox outside of the control rect on the bottom edge. Useful in combination with $(D borderWidthBottom) to draw a border outside the control rect.
558 	*/
559 	@property double expandMarginBottom()
560 	{
561 		return getExpandMargin(3);
562 	}
563 	/// ditto
564 	@property void expandMarginBottom(double v)
565 	{
566 		setExpandMargin(3, v);
567 	}
568 	/**
569 	Expands the stylebox outside of the control rect on the left edge. Useful in combination with $(D borderWidthLeft) to draw a border outside the control rect.
570 	*/
571 	@property double expandMarginLeft()
572 	{
573 		return getExpandMargin(0);
574 	}
575 	/// ditto
576 	@property void expandMarginLeft(double v)
577 	{
578 		setExpandMargin(0, v);
579 	}
580 	/**
581 	Expands the stylebox outside of the control rect on the right edge. Useful in combination with $(D borderWidthRight) to draw a border outside the control rect.
582 	*/
583 	@property double expandMarginRight()
584 	{
585 		return getExpandMargin(2);
586 	}
587 	/// ditto
588 	@property void expandMarginRight(double v)
589 	{
590 		setExpandMargin(2, v);
591 	}
592 	/**
593 	Expands the stylebox outside of the control rect on the top edge. Useful in combination with $(D borderWidthTop) to draw a border outside the control rect.
594 	*/
595 	@property double expandMarginTop()
596 	{
597 		return getExpandMargin(1);
598 	}
599 	/// ditto
600 	@property void expandMarginTop(double v)
601 	{
602 		setExpandMargin(1, v);
603 	}
604 	/**
605 	The color of the shadow. This has no effect if $(D shadowSize) is lower than 1.
606 	*/
607 	@property Color shadowColor()
608 	{
609 		return getShadowColor();
610 	}
611 	/// ditto
612 	@property void shadowColor(Color v)
613 	{
614 		setShadowColor(v);
615 	}
616 	/**
617 	The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox.
618 	*/
619 	@property Vector2 shadowOffset()
620 	{
621 		return getShadowOffset();
622 	}
623 	/// ditto
624 	@property void shadowOffset(Vector2 v)
625 	{
626 		setShadowOffset(v);
627 	}
628 	/**
629 	The shadow size in pixels.
630 	*/
631 	@property long shadowSize()
632 	{
633 		return getShadowSize();
634 	}
635 	/// ditto
636 	@property void shadowSize(long v)
637 	{
638 		setShadowSize(v);
639 	}
640 }