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.

118 lines
2.9KB

  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-2021 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. fInitialized(false),
  27. fResizeHandle(this)
  28. {
  29. setGeometryConstraints(256, 256, true);
  30. // no need to show resize handle if window is user-resizable
  31. if (isResizable())
  32. fResizeHandle.hide();
  33. }
  34. DistrhoUIGLBars::~DistrhoUIGLBars()
  35. {
  36. if (! fInitialized)
  37. return;
  38. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  39. {
  40. const MutexLocker csm(dspPtr->fMutex);
  41. dspPtr->fState = nullptr;
  42. }
  43. }
  44. // -----------------------------------------------------------------------
  45. // DSP Callbacks
  46. void DistrhoUIGLBars::parameterChanged(uint32_t index, float value)
  47. {
  48. switch (index)
  49. {
  50. case kParameterScale:
  51. fState.scale = value;
  52. break;
  53. case kParameterSpeed:
  54. fState.hSpeed = value;
  55. break;
  56. case kParameterX:
  57. fState.x_speed = value;
  58. break;
  59. case kParameterY:
  60. fState.y_speed = value;
  61. break;
  62. case kParameterZ:
  63. fState.z_speed = value;
  64. break;
  65. }
  66. }
  67. // -----------------------------------------------------------------------
  68. // UI Callbacks
  69. void DistrhoUIGLBars::uiIdle()
  70. {
  71. repaint();
  72. if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
  73. {
  74. if (dspPtr->fState != nullptr)
  75. return;
  76. fInitialized = true;
  77. const MutexLocker csm(dspPtr->fMutex);
  78. dspPtr->fState = &fState;
  79. }
  80. }
  81. // -----------------------------------------------------------------------
  82. // Widget Callbacks
  83. void DistrhoUIGLBars::onDisplay()
  84. {
  85. fState.Render();
  86. }
  87. // -----------------------------------------------------------------------
  88. UI* createUI()
  89. {
  90. return new DistrhoUIGLBars();
  91. }
  92. // -----------------------------------------------------------------------
  93. END_NAMESPACE_DISTRHO