Collection of DPF-based plugins for packaging
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.

137 lines
3.5KB

  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. {
  27. setGeometryConstraints(256, 256, true);
  28. }
  29. DistrhoUIGLBars::~DistrhoUIGLBars()
  30. {
  31. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  32. {
  33. const MutexLocker csm(dspPtr->fMutex);
  34. dspPtr->fState = nullptr;
  35. }
  36. }
  37. // -----------------------------------------------------------------------
  38. // DSP Callbacks
  39. void DistrhoUIGLBars::parameterChanged(uint32_t index, float value)
  40. {
  41. switch (index)
  42. {
  43. case kParameterScale:
  44. fState.scale = value;
  45. break;
  46. case kParameterSpeed:
  47. fState.hSpeed = value;
  48. break;
  49. case kParameterX:
  50. fState.x_speed = value;
  51. break;
  52. case kParameterY:
  53. fState.y_speed = value;
  54. break;
  55. case kParameterZ:
  56. fState.z_speed = value;
  57. break;
  58. }
  59. }
  60. // -----------------------------------------------------------------------
  61. // UI Callbacks
  62. void DistrhoUIGLBars::uiIdle()
  63. {
  64. repaint();
  65. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  66. {
  67. if (dspPtr->fState != nullptr)
  68. return;
  69. const MutexLocker csm(dspPtr->fMutex);
  70. dspPtr->fState = &fState;
  71. }
  72. }
  73. // -----------------------------------------------------------------------
  74. // Widget Callbacks
  75. void DistrhoUIGLBars::onDisplay()
  76. {
  77. fState.Render();
  78. }
  79. bool DistrhoUIGLBars::onKeyboard(const KeyboardEvent& ev)
  80. {
  81. if (ev.press && (ev.key == '1' || ev.key == '+' || ev.key == '-'))
  82. {
  83. if (ev.key == '1')
  84. {
  85. if (getWidth() != 512 || getHeight() != 512)
  86. setSize(512, 512);
  87. }
  88. else if (ev.key == '+')
  89. {
  90. /**/ if (getWidth() < 1100 && getHeight() < 1100)
  91. setSize(std::min(getWidth()+100, 1100U), std::min(getHeight()+100, 1100U));
  92. else if (getWidth() != 1100 || getHeight() != 1100)
  93. setSize(1100, 1100);
  94. }
  95. else if (ev.key == '-')
  96. {
  97. /**/ if (getWidth() > 100 && getHeight() > 100)
  98. setSize(std::max(getWidth()-100, 100U), std::max(getHeight()-100, 100U));
  99. else if (getWidth() != 100 || getHeight() != 100)
  100. setSize(100, 100);
  101. }
  102. return true;
  103. }
  104. return true;
  105. }
  106. // -----------------------------------------------------------------------
  107. UI* createUI()
  108. {
  109. return new DistrhoUIGLBars();
  110. }
  111. // -----------------------------------------------------------------------
  112. END_NAMESPACE_DISTRHO