Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #if !defined(DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED) && !defined(DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED)
  17. # error bad include
  18. #endif
  19. #if !defined(DGL_USE_FILE_BROWSER) && defined(DISTRHO_UI_FILE_BROWSER) && DISTRHO_UI_FILE_BROWSER == 0
  20. # error To use File Browser in DPF plugins please set DISTRHO_UI_FILE_BROWSER to 1
  21. #endif
  22. // --------------------------------------------------------------------------------------------------------------------
  23. // File Browser Dialog stuff
  24. struct FileBrowserData;
  25. typedef FileBrowserData* FileBrowserHandle;
  26. // --------------------------------------------------------------------------------------------------------------------
  27. /**
  28. File browser options, for customizing the file browser dialog.@n
  29. By default the file browser dialog will be work as "open file" in the current working directory.
  30. */
  31. struct FileBrowserOptions {
  32. /** Whether we are saving, opening files otherwise (default) */
  33. bool saving;
  34. /** Default filename when saving, required in some platforms (basename without path separators) */
  35. const char* defaultName;
  36. /** Start directory, uses current working directory if null */
  37. const char* startDir;
  38. /** File browser dialog window title, uses "FileBrowser" if null */
  39. const char* title;
  40. /** Class name of the matching Application instance that controls this dialog */
  41. const char* className;
  42. // TODO file filter
  43. /**
  44. File browser button state.
  45. This allows to customize the behaviour of the file browse dialog buttons.
  46. Note these are merely hints, not all systems support them.
  47. */
  48. enum ButtonState {
  49. kButtonInvisible,
  50. kButtonVisibleUnchecked,
  51. kButtonVisibleChecked,
  52. };
  53. /**
  54. File browser buttons.
  55. */
  56. struct Buttons {
  57. /** Whether to list all files vs only those with matching file extension */
  58. ButtonState listAllFiles;
  59. /** Whether to show hidden files */
  60. ButtonState showHidden;
  61. /** Whether to show list of places (bookmarks) */
  62. ButtonState showPlaces;
  63. /** Constructor for default values */
  64. Buttons()
  65. : listAllFiles(kButtonVisibleChecked),
  66. showHidden(kButtonVisibleUnchecked),
  67. showPlaces(kButtonVisibleChecked) {}
  68. } buttons;
  69. /** Constructor for default values */
  70. FileBrowserOptions()
  71. : saving(false),
  72. defaultName(nullptr),
  73. startDir(nullptr),
  74. title(nullptr),
  75. className(nullptr),
  76. buttons() {}
  77. };
  78. // --------------------------------------------------------------------------------------------------------------------
  79. /**
  80. Create a new file browser dialog.
  81. @p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows)
  82. @p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*)
  83. @p scaleFactor: Scale factor to use (only used on X11)
  84. @p options: Extra options, optional
  85. By default the file browser dialog will work as "open file" in the current working directory.
  86. */
  87. FileBrowserHandle fileBrowserCreate(bool isEmbed,
  88. uintptr_t windowId,
  89. double scaleFactor,
  90. const FileBrowserOptions& options = FileBrowserOptions());
  91. /**
  92. Idle the file browser dialog handle.@n
  93. Returns true if dialog was closed (with or without a file selection),
  94. in which case this idle function must not be called anymore for this handle.
  95. You can then call fileBrowserGetPath to know the selected file (or null if cancelled).
  96. */
  97. bool fileBrowserIdle(FileBrowserHandle handle);
  98. /**
  99. Close and free the file browser dialog, handle must not be used afterwards.
  100. */
  101. void fileBrowserClose(FileBrowserHandle handle);
  102. /**
  103. Get the path chosen by the user or null.@n
  104. Should only be called after fileBrowserIdle returns true.
  105. */
  106. const char* fileBrowserGetPath(FileBrowserHandle handle);
  107. // --------------------------------------------------------------------------------------------------------------------