1 /** 2 Dialog for selecting files or directories in the filesystem. 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.filedialog; 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.confirmationdialog; 24 import godot.inputevent; 25 import godot.vboxcontainer; 26 import godot.lineedit; 27 import godot.acceptdialog; 28 import godot.windowdialog; 29 import godot.popup; 30 import godot.control; 31 import godot.canvasitem; 32 import godot.node; 33 /** 34 Dialog for selecting files or directories in the filesystem. 35 36 FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. 37 */ 38 @GodotBaseClass struct FileDialog 39 { 40 enum string _GODOT_internal_name = "FileDialog"; 41 public: 42 @nogc nothrow: 43 union { godot_object _godot_object; ConfirmationDialog _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("_unhandled_input") GodotMethod!(void, InputEvent) _unhandledInput; 51 @GodotName("_tree_multi_selected") GodotMethod!(void, GodotObject, long, bool) _treeMultiSelected; 52 @GodotName("_tree_selected") GodotMethod!(void) _treeSelected; 53 @GodotName("_tree_item_activated") GodotMethod!(void) _treeItemActivated; 54 @GodotName("_dir_entered") GodotMethod!(void, String) _dirEntered; 55 @GodotName("_file_entered") GodotMethod!(void, String) _fileEntered; 56 @GodotName("_action_pressed") GodotMethod!(void) _actionPressed; 57 @GodotName("_cancel_pressed") GodotMethod!(void) _cancelPressed; 58 @GodotName("_filter_selected") GodotMethod!(void, long) _filterSelected; 59 @GodotName("_save_confirm_pressed") GodotMethod!(void) _saveConfirmPressed; 60 @GodotName("clear_filters") GodotMethod!(void) clearFilters; 61 @GodotName("add_filter") GodotMethod!(void, String) addFilter; 62 @GodotName("set_filters") GodotMethod!(void, PoolStringArray) setFilters; 63 @GodotName("get_filters") GodotMethod!(PoolStringArray) getFilters; 64 @GodotName("get_current_dir") GodotMethod!(String) getCurrentDir; 65 @GodotName("get_current_file") GodotMethod!(String) getCurrentFile; 66 @GodotName("get_current_path") GodotMethod!(String) getCurrentPath; 67 @GodotName("set_current_dir") GodotMethod!(void, String) setCurrentDir; 68 @GodotName("set_current_file") GodotMethod!(void, String) setCurrentFile; 69 @GodotName("set_current_path") GodotMethod!(void, String) setCurrentPath; 70 @GodotName("set_mode_overrides_title") GodotMethod!(void, bool) setModeOverridesTitle; 71 @GodotName("is_mode_overriding_title") GodotMethod!(bool) isModeOverridingTitle; 72 @GodotName("set_mode") GodotMethod!(void, long) setMode; 73 @GodotName("get_mode") GodotMethod!(FileDialog.Mode) getMode; 74 @GodotName("get_vbox") GodotMethod!(VBoxContainer) getVbox; 75 @GodotName("get_line_edit") GodotMethod!(LineEdit) getLineEdit; 76 @GodotName("set_access") GodotMethod!(void, long) setAccess; 77 @GodotName("get_access") GodotMethod!(FileDialog.Access) getAccess; 78 @GodotName("set_show_hidden_files") GodotMethod!(void, bool) setShowHiddenFiles; 79 @GodotName("is_showing_hidden_files") GodotMethod!(bool) isShowingHiddenFiles; 80 @GodotName("_select_drive") GodotMethod!(void, long) _selectDrive; 81 @GodotName("_make_dir") GodotMethod!(void) _makeDir; 82 @GodotName("_make_dir_confirm") GodotMethod!(void) _makeDirConfirm; 83 @GodotName("_update_file_list") GodotMethod!(void) _updateFileList; 84 @GodotName("_update_dir") GodotMethod!(void) _updateDir; 85 @GodotName("_go_up") GodotMethod!(void) _goUp; 86 @GodotName("deselect_items") GodotMethod!(void) deselectItems; 87 @GodotName("invalidate") GodotMethod!(void) invalidate; 88 } 89 bool opEquals(in FileDialog other) const { return _godot_object.ptr is other._godot_object.ptr; } 90 FileDialog opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 91 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 92 mixin baseCasts; 93 static FileDialog _new() 94 { 95 static godot_class_constructor constructor; 96 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("FileDialog"); 97 if(constructor is null) return typeof(this).init; 98 return cast(FileDialog)(constructor()); 99 } 100 @disable new(size_t s); 101 /// 102 enum Mode : int 103 { 104 /** 105 The dialog allows the selection of one, and only one file. 106 */ 107 modeOpenFile = 0, 108 /** 109 The dialog allows the selection of multiple files. 110 */ 111 modeOpenFiles = 1, 112 /** 113 The dialog functions as a folder selector, disallowing the selection of any file. 114 */ 115 modeOpenDir = 2, 116 /** 117 The dialog allows the selection of a file or a directory. 118 */ 119 modeOpenAny = 3, 120 /** 121 The dialog will warn when a file exists. 122 */ 123 modeSaveFile = 4, 124 } 125 /// 126 enum Access : int 127 { 128 /** 129 The dialog allows the selection of file and directory. 130 */ 131 accessResources = 0, 132 /** 133 The dialog allows access files under $(D Resource) path(res://) . 134 */ 135 accessUserdata = 1, 136 /** 137 The dialog allows access files in whole file system. 138 */ 139 accessFilesystem = 2, 140 } 141 /// 142 enum Constants : int 143 { 144 modeOpenFile = 0, 145 accessResources = 0, 146 accessUserdata = 1, 147 modeOpenFiles = 1, 148 accessFilesystem = 2, 149 modeOpenDir = 2, 150 modeOpenAny = 3, 151 modeSaveFile = 4, 152 } 153 /** 154 155 */ 156 void _unhandledInput(InputEvent arg0) 157 { 158 Array _GODOT_args = Array.empty_array; 159 _GODOT_args.append(arg0); 160 String _GODOT_method_name = String("_unhandled_input"); 161 this.callv(_GODOT_method_name, _GODOT_args); 162 } 163 /** 164 165 */ 166 void _treeMultiSelected(GodotObject arg0, in long arg1, in bool arg2) 167 { 168 Array _GODOT_args = Array.empty_array; 169 _GODOT_args.append(arg0); 170 _GODOT_args.append(arg1); 171 _GODOT_args.append(arg2); 172 String _GODOT_method_name = String("_tree_multi_selected"); 173 this.callv(_GODOT_method_name, _GODOT_args); 174 } 175 /** 176 177 */ 178 void _treeSelected() 179 { 180 Array _GODOT_args = Array.empty_array; 181 String _GODOT_method_name = String("_tree_selected"); 182 this.callv(_GODOT_method_name, _GODOT_args); 183 } 184 /** 185 186 */ 187 void _treeItemActivated() 188 { 189 Array _GODOT_args = Array.empty_array; 190 String _GODOT_method_name = String("_tree_item_activated"); 191 this.callv(_GODOT_method_name, _GODOT_args); 192 } 193 /** 194 195 */ 196 void _dirEntered(StringArg0)(in StringArg0 arg0) 197 { 198 Array _GODOT_args = Array.empty_array; 199 _GODOT_args.append(arg0); 200 String _GODOT_method_name = String("_dir_entered"); 201 this.callv(_GODOT_method_name, _GODOT_args); 202 } 203 /** 204 205 */ 206 void _fileEntered(StringArg0)(in StringArg0 arg0) 207 { 208 Array _GODOT_args = Array.empty_array; 209 _GODOT_args.append(arg0); 210 String _GODOT_method_name = String("_file_entered"); 211 this.callv(_GODOT_method_name, _GODOT_args); 212 } 213 /** 214 215 */ 216 void _actionPressed() 217 { 218 Array _GODOT_args = Array.empty_array; 219 String _GODOT_method_name = String("_action_pressed"); 220 this.callv(_GODOT_method_name, _GODOT_args); 221 } 222 /** 223 224 */ 225 void _cancelPressed() 226 { 227 Array _GODOT_args = Array.empty_array; 228 String _GODOT_method_name = String("_cancel_pressed"); 229 this.callv(_GODOT_method_name, _GODOT_args); 230 } 231 /** 232 233 */ 234 void _filterSelected(in long arg0) 235 { 236 Array _GODOT_args = Array.empty_array; 237 _GODOT_args.append(arg0); 238 String _GODOT_method_name = String("_filter_selected"); 239 this.callv(_GODOT_method_name, _GODOT_args); 240 } 241 /** 242 243 */ 244 void _saveConfirmPressed() 245 { 246 Array _GODOT_args = Array.empty_array; 247 String _GODOT_method_name = String("_save_confirm_pressed"); 248 this.callv(_GODOT_method_name, _GODOT_args); 249 } 250 /** 251 Clear all the added filters in the dialog. 252 */ 253 void clearFilters() 254 { 255 checkClassBinding!(typeof(this))(); 256 ptrcall!(void)(_classBinding.clearFilters, _godot_object); 257 } 258 /** 259 Add a custom filter. Example: `add_filter("*.png ; PNG Images")` 260 */ 261 void addFilter(StringArg0)(in StringArg0 filter) 262 { 263 checkClassBinding!(typeof(this))(); 264 ptrcall!(void)(_classBinding.addFilter, _godot_object, filter); 265 } 266 /** 267 268 */ 269 void setFilters(in PoolStringArray filters) 270 { 271 checkClassBinding!(typeof(this))(); 272 ptrcall!(void)(_classBinding.setFilters, _godot_object, filters); 273 } 274 /** 275 276 */ 277 PoolStringArray getFilters() const 278 { 279 checkClassBinding!(typeof(this))(); 280 return ptrcall!(PoolStringArray)(_classBinding.getFilters, _godot_object); 281 } 282 /** 283 284 */ 285 String getCurrentDir() const 286 { 287 checkClassBinding!(typeof(this))(); 288 return ptrcall!(String)(_classBinding.getCurrentDir, _godot_object); 289 } 290 /** 291 292 */ 293 String getCurrentFile() const 294 { 295 checkClassBinding!(typeof(this))(); 296 return ptrcall!(String)(_classBinding.getCurrentFile, _godot_object); 297 } 298 /** 299 300 */ 301 String getCurrentPath() const 302 { 303 checkClassBinding!(typeof(this))(); 304 return ptrcall!(String)(_classBinding.getCurrentPath, _godot_object); 305 } 306 /** 307 308 */ 309 void setCurrentDir(StringArg0)(in StringArg0 dir) 310 { 311 checkClassBinding!(typeof(this))(); 312 ptrcall!(void)(_classBinding.setCurrentDir, _godot_object, dir); 313 } 314 /** 315 316 */ 317 void setCurrentFile(StringArg0)(in StringArg0 file) 318 { 319 checkClassBinding!(typeof(this))(); 320 ptrcall!(void)(_classBinding.setCurrentFile, _godot_object, file); 321 } 322 /** 323 324 */ 325 void setCurrentPath(StringArg0)(in StringArg0 path) 326 { 327 checkClassBinding!(typeof(this))(); 328 ptrcall!(void)(_classBinding.setCurrentPath, _godot_object, path); 329 } 330 /** 331 332 */ 333 void setModeOverridesTitle(in bool _override) 334 { 335 checkClassBinding!(typeof(this))(); 336 ptrcall!(void)(_classBinding.setModeOverridesTitle, _godot_object, _override); 337 } 338 /** 339 340 */ 341 bool isModeOverridingTitle() const 342 { 343 checkClassBinding!(typeof(this))(); 344 return ptrcall!(bool)(_classBinding.isModeOverridingTitle, _godot_object); 345 } 346 /** 347 348 */ 349 void setMode(in long mode) 350 { 351 checkClassBinding!(typeof(this))(); 352 ptrcall!(void)(_classBinding.setMode, _godot_object, mode); 353 } 354 /** 355 356 */ 357 FileDialog.Mode getMode() const 358 { 359 checkClassBinding!(typeof(this))(); 360 return ptrcall!(FileDialog.Mode)(_classBinding.getMode, _godot_object); 361 } 362 /** 363 Return the vertical box container of the dialog, custom controls can be added to it. 364 */ 365 VBoxContainer getVbox() 366 { 367 checkClassBinding!(typeof(this))(); 368 return ptrcall!(VBoxContainer)(_classBinding.getVbox, _godot_object); 369 } 370 /** 371 Returns the LineEdit for the selected file. 372 */ 373 LineEdit getLineEdit() 374 { 375 checkClassBinding!(typeof(this))(); 376 return ptrcall!(LineEdit)(_classBinding.getLineEdit, _godot_object); 377 } 378 /** 379 380 */ 381 void setAccess(in long access) 382 { 383 checkClassBinding!(typeof(this))(); 384 ptrcall!(void)(_classBinding.setAccess, _godot_object, access); 385 } 386 /** 387 388 */ 389 FileDialog.Access getAccess() const 390 { 391 checkClassBinding!(typeof(this))(); 392 return ptrcall!(FileDialog.Access)(_classBinding.getAccess, _godot_object); 393 } 394 /** 395 396 */ 397 void setShowHiddenFiles(in bool show) 398 { 399 checkClassBinding!(typeof(this))(); 400 ptrcall!(void)(_classBinding.setShowHiddenFiles, _godot_object, show); 401 } 402 /** 403 404 */ 405 bool isShowingHiddenFiles() const 406 { 407 checkClassBinding!(typeof(this))(); 408 return ptrcall!(bool)(_classBinding.isShowingHiddenFiles, _godot_object); 409 } 410 /** 411 412 */ 413 void _selectDrive(in long arg0) 414 { 415 Array _GODOT_args = Array.empty_array; 416 _GODOT_args.append(arg0); 417 String _GODOT_method_name = String("_select_drive"); 418 this.callv(_GODOT_method_name, _GODOT_args); 419 } 420 /** 421 422 */ 423 void _makeDir() 424 { 425 Array _GODOT_args = Array.empty_array; 426 String _GODOT_method_name = String("_make_dir"); 427 this.callv(_GODOT_method_name, _GODOT_args); 428 } 429 /** 430 431 */ 432 void _makeDirConfirm() 433 { 434 Array _GODOT_args = Array.empty_array; 435 String _GODOT_method_name = String("_make_dir_confirm"); 436 this.callv(_GODOT_method_name, _GODOT_args); 437 } 438 /** 439 440 */ 441 void _updateFileList() 442 { 443 Array _GODOT_args = Array.empty_array; 444 String _GODOT_method_name = String("_update_file_list"); 445 this.callv(_GODOT_method_name, _GODOT_args); 446 } 447 /** 448 449 */ 450 void _updateDir() 451 { 452 Array _GODOT_args = Array.empty_array; 453 String _GODOT_method_name = String("_update_dir"); 454 this.callv(_GODOT_method_name, _GODOT_args); 455 } 456 /** 457 458 */ 459 void _goUp() 460 { 461 Array _GODOT_args = Array.empty_array; 462 String _GODOT_method_name = String("_go_up"); 463 this.callv(_GODOT_method_name, _GODOT_args); 464 } 465 /** 466 Clear currently selected items in the dialog. 467 */ 468 void deselectItems() 469 { 470 checkClassBinding!(typeof(this))(); 471 ptrcall!(void)(_classBinding.deselectItems, _godot_object); 472 } 473 /** 474 Invalidate and update the current dialog content list. 475 */ 476 void invalidate() 477 { 478 checkClassBinding!(typeof(this))(); 479 ptrcall!(void)(_classBinding.invalidate, _godot_object); 480 } 481 /** 482 If `true`, changing the `Mode` property will set the window title accordingly (e. g. setting mode to `MODE_OPEN_FILE` will change the window title to "Open a File"). 483 */ 484 @property bool modeOverridesTitle() 485 { 486 return isModeOverridingTitle(); 487 } 488 /// ditto 489 @property void modeOverridesTitle(bool v) 490 { 491 setModeOverridesTitle(v); 492 } 493 /** 494 Set dialog to open or save mode, changes selection behavior. See enum `Mode` constants. 495 */ 496 @property FileDialog.Mode mode() 497 { 498 return getMode(); 499 } 500 /// ditto 501 @property void mode(long v) 502 { 503 setMode(v); 504 } 505 /** 506 The file system access scope. See enum `Access` constants. 507 */ 508 @property FileDialog.Access access() 509 { 510 return getAccess(); 511 } 512 /// ditto 513 @property void access(long v) 514 { 515 setAccess(v); 516 } 517 /** 518 Set file type filters. This example shows only .png and .gd files `set_filters(PoolStringArray($(D "*.png ; PNG Images","*.gd ; GD Script")))`. 519 */ 520 @property PoolStringArray filters() 521 { 522 return getFilters(); 523 } 524 /// ditto 525 @property void filters(PoolStringArray v) 526 { 527 setFilters(v); 528 } 529 /** 530 If `true`, the dialog will show hidden files. 531 */ 532 @property bool showHiddenFiles() 533 { 534 return isShowingHiddenFiles(); 535 } 536 /// ditto 537 @property void showHiddenFiles(bool v) 538 { 539 setShowHiddenFiles(v); 540 } 541 /** 542 The current working directory of the file dialog. 543 */ 544 @property String currentDir() 545 { 546 return getCurrentDir(); 547 } 548 /// ditto 549 @property void currentDir(String v) 550 { 551 setCurrentDir(v); 552 } 553 /** 554 The currently selected file of the file dialog. 555 */ 556 @property String currentFile() 557 { 558 return getCurrentFile(); 559 } 560 /// ditto 561 @property void currentFile(String v) 562 { 563 setCurrentFile(v); 564 } 565 /** 566 The currently selected file path of the file dialog. 567 */ 568 @property String currentPath() 569 { 570 return getCurrentPath(); 571 } 572 /// ditto 573 @property void currentPath(String v) 574 { 575 setCurrentPath(v); 576 } 577 }