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.

view.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021 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. #pragma once
  17. #include "base.h"
  18. /**
  19. * base view stuff
  20. */
  21. struct v3_view_rect {
  22. int32_t left;
  23. int32_t top;
  24. int32_t right;
  25. int32_t bottom;
  26. };
  27. #define V3_VIEW_PLATFORM_TYPE_HWND "HWND"
  28. #define V3_VIEW_PLATFORM_TYPE_NSVIEW "NSView"
  29. #define V3_VIEW_PLATFORM_TYPE_X11 "X11EmbedWindowID"
  30. #if defined(__APPLE__)
  31. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_NSVIEW
  32. #elif defined(_WIN32)
  33. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_HWND
  34. #else
  35. # define V3_VIEW_PLATFORM_TYPE_NATIVE V3_VIEW_PLATFORM_TYPE_X11
  36. #endif
  37. /**
  38. * plugin view
  39. */
  40. struct v3_plugin_frame;
  41. struct v3_plugin_view {
  42. struct v3_funknown;
  43. v3_result (V3_API* is_platform_type_supported)(void* self, const char* platform_type);
  44. v3_result (V3_API* attached)(void* self, void* parent, const char* platform_type);
  45. v3_result (V3_API* removed)(void* self);
  46. v3_result (V3_API* on_wheel)(void* self, float distance);
  47. v3_result (V3_API* on_key_down)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
  48. v3_result (V3_API* on_key_up)(void* self, int16_t key_char, int16_t key_code, int16_t modifiers);
  49. v3_result (V3_API* get_size)(void* self, struct v3_view_rect*);
  50. v3_result (V3_API* on_size)(void* self, struct v3_view_rect*);
  51. v3_result (V3_API* on_focus)(void* self, v3_bool state);
  52. v3_result (V3_API* set_frame)(void* self, struct v3_plugin_frame**);
  53. v3_result (V3_API* can_resize)(void* self);
  54. v3_result (V3_API* check_size_constraint)(void* self, struct v3_view_rect*);
  55. };
  56. static constexpr const v3_tuid v3_plugin_view_iid =
  57. V3_ID(0x5BC32507, 0xD06049EA, 0xA6151B52, 0x2B755B29);
  58. /**
  59. * plugin frame
  60. */
  61. struct v3_plugin_frame {
  62. struct v3_funknown;
  63. v3_result (V3_API* resize_view)(void* self, struct v3_plugin_view**, struct v3_view_rect*);
  64. };
  65. static constexpr const v3_tuid v3_plugin_frame_iid =
  66. V3_ID(0x367FAF01, 0xAFA94693, 0x8D4DA2A0, 0xED0882A3);
  67. /**
  68. * steinberg content scaling support
  69. * (same IID/iface as presonus view scaling)
  70. */
  71. struct v3_plugin_view_content_scale {
  72. struct v3_funknown;
  73. v3_result (V3_API* set_content_scale_factor)(void* self, float factor);
  74. };
  75. static constexpr const v3_tuid v3_plugin_view_content_scale_iid =
  76. V3_ID(0x65ED9690, 0x8AC44525, 0x8AADEF7A, 0x72EA703F);
  77. /**
  78. * support for querying the view to find what control is underneath the mouse
  79. */
  80. struct v3_plugin_view_parameter_finder {
  81. struct v3_funknown;
  82. v3_result (V3_API* find_parameter)(void* self, int32_t x, int32_t y, v3_param_id *);
  83. };
  84. static constexpr const v3_tuid v3_plugin_view_parameter_finder_iid =
  85. V3_ID(0x0F618302, 0x215D4587, 0xA512073C, 0x77B9D383);
  86. /**
  87. * linux event handler
  88. */
  89. struct v3_event_handler {
  90. struct v3_funknown;
  91. void (V3_API* on_fd_is_set)(void* self, int fd);
  92. };
  93. static constexpr const v3_tuid v3_event_handler_iid =
  94. V3_ID(0x561E65C9, 0x13A0496F, 0x813A2C35, 0x654D7983);
  95. /**
  96. * linux timer handler
  97. */
  98. struct v3_timer_handler {
  99. struct v3_funknown;
  100. void (V3_API* on_timer)(void* self);
  101. };
  102. static constexpr const v3_tuid v3_timer_handler_iid =
  103. V3_ID(0x10BDD94F, 0x41424774, 0x821FAD8F, 0xECA72CA9);
  104. /**
  105. * linux host run loop
  106. */
  107. struct v3_run_loop {
  108. struct v3_funknown;
  109. v3_result (V3_API* register_event_handler)(void* self, v3_event_handler** handler, int fd);
  110. v3_result (V3_API* unregister_event_handler)(void* self, v3_event_handler** handler);
  111. v3_result (V3_API* register_timer)(void* self, v3_timer_handler** handler, uint64_t ms);
  112. v3_result (V3_API* unregister_timer)(void* self, v3_timer_handler** handler);
  113. };
  114. static constexpr const v3_tuid v3_run_loop_iid =
  115. V3_ID(0x18C35366, 0x97764F1A, 0x9C5B8385, 0x7A871389);
  116. #ifdef __cplusplus
  117. /**
  118. * C++ variants
  119. */
  120. struct v3_plugin_view_cpp : v3_funknown {
  121. v3_plugin_view view;
  122. };
  123. struct v3_plugin_frame_cpp : v3_funknown {
  124. v3_plugin_frame frame;
  125. };
  126. struct v3_plugin_view_content_scale_cpp : v3_funknown {
  127. v3_plugin_view_content_scale scale;
  128. };
  129. struct v3_plugin_view_parameter_finder_cpp : v3_funknown {
  130. v3_plugin_view_parameter_finder finder;
  131. };
  132. struct v3_event_handler_cpp : v3_funknown {
  133. v3_event_handler handler;
  134. };
  135. struct v3_timer_handler_cpp : v3_funknown {
  136. v3_timer_handler handler;
  137. };
  138. struct v3_run_loop_cpp : v3_funknown {
  139. v3_run_loop loop;
  140. };
  141. #endif