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.

122 lines
4.5KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2022 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. // --------------------------------------------------------------------------------------------------------------------
  20. // File Browser Dialog stuff
  21. struct FileBrowserData;
  22. typedef FileBrowserData* FileBrowserHandle;
  23. // --------------------------------------------------------------------------------------------------------------------
  24. /**
  25. File browser options, for customizing the file browser dialog.@n
  26. By default the file browser dialog will be work as "open file" in the current working directory.
  27. */
  28. struct FileBrowserOptions {
  29. /** Whether we are saving, opening files otherwise (default) */
  30. bool saving;
  31. /** Default filename when saving, required in some platforms (basename without path separators) */
  32. const char* defaultName;
  33. /** Start directory, uses current working directory if null */
  34. const char* startDir;
  35. /** File browser dialog window title, uses "FileBrowser" if null */
  36. const char* title;
  37. // TODO file filter
  38. /**
  39. File browser button state.
  40. This allows to customize the behaviour of the file browse dialog buttons.
  41. Note these are merely hints, not all systems support them.
  42. */
  43. enum ButtonState {
  44. kButtonInvisible,
  45. kButtonVisibleUnchecked,
  46. kButtonVisibleChecked,
  47. };
  48. /**
  49. File browser buttons.
  50. */
  51. struct Buttons {
  52. /** Whether to list all files vs only those with matching file extension */
  53. ButtonState listAllFiles;
  54. /** Whether to show hidden files */
  55. ButtonState showHidden;
  56. /** Whether to show list of places (bookmarks) */
  57. ButtonState showPlaces;
  58. /** Constructor for default values */
  59. Buttons()
  60. : listAllFiles(kButtonVisibleChecked),
  61. showHidden(kButtonVisibleUnchecked),
  62. showPlaces(kButtonVisibleChecked) {}
  63. } buttons;
  64. /** Constructor for default values */
  65. FileBrowserOptions()
  66. : saving(false),
  67. defaultName(nullptr),
  68. startDir(nullptr),
  69. title(nullptr),
  70. buttons() {}
  71. };
  72. // --------------------------------------------------------------------------------------------------------------------
  73. /**
  74. Create a new file browser dialog.
  75. @p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows)
  76. @p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*)
  77. @p scaleFactor: Scale factor to use (only used on X11)
  78. @p options: Extra options, optional
  79. By default the file browser dialog will be work as "open file" in the current working directory.
  80. */
  81. FileBrowserHandle fileBrowserCreate(bool isEmbed,
  82. uintptr_t windowId,
  83. double scaleFactor,
  84. const FileBrowserOptions& options = FileBrowserOptions());
  85. /**
  86. Idle the file browser dialog handle.@n
  87. Returns true if dialog was closed (with or without a file selection),
  88. in which case the handle must not be used afterwards.
  89. You can then call fileBrowserGetPath to know the selected file (or null if cancelled).
  90. */
  91. bool fileBrowserIdle(const FileBrowserHandle handle);
  92. /**
  93. Close the file browser dialog, handle must not be used afterwards.
  94. */
  95. void fileBrowserClose(const FileBrowserHandle handle);
  96. /**
  97. Get the path chosen by the user or null.@n
  98. Should only be called after fileBrowserIdle returns true.
  99. */
  100. const char* fileBrowserGetPath(const FileBrowserHandle handle);
  101. // --------------------------------------------------------------------------------------------------------------------