1 /** 2 Sort all child nodes based on their Y positions. 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.ysort; 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.node2d; 25 import godot.canvasitem; 26 import godot.node; 27 /** 28 Sort all child nodes based on their Y positions. 29 30 The child node must inherit from $(D CanvasItem) for it to be sorted. Nodes that have a higher Y position will be drawn later, so they will appear on top of nodes that have a lower Y position. 31 Nesting of YSort nodes is possible. Children YSort nodes will be sorted in the same space as the parent YSort, allowing to better organize a scene or divide it in multiple ones, yet keep the unique sorting. 32 */ 33 @GodotBaseClass struct YSort 34 { 35 package(godot) enum string _GODOT_internal_name = "YSort"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ Node2D _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 GDNativeClassBinding 43 { 44 __gshared: 45 @GodotName("is_sort_enabled") GodotMethod!(bool) isSortEnabled; 46 @GodotName("set_sort_enabled") GodotMethod!(void, bool) setSortEnabled; 47 } 48 /// 49 pragma(inline, true) bool opEquals(in YSort 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 YSort. 61 /// Note: use `memnew!YSort` instead. 62 static YSort _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("YSort"); 66 if(constructor is null) return typeof(this).init; 67 return cast(YSort)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 72 */ 73 bool isSortEnabled() const 74 { 75 checkClassBinding!(typeof(this))(); 76 return ptrcall!(bool)(GDNativeClassBinding.isSortEnabled, _godot_object); 77 } 78 /** 79 80 */ 81 void setSortEnabled(in bool enabled) 82 { 83 checkClassBinding!(typeof(this))(); 84 ptrcall!(void)(GDNativeClassBinding.setSortEnabled, _godot_object, enabled); 85 } 86 /** 87 If `true`, child nodes are sorted, otherwise sorting is disabled. 88 */ 89 @property bool sortEnabled() 90 { 91 return isSortEnabled(); 92 } 93 /// ditto 94 @property void sortEnabled(bool v) 95 { 96 setSortEnabled(v); 97 } 98 }