DISTRHO glBars
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.

134 lines
3.4KB

  1. /*
  2. * DISTRHO glBars Plugin based on XMMS/XBMC "GL Bars"
  3. * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
  4. * Copyright (C) 2000 Christian Zander <phoenix@minion.de>
  5. * Copyright (C) 2015 Nedko Arnaudov
  6. * Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * For a full copy of the license see the LICENSE file.
  19. */
  20. #include "DistrhoPluginGLBars.hpp"
  21. #include "DistrhoUIGLBars.hpp"
  22. START_NAMESPACE_DISTRHO
  23. // -----------------------------------------------------------------------
  24. DistrhoUIGLBars::DistrhoUIGLBars()
  25. : UI(512, 512) {}
  26. DistrhoUIGLBars::~DistrhoUIGLBars()
  27. {
  28. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  29. {
  30. const MutexLocker csm(dspPtr->fMutex);
  31. dspPtr->fState = nullptr;
  32. }
  33. }
  34. // -----------------------------------------------------------------------
  35. // DSP Callbacks
  36. void DistrhoUIGLBars::parameterChanged(uint32_t index, float value)
  37. {
  38. switch (index)
  39. {
  40. case kParameterScale:
  41. fState.scale = value;
  42. break;
  43. case kParameterSpeed:
  44. fState.hSpeed = value;
  45. break;
  46. case kParameterX:
  47. fState.x_speed = value;
  48. break;
  49. case kParameterY:
  50. fState.y_speed = value;
  51. break;
  52. case kParameterZ:
  53. fState.z_speed = value;
  54. break;
  55. }
  56. }
  57. // -----------------------------------------------------------------------
  58. // UI Callbacks
  59. void DistrhoUIGLBars::uiIdle()
  60. {
  61. repaint();
  62. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  63. {
  64. if (dspPtr->fState != nullptr)
  65. return;
  66. const MutexLocker csm(dspPtr->fMutex);
  67. dspPtr->fState = &fState;
  68. }
  69. }
  70. // -----------------------------------------------------------------------
  71. // Widget Callbacks
  72. void DistrhoUIGLBars::onDisplay()
  73. {
  74. fState.Render();
  75. }
  76. bool DistrhoUIGLBars::onKeyboard(const KeyboardEvent& ev)
  77. {
  78. if (ev.press && (ev.key == '1' || ev.key == '+' || ev.key == '-'))
  79. {
  80. if (ev.key == '1')
  81. {
  82. if (getWidth() != 512 || getHeight() != 512)
  83. setSize(512, 512);
  84. }
  85. else if (ev.key == '+')
  86. {
  87. /**/ if (getWidth() < 1100 && getHeight() < 1100)
  88. setSize(getWidth()+100, getHeight()+100);
  89. else if (getWidth() != 1100 || getHeight() != 1100)
  90. setSize(1100, 1100);
  91. }
  92. else if (ev.key == '-')
  93. {
  94. /**/ if (getWidth() >= 200 && getHeight() >= 200)
  95. setSize(getWidth()-100, getHeight()-100);
  96. else if (getWidth() != 100 || getHeight() != 100)
  97. setSize(100, 100);
  98. }
  99. return true;
  100. }
  101. return true;
  102. }
  103. // -----------------------------------------------------------------------
  104. UI* createUI()
  105. {
  106. return new DistrhoUIGLBars();
  107. }
  108. // -----------------------------------------------------------------------
  109. END_NAMESPACE_DISTRHO