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.

139 lines
3.1KB

  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #ifndef __DISTRHO_UI_OPENGL_H__
  17. #define __DISTRHO_UI_OPENGL_H__
  18. #include "src/DistrhoMacros.h"
  19. #ifdef DISTRHO_UI_OPENGL
  20. #include "DistrhoUI.h"
  21. #if DISTRHO_OS_MAC
  22. # include <OpenGL/glu.h>
  23. #else
  24. # include <GL/glu.h>
  25. #endif
  26. #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
  27. # define GL_BGR GL_BGR_EXT
  28. #endif
  29. #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
  30. # define GL_BGRA GL_BGRA_EXT
  31. #endif
  32. START_NAMESPACE_DISTRHO
  33. // -------------------------------------------------
  34. enum Char {
  35. CHAR_BACKSPACE = 0x08,
  36. CHAR_ESCAPE = 0x1B,
  37. CHAR_DELETE = 0x7F
  38. };
  39. enum Key {
  40. KEY_F1 = 1,
  41. KEY_F2,
  42. KEY_F3,
  43. KEY_F4,
  44. KEY_F5,
  45. KEY_F6,
  46. KEY_F7,
  47. KEY_F8,
  48. KEY_F9,
  49. KEY_F10,
  50. KEY_F11,
  51. KEY_F12,
  52. KEY_LEFT,
  53. KEY_UP,
  54. KEY_RIGHT,
  55. KEY_DOWN,
  56. KEY_PAGE_UP,
  57. KEY_PAGE_DOWN,
  58. KEY_HOME,
  59. KEY_END,
  60. KEY_INSERT,
  61. KEY_SHIFT,
  62. KEY_CTRL,
  63. KEY_ALT,
  64. KEY_SUPER
  65. };
  66. enum Modifier {
  67. MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  68. MODIFIER_CTRL = 1 << 1, /**< Control key */
  69. MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  70. MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  71. };
  72. // -------------------------------------------------
  73. class OpenGLUI : public UI
  74. {
  75. public:
  76. OpenGLUI();
  77. virtual ~OpenGLUI();
  78. // ---------------------------------------------
  79. // Host UI State (OpenGL)
  80. int d_uiGetModifiers();
  81. void d_uiIgnoreKeyRepeat(bool ignore);
  82. void d_uiRepaint();
  83. // ---------------------------------------------
  84. protected:
  85. // Information
  86. virtual int d_width() = 0;
  87. virtual int d_height() = 0;
  88. // DSP Callbacks
  89. virtual void d_parameterChanged(uint32_t index, float value) = 0;
  90. #if DISTRHO_PLUGIN_WANT_PROGRAMS
  91. virtual void d_programChanged(uint32_t index) = 0;
  92. #endif
  93. #if DISTRHO_PLUGIN_WANT_STATE
  94. virtual void d_stateChanged(const char* key, const char* value) = 0;
  95. #endif
  96. // UI Callbacks
  97. virtual void d_uiIdle();
  98. virtual void d_onInit() = 0;
  99. virtual void d_onDisplay() = 0;
  100. virtual void d_onKeyboard(bool press, uint32_t key) = 0;
  101. virtual void d_onMotion(int x, int y) = 0;
  102. virtual void d_onMouse(int button, bool press, int x, int y) = 0;
  103. virtual void d_onReshape(int width, int height) = 0;
  104. virtual void d_onScroll(float dx, float dy) = 0;
  105. virtual void d_onSpecial(bool press, Key key) = 0;
  106. virtual void d_onClose() = 0;
  107. private:
  108. friend class UIInternal;
  109. };
  110. // -------------------------------------------------
  111. END_NAMESPACE_DISTRHO
  112. #endif // DISTRHO_UI_OPENGL
  113. #endif // __DISTRHO_UI_OPENGL_H__