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.

96 lines
2.9KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
  4. * Copyright (C) 2019-2021 Jean Pierre Cimalando <jp-dev@inbox.ru>
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  7. * or without fee is hereby granted, provided that the above copyright notice and this
  8. * permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  11. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  12. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  14. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  15. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "DistrhoUI.hpp"
  18. #include "Artwork.hpp"
  19. #include "DemoWidgetBanner.hpp"
  20. #include "DemoWidgetClickable.hpp"
  21. START_NAMESPACE_DISTRHO
  22. /**
  23. We need a few classes from DGL.
  24. */
  25. using DGL_NAMESPACE::CairoGraphicsContext;
  26. using DGL_NAMESPACE::CairoImage;
  27. using DGL_NAMESPACE::CairoImageButton;
  28. using DGL_NAMESPACE::CairoImageKnob;
  29. class CairoExampleUI : public UI
  30. {
  31. public:
  32. CairoExampleUI()
  33. : UI(200, 200)
  34. {
  35. DemoWidgetClickable* widgetClickable = new DemoWidgetClickable(this);
  36. fWidgetClickable = widgetClickable;
  37. widgetClickable->setSize(50, 50);
  38. widgetClickable->setAbsolutePos(100, 100);
  39. DemoWidgetBanner* widgetBanner = new DemoWidgetBanner(this);
  40. fWidgetBanner = widgetBanner;
  41. widgetBanner->setSize(180, 80);
  42. widgetBanner->setAbsolutePos(10, 10);
  43. CairoImage knobSkin;
  44. knobSkin.loadFromPNG(Artwork::knobData, Artwork::knobDataSize);
  45. CairoImageKnob* knob = new CairoImageKnob(this, knobSkin);
  46. fKnob = knob;
  47. knob->setSize(80, 80);
  48. knob->setAbsolutePos(10, 100);
  49. CairoImage buttonOn, buttonOff;
  50. buttonOn.loadFromPNG(Artwork::buttonOnData, Artwork::buttonOnDataSize);
  51. buttonOff.loadFromPNG(Artwork::buttonOffData, Artwork::buttonOffDataSize);
  52. CairoImageButton* button = new CairoImageButton(this, buttonOff, buttonOn);
  53. fButton = button;
  54. button->setSize(60, 35);
  55. button->setAbsolutePos(100, 160);
  56. }
  57. protected:
  58. void onCairoDisplay(const CairoGraphicsContext& context)
  59. {
  60. cairo_t* const cr = context.handle;
  61. cairo_set_source_rgb(cr, 1.0, 0.8, 0.5);
  62. cairo_paint(cr);
  63. }
  64. void parameterChanged(uint32_t index, float value)
  65. {
  66. // unused
  67. (void)index;
  68. (void)value;
  69. }
  70. private:
  71. ScopedPointer<DemoWidgetClickable> fWidgetClickable;
  72. ScopedPointer<DemoWidgetBanner> fWidgetBanner;
  73. ScopedPointer<CairoImageKnob> fKnob;
  74. ScopedPointer<CairoImageButton> fButton;
  75. };
  76. UI* createUI()
  77. {
  78. return new CairoExampleUI;
  79. }
  80. END_NAMESPACE_DISTRHO