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.

140 lines
3.2KB

  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. #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
  28. # define GL_BGR GL_BGR_EXT
  29. #endif
  30. #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
  31. # define GL_BGRA GL_BGRA_EXT
  32. #endif
  33. START_NAMESPACE_DISTRHO
  34. // -------------------------------------------------
  35. enum Char {
  36. CHAR_BACKSPACE = 0x08,
  37. CHAR_ESCAPE = 0x1B,
  38. CHAR_DELETE = 0x7F
  39. };
  40. enum Key {
  41. KEY_F1 = 1,
  42. KEY_F2,
  43. KEY_F3,
  44. KEY_F4,
  45. KEY_F5,
  46. KEY_F6,
  47. KEY_F7,
  48. KEY_F8,
  49. KEY_F9,
  50. KEY_F10,
  51. KEY_F11,
  52. KEY_F12,
  53. KEY_LEFT,
  54. KEY_UP,
  55. KEY_RIGHT,
  56. KEY_DOWN,
  57. KEY_PAGE_UP,
  58. KEY_PAGE_DOWN,
  59. KEY_HOME,
  60. KEY_END,
  61. KEY_INSERT,
  62. KEY_SHIFT,
  63. KEY_CTRL,
  64. KEY_ALT,
  65. KEY_SUPER
  66. };
  67. enum Modifier {
  68. MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  69. MODIFIER_CTRL = 1 << 1, /**< Control key */
  70. MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  71. MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  72. };
  73. // -------------------------------------------------
  74. class OpenGLUI : public UI
  75. {
  76. public:
  77. OpenGLUI();
  78. virtual ~OpenGLUI();
  79. // ---------------------------------------------
  80. // Host UI State (OpenGL)
  81. int d_uiGetModifiers();
  82. void d_uiIgnoreKeyRepeat(bool ignore);
  83. void d_uiRepaint();
  84. // ---------------------------------------------
  85. protected:
  86. // Information
  87. virtual unsigned int d_width() = 0;
  88. virtual unsigned int d_height() = 0;
  89. // DSP Callbacks
  90. virtual void d_parameterChanged(uint32_t index, float value) = 0;
  91. #if DISTRHO_PLUGIN_WANT_PROGRAMS
  92. virtual void d_programChanged(uint32_t index) = 0;
  93. #endif
  94. #if DISTRHO_PLUGIN_WANT_STATE
  95. virtual void d_stateChanged(const char* key, const char* value) = 0;
  96. #endif
  97. // UI Callbacks
  98. virtual void d_uiIdle();
  99. virtual void d_onInit() = 0;
  100. virtual void d_onDisplay() = 0;
  101. virtual void d_onKeyboard(bool press, uint32_t key) = 0;
  102. virtual void d_onMotion(int x, int y) = 0;
  103. virtual void d_onMouse(int button, bool press, int x, int y) = 0;
  104. virtual void d_onReshape(int width, int height) = 0;
  105. virtual void d_onScroll(float dx, float dy) = 0;
  106. virtual void d_onSpecial(bool press, Key key) = 0;
  107. virtual void d_onClose() = 0;
  108. private:
  109. friend class UIInternal;
  110. };
  111. // -------------------------------------------------
  112. END_NAMESPACE_DISTRHO
  113. #endif // DISTRHO_UI_OPENGL
  114. #endif // __DISTRHO_UI_OPENGL_H__