Audio plugin host https://kx.studio/carla
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.

141 lines
3.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2016 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. #ifndef DGL_WINDOW_HPP_INCLUDED
  17. #define DGL_WINDOW_HPP_INCLUDED
  18. #include "Geometry.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. class Application;
  22. class Widget;
  23. class StandaloneWindow;
  24. class Window
  25. {
  26. public:
  27. #ifndef DGL_FILE_BROWSER_DISABLED
  28. /**
  29. File browser options.
  30. */
  31. struct FileBrowserOptions {
  32. const char* startDir;
  33. const char* title;
  34. uint width;
  35. uint height;
  36. /**
  37. File browser buttons.
  38. 0 means hidden.
  39. 1 means visible and unchecked.
  40. 2 means visible and checked.
  41. */
  42. struct Buttons {
  43. uint listAllFiles;
  44. uint showHidden;
  45. uint showPlaces;
  46. /** Constuctor for default values */
  47. Buttons()
  48. : listAllFiles(2),
  49. showHidden(1),
  50. showPlaces(1) {}
  51. } buttons;
  52. /** Constuctor for default values */
  53. FileBrowserOptions()
  54. : startDir(nullptr),
  55. title(nullptr),
  56. width(0),
  57. height(0),
  58. buttons() {}
  59. };
  60. #endif // DGL_FILE_BROWSER_DISABLED
  61. explicit Window(Application& app);
  62. explicit Window(Application& app, Window& parent);
  63. explicit Window(Application& app, intptr_t parentId);
  64. virtual ~Window();
  65. void show();
  66. void hide();
  67. void close();
  68. void exec(bool lockWait = false);
  69. void focus();
  70. void repaint() noexcept;
  71. #ifndef DGL_FILE_BROWSER_DISABLED
  72. bool openFileBrowser(const FileBrowserOptions& options);
  73. #endif
  74. bool isVisible() const noexcept;
  75. void setVisible(bool yesNo);
  76. bool isResizable() const noexcept;
  77. void setResizable(bool yesNo);
  78. uint getWidth() const noexcept;
  79. uint getHeight() const noexcept;
  80. Size<uint> getSize() const noexcept;
  81. void setSize(uint width, uint height);
  82. void setSize(Size<uint> size);
  83. const char* getTitle() const noexcept;
  84. void setTitle(const char* title);
  85. void setTransientWinId(uintptr_t winId);
  86. Application& getApp() const noexcept;
  87. intptr_t getWindowId() const noexcept;
  88. void addIdleCallback(IdleCallback* const callback);
  89. void removeIdleCallback(IdleCallback* const callback);
  90. protected:
  91. virtual void onDisplayBefore();
  92. virtual void onDisplayAfter();
  93. virtual void onReshape(uint width, uint height);
  94. virtual void onClose();
  95. #ifndef DGL_FILE_BROWSER_DISABLED
  96. virtual void fileBrowserSelected(const char* filename);
  97. #endif
  98. private:
  99. struct PrivateData;
  100. PrivateData* const pData;
  101. friend class Application;
  102. friend class Widget;
  103. friend class StandaloneWindow;
  104. virtual void _addWidget(Widget* const widget);
  105. virtual void _removeWidget(Widget* const widget);
  106. void _idle();
  107. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window)
  108. };
  109. // -----------------------------------------------------------------------
  110. END_NAMESPACE_DGL
  111. #endif // DGL_WINDOW_HPP_INCLUDED