1 /**
2 Base node for containers.
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.container;
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.control;
25 /**
26 Base node for containers.
27 
28 A $(D Container) contains other controls and automatically arranges them in a certain way.
29 A Control can inherit this to create custom container classes.
30 */
31 @GodotBaseClass struct Container
32 {
33 	package(godot) enum string _GODOT_internal_name = "Container";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Control _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("_child_minsize_changed") GodotMethod!(void) _childMinsizeChanged;
44 		@GodotName("_sort_children") GodotMethod!(void) _sortChildren;
45 		@GodotName("fit_child_in_rect") GodotMethod!(void, Control, Rect2) fitChildInRect;
46 		@GodotName("queue_sort") GodotMethod!(void) queueSort;
47 	}
48 	/// 
49 	pragma(inline, true) bool opEquals(in Container other) const
50 	{ return _godot_object.ptr is other._godot_object.ptr; }
51 	/// 
52 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
53 	{ _godot_object.ptr = n; return null; }
54 	/// 
55 	pragma(inline, true) bool opEquals(typeof(null) n) const
56 	{ return _godot_object.ptr is n; }
57 	/// 
58 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
59 	mixin baseCasts;
60 	/// Construct a new instance of Container.
61 	/// Note: use `memnew!Container` instead.
62 	static Container _new()
63 	{
64 		static godot_class_constructor constructor;
65 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Container");
66 		if(constructor is null) return typeof(this).init;
67 		return cast(Container)(constructor());
68 	}
69 	@disable new(size_t s);
70 	/// 
71 	enum Constants : int
72 	{
73 		/**
74 		Notification for when sorting the children, it must be obeyed immediately.
75 		*/
76 		notificationSortChildren = 50,
77 	}
78 	/**
79 	
80 	*/
81 	void _childMinsizeChanged()
82 	{
83 		Array _GODOT_args = Array.make();
84 		String _GODOT_method_name = String("_child_minsize_changed");
85 		this.callv(_GODOT_method_name, _GODOT_args);
86 	}
87 	/**
88 	
89 	*/
90 	void _sortChildren()
91 	{
92 		Array _GODOT_args = Array.make();
93 		String _GODOT_method_name = String("_sort_children");
94 		this.callv(_GODOT_method_name, _GODOT_args);
95 	}
96 	/**
97 	Fit a child control in a given rect. This is mainly a helper for creating custom container classes.
98 	*/
99 	void fitChildInRect(Control child, in Rect2 rect)
100 	{
101 		checkClassBinding!(typeof(this))();
102 		ptrcall!(void)(GDNativeClassBinding.fitChildInRect, _godot_object, child, rect);
103 	}
104 	/**
105 	Queue resort of the contained children. This is called automatically anyway, but can be called upon request.
106 	*/
107 	void queueSort()
108 	{
109 		checkClassBinding!(typeof(this))();
110 		ptrcall!(void)(GDNativeClassBinding.queueSort, _godot_object);
111 	}
112 }