1 /**
2 Tabbed container.
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.tabcontainer;
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.container;
25 import godot.control;
26 import godot.canvasitem;
27 import godot.node;
28 import godot.inputevent;
29 import godot.popup;
30 import godot.texture;
31 /**
32 Tabbed container.
33 
34 Sets the active tab's `visible` property to the value `true`. Sets all other children's to `false`.
35 Ignores non-$(D Control) children.
36 Individual tabs are always visible unless you use $(D setTabDisabled) and $(D setTabTitle) to hide it.
37 To hide only a tab's content, nest the content inside a child $(D Control), so it receives the $(D TabContainer)'s visibility setting instead.
38 */
39 @GodotBaseClass struct TabContainer
40 {
41 	package(godot) enum string _GODOT_internal_name = "TabContainer";
42 public:
43 @nogc nothrow:
44 	union { /** */ godot_object _godot_object; /** */ Container _GODOT_base; }
45 	alias _GODOT_base this;
46 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
47 	package(godot) __gshared bool _classBindingInitialized = false;
48 	package(godot) static struct GDNativeClassBinding
49 	{
50 		__gshared:
51 		@GodotName("_child_renamed_callback") GodotMethod!(void) _childRenamedCallback;
52 		@GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput;
53 		@GodotName("_on_mouse_exited") GodotMethod!(void) _onMouseExited;
54 		@GodotName("_on_theme_changed") GodotMethod!(void) _onThemeChanged;
55 		@GodotName("_update_current_tab") GodotMethod!(void) _updateCurrentTab;
56 		@GodotName("are_tabs_visible") GodotMethod!(bool) areTabsVisible;
57 		@GodotName("get_current_tab") GodotMethod!(long) getCurrentTab;
58 		@GodotName("get_current_tab_control") GodotMethod!(Control) getCurrentTabControl;
59 		@GodotName("get_drag_to_rearrange_enabled") GodotMethod!(bool) getDragToRearrangeEnabled;
60 		@GodotName("get_popup") GodotMethod!(Popup) getPopup;
61 		@GodotName("get_previous_tab") GodotMethod!(long) getPreviousTab;
62 		@GodotName("get_tab_align") GodotMethod!(TabContainer.TabAlign) getTabAlign;
63 		@GodotName("get_tab_control") GodotMethod!(Control, long) getTabControl;
64 		@GodotName("get_tab_count") GodotMethod!(long) getTabCount;
65 		@GodotName("get_tab_disabled") GodotMethod!(bool, long) getTabDisabled;
66 		@GodotName("get_tab_icon") GodotMethod!(Texture, long) getTabIcon;
67 		@GodotName("get_tab_title") GodotMethod!(String, long) getTabTitle;
68 		@GodotName("get_tabs_rearrange_group") GodotMethod!(long) getTabsRearrangeGroup;
69 		@GodotName("get_use_hidden_tabs_for_min_size") GodotMethod!(bool) getUseHiddenTabsForMinSize;
70 		@GodotName("is_all_tabs_in_front") GodotMethod!(bool) isAllTabsInFront;
71 		@GodotName("set_all_tabs_in_front") GodotMethod!(void, bool) setAllTabsInFront;
72 		@GodotName("set_current_tab") GodotMethod!(void, long) setCurrentTab;
73 		@GodotName("set_drag_to_rearrange_enabled") GodotMethod!(void, bool) setDragToRearrangeEnabled;
74 		@GodotName("set_popup") GodotMethod!(void, Node) setPopup;
75 		@GodotName("set_tab_align") GodotMethod!(void, long) setTabAlign;
76 		@GodotName("set_tab_disabled") GodotMethod!(void, long, bool) setTabDisabled;
77 		@GodotName("set_tab_icon") GodotMethod!(void, long, Texture) setTabIcon;
78 		@GodotName("set_tab_title") GodotMethod!(void, long, String) setTabTitle;
79 		@GodotName("set_tabs_rearrange_group") GodotMethod!(void, long) setTabsRearrangeGroup;
80 		@GodotName("set_tabs_visible") GodotMethod!(void, bool) setTabsVisible;
81 		@GodotName("set_use_hidden_tabs_for_min_size") GodotMethod!(void, bool) setUseHiddenTabsForMinSize;
82 	}
83 	/// 
84 	pragma(inline, true) bool opEquals(in TabContainer other) const
85 	{ return _godot_object.ptr is other._godot_object.ptr; }
86 	/// 
87 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
88 	{ _godot_object.ptr = n; return null; }
89 	/// 
90 	pragma(inline, true) bool opEquals(typeof(null) n) const
91 	{ return _godot_object.ptr is n; }
92 	/// 
93 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
94 	mixin baseCasts;
95 	/// Construct a new instance of TabContainer.
96 	/// Note: use `memnew!TabContainer` instead.
97 	static TabContainer _new()
98 	{
99 		static godot_class_constructor constructor;
100 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TabContainer");
101 		if(constructor is null) return typeof(this).init;
102 		return cast(TabContainer)(constructor());
103 	}
104 	@disable new(size_t s);
105 	/// 
106 	enum TabAlign : int
107 	{
108 		/**
109 		Align the tabs to the left.
110 		*/
111 		alignLeft = 0,
112 		/**
113 		Align the tabs to the center.
114 		*/
115 		alignCenter = 1,
116 		/**
117 		Align the tabs to the right.
118 		*/
119 		alignRight = 2,
120 	}
121 	/// 
122 	enum Constants : int
123 	{
124 		alignLeft = 0,
125 		alignCenter = 1,
126 		alignRight = 2,
127 	}
128 	/**
129 	
130 	*/
131 	void _childRenamedCallback()
132 	{
133 		Array _GODOT_args = Array.make();
134 		String _GODOT_method_name = String("_child_renamed_callback");
135 		this.callv(_GODOT_method_name, _GODOT_args);
136 	}
137 	/**
138 	
139 	*/
140 	void _guiInput(InputEvent arg0)
141 	{
142 		Array _GODOT_args = Array.make();
143 		_GODOT_args.append(arg0);
144 		String _GODOT_method_name = String("_gui_input");
145 		this.callv(_GODOT_method_name, _GODOT_args);
146 	}
147 	/**
148 	
149 	*/
150 	void _onMouseExited()
151 	{
152 		Array _GODOT_args = Array.make();
153 		String _GODOT_method_name = String("_on_mouse_exited");
154 		this.callv(_GODOT_method_name, _GODOT_args);
155 	}
156 	/**
157 	
158 	*/
159 	void _onThemeChanged()
160 	{
161 		Array _GODOT_args = Array.make();
162 		String _GODOT_method_name = String("_on_theme_changed");
163 		this.callv(_GODOT_method_name, _GODOT_args);
164 	}
165 	/**
166 	
167 	*/
168 	void _updateCurrentTab()
169 	{
170 		Array _GODOT_args = Array.make();
171 		String _GODOT_method_name = String("_update_current_tab");
172 		this.callv(_GODOT_method_name, _GODOT_args);
173 	}
174 	/**
175 	
176 	*/
177 	bool areTabsVisible() const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(bool)(GDNativeClassBinding.areTabsVisible, _godot_object);
181 	}
182 	/**
183 	
184 	*/
185 	long getCurrentTab() const
186 	{
187 		checkClassBinding!(typeof(this))();
188 		return ptrcall!(long)(GDNativeClassBinding.getCurrentTab, _godot_object);
189 	}
190 	/**
191 	Returns the child $(D Control) node located at the active tab index.
192 	*/
193 	Control getCurrentTabControl() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(Control)(GDNativeClassBinding.getCurrentTabControl, _godot_object);
197 	}
198 	/**
199 	
200 	*/
201 	bool getDragToRearrangeEnabled() const
202 	{
203 		checkClassBinding!(typeof(this))();
204 		return ptrcall!(bool)(GDNativeClassBinding.getDragToRearrangeEnabled, _godot_object);
205 	}
206 	/**
207 	Returns the $(D Popup) node instance if one has been set already with $(D setPopup).
208 	*/
209 	Popup getPopup() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(Popup)(GDNativeClassBinding.getPopup, _godot_object);
213 	}
214 	/**
215 	Returns the previously active tab index.
216 	*/
217 	long getPreviousTab() const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(long)(GDNativeClassBinding.getPreviousTab, _godot_object);
221 	}
222 	/**
223 	
224 	*/
225 	TabContainer.TabAlign getTabAlign() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(TabContainer.TabAlign)(GDNativeClassBinding.getTabAlign, _godot_object);
229 	}
230 	/**
231 	Returns the $(D Control) node from the tab at index `tab_idx`.
232 	*/
233 	Control getTabControl(in long tab_idx) const
234 	{
235 		checkClassBinding!(typeof(this))();
236 		return ptrcall!(Control)(GDNativeClassBinding.getTabControl, _godot_object, tab_idx);
237 	}
238 	/**
239 	Returns the number of tabs.
240 	*/
241 	long getTabCount() const
242 	{
243 		checkClassBinding!(typeof(this))();
244 		return ptrcall!(long)(GDNativeClassBinding.getTabCount, _godot_object);
245 	}
246 	/**
247 	Returns `true` if the tab at index `tab_idx` is disabled.
248 	*/
249 	bool getTabDisabled(in long tab_idx) const
250 	{
251 		checkClassBinding!(typeof(this))();
252 		return ptrcall!(bool)(GDNativeClassBinding.getTabDisabled, _godot_object, tab_idx);
253 	}
254 	/**
255 	Returns the $(D Texture) for the tab at index `tab_idx` or `null` if the tab has no $(D Texture).
256 	*/
257 	Ref!Texture getTabIcon(in long tab_idx) const
258 	{
259 		checkClassBinding!(typeof(this))();
260 		return ptrcall!(Texture)(GDNativeClassBinding.getTabIcon, _godot_object, tab_idx);
261 	}
262 	/**
263 	Returns the title of the tab at index `tab_idx`. Tab titles default to the name of the indexed child node, but this can be overridden with $(D setTabTitle).
264 	*/
265 	String getTabTitle(in long tab_idx) const
266 	{
267 		checkClassBinding!(typeof(this))();
268 		return ptrcall!(String)(GDNativeClassBinding.getTabTitle, _godot_object, tab_idx);
269 	}
270 	/**
271 	Returns the $(D TabContainer) rearrange group id.
272 	*/
273 	long getTabsRearrangeGroup() const
274 	{
275 		checkClassBinding!(typeof(this))();
276 		return ptrcall!(long)(GDNativeClassBinding.getTabsRearrangeGroup, _godot_object);
277 	}
278 	/**
279 	
280 	*/
281 	bool getUseHiddenTabsForMinSize() const
282 	{
283 		checkClassBinding!(typeof(this))();
284 		return ptrcall!(bool)(GDNativeClassBinding.getUseHiddenTabsForMinSize, _godot_object);
285 	}
286 	/**
287 	
288 	*/
289 	bool isAllTabsInFront() const
290 	{
291 		checkClassBinding!(typeof(this))();
292 		return ptrcall!(bool)(GDNativeClassBinding.isAllTabsInFront, _godot_object);
293 	}
294 	/**
295 	
296 	*/
297 	void setAllTabsInFront(in bool is_front)
298 	{
299 		checkClassBinding!(typeof(this))();
300 		ptrcall!(void)(GDNativeClassBinding.setAllTabsInFront, _godot_object, is_front);
301 	}
302 	/**
303 	
304 	*/
305 	void setCurrentTab(in long tab_idx)
306 	{
307 		checkClassBinding!(typeof(this))();
308 		ptrcall!(void)(GDNativeClassBinding.setCurrentTab, _godot_object, tab_idx);
309 	}
310 	/**
311 	
312 	*/
313 	void setDragToRearrangeEnabled(in bool enabled)
314 	{
315 		checkClassBinding!(typeof(this))();
316 		ptrcall!(void)(GDNativeClassBinding.setDragToRearrangeEnabled, _godot_object, enabled);
317 	}
318 	/**
319 	If set on a $(D Popup) node instance, a popup menu icon appears in the top-right corner of the $(D TabContainer). Clicking it will expand the $(D Popup) node.
320 	*/
321 	void setPopup(Node popup)
322 	{
323 		checkClassBinding!(typeof(this))();
324 		ptrcall!(void)(GDNativeClassBinding.setPopup, _godot_object, popup);
325 	}
326 	/**
327 	
328 	*/
329 	void setTabAlign(in long _align)
330 	{
331 		checkClassBinding!(typeof(this))();
332 		ptrcall!(void)(GDNativeClassBinding.setTabAlign, _godot_object, _align);
333 	}
334 	/**
335 	If `disabled` is `false`, hides the tab at index `tab_idx`.
336 	$(B Note:) Its title text will remain, unless also removed with $(D setTabTitle).
337 	*/
338 	void setTabDisabled(in long tab_idx, in bool disabled)
339 	{
340 		checkClassBinding!(typeof(this))();
341 		ptrcall!(void)(GDNativeClassBinding.setTabDisabled, _godot_object, tab_idx, disabled);
342 	}
343 	/**
344 	Sets an icon for the tab at index `tab_idx`.
345 	*/
346 	void setTabIcon(in long tab_idx, Texture icon)
347 	{
348 		checkClassBinding!(typeof(this))();
349 		ptrcall!(void)(GDNativeClassBinding.setTabIcon, _godot_object, tab_idx, icon);
350 	}
351 	/**
352 	Sets a title for the tab at index `tab_idx`. Tab titles default to the name of the indexed child node, but this can be overridden with $(D setTabTitle).
353 	*/
354 	void setTabTitle(in long tab_idx, in String title)
355 	{
356 		checkClassBinding!(typeof(this))();
357 		ptrcall!(void)(GDNativeClassBinding.setTabTitle, _godot_object, tab_idx, title);
358 	}
359 	/**
360 	Defines rearrange group id, choose for each $(D TabContainer) the same value to enable tab drag between $(D TabContainer). Enable drag with `set_drag_to_rearrange_enabled(true)`.
361 	*/
362 	void setTabsRearrangeGroup(in long group_id)
363 	{
364 		checkClassBinding!(typeof(this))();
365 		ptrcall!(void)(GDNativeClassBinding.setTabsRearrangeGroup, _godot_object, group_id);
366 	}
367 	/**
368 	
369 	*/
370 	void setTabsVisible(in bool visible)
371 	{
372 		checkClassBinding!(typeof(this))();
373 		ptrcall!(void)(GDNativeClassBinding.setTabsVisible, _godot_object, visible);
374 	}
375 	/**
376 	
377 	*/
378 	void setUseHiddenTabsForMinSize(in bool enabled)
379 	{
380 		checkClassBinding!(typeof(this))();
381 		ptrcall!(void)(GDNativeClassBinding.setUseHiddenTabsForMinSize, _godot_object, enabled);
382 	}
383 	/**
384 	If `true`, all tabs are drawn in front of the panel. If `false`, inactive tabs are drawn behind the panel.
385 	*/
386 	@property bool allTabsInFront()
387 	{
388 		return isAllTabsInFront();
389 	}
390 	/// ditto
391 	@property void allTabsInFront(bool v)
392 	{
393 		setAllTabsInFront(v);
394 	}
395 	/**
396 	The current tab index. When set, this index's $(D Control) node's `visible` property is set to `true` and all others are set to `false`.
397 	*/
398 	@property long currentTab()
399 	{
400 		return getCurrentTab();
401 	}
402 	/// ditto
403 	@property void currentTab(long v)
404 	{
405 		setCurrentTab(v);
406 	}
407 	/**
408 	If `true`, tabs can be rearranged with mouse drag.
409 	*/
410 	@property bool dragToRearrangeEnabled()
411 	{
412 		return getDragToRearrangeEnabled();
413 	}
414 	/// ditto
415 	@property void dragToRearrangeEnabled(bool v)
416 	{
417 		setDragToRearrangeEnabled(v);
418 	}
419 	/**
420 	The alignment of all tabs in the tab container. See the $(D tabalign) constants for details.
421 	*/
422 	@property TabContainer.TabAlign tabAlign()
423 	{
424 		return getTabAlign();
425 	}
426 	/// ditto
427 	@property void tabAlign(long v)
428 	{
429 		setTabAlign(v);
430 	}
431 	/**
432 	If `true`, tabs are visible. If `false`, tabs' content and titles are hidden.
433 	*/
434 	@property bool tabsVisible()
435 	{
436 		return areTabsVisible();
437 	}
438 	/// ditto
439 	@property void tabsVisible(bool v)
440 	{
441 		setTabsVisible(v);
442 	}
443 	/**
444 	If `true`, children $(D Control) nodes that are hidden have their minimum size take into account in the total, instead of only the currently visible one.
445 	*/
446 	@property bool useHiddenTabsForMinSize()
447 	{
448 		return getUseHiddenTabsForMinSize();
449 	}
450 	/// ditto
451 	@property void useHiddenTabsForMinSize(bool v)
452 	{
453 		setUseHiddenTabsForMinSize(v);
454 	}
455 }