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.

143 lines
3.9KB

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