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 3.6KB

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