1 /**
2 Manages the SceneTree selection in the editor.
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.editorselection;
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.node;
24 /**
25 Manages the SceneTree selection in the editor.
26 
27 This object manages the SceneTree selection in the editor.
28 $(B Note:) This class shouldn't be instantiated directly. Instead, access the singleton using $(D EditorInterface.getSelection).
29 */
30 @GodotBaseClass struct EditorSelection
31 {
32 	package(godot) enum string _GODOT_internal_name = "EditorSelection";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("_emit_change") GodotMethod!(void) _emitChange;
43 		@GodotName("_node_removed") GodotMethod!(void, Node) _nodeRemoved;
44 		@GodotName("add_node") GodotMethod!(void, Node) addNode;
45 		@GodotName("clear") GodotMethod!(void) clear;
46 		@GodotName("get_selected_nodes") GodotMethod!(Array) getSelectedNodes;
47 		@GodotName("get_transformable_selected_nodes") GodotMethod!(Array) getTransformableSelectedNodes;
48 		@GodotName("remove_node") GodotMethod!(void, Node) removeNode;
49 	}
50 	/// 
51 	pragma(inline, true) bool opEquals(in EditorSelection other) const
52 	{ return _godot_object.ptr is other._godot_object.ptr; }
53 	/// 
54 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
55 	{ _godot_object.ptr = n; return null; }
56 	/// 
57 	pragma(inline, true) bool opEquals(typeof(null) n) const
58 	{ return _godot_object.ptr is n; }
59 	/// 
60 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
61 	mixin baseCasts;
62 	/// Construct a new instance of EditorSelection.
63 	/// Note: use `memnew!EditorSelection` instead.
64 	static EditorSelection _new()
65 	{
66 		static godot_class_constructor constructor;
67 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorSelection");
68 		if(constructor is null) return typeof(this).init;
69 		return cast(EditorSelection)(constructor());
70 	}
71 	@disable new(size_t s);
72 	/**
73 	
74 	*/
75 	void _emitChange()
76 	{
77 		Array _GODOT_args = Array.make();
78 		String _GODOT_method_name = String("_emit_change");
79 		this.callv(_GODOT_method_name, _GODOT_args);
80 	}
81 	/**
82 	
83 	*/
84 	void _nodeRemoved(Node arg0)
85 	{
86 		Array _GODOT_args = Array.make();
87 		_GODOT_args.append(arg0);
88 		String _GODOT_method_name = String("_node_removed");
89 		this.callv(_GODOT_method_name, _GODOT_args);
90 	}
91 	/**
92 	Adds a node to the selection.
93 	$(B Note:) The newly selected node will not be automatically edited in the inspector. If you want to edit a node, use $(D EditorInterface.editNode).
94 	*/
95 	void addNode(Node node)
96 	{
97 		checkClassBinding!(typeof(this))();
98 		ptrcall!(void)(GDNativeClassBinding.addNode, _godot_object, node);
99 	}
100 	/**
101 	Clear the selection.
102 	*/
103 	void clear()
104 	{
105 		checkClassBinding!(typeof(this))();
106 		ptrcall!(void)(GDNativeClassBinding.clear, _godot_object);
107 	}
108 	/**
109 	Gets the list of selected nodes.
110 	*/
111 	Array getSelectedNodes()
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(Array)(GDNativeClassBinding.getSelectedNodes, _godot_object);
115 	}
116 	/**
117 	Gets the list of selected nodes, optimized for transform operations (i.e. moving them, rotating, etc). This list avoids situations where a node is selected and also child/grandchild.
118 	*/
119 	Array getTransformableSelectedNodes()
120 	{
121 		checkClassBinding!(typeof(this))();
122 		return ptrcall!(Array)(GDNativeClassBinding.getTransformableSelectedNodes, _godot_object);
123 	}
124 	/**
125 	Removes a node from the selection.
126 	*/
127 	void removeNode(Node node)
128 	{
129 		checkClassBinding!(typeof(this))();
130 		ptrcall!(void)(GDNativeClassBinding.removeNode, _godot_object, node);
131 	}
132 }