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.

239 lines
9.9KB

  1. //-----------------------------------------------------------------------------
  2. // Project : SDK Core
  3. //
  4. // Category : SDK GUI Interfaces
  5. // Filename : pluginterfaces/gui/iplugview.h
  6. // Created by : Steinberg, 12/2007
  7. // Description : Plug-in User Interface
  8. //
  9. //-----------------------------------------------------------------------------
  10. // This file is part of a Steinberg SDK. It is subject to the license terms
  11. // in the LICENSE file found in the top-level directory of this distribution
  12. // and at www.steinberg.net/sdklicenses.
  13. // No part of the SDK, including this file, may be copied, modified, propagated,
  14. // or distributed except according to the terms contained in the LICENSE file.
  15. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "../base/funknown.h"
  18. namespace Steinberg {
  19. class IPlugFrame;
  20. //------------------------------------------------------------------------
  21. /*! \defgroup pluginGUI Graphical User Interface
  22. */
  23. //------------------------------------------------------------------------
  24. /** Graphical rectangle structure. Used with IPlugView.
  25. \ingroup pluginGUI
  26. */
  27. //------------------------------------------------------------------------
  28. struct ViewRect
  29. {
  30. ViewRect (int32 l = 0, int32 t = 0, int32 r = 0, int32 b = 0)
  31. : left (l), top (t), right (r), bottom (b)
  32. {
  33. }
  34. int32 left;
  35. int32 top;
  36. int32 right;
  37. int32 bottom;
  38. //--- ---------------------------------------------------------------------
  39. int32 getWidth () const { return right - left; }
  40. int32 getHeight () const { return bottom - top; }
  41. };
  42. //------------------------------------------------------------------------
  43. /** \defgroup platformUIType Platform UI Types
  44. \ingroup pluginGUI
  45. List of Platform UI types for IPlugView. This list is used to match the GUI-System between
  46. the host and a Plug-in in case that an OS provides multiple GUI-APIs.
  47. */
  48. /*@{*/
  49. /** The parent parameter in IPlugView::attached() is a HWND handle. You should attach a child window
  50. * to it. */
  51. const FIDString kPlatformTypeHWND = "HWND"; ///< HWND handle. (Microsoft Windows)
  52. /** The parent parameter in IPlugView::attached() is a WindowRef. You should attach a HIViewRef to
  53. * the content view of the window. */
  54. const FIDString kPlatformTypeHIView = "HIView"; ///< HIViewRef. (Mac OS X)
  55. /** The parent parameter in IPlugView::attached() is a NSView pointer. You should attach a NSView to it. */
  56. const FIDString kPlatformTypeNSView = "NSView"; ///< NSView pointer. (Mac OS X)
  57. /** The parent parameter in IPlugView::attached() is a UIView pointer. You should attach an UIView to it. */
  58. const FIDString kPlatformTypeUIView = "UIView"; ///< UIView pointer. (iOS)
  59. /** The parent parameter in IPlugView::attached() is a X11 Window supporting XEmbed. You should attach
  60. * a Window to it. */
  61. const FIDString kPlatformTypeX11EmbedWindowID = "X11EmbedWindowID"; ///< X11 Window ID. (X11)
  62. /*@}*/
  63. //------------------------------------------------------------------------
  64. //------------------------------------------------------------------------
  65. /** Plug-in definition of a view.
  66. \ingroup pluginGUI
  67. - [plug imp]
  68. \par Sizing of a view
  69. Usually the size of a Plug-in view is fixed. But both the host and the Plug-in can cause
  70. a view to be resized:
  71. \n
  72. - <b> Host </b> : If IPlugView::canResize () returns kResultTrue the host will setup the window
  73. so that the user can resize it. While the user resizes the window IPlugView::checkSizeConstraint
  74. ()
  75. is called, allowing the Plug-in to change the size to a valid rect. The host then resizes the
  76. window to this rect and has to call IPlugView::onSize ().
  77. \n
  78. \n
  79. - <b> Plug-in </b> : The Plug-in can call IPlugFrame::resizeView () and cause the host to resize the
  80. window.
  81. Afterwards the host has to call IPlugView::onSize () if a resize is needed (size was changed).
  82. Note that if the host calls IPlugView::getSize () before calling IPlugView::onSize () (if needed),
  83. it will get the current (old) size not the wanted one!!
  84. Here the calling sequence:
  85. * plug-in->host: IPlugFrame::resizeView (newSize)
  86. * host->plug-in (optional): IPlugView::getSize () returns the currentSize (not the wanted
  87. newSize)!
  88. * host->plug-in: if newSize is different than its actual current size: IPlugView::onSize
  89. (newSize)
  90. * host->plug-in (optional): IPlugView::getSize () returns the newSize
  91. \n
  92. Please only resize the platform representation of the view when IPlugView::onSize () is called.
  93. \par Keyboard handling
  94. The Plug-in view receives keyboard events from the host. A view implementation must not handle
  95. keyboard events by the means of platform callbacks, but let the host pass them to the view. The host
  96. depends on a proper return value when IPlugView::onKeyDown is called, otherwise the Plug-in view may
  97. cause a malfunction of the host's key command handling!
  98. \see IPlugFrame, \ref platformUIType
  99. */
  100. //------------------------------------------------------------------------
  101. class IPlugView: public FUnknown
  102. {
  103. public:
  104. //------------------------------------------------------------------------
  105. /** Is Platform UI Type supported
  106. \param type : IDString of \ref platformUIType */
  107. virtual tresult PLUGIN_API isPlatformTypeSupported (FIDString type) = 0;
  108. /** The parent window of the view has been created, the (platform) representation of the view
  109. should now be created as well.
  110. Note that the parent is owned by the caller and you are not allowed to alter it in any way
  111. other than adding your own views.
  112. Note that in this call the Plug-in could call a IPlugFrame::resizeView ()!
  113. \param parent : platform handle of the parent window or view
  114. \param type : \ref platformUIType which should be created */
  115. virtual tresult PLUGIN_API attached (void* parent, FIDString type) = 0;
  116. /** The parent window of the view is about to be destroyed.
  117. You have to remove all your own views from the parent window or view. */
  118. virtual tresult PLUGIN_API removed () = 0;
  119. /** Handling of mouse wheel. */
  120. virtual tresult PLUGIN_API onWheel (float distance) = 0;
  121. /** Handling of keyboard events : Key Down.
  122. \param key : unicode code of key
  123. \param keyCode : virtual keycode for non ascii keys - see \ref VirtualKeyCodes in keycodes.h
  124. \param modifiers : any combination of modifiers - see \ref KeyModifier in keycodes.h
  125. \return kResultTrue if the key is handled, otherwise kResultFalse. \n
  126. <b> Please note that kResultTrue must only be returned if the key has really been
  127. handled. </b> Otherwise key command handling of the host might be blocked! */
  128. virtual tresult PLUGIN_API onKeyDown (char16 key, int16 keyCode, int16 modifiers) = 0;
  129. /** Handling of keyboard events : Key Up.
  130. \param key : unicode code of key
  131. \param keyCode : virtual keycode for non ascii keys - see \ref VirtualKeyCodes in keycodes.h
  132. \param modifiers : any combination of KeyModifier - see \ref KeyModifier in keycodes.h
  133. \return kResultTrue if the key is handled, otherwise return kResultFalse. */
  134. virtual tresult PLUGIN_API onKeyUp (char16 key, int16 keyCode, int16 modifiers) = 0;
  135. /** Returns the size of the platform representation of the view. */
  136. virtual tresult PLUGIN_API getSize (ViewRect* size) = 0;
  137. /** Resizes the platform representation of the view to the given rect. Note that if the Plug-in
  138. * requests a resize (IPlugFrame::resizeView ()) onSize has to be called afterward. */
  139. virtual tresult PLUGIN_API onSize (ViewRect* newSize) = 0;
  140. /** Focus changed message. */
  141. virtual tresult PLUGIN_API onFocus (TBool state) = 0;
  142. /** Sets IPlugFrame object to allow the Plug-in to inform the host about resizing. */
  143. virtual tresult PLUGIN_API setFrame (IPlugFrame* frame) = 0;
  144. /** Is view sizable by user. */
  145. virtual tresult PLUGIN_API canResize () = 0;
  146. /** On live resize this is called to check if the view can be resized to the given rect, if not
  147. * adjust the rect to the allowed size. */
  148. virtual tresult PLUGIN_API checkSizeConstraint (ViewRect* rect) = 0;
  149. //------------------------------------------------------------------------
  150. static const FUID iid;
  151. };
  152. DECLARE_CLASS_IID (IPlugView, 0x5BC32507, 0xD06049EA, 0xA6151B52, 0x2B755B29)
  153. //------------------------------------------------------------------------
  154. /** Callback interface passed to IPlugView.
  155. \ingroup pluginGUI
  156. - [host imp]
  157. Enables a Plug-in to resize the view and cause the host to resize the window.
  158. */
  159. //------------------------------------------------------------------------
  160. class IPlugFrame : public FUnknown
  161. {
  162. public:
  163. //------------------------------------------------------------------------
  164. /** Called to inform the host about the resize of a given view.
  165. Afterwards the host has to call IPlugView::onSize (). */
  166. virtual tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* newSize) = 0;
  167. //------------------------------------------------------------------------
  168. static const FUID iid;
  169. };
  170. DECLARE_CLASS_IID (IPlugFrame, 0x367FAF01, 0xAFA94693, 0x8D4DA2A0, 0xED0882A3)
  171. //------------------------------------------------------------------------
  172. class IPlugViewIdleHandler : public FUnknown
  173. {
  174. public:
  175. virtual void PLUGIN_API onPlugViewIdle () = 0;
  176. //------------------------------------------------------------------------
  177. static const FUID iid;
  178. };
  179. DECLARE_CLASS_IID (IPlugViewIdleHandler, 0x35BD6C3A, 0x9C1F4073, 0x89C7DA88, 0xBF6595D3)
  180. //------------------------------------------------------------------------
  181. /** Extension to IPlugFrame
  182. \ingroup pluginGUI
  183. - [host impl]
  184. Enables a Plug-in to add an idle handler to the main event loop (Linux only)
  185. */
  186. //------------------------------------------------------------------------
  187. class IPlugFrameIdle : public FUnknown
  188. {
  189. public:
  190. virtual tresult PLUGIN_API addIdleHandler (IPlugViewIdleHandler* handler) = 0;
  191. virtual tresult PLUGIN_API removeIdleHandler (IPlugViewIdleHandler* handler) = 0;
  192. //------------------------------------------------------------------------
  193. static const FUID iid;
  194. };
  195. DECLARE_CLASS_IID (IPlugFrameIdle, 0x31DE26C9, 0x36654639, 0x9F858E64, 0xE211817A)
  196. //------------------------------------------------------------------------
  197. } // namespace Steinberg