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.

178 lines
5.2KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-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. #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 PuglEventKey::key. This
  43. enumeration defines constants for special keys that do not have a standard
  44. code point, and some convenience constants for control characters. Note
  45. 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`). Applications
  49. must take care to not interpret these values beyond key detection, the
  50. 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 Flag {
  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. Scroll direction.
  119. Describes the direction of a scroll event along with whether the scroll is a "smooth" scroll.
  120. The discrete directions are for devices like mouse wheels with constrained axes,
  121. while a smooth scroll is for those with arbitrary scroll direction freedom, like some touchpads.
  122. */
  123. enum ScrollDirection {
  124. kScrollUp, ///< Scroll up
  125. kScrollDown, ///< Scroll down
  126. kScrollLeft, ///< Scroll left
  127. kScrollRight, ///< Scroll right
  128. kScrollSmooth ///< Smooth scroll in any direction
  129. };
  130. // --------------------------------------------------------------------------------------------------------------------
  131. // Base DGL classes
  132. /**
  133. Graphics context, definition depends on build type.
  134. */
  135. struct GraphicsContext {};
  136. /**
  137. Idle callback.
  138. */
  139. struct IdleCallback
  140. {
  141. virtual ~IdleCallback() {}
  142. virtual void idleCallback() = 0;
  143. };
  144. // --------------------------------------------------------------------------------------------------------------------
  145. END_NAMESPACE_DGL
  146. #ifndef DONT_SET_USING_DGL_NAMESPACE
  147. // If your code uses a lot of DGL classes, then this will obviously save you
  148. // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
  149. using namespace DGL_NAMESPACE;
  150. #endif
  151. // --------------------------------------------------------------------------------------------------------------------
  152. #endif // DGL_BASE_HPP_INCLUDED