DISTRHO Plugin Framework
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.

118 lines
4.3KB

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