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.

162 lines
4.4KB

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