Audio plugin host https://kx.studio/carla
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.

DistrhoUIKars.cpp 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * DISTRHO Kars Plugin, based on karplong by Chris Cannam.
  3. * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "DistrhoPluginKars.hpp"
  17. #include "DistrhoUIKars.hpp"
  18. START_NAMESPACE_DISTRHO
  19. namespace Art = DistrhoArtworkKars;
  20. // -----------------------------------------------------------------------
  21. DistrhoUIKars::DistrhoUIKars()
  22. : UI(Art::backgroundWidth, Art::backgroundHeight),
  23. fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight)
  24. {
  25. // sustain switch
  26. Image switchImageNormal(Art::switchData, Art::switchWidth, Art::switchHeight/2);
  27. Image switchImageDown(Art::switchData+(Art::switchWidth*Art::switchHeight/2*4), Art::switchWidth, Art::switchHeight/2);
  28. fSwitchSustain = new ImageSwitch(this, switchImageNormal, switchImageDown);
  29. fSwitchSustain->setAbsolutePos(Art::backgroundWidth/2-Art::switchWidth/2, Art::backgroundHeight/2-Art::switchHeight/4);
  30. fSwitchSustain->setId(DistrhoPluginKars::paramSustain);
  31. fSwitchSustain->setCallback(this);
  32. }
  33. // -----------------------------------------------------------------------
  34. // DSP Callbacks
  35. void DistrhoUIKars::parameterChanged(uint32_t index, float value)
  36. {
  37. if (index != 0)
  38. return;
  39. fSwitchSustain->setDown(value > 0.5f);
  40. }
  41. // -----------------------------------------------------------------------
  42. // Widget Callbacks
  43. void DistrhoUIKars::imageSwitchClicked(ImageSwitch* imageSwitch, bool down)
  44. {
  45. if (imageSwitch != fSwitchSustain)
  46. return;
  47. editParameter(DistrhoPluginKars::paramSustain, true);
  48. setParameterValue(DistrhoPluginKars::paramSustain, down ? 1.0f : 0.0f);
  49. editParameter(DistrhoPluginKars::paramSustain, false);
  50. }
  51. void DistrhoUIKars::onDisplay()
  52. {
  53. fImgBackground.draw();
  54. }
  55. // -----------------------------------------------------------------------
  56. UI* createUI()
  57. {
  58. return new DistrhoUIKars();
  59. }
  60. // -----------------------------------------------------------------------
  61. END_NAMESPACE_DISTRHO