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.

123 lines
3.0KB

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