Collection of tools useful for audio production
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.

132 lines
3.0KB

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