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.

236 lines
7.0KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2022 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_BASE_HPP_INCLUDED
  17. #define DGL_BASE_HPP_INCLUDED
  18. #include "../distrho/extra/LeakDetector.hpp"
  19. #include "../distrho/extra/ScopedPointer.hpp"
  20. // --------------------------------------------------------------------------------------------------------------------
  21. // Define namespace
  22. #ifndef DGL_NAMESPACE
  23. # define DGL_NAMESPACE DGL
  24. #endif
  25. #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
  26. #define END_NAMESPACE_DGL }
  27. #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
  28. START_NAMESPACE_DGL
  29. // --------------------------------------------------------------------------------------------------------------------
  30. // Base DGL enums
  31. /**
  32. Keyboard modifier flags.
  33. */
  34. enum Modifier {
  35. kModifierShift = 1u << 0u, ///< Shift key
  36. kModifierControl = 1u << 1u, ///< Control key
  37. kModifierAlt = 1u << 2u, ///< Alt/Option key
  38. kModifierSuper = 1u << 3u ///< Mod4/Command/Windows key
  39. };
  40. /**
  41. Keyboard key codepoints.
  42. All keys are identified by a Unicode code point in Widget::KeyboardEvent::key.
  43. This enumeration defines constants for special keys that do not have a standard
  44. code point, and some convenience constants for control characters.
  45. Note that all keys are handled in the same way, this enumeration is just for
  46. convenience when writing hard-coded key bindings.
  47. Keys that do not have a standard code point use values in the Private Use
  48. Area in the Basic Multilingual Plane (`U+E000` to `U+F8FF`).
  49. Applications must take care to not interpret these values beyond key detection,
  50. the mapping used here is arbitrary and specific to DPF.
  51. */
  52. enum Key {
  53. // Convenience symbols for ASCII control characters
  54. kKeyBackspace = 0x08,
  55. kKeyEscape = 0x1B,
  56. kKeyDelete = 0x7F,
  57. // Backwards compatibility with old DPF
  58. kCharBackspace DISTRHO_DEPRECATED_BY("kKeyBackspace") = kKeyBackspace,
  59. kCharEscape DISTRHO_DEPRECATED_BY("kKeyEscape") = kKeyEscape,
  60. kCharDelete DISTRHO_DEPRECATED_BY("kKeyDelete") = kKeyDelete,
  61. // Unicode Private Use Area
  62. kKeyF1 = 0xE000,
  63. kKeyF2,
  64. kKeyF3,
  65. kKeyF4,
  66. kKeyF5,
  67. kKeyF6,
  68. kKeyF7,
  69. kKeyF8,
  70. kKeyF9,
  71. kKeyF10,
  72. kKeyF11,
  73. kKeyF12,
  74. kKeyLeft,
  75. kKeyUp,
  76. kKeyRight,
  77. kKeyDown,
  78. kKeyPageUp,
  79. kKeyPageDown,
  80. kKeyHome,
  81. kKeyEnd,
  82. kKeyInsert,
  83. kKeyShift,
  84. kKeyShiftL = kKeyShift,
  85. kKeyShiftR,
  86. kKeyControl,
  87. kKeyControlL = kKeyControl,
  88. kKeyControlR,
  89. kKeyAlt,
  90. kKeyAltL = kKeyAlt,
  91. kKeyAltR,
  92. kKeySuper,
  93. kKeySuperL = kKeySuper,
  94. kKeySuperR,
  95. kKeyMenu,
  96. kKeyCapsLock,
  97. kKeyScrollLock,
  98. kKeyNumLock,
  99. kKeyPrintScreen,
  100. kKeyPause
  101. };
  102. /**
  103. Common flags for all events.
  104. */
  105. enum EventFlag {
  106. kFlagSendEvent = 1, ///< Event is synthetic
  107. kFlagIsHint = 2 ///< Event is a hint (not direct user input)
  108. };
  109. /**
  110. Reason for a crossing event.
  111. */
  112. enum CrossingMode {
  113. kCrossingNormal, ///< Crossing due to pointer motion
  114. kCrossingGrab, ///< Crossing due to a grab
  115. kCrossingUngrab ///< Crossing due to a grab release
  116. };
  117. /**
  118. A mouse button.
  119. Mouse button numbers start from 1, and are ordered: primary, secondary, middle.
  120. So, on a typical right-handed mouse, the button numbers are:
  121. Left: 1
  122. Right: 2
  123. Middle (often a wheel): 3
  124. Higher button numbers are reported in the same order they are represented on the system.
  125. There is no universal standard here, but buttons 4 and 5 are typically a pair of buttons or a rocker,
  126. which are usually bound to "back" and "forward" operations.
  127. Note that these numbers may differ from those used on the underlying
  128. platform, since they are manipulated to provide a consistent portable API.
  129. */
  130. enum MouseButton {
  131. kMouseButtonLeft = 1,
  132. kMouseButtonRight,
  133. kMouseButtonMiddle,
  134. };
  135. /**
  136. A mouse cursor type.
  137. This is a portable subset of mouse cursors that exist on X11, MacOS, and Windows.
  138. */
  139. enum MouseCursor {
  140. kMouseCursorArrow, ///< Default pointing arrow
  141. kMouseCursorCaret, ///< Caret (I-Beam) for text entry
  142. kMouseCursorCrosshair, ///< Cross-hair
  143. kMouseCursorHand, ///< Hand with a pointing finger
  144. kMouseCursorNotAllowed, ///< Operation not allowed
  145. kMouseCursorLeftRight, ///< Left/right arrow for horizontal resize
  146. kMouseCursorUpDown, ///< Up/down arrow for vertical resize
  147. kMouseCursorDiagonal, ///< Top-left to bottom-right arrow for diagonal resize
  148. kMouseCursorAntiDiagonal ///< Bottom-left to top-right arrow for diagonal resize
  149. };
  150. /**
  151. Scroll direction.
  152. Describes the direction of a scroll event along with whether the scroll is a "smooth" scroll.
  153. The discrete directions are for devices like mouse wheels with constrained axes,
  154. while a smooth scroll is for those with arbitrary scroll direction freedom, like some touchpads.
  155. */
  156. enum ScrollDirection {
  157. kScrollUp, ///< Scroll up
  158. kScrollDown, ///< Scroll down
  159. kScrollLeft, ///< Scroll left
  160. kScrollRight, ///< Scroll right
  161. kScrollSmooth ///< Smooth scroll in any direction
  162. };
  163. /**
  164. A clipboard data offer.
  165. @see Window::onClipboardDataOffer
  166. */
  167. struct ClipboardDataOffer {
  168. /**
  169. The id of this data offer.
  170. @note The value 0 is reserved for null/invalid.
  171. */
  172. uint32_t id;
  173. /**
  174. The type of this data offer.
  175. Usually a MIME type, but may also be another platform-specific type identifier.
  176. */
  177. const char* type;
  178. };
  179. // --------------------------------------------------------------------------------------------------------------------
  180. // Base DGL classes
  181. /**
  182. Graphics context, definition depends on build type.
  183. */
  184. struct GraphicsContext {};
  185. /**
  186. Idle callback.
  187. */
  188. struct IdleCallback
  189. {
  190. virtual ~IdleCallback() {}
  191. virtual void idleCallback() = 0;
  192. };
  193. // --------------------------------------------------------------------------------------------------------------------
  194. END_NAMESPACE_DGL
  195. #ifndef DONT_SET_USING_DGL_NAMESPACE
  196. // If your code uses a lot of DGL classes, then this will obviously save you
  197. // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
  198. using namespace DGL_NAMESPACE;
  199. #endif
  200. // --------------------------------------------------------------------------------------------------------------------
  201. #endif // DGL_BASE_HPP_INCLUDED