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.

Window.hpp 4.1KB

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