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.

149 lines
4.0KB

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