1 /**
2 Tabs Control.
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.tabs;
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.inputevent;
25 import godot.texture;
26 import godot.canvasitem;
27 import godot.node;
28 /**
29 Tabs Control.
30 
31 Simple tabs control, similar to $(D TabContainer) but is only in charge of drawing tabs, not interact with children.
32 */
33 @GodotBaseClass struct Tabs
34 {
35 	enum string _GODOT_internal_name = "Tabs";
36 public:
37 @nogc nothrow:
38 	union { godot_object _godot_object; Control _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 _classBinding
43 	{
44 		__gshared:
45 		@GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput;
46 		@GodotName("_update_hover") GodotMethod!(void) _updateHover;
47 		@GodotName("get_tab_count") GodotMethod!(long) getTabCount;
48 		@GodotName("set_current_tab") GodotMethod!(void, long) setCurrentTab;
49 		@GodotName("get_current_tab") GodotMethod!(long) getCurrentTab;
50 		@GodotName("set_tab_title") GodotMethod!(void, long, String) setTabTitle;
51 		@GodotName("get_tab_title") GodotMethod!(String, long) getTabTitle;
52 		@GodotName("set_tab_icon") GodotMethod!(void, long, Texture) setTabIcon;
53 		@GodotName("get_tab_icon") GodotMethod!(Texture, long) getTabIcon;
54 		@GodotName("set_tab_disabled") GodotMethod!(void, long, bool) setTabDisabled;
55 		@GodotName("get_tab_disabled") GodotMethod!(bool, long) getTabDisabled;
56 		@GodotName("remove_tab") GodotMethod!(void, long) removeTab;
57 		@GodotName("add_tab") GodotMethod!(void, String, Texture) addTab;
58 		@GodotName("set_tab_align") GodotMethod!(void, long) setTabAlign;
59 		@GodotName("get_tab_align") GodotMethod!(Tabs.TabAlign) getTabAlign;
60 		@GodotName("get_tab_offset") GodotMethod!(long) getTabOffset;
61 		@GodotName("get_offset_buttons_visible") GodotMethod!(bool) getOffsetButtonsVisible;
62 		@GodotName("ensure_tab_visible") GodotMethod!(void, long) ensureTabVisible;
63 		@GodotName("get_tab_rect") GodotMethod!(Rect2, long) getTabRect;
64 		@GodotName("move_tab") GodotMethod!(void, long, long) moveTab;
65 		@GodotName("set_tab_close_display_policy") GodotMethod!(void, long) setTabCloseDisplayPolicy;
66 		@GodotName("get_tab_close_display_policy") GodotMethod!(Tabs.CloseButtonDisplayPolicy) getTabCloseDisplayPolicy;
67 		@GodotName("set_scrolling_enabled") GodotMethod!(void, bool) setScrollingEnabled;
68 		@GodotName("get_scrolling_enabled") GodotMethod!(bool) getScrollingEnabled;
69 		@GodotName("set_drag_to_rearrange_enabled") GodotMethod!(void, bool) setDragToRearrangeEnabled;
70 		@GodotName("get_drag_to_rearrange_enabled") GodotMethod!(bool) getDragToRearrangeEnabled;
71 		@GodotName("set_tabs_rearrange_group") GodotMethod!(void, long) setTabsRearrangeGroup;
72 		@GodotName("get_tabs_rearrange_group") GodotMethod!(long) getTabsRearrangeGroup;
73 		@GodotName("set_select_with_rmb") GodotMethod!(void, bool) setSelectWithRmb;
74 		@GodotName("get_select_with_rmb") GodotMethod!(bool) getSelectWithRmb;
75 	}
76 	bool opEquals(in Tabs other) const { return _godot_object.ptr is other._godot_object.ptr; }
77 	Tabs opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
78 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
79 	mixin baseCasts;
80 	static Tabs _new()
81 	{
82 		static godot_class_constructor constructor;
83 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Tabs");
84 		if(constructor is null) return typeof(this).init;
85 		return cast(Tabs)(constructor());
86 	}
87 	@disable new(size_t s);
88 	/// 
89 	enum CloseButtonDisplayPolicy : int
90 	{
91 		/**
92 		
93 		*/
94 		closeButtonShowNever = 0,
95 		/**
96 		
97 		*/
98 		closeButtonShowActiveOnly = 1,
99 		/**
100 		
101 		*/
102 		closeButtonShowAlways = 2,
103 		/**
104 		
105 		*/
106 		closeButtonMax = 3,
107 	}
108 	/// 
109 	enum TabAlign : int
110 	{
111 		/**
112 		Align the tabs to the left.
113 		*/
114 		alignLeft = 0,
115 		/**
116 		Align the tabs to the center.
117 		*/
118 		alignCenter = 1,
119 		/**
120 		Align the tabs to the right.
121 		*/
122 		alignRight = 2,
123 		/**
124 		
125 		*/
126 		alignMax = 3,
127 	}
128 	/// 
129 	enum Constants : int
130 	{
131 		alignLeft = 0,
132 		closeButtonShowNever = 0,
133 		alignCenter = 1,
134 		closeButtonShowActiveOnly = 1,
135 		closeButtonShowAlways = 2,
136 		alignRight = 2,
137 		alignMax = 3,
138 		closeButtonMax = 3,
139 	}
140 	/**
141 	
142 	*/
143 	void _guiInput(InputEvent arg0)
144 	{
145 		Array _GODOT_args = Array.empty_array;
146 		_GODOT_args.append(arg0);
147 		String _GODOT_method_name = String("_gui_input");
148 		this.callv(_GODOT_method_name, _GODOT_args);
149 	}
150 	/**
151 	
152 	*/
153 	void _updateHover()
154 	{
155 		Array _GODOT_args = Array.empty_array;
156 		String _GODOT_method_name = String("_update_hover");
157 		this.callv(_GODOT_method_name, _GODOT_args);
158 	}
159 	/**
160 	Returns the number of tabs.
161 	*/
162 	long getTabCount() const
163 	{
164 		checkClassBinding!(typeof(this))();
165 		return ptrcall!(long)(_classBinding.getTabCount, _godot_object);
166 	}
167 	/**
168 	
169 	*/
170 	void setCurrentTab(in long tab_idx)
171 	{
172 		checkClassBinding!(typeof(this))();
173 		ptrcall!(void)(_classBinding.setCurrentTab, _godot_object, tab_idx);
174 	}
175 	/**
176 	
177 	*/
178 	long getCurrentTab() const
179 	{
180 		checkClassBinding!(typeof(this))();
181 		return ptrcall!(long)(_classBinding.getCurrentTab, _godot_object);
182 	}
183 	/**
184 	Sets a title for the tab at index `tab_idx`.
185 	*/
186 	void setTabTitle(StringArg1)(in long tab_idx, in StringArg1 title)
187 	{
188 		checkClassBinding!(typeof(this))();
189 		ptrcall!(void)(_classBinding.setTabTitle, _godot_object, tab_idx, title);
190 	}
191 	/**
192 	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).
193 	*/
194 	String getTabTitle(in long tab_idx) const
195 	{
196 		checkClassBinding!(typeof(this))();
197 		return ptrcall!(String)(_classBinding.getTabTitle, _godot_object, tab_idx);
198 	}
199 	/**
200 	Sets an icon for the tab at index `tab_idx`.
201 	*/
202 	void setTabIcon(in long tab_idx, Texture icon)
203 	{
204 		checkClassBinding!(typeof(this))();
205 		ptrcall!(void)(_classBinding.setTabIcon, _godot_object, tab_idx, icon);
206 	}
207 	/**
208 	Returns the $(D Texture) for the tab at index `tab_idx` or null if the tab has no $(D Texture).
209 	*/
210 	Ref!Texture getTabIcon(in long tab_idx) const
211 	{
212 		checkClassBinding!(typeof(this))();
213 		return ptrcall!(Texture)(_classBinding.getTabIcon, _godot_object, tab_idx);
214 	}
215 	/**
216 	If `disabled` is false, hides the tab at index `tab_idx`. Note that its title text will remain, unless also removed with $(D setTabTitle).
217 	*/
218 	void setTabDisabled(in long tab_idx, in bool disabled)
219 	{
220 		checkClassBinding!(typeof(this))();
221 		ptrcall!(void)(_classBinding.setTabDisabled, _godot_object, tab_idx, disabled);
222 	}
223 	/**
224 	Returns `true` if the tab at index `tab_idx` is disabled.
225 	*/
226 	bool getTabDisabled(in long tab_idx) const
227 	{
228 		checkClassBinding!(typeof(this))();
229 		return ptrcall!(bool)(_classBinding.getTabDisabled, _godot_object, tab_idx);
230 	}
231 	/**
232 	Removes tab at index `tab_idx`
233 	*/
234 	void removeTab(in long tab_idx)
235 	{
236 		checkClassBinding!(typeof(this))();
237 		ptrcall!(void)(_classBinding.removeTab, _godot_object, tab_idx);
238 	}
239 	/**
240 	Adds a new tab.
241 	*/
242 	void addTab(StringArg0)(in StringArg0 title = "", Texture icon = Texture.init)
243 	{
244 		checkClassBinding!(typeof(this))();
245 		ptrcall!(void)(_classBinding.addTab, _godot_object, title, icon);
246 	}
247 	/**
248 	
249 	*/
250 	void setTabAlign(in long _align)
251 	{
252 		checkClassBinding!(typeof(this))();
253 		ptrcall!(void)(_classBinding.setTabAlign, _godot_object, _align);
254 	}
255 	/**
256 	
257 	*/
258 	Tabs.TabAlign getTabAlign() const
259 	{
260 		checkClassBinding!(typeof(this))();
261 		return ptrcall!(Tabs.TabAlign)(_classBinding.getTabAlign, _godot_object);
262 	}
263 	/**
264 	
265 	*/
266 	long getTabOffset() const
267 	{
268 		checkClassBinding!(typeof(this))();
269 		return ptrcall!(long)(_classBinding.getTabOffset, _godot_object);
270 	}
271 	/**
272 	
273 	*/
274 	bool getOffsetButtonsVisible() const
275 	{
276 		checkClassBinding!(typeof(this))();
277 		return ptrcall!(bool)(_classBinding.getOffsetButtonsVisible, _godot_object);
278 	}
279 	/**
280 	Moves the Scroll view to make the tab visible.
281 	*/
282 	void ensureTabVisible(in long idx)
283 	{
284 		checkClassBinding!(typeof(this))();
285 		ptrcall!(void)(_classBinding.ensureTabVisible, _godot_object, idx);
286 	}
287 	/**
288 	Returns tab $(D Rect2) with local position and size.
289 	*/
290 	Rect2 getTabRect(in long tab_idx) const
291 	{
292 		checkClassBinding!(typeof(this))();
293 		return ptrcall!(Rect2)(_classBinding.getTabRect, _godot_object, tab_idx);
294 	}
295 	/**
296 	Rearrange tab.
297 	*/
298 	void moveTab(in long from, in long to)
299 	{
300 		checkClassBinding!(typeof(this))();
301 		ptrcall!(void)(_classBinding.moveTab, _godot_object, from, to);
302 	}
303 	/**
304 	
305 	*/
306 	void setTabCloseDisplayPolicy(in long policy)
307 	{
308 		checkClassBinding!(typeof(this))();
309 		ptrcall!(void)(_classBinding.setTabCloseDisplayPolicy, _godot_object, policy);
310 	}
311 	/**
312 	
313 	*/
314 	Tabs.CloseButtonDisplayPolicy getTabCloseDisplayPolicy() const
315 	{
316 		checkClassBinding!(typeof(this))();
317 		return ptrcall!(Tabs.CloseButtonDisplayPolicy)(_classBinding.getTabCloseDisplayPolicy, _godot_object);
318 	}
319 	/**
320 	
321 	*/
322 	void setScrollingEnabled(in bool enabled)
323 	{
324 		checkClassBinding!(typeof(this))();
325 		ptrcall!(void)(_classBinding.setScrollingEnabled, _godot_object, enabled);
326 	}
327 	/**
328 	
329 	*/
330 	bool getScrollingEnabled() const
331 	{
332 		checkClassBinding!(typeof(this))();
333 		return ptrcall!(bool)(_classBinding.getScrollingEnabled, _godot_object);
334 	}
335 	/**
336 	
337 	*/
338 	void setDragToRearrangeEnabled(in bool enabled)
339 	{
340 		checkClassBinding!(typeof(this))();
341 		ptrcall!(void)(_classBinding.setDragToRearrangeEnabled, _godot_object, enabled);
342 	}
343 	/**
344 	
345 	*/
346 	bool getDragToRearrangeEnabled() const
347 	{
348 		checkClassBinding!(typeof(this))();
349 		return ptrcall!(bool)(_classBinding.getDragToRearrangeEnabled, _godot_object);
350 	}
351 	/**
352 	Defines rearrange group id, choose for each `Tabs` the same value to enable tab drag between `Tabs`. Enable drag with `set_drag_to_rearrange_enabled(true)`.
353 	*/
354 	void setTabsRearrangeGroup(in long group_id)
355 	{
356 		checkClassBinding!(typeof(this))();
357 		ptrcall!(void)(_classBinding.setTabsRearrangeGroup, _godot_object, group_id);
358 	}
359 	/**
360 	Returns the `Tabs` rearrange group id.
361 	*/
362 	long getTabsRearrangeGroup() const
363 	{
364 		checkClassBinding!(typeof(this))();
365 		return ptrcall!(long)(_classBinding.getTabsRearrangeGroup, _godot_object);
366 	}
367 	/**
368 	If `true` enables selecting a tab with right mouse button.
369 	*/
370 	void setSelectWithRmb(in bool enabled)
371 	{
372 		checkClassBinding!(typeof(this))();
373 		ptrcall!(void)(_classBinding.setSelectWithRmb, _godot_object, enabled);
374 	}
375 	/**
376 	Returns `true` if select with right mouse button is enabled.
377 	*/
378 	bool getSelectWithRmb() const
379 	{
380 		checkClassBinding!(typeof(this))();
381 		return ptrcall!(bool)(_classBinding.getSelectWithRmb, _godot_object);
382 	}
383 	/**
384 	Select tab at index `tab_idx`.
385 	*/
386 	@property long currentTab()
387 	{
388 		return getCurrentTab();
389 	}
390 	/// ditto
391 	@property void currentTab(long v)
392 	{
393 		setCurrentTab(v);
394 	}
395 	/**
396 	The alignment of all tabs. See enum `TabAlign` constants for details.
397 	*/
398 	@property Tabs.TabAlign tabAlign()
399 	{
400 		return getTabAlign();
401 	}
402 	/// ditto
403 	@property void tabAlign(long v)
404 	{
405 		setTabAlign(v);
406 	}
407 	/**
408 	
409 	*/
410 	@property Tabs.CloseButtonDisplayPolicy tabCloseDisplayPolicy()
411 	{
412 		return getTabCloseDisplayPolicy();
413 	}
414 	/// ditto
415 	@property void tabCloseDisplayPolicy(long v)
416 	{
417 		setTabCloseDisplayPolicy(v);
418 	}
419 	/**
420 	
421 	*/
422 	@property bool scrollingEnabled()
423 	{
424 		return getScrollingEnabled();
425 	}
426 	/// ditto
427 	@property void scrollingEnabled(bool v)
428 	{
429 		setScrollingEnabled(v);
430 	}
431 	/**
432 	If `true`, tabs can be rearranged with mouse drag.
433 	*/
434 	@property bool dragToRearrangeEnabled()
435 	{
436 		return getDragToRearrangeEnabled();
437 	}
438 	/// ditto
439 	@property void dragToRearrangeEnabled(bool v)
440 	{
441 		setDragToRearrangeEnabled(v);
442 	}
443 }