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.

115 lines
3.7KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2024 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. #if !defined(DISTRHO_WEB_VIEW_HPP_INCLUDED) && !defined(DGL_WEB_VIEW_HPP_INCLUDED)
  17. # error bad include
  18. #endif
  19. // --------------------------------------------------------------------------------------------------------------------
  20. // Web View stuff
  21. struct WebViewData;
  22. typedef WebViewData* WebViewHandle;
  23. typedef void (*WebViewMessageCallback)(void* arg, char* msg);
  24. // --------------------------------------------------------------------------------------------------------------------
  25. /**
  26. Web view options, for customizing web view details.
  27. */
  28. struct WebViewOptions {
  29. /**
  30. Position offset, for cases of mixing regular widgets with web views.
  31. */
  32. struct PositionOffset {
  33. /** Horizontal offset */
  34. int x;
  35. /** Vertical offset */
  36. int y;
  37. /** Constructor for default values */
  38. PositionOffset() : x(0), y(0) {}
  39. } offset;
  40. /**
  41. Message callback triggered from JavaScript code inside the WebView.
  42. */
  43. WebViewMessageCallback callback;
  44. void* callbackPtr;
  45. /** Constructor for default values */
  46. WebViewOptions()
  47. : offset(),
  48. callback(nullptr),
  49. callbackPtr(nullptr) {}
  50. /** Constructor providing a callback */
  51. WebViewOptions(const WebViewMessageCallback cb, void* const ptr)
  52. : offset(),
  53. callback(cb),
  54. callbackPtr(ptr) {}
  55. };
  56. // --------------------------------------------------------------------------------------------------------------------
  57. /**
  58. Create a new web view.
  59. The web view will be added on top of an existing platform-specific view/window.
  60. This means it will draw on top of whatever is below it,
  61. something to take into consideration if mixing regular widgets with web views.
  62. Provided metrics must not have scale factor pre-applied.
  63. @p windowId: The native window id to attach this view to (X11 Window, HWND or NSView*)
  64. @p scaleFactor: Scale factor to use (ignored on macOS)
  65. @p options: Extra options, optional
  66. */
  67. WebViewHandle webViewCreate(uintptr_t windowId,
  68. uint initialWidth,
  69. uint initialHeight,
  70. double scaleFactor,
  71. const WebViewOptions& options = WebViewOptions());
  72. /**
  73. Destroy the web view, handle must not be used afterwards.
  74. */
  75. void webViewDestroy(WebViewHandle webview);
  76. /**
  77. Idle the web view, to be called on regular intervals.
  78. Can cause callbacks to trigger.
  79. */
  80. void webViewIdle(WebViewHandle webview);
  81. /**
  82. Evaluate/run JavaScript on the web view.
  83. */
  84. void webViewEvaluateJS(WebViewHandle webview, const char* js);
  85. /**
  86. Reload the web view current page.
  87. */
  88. void webViewReload(WebViewHandle webview);
  89. /**
  90. Resize the web view.
  91. */
  92. void webViewResize(WebViewHandle webview, uint width, uint height, double scaleFactor);
  93. // --------------------------------------------------------------------------------------------------------------------