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