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.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 Base node for containers. 28 29 A `Container` contains other controls and automatically arranges them in a certain way. 30 A Control can inherit this to create custom container classes. 31 */ 32 @GodotBaseClass struct Container 33 { 34 enum string _GODOT_internal_name = "Container"; 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("_sort_children") GodotMethod!(void) _sortChildren; 45 @GodotName("_child_minsize_changed") GodotMethod!(void) _childMinsizeChanged; 46 @GodotName("queue_sort") GodotMethod!(void) queueSort; 47 @GodotName("fit_child_in_rect") GodotMethod!(void, GodotObject, Rect2) fitChildInRect; 48 } 49 bool opEquals(in Container other) const { return _godot_object.ptr is other._godot_object.ptr; } 50 Container opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 51 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 52 mixin baseCasts; 53 static Container _new() 54 { 55 static godot_class_constructor constructor; 56 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Container"); 57 if(constructor is null) return typeof(this).init; 58 return cast(Container)(constructor()); 59 } 60 @disable new(size_t s); 61 /// 62 enum Constants : int 63 { 64 /** 65 Notification for when sorting the children, it must be obeyed immediately. 66 */ 67 notificationSortChildren = 50, 68 } 69 /** 70 71 */ 72 void _sortChildren() 73 { 74 Array _GODOT_args = Array.empty_array; 75 String _GODOT_method_name = String("_sort_children"); 76 this.callv(_GODOT_method_name, _GODOT_args); 77 } 78 /** 79 80 */ 81 void _childMinsizeChanged() 82 { 83 Array _GODOT_args = Array.empty_array; 84 String _GODOT_method_name = String("_child_minsize_changed"); 85 this.callv(_GODOT_method_name, _GODOT_args); 86 } 87 /** 88 Queue resort of the contained children. This is called automatically anyway, but can be called upon request. 89 */ 90 void queueSort() 91 { 92 checkClassBinding!(typeof(this))(); 93 ptrcall!(void)(_classBinding.queueSort, _godot_object); 94 } 95 /** 96 Fit a child control in a given rect. This is mainly a helper for creating custom container classes. 97 */ 98 void fitChildInRect(GodotObject child, in Rect2 rect) 99 { 100 checkClassBinding!(typeof(this))(); 101 ptrcall!(void)(_classBinding.fitChildInRect, _godot_object, child, rect); 102 } 103 }