DISTRHO Plugin Framework
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.

103 lines
3.1KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2019 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 "DistrhoUI.hpp"
  17. #include "Window.hpp"
  18. #include "KeyboardWidget.hpp"
  19. START_NAMESPACE_DISTRHO
  20. /**
  21. We need the rectangle class from DGL.
  22. */
  23. using DGL::Rectangle;
  24. // -----------------------------------------------------------------------------------------------------------
  25. class MidiKeyboardExampleUI : public UI
  26. {
  27. public:
  28. /* constructor */
  29. MidiKeyboardExampleUI()
  30. : UI(512, 512)
  31. {
  32. //getParentWindow().focus();
  33. // Add a min-size constraint to the window, to make sure that it can't become too small
  34. setGeometryConstraints(getWidth(), getHeight(), true, true);
  35. }
  36. protected:
  37. /* --------------------------------------------------------------------------------------------------------
  38. * DSP/Plugin Callbacks */
  39. /**
  40. A parameter has changed on the plugin side.
  41. This is called by the host to inform the UI about parameter changes.
  42. */
  43. void parameterChanged(uint32_t index, float value) override
  44. {
  45. }
  46. /* --------------------------------------------------------------------------------------------------------
  47. * Widget Callbacks */
  48. /**
  49. The OpenGL drawing function.
  50. */
  51. void onNanoDisplay() override
  52. {
  53. const uint width = getWidth();
  54. const uint height = getHeight();
  55. //KeyboardRenderer().draw(getContext());
  56. }
  57. /**
  58. Mouse press event.
  59. */
  60. bool onMouse(const MouseEvent &ev) override
  61. {
  62. return false;
  63. }
  64. bool onKeyboard(const KeyboardEvent &ev) override
  65. {
  66. fprintf(stderr, "%u\n", ev.key);
  67. repaint();
  68. return false;
  69. }
  70. // -------------------------------------------------------------------------------------------------------
  71. private:
  72. /**
  73. Set our UI class as non-copyable and add a leak detector just in case.
  74. */
  75. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MidiKeyboardExampleUI)
  76. };
  77. /* ------------------------------------------------------------------------------------------------------------
  78. * UI entry point, called by DPF to create a new UI instance. */
  79. UI *createUI()
  80. {
  81. return new MidiKeyboardExampleUI();
  82. }
  83. // -----------------------------------------------------------------------------------------------------------
  84. END_NAMESPACE_DISTRHO