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.

88 lines
2.7KB

  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. class CairoExampleUI : public UI
  23. {
  24. public:
  25. CairoExampleUI()
  26. : UI(200, 200)
  27. {
  28. DemoWidgetClickable* widgetClickable = new DemoWidgetClickable(this);
  29. fWidgetClickable = widgetClickable;
  30. widgetClickable->setSize(50, 50);
  31. widgetClickable->setAbsolutePos(100, 100);
  32. DemoWidgetBanner* widgetBanner = new DemoWidgetBanner(this);
  33. fWidgetBanner = widgetBanner;
  34. widgetBanner->setSize(180, 80);
  35. widgetBanner->setAbsolutePos(10, 10);
  36. CairoImage knobSkin;
  37. knobSkin.loadFromPNG(Artwork::knobData, Artwork::knobDataSize);
  38. CairoImageKnob* knob = new CairoImageKnob(this, knobSkin);
  39. fKnob = knob;
  40. knob->setSize(80, 80);
  41. knob->setAbsolutePos(10, 100);
  42. CairoImage buttonOn, buttonOff;
  43. buttonOn.loadFromPNG(Artwork::buttonOnData, Artwork::buttonOnDataSize);
  44. buttonOff.loadFromPNG(Artwork::buttonOffData, Artwork::buttonOffDataSize);
  45. CairoImageButton* button = new CairoImageButton(this, buttonOff, buttonOn);
  46. fButton = button;
  47. button->setSize(60, 35);
  48. button->setAbsolutePos(100, 160);
  49. }
  50. protected:
  51. void onCairoDisplay(const CairoGraphicsContext& context)
  52. {
  53. cairo_t* const cr = context.handle;
  54. cairo_set_source_rgb(cr, 1.0, 0.8, 0.5);
  55. cairo_paint(cr);
  56. }
  57. void parameterChanged(uint32_t index, float value)
  58. {
  59. // unused
  60. (void)index;
  61. (void)value;
  62. }
  63. private:
  64. ScopedPointer<DemoWidgetClickable> fWidgetClickable;
  65. ScopedPointer<DemoWidgetBanner> fWidgetBanner;
  66. ScopedPointer<CairoImageKnob> fKnob;
  67. ScopedPointer<CairoImageButton> fButton;
  68. };
  69. UI* createUI()
  70. {
  71. return new CairoExampleUI;
  72. }
  73. END_NAMESPACE_DISTRHO