1 /**
2 Button control that provides selectable options when pressed.
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.optionbutton;
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.button;
24 import godot.texture;
25 import godot.popupmenu;
26 import godot.basebutton;
27 import godot.control;
28 import godot.canvasitem;
29 import godot.node;
30 /**
31 Button control that provides selectable options when pressed.
32 
33 OptionButton is a type button that provides a selectable list of items when pressed. The item selected becomes the "current" item and is displayed as the button text.
34 */
35 @GodotBaseClass struct OptionButton
36 {
37 	enum string _GODOT_internal_name = "OptionButton";
38 public:
39 @nogc nothrow:
40 	union { godot_object _godot_object; Button _GODOT_base; }
41 	alias _GODOT_base this;
42 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
43 	package(godot) __gshared bool _classBindingInitialized = false;
44 	package(godot) static struct _classBinding
45 	{
46 		__gshared:
47 		@GodotName("_selected") GodotMethod!(void, long) _selected;
48 		@GodotName("_focused") GodotMethod!(void, long) _focused;
49 		@GodotName("add_item") GodotMethod!(void, String, long) addItem;
50 		@GodotName("add_icon_item") GodotMethod!(void, Texture, String, long) addIconItem;
51 		@GodotName("set_item_text") GodotMethod!(void, long, String) setItemText;
52 		@GodotName("set_item_icon") GodotMethod!(void, long, Texture) setItemIcon;
53 		@GodotName("set_item_disabled") GodotMethod!(void, long, bool) setItemDisabled;
54 		@GodotName("set_item_id") GodotMethod!(void, long, long) setItemId;
55 		@GodotName("set_item_metadata") GodotMethod!(void, long, Variant) setItemMetadata;
56 		@GodotName("get_item_text") GodotMethod!(String, long) getItemText;
57 		@GodotName("get_item_icon") GodotMethod!(Texture, long) getItemIcon;
58 		@GodotName("get_item_id") GodotMethod!(long, long) getItemId;
59 		@GodotName("get_item_metadata") GodotMethod!(Variant, long) getItemMetadata;
60 		@GodotName("is_item_disabled") GodotMethod!(bool, long) isItemDisabled;
61 		@GodotName("get_item_count") GodotMethod!(long) getItemCount;
62 		@GodotName("add_separator") GodotMethod!(void) addSeparator;
63 		@GodotName("clear") GodotMethod!(void) clear;
64 		@GodotName("select") GodotMethod!(void, long) select;
65 		@GodotName("get_selected") GodotMethod!(long) getSelected;
66 		@GodotName("get_selected_id") GodotMethod!(long) getSelectedId;
67 		@GodotName("get_selected_metadata") GodotMethod!(Variant) getSelectedMetadata;
68 		@GodotName("remove_item") GodotMethod!(void, long) removeItem;
69 		@GodotName("_select_int") GodotMethod!(void, long) _selectInt;
70 		@GodotName("get_popup") GodotMethod!(PopupMenu) getPopup;
71 		@GodotName("_set_items") GodotMethod!(void, Array) _setItems;
72 		@GodotName("_get_items") GodotMethod!(Array) _getItems;
73 	}
74 	bool opEquals(in OptionButton other) const { return _godot_object.ptr is other._godot_object.ptr; }
75 	OptionButton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
76 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
77 	mixin baseCasts;
78 	static OptionButton _new()
79 	{
80 		static godot_class_constructor constructor;
81 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("OptionButton");
82 		if(constructor is null) return typeof(this).init;
83 		return cast(OptionButton)(constructor());
84 	}
85 	@disable new(size_t s);
86 	/**
87 	
88 	*/
89 	void _selected(in long arg0)
90 	{
91 		Array _GODOT_args = Array.empty_array;
92 		_GODOT_args.append(arg0);
93 		String _GODOT_method_name = String("_selected");
94 		this.callv(_GODOT_method_name, _GODOT_args);
95 	}
96 	/**
97 	
98 	*/
99 	void _focused(in long arg0)
100 	{
101 		Array _GODOT_args = Array.empty_array;
102 		_GODOT_args.append(arg0);
103 		String _GODOT_method_name = String("_focused");
104 		this.callv(_GODOT_method_name, _GODOT_args);
105 	}
106 	/**
107 	Add an item, with text "label" and (optionally) id. If no "id" is passed, "id" becomes the item index. New items are appended at the end.
108 	*/
109 	void addItem(StringArg0)(in StringArg0 label, in long id = -1)
110 	{
111 		checkClassBinding!(typeof(this))();
112 		ptrcall!(void)(_classBinding.addItem, _godot_object, label, id);
113 	}
114 	/**
115 	Add an item, with a "texture" icon, text "label" and (optionally) id. If no "id" is passed, "id" becomes the item index. New items are appended at the end.
116 	*/
117 	void addIconItem(StringArg1)(Texture texture, in StringArg1 label, in long id = -1)
118 	{
119 		checkClassBinding!(typeof(this))();
120 		ptrcall!(void)(_classBinding.addIconItem, _godot_object, texture, label, id);
121 	}
122 	/**
123 	Set the text of an item at index "idx".
124 	*/
125 	void setItemText(StringArg1)(in long idx, in StringArg1 text)
126 	{
127 		checkClassBinding!(typeof(this))();
128 		ptrcall!(void)(_classBinding.setItemText, _godot_object, idx, text);
129 	}
130 	/**
131 	Set the icon of an item at index "idx".
132 	*/
133 	void setItemIcon(in long idx, Texture texture)
134 	{
135 		checkClassBinding!(typeof(this))();
136 		ptrcall!(void)(_classBinding.setItemIcon, _godot_object, idx, texture);
137 	}
138 	/**
139 	
140 	*/
141 	void setItemDisabled(in long idx, in bool disabled)
142 	{
143 		checkClassBinding!(typeof(this))();
144 		ptrcall!(void)(_classBinding.setItemDisabled, _godot_object, idx, disabled);
145 	}
146 	/**
147 	Set the ID of an item at index "idx".
148 	*/
149 	void setItemId(in long idx, in long id)
150 	{
151 		checkClassBinding!(typeof(this))();
152 		ptrcall!(void)(_classBinding.setItemId, _godot_object, idx, id);
153 	}
154 	/**
155 	
156 	*/
157 	void setItemMetadata(VariantArg1)(in long idx, in VariantArg1 metadata)
158 	{
159 		checkClassBinding!(typeof(this))();
160 		ptrcall!(void)(_classBinding.setItemMetadata, _godot_object, idx, metadata);
161 	}
162 	/**
163 	Return the text of the item at index "idx".
164 	*/
165 	String getItemText(in long idx) const
166 	{
167 		checkClassBinding!(typeof(this))();
168 		return ptrcall!(String)(_classBinding.getItemText, _godot_object, idx);
169 	}
170 	/**
171 	Return the icon of the item at index "idx".
172 	*/
173 	Ref!Texture getItemIcon(in long idx) const
174 	{
175 		checkClassBinding!(typeof(this))();
176 		return ptrcall!(Texture)(_classBinding.getItemIcon, _godot_object, idx);
177 	}
178 	/**
179 	Return the ID of the item at index "idx".
180 	*/
181 	long getItemId(in long idx) const
182 	{
183 		checkClassBinding!(typeof(this))();
184 		return ptrcall!(long)(_classBinding.getItemId, _godot_object, idx);
185 	}
186 	/**
187 	
188 	*/
189 	Variant getItemMetadata(in long idx) const
190 	{
191 		checkClassBinding!(typeof(this))();
192 		return ptrcall!(Variant)(_classBinding.getItemMetadata, _godot_object, idx);
193 	}
194 	/**
195 	
196 	*/
197 	bool isItemDisabled(in long idx) const
198 	{
199 		checkClassBinding!(typeof(this))();
200 		return ptrcall!(bool)(_classBinding.isItemDisabled, _godot_object, idx);
201 	}
202 	/**
203 	Return the amount of items in the OptionButton.
204 	*/
205 	long getItemCount() const
206 	{
207 		checkClassBinding!(typeof(this))();
208 		return ptrcall!(long)(_classBinding.getItemCount, _godot_object);
209 	}
210 	/**
211 	Add a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.
212 	*/
213 	void addSeparator()
214 	{
215 		checkClassBinding!(typeof(this))();
216 		ptrcall!(void)(_classBinding.addSeparator, _godot_object);
217 	}
218 	/**
219 	Clear all the items in the `OptionButton`.
220 	*/
221 	void clear()
222 	{
223 		checkClassBinding!(typeof(this))();
224 		ptrcall!(void)(_classBinding.clear, _godot_object);
225 	}
226 	/**
227 	Select an item by index and make it the current item.
228 	*/
229 	void select(in long idx)
230 	{
231 		checkClassBinding!(typeof(this))();
232 		ptrcall!(void)(_classBinding.select, _godot_object, idx);
233 	}
234 	/**
235 	
236 	*/
237 	long getSelected() const
238 	{
239 		checkClassBinding!(typeof(this))();
240 		return ptrcall!(long)(_classBinding.getSelected, _godot_object);
241 	}
242 	/**
243 	
244 	*/
245 	long getSelectedId() const
246 	{
247 		checkClassBinding!(typeof(this))();
248 		return ptrcall!(long)(_classBinding.getSelectedId, _godot_object);
249 	}
250 	/**
251 	
252 	*/
253 	Variant getSelectedMetadata() const
254 	{
255 		checkClassBinding!(typeof(this))();
256 		return ptrcall!(Variant)(_classBinding.getSelectedMetadata, _godot_object);
257 	}
258 	/**
259 	
260 	*/
261 	void removeItem(in long idx)
262 	{
263 		checkClassBinding!(typeof(this))();
264 		ptrcall!(void)(_classBinding.removeItem, _godot_object, idx);
265 	}
266 	/**
267 	
268 	*/
269 	void _selectInt(in long arg0)
270 	{
271 		Array _GODOT_args = Array.empty_array;
272 		_GODOT_args.append(arg0);
273 		String _GODOT_method_name = String("_select_int");
274 		this.callv(_GODOT_method_name, _GODOT_args);
275 	}
276 	/**
277 	Return the $(D PopupMenu) contained in this button.
278 	*/
279 	PopupMenu getPopup() const
280 	{
281 		checkClassBinding!(typeof(this))();
282 		return ptrcall!(PopupMenu)(_classBinding.getPopup, _godot_object);
283 	}
284 	/**
285 	
286 	*/
287 	void _setItems(in Array arg0)
288 	{
289 		Array _GODOT_args = Array.empty_array;
290 		_GODOT_args.append(arg0);
291 		String _GODOT_method_name = String("_set_items");
292 		this.callv(_GODOT_method_name, _GODOT_args);
293 	}
294 	/**
295 	
296 	*/
297 	Array _getItems() const
298 	{
299 		Array _GODOT_args = Array.empty_array;
300 		String _GODOT_method_name = String("_get_items");
301 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array);
302 	}
303 	/**
304 	
305 	*/
306 	@property Array items()
307 	{
308 		return _getItems();
309 	}
310 	/// ditto
311 	@property void items(Array v)
312 	{
313 		_setItems(v);
314 	}
315 	/**
316 	
317 	*/
318 	@property long selected()
319 	{
320 		return getSelected();
321 	}
322 	/// ditto
323 	@property void selected(long v)
324 	{
325 		_selectInt(v);
326 	}
327 }